GIF89a; %PDF-1.5 %���� ºaâÚÎΞ-ÌE1ÍØÄ÷{òò2ÿ ÛÖ^ÔÀá TÎ{¦?§®¥kuµù Õ5sLOšuY Donat Was Here
DonatShell
Server IP : 134.29.175.74  /  Your IP : 216.73.216.160
Web Server : nginx/1.10.2
System : Windows NT CST-WEBSERVER 10.0 build 19045 (Windows 10) i586
User : Administrator ( 0)
PHP Version : 7.1.0
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : OFF  |  Perl : OFF  |  Python : OFF  |  Sudo : OFF  |  Pkexec : OFF
Directory :  C:/nginx/html/JimMartinson/Classes/CST1021/test/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ HOME SHELL ]     

Current File : C:/nginx/html/JimMartinson/Classes/CST1021/test//HTML Standard.html
<!DOCTYPE html><html lang=en-US-x-hixie><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><link rel=stylesheet href=https://resources.whatwg.org/spec.css><link rel=stylesheet href=https://resources.whatwg.org/standard.css><link rel=icon href=https://resources.whatwg.org/logo.svg><script>
   function toggleStatus(div) {
     div.parentNode.classList.toggle('wrapped');
   }
  </script><style>
   .status { min-height: 0.6em; font: 1em sans-serif; width: 9em; padding: 0.3em; position: absolute; z-index: 8; right: 0.3em; background: #EEE; color: black; box-shadow: 0 0 3px #999; overflow: hidden; margin: -2em 0 0 0; border-collapse: initial; border-spacing: initial; }
   .status:hover { z-index: 9; }
   .status:focus-within { z-index: 9; }
   .status.wrapped > :not(input) { display: none; }
   .status > input { position: absolute; left: 0; top: 0; width: 1em; height: 1em; border: none; background: transparent; padding: 0; margin: 0; }
   .status > p { font-size: 0.6em; margin: 0; padding: 0; }
   .status > p + p { padding-top: 0.5em; }
   .status > p > strong { margin-left: 1.5em; }
   .status > .support { display: block; }
   .status > .support > span { padding: 0.2em 0; display: block; display: table; }
   .status > .support > span.partial { color: #666666; filter: grayscale(50%); }
   .status > .support > span.no { color: #CCCCCC; filter: grayscale(100%); }
   .status > .support > span.no::before { opacity: 0.5; }
   .status > .support > span:first-of-type { padding-top: 0.5em; }
   .status > .support > span > span { padding: 0 0.5em; display: table-cell; vertical-align: top; }
   .status > .support > span > span:first-child { width: 100%; }
   .status > .support > span > span:last-child { width: 100%; white-space: pre; padding: 0; }
   .status > .support > span::before { content: ' '; display: table-cell; min-width: 1.5em; height: 1.5em; background: no-repeat center center; background-size: contain; text-align: right; font-size: 0.75em; font-weight: bold; }
   .status > .support > .and_chr::before { background-image: url(https://resources.whatwg.org/browser-logos/chrome.svg); }
   .status > .support > .and_ff::before { background-image: url(https://resources.whatwg.org/browser-logos/firefox.png); }
   .status > .support > .and_uc::before { background-image: url(https://resources.whatwg.org/browser-logos/uc.png); } /* UC Browser for Android */
   .status > .support > .android::before { background-image: url(https://resources.whatwg.org/browser-logos/android.svg); }
   .status > .support > .bb::before { background-image: url(https://resources.whatwg.org/browser-logos/bb.jpg); } /* Blackberry Browser */
   .status > .support > .chrome::before { background-image: url(https://resources.whatwg.org/browser-logos/chrome.svg); }
   .status > .support > .edge::before { background-image: url(https://resources.whatwg.org/browser-logos/edge.svg); }
   .status > .support > .firefox::before { background-image: url(https://resources.whatwg.org/browser-logos/firefox.png); }
   .status > .support > .ie::before { background-image: url(https://resources.whatwg.org/browser-logos/ie.png); }
   .status > .support > .ie_mob::before { background-image: url(https://resources.whatwg.org/browser-logos/ie-mobile.svg); }
   .status > .support > .ios_saf::before { background-image: url(https://resources.whatwg.org/browser-logos/safari-ios.svg); }
   .status > .support > .op_mini::before { background-image: url(https://resources.whatwg.org/browser-logos/opera-mini.png); }
   .status > .support > .op_mob::before { background-image: url(https://resources.whatwg.org/browser-logos/opera.png); }
   .status > .support > .opera::before { background-image: url(https://resources.whatwg.org/browser-logos/opera.png); }
   .status > .support > .safari::before { background-image: url(https://resources.whatwg.org/browser-logos/safari.png); }
   .status > .support > .samsung::before { background-image: url(https://resources.whatwg.org/browser-logos/samsung.png); }
   .status > .caniuse { text-align: right; font-style: italic; width: 100%; }
   .status > .caniuse + p { margin-top: 0.5em; border-top: 1px solid silver; }

   @media (max-width: 767px) {
     .status { right: -9em; }
   }
  </style><style>
   .bad, .bad *:not(.X\58X) { color: gray; }

   .fingerprint { position: absolute; right: 0; z-index: 5; }
   @media (max-width: 767px) {
     .fingerprint { max-width: 35px; }
   }

   .applies .yes, .yesno .yes { background: yellow; }
   .yesno .yes, .yesno .no { text-align: center; }

   .applies thead th > * { display: block; }
   .applies thead code { display: block; }
   .applies td { text-align: center; }

   .matrix, .matrix td { border: hidden; text-align: right; }
   .matrix { margin-left: 2em; }

   .vertical-summary-table tr > th[rowspan="2"]:first-child + th,
   .vertical-summary-table tr > td[rowspan="2"]:first-child + td { border-bottom: hidden; }

   .dice-example { border-collapse: collapse; border-style: hidden solid solid hidden; border-width: thin; margin-left: 3em; }
   .dice-example caption { width: 30em; font-size: smaller; font-style: italic; padding: 0.75em 0; text-align: left; }
   .dice-example td, .dice-example th { border: solid thin; width: 1.35em; height: 1.05em; text-align: center; padding: 0; }

   td.eg { border-width: thin; text-align: center; }

   #table-example-1 { border: solid thin; border-collapse: collapse; margin-left: 3em; }
   #table-example-1 caption { padding-bottom: 0.5em; }
   #table-example-1 thead, #table-example-1 tbody { border: none; }
   #table-example-1 th, #table-example-1 td { border: solid thin; }
   #table-example-1 th { font-weight: normal; }
   #table-example-1 td { border-style: none solid; vertical-align: top; }
   #table-example-1 th { padding: 0.5em; vertical-align: middle; text-align: center; }
   #table-example-1 tbody tr:first-child td { padding-top: 0.5em; }
   #table-example-1 tbody tr:last-child td { padding-bottom: 1.5em; }
   #table-example-1 tbody td:first-child { padding-left: 2.5em; padding-right: 0; width: 9em; }
   #table-example-1 tbody td:first-child::after { content: leader(". "); }
   #table-example-1 tbody td { padding-left: 2em; padding-right: 2em; }
   #table-example-1 tbody td:first-child + td { width: 10em; }
   #table-example-1 tbody td:first-child + td ~ td { width: 2.5em; }
   #table-example-1 tbody td:first-child + td + td + td ~ td { width: 1.25em; }

   .apple-table-examples { border: none; border-collapse: separate; border-spacing: 1.5em 0em; width: 40em; margin-left: 3em; }
   .apple-table-examples * { font-family: "Times", serif; }
   .apple-table-examples td, .apple-table-examples th { border: none; white-space: nowrap; padding-top: 0; padding-bottom: 0; }
   .apple-table-examples tbody th:first-child { border-left: none; width: 100%; }
   .apple-table-examples thead th:first-child ~ th { font-size: smaller; font-weight: bolder; border-bottom: solid 2px; text-align: center; }
   .apple-table-examples tbody th::after, .apple-table-examples tfoot th::after { content: leader(". ") }
   .apple-table-examples tbody th, .apple-table-examples tfoot th { font: inherit; text-align: left; }
   .apple-table-examples td { text-align: right; vertical-align: top; }
   .apple-table-examples.e1 tbody tr:last-child td { border-bottom: solid 1px; }
   .apple-table-examples.e1 tbody + tbody tr:last-child td { border-bottom: double 3px; }
   .apple-table-examples.e2 th[scope=row] { padding-left: 1em; }
   .apple-table-examples sup { line-height: 0; }

   .three-column-nowrap tr > td:first-child,
   .three-column-nowrap tr > td:first-child + td,
   .three-column-nowrap tr > td:first-child + td + td { white-space: nowrap; }

   .details-example img { vertical-align: top; }

   .parse-error-table td > p:first-child { margin-top: 0; }

   #named-character-references-table {
     white-space: nowrap;
     font-size: 0.6em;
     column-width: 30em;
     column-gap: 1em;
     -moz-column-width: 30em;
     -moz-column-gap: 1em;
     -webkit-column-width: 30em;
     -webkit-column-gap: 1em;
   }
   #named-character-references-table > table > tbody > tr > td:first-child + td,
   #named-character-references-table > table > tbody > tr > td:last-child { text-align: center; }
   #named-character-references-table > table > tbody > tr > td:last-child:hover > span { position: absolute; top: auto; left: auto; margin-left: 0.5em; line-height: 1.2; font-size: 5em; border: outset; padding: 0.25em 0.5em; background: white; width: 1.25em; height: auto; text-align: center; }
   #named-character-references-table > table > tbody > tr#entity-CounterClockwiseContourIntegral > td:first-child { font-size: 0.5em; }

   .glyph.control { color: red; }

   #table-example-1 * { font-family: "Essays1743", serif; line-height: 1.01em; }
   @font-face {
     font-family: 'Essays1743';
     src: url('/fonts/Essays1743.ttf');
   }
   @font-face {
     font-family: 'Essays1743';
     font-weight: bold;
     src: url('/fonts/Essays1743-Bold.ttf');
   }
   @font-face {
     font-family: 'Essays1743';
     font-style: italic;
     src: url('/fonts/Essays1743-Italic.ttf');
   }
   @font-face {
     font-family: 'Essays1743';
     font-style: italic;
     font-weight: bold;
     src: url('/fonts/Essays1743-BoldItalic.ttf');
   }

   @media (max-width: 767px) {
     #abstractimg { width: 100%; }
   }
   #abstractimg, #abstractimg text { font: inherit; }
   #abstractimg rect { fill: #424242; }
   #abstractimg text { fill: #ffffff; font-size: 18px }
   #abstractimg .top { word-spacing: 50px; text-anchor: middle; }
   #abstractimg .left, #abstractimg .bottom { word-spacing: 12px; }
   #abstractimg .right { font-size: 25px; }
  </style><body>
  
  <script async="" src=/html-dfn.js></script>
  <script data-file-issue-url=https://github.com/whatwg/html/issues/new async="" src=https://resources.whatwg.org/file-issue.js></script>
  <header id=head class="head with-buttons">
   <a href=https://whatwg.org/ class=logo><img src=https://resources.whatwg.org/logo.svg width=100 alt=WHATWG height=100></a>
   <hgroup><h1 class=allcaps>HTML</h1><h2 id=living-standard class="no-num no-toc">Living Standard — Last Updated <span class=pubdate>19 September 2018</span></h2></hgroup>
   
   <nav>
    <div>
     <a href=/><span><strong>One-Page Version</strong> <code>html.spec.whatwg.org</code></span></a>
     <a id=multipage-link href=/multipage/><span><strong>Multipage Version</strong> <code>/multipage</code></span></a>
     <a href=/dev/><span><strong>Developer Version</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/master/FAQ.md class=misc><span><strong>FAQ</strong> <code>on GitHub</code></span></a>
     <a href=https://wiki.whatwg.org/wiki/IRC class=comms><span><strong>Join us on IRC</strong> <code>#whatwg on Freenode</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 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>
    </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><a href=#toc-infrastructure><span class=secno>2</span> Common infrastructure</a><li><a href=#toc-dom><span class=secno>3</span> Semantics, structure, and APIs of HTML documents</a><li><a href=#toc-semantics><span class=secno>4</span> The elements of HTML</a><li><a href=#toc-microdata><span class=secno>5</span> Microdata</a><li><a href=#toc-editing><span class=secno>6</span> User interaction</a><li><a href=#toc-browsers><span class=secno>7</span> Loading Web pages</a><li><a href=#toc-webappapis><span class=secno>8</span> Web application APIs</a><li><a href=#toc-comms><span class=secno>9</span> Communication</a><li><a href=#toc-workers><span class=secno>10</span> Web workers</a><li><a href=#toc-webstorage><span class=secno>11</span> Web storage</a><li><a href=#toc-syntax><span class=secno>12</span> The HTML syntax</a><li><a href=#toc-the-xhtml-syntax><span class=secno>13</span> The XML syntax</a><li><a href=#toc-rendering><span class=secno>14</span> Rendering</a><li><a href=#toc-obsolete><span class=secno>15</span> Obsolete features</a><li><a href=#toc-iana><span class=secno>16</span> IANA considerations</a><li><a href=#toc-index>Index</a><li><a href=#toc-references>References</a><li><a href=#toc-acknowledgments>Acknowledgments</a></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><a href=#is-this-html5?><span class=secno>1.2</span> Is this HTML5?</a><li><a href=#background><span class=secno>1.3</span> Background</a><li><a href=#audience><span class=secno>1.4</span> Audience</a><li><a href=#scope><span class=secno>1.5</span> Scope</a><li><a href=#history-2><span class=secno>1.6</span> History</a><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><a href=#compliance-with-other-specifications><span class=secno>1.7.2</span> Compliance with other specifications</a><li><a href=#extensibility><span class=secno>1.7.3</span> Extensibility</a></ol><li><a href=#html-vs-xhtml><span class=secno>1.8</span> HTML vs XML syntax</a><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><a href=#typographic-conventions><span class=secno>1.9.2</span> Typographic conventions</a></ol><li><a href=#fingerprint><span class=secno>1.10</span> Privacy concerns</a><ol><li><a href=#fingerprint-postMessage><span class=secno>1.10.1</span> Cross-site communication</a></ol><li><a href=#a-quick-introduction-to-html><span class=secno>1.11</span> A quick introduction to HTML</a><ol><li><a href=#writing-secure-applications-with-html><span class=secno>1.11.1</span> Writing secure applications with HTML</a><li><a href=#common-pitfalls-to-avoid-when-using-the-scripting-apis><span class=secno>1.11.2</span> Common pitfalls to avoid when using the scripting APIs</a><li><a href=#how-to-catch-mistakes-when-writing-html:-validators-and-conformance-checkers><span class=secno>1.11.3</span> How to catch mistakes when writing HTML: validators and conformance checkers</a></ol><li><a href=#conformance-requirements-for-authors><span class=secno>1.12</span> Conformance requirements for authors</a><ol><li><a href=#presentational-markup><span class=secno>1.12.1</span> Presentational markup</a><li><a href=#syntax-errors><span class=secno>1.12.2</span> Syntax errors</a><li><a href=#restrictions-on-content-models-and-on-attribute-values><span class=secno>1.12.3</span> Restrictions on content models and on attribute values</a></ol><li><a href=#suggested-reading><span class=secno>1.13</span> Suggested reading</a></ol><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><a href=#resources><span class=secno>2.1.2</span> Resources</a><li><a href=#xml><span class=secno>2.1.3</span> XML compatibility</a><li><a href=#dom-trees><span class=secno>2.1.4</span> DOM trees</a><li><a href=#scripting-2><span class=secno>2.1.5</span> Scripting</a><li><a href=#plugins><span class=secno>2.1.6</span> Plugins</a><li><a href=#encoding-terminology><span class=secno>2.1.7</span> Character encodings</a><li><a href=#conformance-classes><span class=secno>2.1.8</span> Conformance classes</a><li><a href=#dependencies><span class=secno>2.1.9</span> Dependencies</a><li><a href=#extensibility-2><span class=secno>2.1.10</span> Extensibility</a><li><a href=#interactions-with-xpath-and-xslt><span class=secno>2.1.11</span> Interactions with XPath and XSLT</a></ol><li><a href=#case-sensitivity-and-string-comparison><span class=secno>2.2</span> Case-sensitivity and string comparison</a><li><a href=#policy-controlled-features><span class=secno>2.3</span> Policy-controlled features</a><li><a href=#common-microsyntaxes><span class=secno>2.4</span> Common microsyntaxes</a><ol><li><a href=#common-parser-idioms><span class=secno>2.4.1</span> Common parser idioms</a><li><a href=#boolean-attributes><span class=secno>2.4.2</span> Boolean attributes</a><li><a href=#keywords-and-enumerated-attributes><span class=secno>2.4.3</span> Keywords and enumerated attributes</a><li><a href=#numbers><span class=secno>2.4.4</span> Numbers</a><ol><li><a href=#signed-integers><span class=secno>2.4.4.1</span> Signed integers</a><li><a href=#non-negative-integers><span class=secno>2.4.4.2</span> Non-negative integers</a><li><a href=#floating-point-numbers><span class=secno>2.4.4.3</span> Floating-point numbers</a><li><a href=#percentages-and-dimensions><span class=secno>2.4.4.4</span> Percentages and lengths</a><li><a href=#non-zero-percentages-and-lengths><span class=secno>2.4.4.5</span> Non-zero percentages and lengths</a><li><a href=#lists-of-floating-point-numbers><span class=secno>2.4.4.6</span> Lists of floating-point numbers</a><li><a href=#lists-of-dimensions><span class=secno>2.4.4.7</span> Lists of dimensions</a></ol><li><a href=#dates-and-times><span class=secno>2.4.5</span> Dates and times</a><ol><li><a href=#months><span class=secno>2.4.5.1</span> Months</a><li><a href=#dates><span class=secno>2.4.5.2</span> Dates</a><li><a href=#yearless-dates><span class=secno>2.4.5.3</span> Yearless dates</a><li><a href=#times><span class=secno>2.4.5.4</span> Times</a><li><a href=#local-dates-and-times><span class=secno>2.4.5.5</span> Local dates and times</a><li><a href=#time-zones><span class=secno>2.4.5.6</span> Time zones</a><li><a href=#global-dates-and-times><span class=secno>2.4.5.7</span> Global dates and times</a><li><a href=#weeks><span class=secno>2.4.5.8</span> Weeks</a><li><a href=#durations><span class=secno>2.4.5.9</span> Durations</a><li><a href=#vaguer-moments-in-time><span class=secno>2.4.5.10</span> Vaguer moments in time</a></ol><li><a href=#colours><span class=secno>2.4.6</span> Colors</a><li><a href=#space-separated-tokens><span class=secno>2.4.7</span> Space-separated tokens</a><li><a href=#comma-separated-tokens><span class=secno>2.4.8</span> Comma-separated tokens</a><li><a href=#syntax-references><span class=secno>2.4.9</span> References</a><li><a href=#mq><span class=secno>2.4.10</span> Media queries</a></ol><li><a href=#urls><span class=secno>2.5</span> URLs</a><ol><li><a href=#terminology-2><span class=secno>2.5.1</span> Terminology</a><li><a href=#resolving-urls><span class=secno>2.5.2</span> Parsing URLs</a><li><a href=#dynamic-changes-to-base-urls><span class=secno>2.5.3</span> Dynamic changes to base URLs</a></ol><li><a href=#fetching-resources><span class=secno>2.6</span> Fetching resources</a><ol><li><a href=#terminology-3><span class=secno>2.6.1</span> Terminology</a><li><a href=#content-type-sniffing><span class=secno>2.6.2</span> Determining the type of a resource</a><li><a href=#extracting-character-encodings-from-meta-elements><span class=secno>2.6.3</span> Extracting character encodings from <code>meta</code> elements</a><li><a href=#cors-settings-attributes><span class=secno>2.6.4</span> CORS settings attributes</a><li><a href=#referrer-policy-attributes><span class=secno>2.6.5</span> Referrer policy attributes</a><li><a href=#nonce-attributes><span class=secno>2.6.6</span> Nonce attributes</a></ol><li><a href=#common-dom-interfaces><span class=secno>2.7</span> Common DOM interfaces</a><ol><li><a href=#reflecting-content-attributes-in-idl-attributes><span class=secno>2.7.1</span> Reflecting content attributes in IDL attributes</a><li><a href=#collections><span class=secno>2.7.2</span> Collections</a><ol><li><a href=#the-htmlallcollection-interface><span class=secno>2.7.2.1</span> The <code>HTMLAllCollection</code> interface</a><ol><li><a href=#HTMLAllCollection-call><span class=secno>2.7.2.1.1</span> [[Call]] ( <var>thisArgument</var>,  <var>argumentsList</var> )</a></ol><li><a href=#the-htmlformcontrolscollection-interface><span class=secno>2.7.2.2</span> The <code>HTMLFormControlsCollection</code> interface</a><li><a href=#the-htmloptionscollection-interface><span class=secno>2.7.2.3</span> The <code>HTMLOptionsCollection</code> interface</a></ol><li><a href=#the-domstringlist-interface><span class=secno>2.7.3</span> The <code>DOMStringList</code> interface</a><li><a href=#garbage-collection><span class=secno>2.7.4</span> Garbage collection</a></ol><li><a href=#safe-passing-of-structured-data><span class=secno>2.8</span> Safe passing of structured data</a><ol><li><a href=#serializable-objects><span class=secno>2.8.1</span> Serializable objects</a><li><a href=#transferable-objects><span class=secno>2.8.2</span> Transferable objects</a><li><a href=#structuredserializeinternal><span class=secno>2.8.3</span> StructuredSerializeInternal ( <var>value</var>,
  <var>forStorage</var> [ , <var>memory</var> ] )</a><li><a href=#structuredserialize><span class=secno>2.8.4</span> StructuredSerialize ( <var>value</var> )</a><li><a href=#structuredserializeforstorage><span class=secno>2.8.5</span> StructuredSerializeForStorage ( <var>value</var> )</a><li><a href=#structureddeserialize><span class=secno>2.8.6</span> StructuredDeserialize ( <var>serialized</var>,
  <var>targetRealm</var> [ , <var>memory</var> ] )</a><li><a href=#structuredserializewithtransfer><span class=secno>2.8.7</span> StructuredSerializeWithTransfer ( <var>value</var>,
  <var>transferList</var> )</a><li><a href=#structureddeserializewithtransfer><span class=secno>2.8.8</span> StructuredDeserializeWithTransfer (
  <var>serializeWithTransferResult</var>, <var>targetRealm</var> )</a><li><a href=#performing-structured-clones-from-other-specifications><span class=secno>2.8.9</span> Performing serialization and
  transferring from other specifications</a></ol></ol><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><a href=#resource-metadata-management><span class=secno>3.1.2</span> Resource metadata management</a><li><a href=#dom-tree-accessors><span class=secno>3.1.3</span> DOM tree accessors</a></ol><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><a href=#elements-in-the-dom><span class=secno>3.2.2</span> Elements in the DOM</a><li><a href=#html-element-constructors><span class=secno>3.2.3</span> HTML element constructors</a><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></ol><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><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><a href=#flow-content><span class=secno>3.2.5.2.2</span> Flow content</a><li><a href=#sectioning-content><span class=secno>3.2.5.2.3</span> Sectioning content</a><li><a href=#heading-content><span class=secno>3.2.5.2.4</span> Heading content</a><li><a href=#phrasing-content><span class=secno>3.2.5.2.5</span> Phrasing content</a><li><a href=#embedded-content-2><span class=secno>3.2.5.2.6</span> Embedded content</a><li><a href=#interactive-content><span class=secno>3.2.5.2.7</span> Interactive content</a><li><a href=#palpable-content><span class=secno>3.2.5.2.8</span> Palpable content</a><li><a href=#script-supporting-elements><span class=secno>3.2.5.2.9</span> Script-supporting elements</a></ol><li><a href=#transparent-content-models><span class=secno>3.2.5.3</span> Transparent content models</a><li><a href=#paragraphs><span class=secno>3.2.5.4</span> Paragraphs</a></ol><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><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><a href=#the-translate-attribute><span class=secno>3.2.6.3</span> The <code>translate</code> attribute</a><li><a href=#the-dir-attribute><span class=secno>3.2.6.4</span> The <code>dir</code> attribute</a><li><a href=#the-style-attribute><span class=secno>3.2.6.5</span> The <code>style</code> attribute</a><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></ol><li><a href=#the-innertext-idl-attribute><span class=secno>3.2.7</span> The <code>innerText</code> IDL attribute</a><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><a href=#user-agent-conformance-criteria><span class=secno>3.2.8.2</span> User agent conformance criteria</a></ol><li><a href=#wai-aria><span class=secno>3.2.9</span> Requirements related to ARIA and to platform accessibility APIs</a></ol></ol><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></ol><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><a href=#the-title-element><span class=secno>4.2.2</span> The <code>title</code> element</a><li><a href=#the-base-element><span class=secno>4.2.3</span> The <code>base</code> element</a><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><a href=#processing-the-type-attribute><span class=secno>4.2.4.2</span> Processing the <code>type</code> attribute</a><li><a href=#obtaining-a-resource-from-a-link-element><span class=secno>4.2.4.3</span> Obtaining a resource from a <code>link</code> element</a><li><a href=#processing-link-headers><span class=secno>4.2.4.4</span> Processing `<code>Link</code>` headers</a><li><a href=#providing-users-with-a-means-to-follow-hyperlinks-created-using-the-link-element><span class=secno>4.2.4.5</span> Providing users with a means to follow hyperlinks created using the <code>link</code>
  element</a></ol><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><a href=#other-metadata-names><span class=secno>4.2.5.2</span> Other metadata names</a><li><a href=#pragma-directives><span class=secno>4.2.5.3</span> Pragma directives</a><li><a href=#charset><span class=secno>4.2.5.4</span> Specifying the document's character encoding</a></ol><li><a href=#the-style-element><span class=secno>4.2.6</span> The <code>style</code> element</a><li><a href=#interactions-of-styling-and-scripting><span class=secno>4.2.7</span> Interactions of styling and scripting</a></ol><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><a href=#the-article-element><span class=secno>4.3.2</span> The <code>article</code> element</a><li><a href=#the-section-element><span class=secno>4.3.3</span> The <code>section</code> element</a><li><a href=#the-nav-element><span class=secno>4.3.4</span> The <code>nav</code> element</a><li><a href=#the-aside-element><span class=secno>4.3.5</span> The <code>aside</code> element</a><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><a href=#the-hgroup-element><span class=secno>4.3.7</span> The <code>hgroup</code> element</a><li><a href=#the-header-element><span class=secno>4.3.8</span> The <code>header</code> element</a><li><a href=#the-footer-element><span class=secno>4.3.9</span> The <code>footer</code> element</a><li><a href=#the-address-element><span class=secno>4.3.10</span> The <code>address</code> element</a><li><a href=#headings-and-sections><span class=secno>4.3.11</span> Headings and sections</a><ol><li><a href=#outlines><span class=secno>4.3.11.1</span> Creating an outline</a><li><a href=#sample-outlines><span class=secno>4.3.11.2</span> Sample outlines</a><li><a href=#exposing-outlines-to-users><span class=secno>4.3.11.3</span> Exposing outlines to users</a></ol><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></ol></ol><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><a href=#the-hr-element><span class=secno>4.4.2</span> The <code>hr</code> element</a><li><a href=#the-pre-element><span class=secno>4.4.3</span> The <code>pre</code> element</a><li><a href=#the-blockquote-element><span class=secno>4.4.4</span> The <code>blockquote</code> element</a><li><a href=#the-ol-element><span class=secno>4.4.5</span> The <code>ol</code> element</a><li><a href=#the-ul-element><span class=secno>4.4.6</span> The <code>ul</code> element</a><li><a href=#the-menu-element><span class=secno>4.4.7</span> The <code>menu</code> element</a><li><a href=#the-li-element><span class=secno>4.4.8</span> The <code>li</code> element</a><li><a href=#the-dl-element><span class=secno>4.4.9</span> The <code>dl</code> element</a><li><a href=#the-dt-element><span class=secno>4.4.10</span> The <code>dt</code> element</a><li><a href=#the-dd-element><span class=secno>4.4.11</span> The <code>dd</code> element</a><li><a href=#the-figure-element><span class=secno>4.4.12</span> The <code>figure</code> element</a><li><a href=#the-figcaption-element><span class=secno>4.4.13</span> The <code>figcaption</code> element</a><li><a href=#the-main-element><span class=secno>4.4.14</span> The <code>main</code> element</a><li><a href=#the-div-element><span class=secno>4.4.15</span> The <code>div</code> element</a></ol><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><a href=#the-em-element><span class=secno>4.5.2</span> The <code>em</code> element</a><li><a href=#the-strong-element><span class=secno>4.5.3</span> The <code>strong</code> element</a><li><a href=#the-small-element><span class=secno>4.5.4</span> The <code>small</code> element</a><li><a href=#the-s-element><span class=secno>4.5.5</span> The <code>s</code> element</a><li><a href=#the-cite-element><span class=secno>4.5.6</span> The <code>cite</code> element</a><li><a href=#the-q-element><span class=secno>4.5.7</span> The <code>q</code> element</a><li><a href=#the-dfn-element><span class=secno>4.5.8</span> The <code>dfn</code> element</a><li><a href=#the-abbr-element><span class=secno>4.5.9</span> The <code>abbr</code> element</a><li><a href=#the-ruby-element><span class=secno>4.5.10</span> The <code>ruby</code> element</a><li><a href=#the-rt-element><span class=secno>4.5.11</span> The <code>rt</code> element</a><li><a href=#the-rp-element><span class=secno>4.5.12</span> The <code>rp</code> element</a><li><a href=#the-data-element><span class=secno>4.5.13</span> The <code>data</code> element</a><li><a href=#the-time-element><span class=secno>4.5.14</span> The <code>time</code> element</a><li><a href=#the-code-element><span class=secno>4.5.15</span> The <code>code</code> element</a><li><a href=#the-var-element><span class=secno>4.5.16</span> The <code>var</code> element</a><li><a href=#the-samp-element><span class=secno>4.5.17</span> The <code>samp</code> element</a><li><a href=#the-kbd-element><span class=secno>4.5.18</span> The <code>kbd</code> element</a><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><a href=#the-i-element><span class=secno>4.5.20</span> The <code>i</code> element</a><li><a href=#the-b-element><span class=secno>4.5.21</span> The <code>b</code> element</a><li><a href=#the-u-element><span class=secno>4.5.22</span> The <code>u</code> element</a><li><a href=#the-mark-element><span class=secno>4.5.23</span> The <code>mark</code> element</a><li><a href=#the-bdi-element><span class=secno>4.5.24</span> The <code>bdi</code> element</a><li><a href=#the-bdo-element><span class=secno>4.5.25</span> The <code>bdo</code> element</a><li><a href=#the-span-element><span class=secno>4.5.26</span> The <code>span</code> element</a><li><a href=#the-br-element><span class=secno>4.5.27</span> The <code>br</code> element</a><li><a href=#the-wbr-element><span class=secno>4.5.28</span> The <code>wbr</code> element</a><li><a href=#usage-summary><span class=secno>4.5.29</span> Usage summary</a></ol><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><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><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><a href=#following-hyperlinks><span class=secno>4.6.4</span> Following hyperlinks</a><li><a href=#downloading-resources><span class=secno>4.6.5</span> Downloading resources</a><ol><li><a href=#hyperlink-auditing><span class=secno>4.6.5.1</span> Hyperlink auditing</a></ol><li><a href=#linkTypes><span class=secno>4.6.6</span> Link types</a><ol><li><a href=#rel-alternate><span class=secno>4.6.6.1</span> Link type "<code>alternate</code>"</a><li><a href=#link-type-author><span class=secno>4.6.6.2</span> Link type "<code>author</code>"</a><li><a href=#link-type-bookmark><span class=secno>4.6.6.3</span> Link type "<code>bookmark</code>"</a><li><a href=#link-type-canonical><span class=secno>4.6.6.4</span> Link type "<code>canonical</code>"</a><li><a href=#link-type-dns-prefetch><span class=secno>4.6.6.5</span> Link type "<code>dns-prefetch</code>"</a><li><a href=#link-type-external><span class=secno>4.6.6.6</span> Link type "<code>external</code>"</a><li><a href=#link-type-help><span class=secno>4.6.6.7</span> Link type "<code>help</code>"</a><li><a href=#rel-icon><span class=secno>4.6.6.8</span> Link type "<code>icon</code>"</a><li><a href=#link-type-license><span class=secno>4.6.6.9</span> Link type "<code>license</code>"</a><li><a href=#link-type-modulepreload><span class=secno>4.6.6.10</span> Link type "<code>modulepreload</code>"</a><li><a href=#link-type-nofollow><span class=secno>4.6.6.11</span> Link type "<code>nofollow</code>"</a><li><a href=#link-type-noopener><span class=secno>4.6.6.12</span> Link type "<code>noopener</code>"</a><li><a href=#link-type-noreferrer><span class=secno>4.6.6.13</span> Link type "<code>noreferrer</code>"</a><li><a href=#link-type-pingback><span class=secno>4.6.6.14</span> Link type "<code>pingback</code>"</a><li><a href=#link-type-preconnect><span class=secno>4.6.6.15</span> Link type "<code>preconnect</code>"</a><li><a href=#link-type-prefetch><span class=secno>4.6.6.16</span> Link type "<code>prefetch</code>"</a><li><a href=#link-type-preload><span class=secno>4.6.6.17</span> Link type "<code>preload</code>"</a><li><a href=#link-type-prerender><span class=secno>4.6.6.18</span> Link type "<code>prerender</code>"</a><li><a href=#link-type-search><span class=secno>4.6.6.19</span> Link type "<code>search</code>"</a><li><a href=#link-type-stylesheet><span class=secno>4.6.6.20</span> Link type "<code>stylesheet</code>"</a><li><a href=#link-type-tag><span class=secno>4.6.6.21</span> Link type "<code>tag</code>"</a><li><a href=#sequential-link-types><span class=secno>4.6.6.22</span> Sequential link types</a><ol><li><a href=#link-type-next><span class=secno>4.6.6.22.1</span> Link type "<code>next</code>"</a><li><a href=#link-type-prev><span class=secno>4.6.6.22.2</span> Link type "<code>prev</code>"</a></ol><li><a href=#other-link-types><span class=secno>4.6.6.23</span> Other link types</a></ol></ol><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><a href=#the-del-element><span class=secno>4.7.2</span> The <code>del</code> element</a><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><a href=#edits-and-paragraphs><span class=secno>4.7.4</span> Edits and paragraphs</a><li><a href=#edits-and-lists><span class=secno>4.7.5</span> Edits and lists</a><li><a href=#edits-and-tables><span class=secno>4.7.6</span> Edits and tables</a></ol><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><a href=#the-source-element><span class=secno>4.8.2</span> The <code>source</code> element</a><li><a href=#the-img-element><span class=secno>4.8.3</span> The <code>img</code> element</a><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></ol><li><a href=#attributes-common-to-source-and-img-elements><span class=secno>4.8.4.2</span> Attributes common to <code>source</code> and <code>img</code> elements</a><ol><li><a href=#srcset-attributes><span class=secno>4.8.4.2.1</span> Srcset attributes</a><li><a href=#sizes-attributes><span class=secno>4.8.4.2.2</span> Sizes attributes</a></ol><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><a href=#reacting-to-dom-mutations><span class=secno>4.8.4.3.2</span> Reacting to DOM mutations</a><li><a href=#the-list-of-available-images><span class=secno>4.8.4.3.3</span> The list of available images</a><li><a href=#decoding-images><span class=secno>4.8.4.3.4</span> Decoding images</a><li><a href=#updating-the-image-data><span class=secno>4.8.4.3.5</span> Updating the image data</a><li><a href=#selecting-an-image-source><span class=secno>4.8.4.3.6</span> Selecting an image source</a><li><a href=#updating-the-source-set><span class=secno>4.8.4.3.7</span> Updating the source set</a><li><a href=#parsing-a-srcset-attribute><span class=secno>4.8.4.3.8</span> Parsing a srcset attribute</a><li><a href=#parsing-a-sizes-attribute><span class=secno>4.8.4.3.9</span> Parsing a sizes attribute</a><li><a href=#normalizing-the-source-densities><span class=secno>4.8.4.3.10</span> Normalizing the source densities</a><li><a href=#reacting-to-environment-changes><span class=secno>4.8.4.3.11</span> Reacting to environment changes</a></ol><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><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><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><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><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><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><a href=#ancillary-images><span class=secno>4.8.4.4.7</span> Ancillary images</a><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><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><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><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><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><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 e-mail or private document intended for a specific person who is known to be able to view images</a><li><a href=#guidance-for-markup-generators><span class=secno>4.8.4.4.14</span> Guidance for markup generators</a><li><a href=#guidance-for-conformance-checkers><span class=secno>4.8.4.4.15</span> Guidance for conformance checkers</a></ol></ol><li><a href=#the-iframe-element><span class=secno>4.8.5</span> The
  <code>iframe</code> element</a><li><a href=#the-embed-element><span class=secno>4.8.6</span> The <code>embed</code> element</a><li><a href=#the-object-element><span class=secno>4.8.7</span> The <code>object</code> element</a><li><a href=#the-param-element><span class=secno>4.8.8</span> The <code>param</code> element</a><li><a href=#the-video-element><span class=secno>4.8.9</span> The <code>video</code> element</a><li><a href=#the-audio-element><span class=secno>4.8.10</span> The <code>audio</code> element</a><li><a href=#the-track-element><span class=secno>4.8.11</span> The <code>track</code> element</a><li><a href=#media-elements><span class=secno>4.8.12</span> Media elements</a><ol><li><a href=#error-codes><span class=secno>4.8.12.1</span> Error codes</a><li><a href=#location-of-the-media-resource><span class=secno>4.8.12.2</span> Location of the media resource</a><li><a href=#mime-types><span class=secno>4.8.12.3</span> MIME types</a><li><a href=#network-states><span class=secno>4.8.12.4</span> Network states</a><li><a href=#loading-the-media-resource><span class=secno>4.8.12.5</span> Loading the media resource</a><li><a href=#offsets-into-the-media-resource><span class=secno>4.8.12.6</span> Offsets into the media resource</a><li><a href=#ready-states><span class=secno>4.8.12.7</span> Ready states</a><li><a href=#playing-the-media-resource><span class=secno>4.8.12.8</span> Playing the media resource</a><li><a href=#seeking><span class=secno>4.8.12.9</span> Seeking</a><li><a href=#media-resources-with-multiple-media-tracks><span class=secno>4.8.12.10</span> Media resources with multiple media tracks</a><ol><li><a href=#audiotracklist-and-videotracklist-objects><span class=secno>4.8.12.10.1</span> <code>AudioTrackList</code> and <code>VideoTrackList</code> objects</a><li><a href=#selecting-specific-audio-and-video-tracks-declaratively><span class=secno>4.8.12.10.2</span> Selecting specific audio and video tracks declaratively</a></ol><li><a href=#timed-text-tracks><span class=secno>4.8.12.11</span> Timed text tracks</a><ol><li><a href=#text-track-model><span class=secno>4.8.12.11.1</span> Text track model</a><li><a href=#sourcing-in-band-text-tracks><span class=secno>4.8.12.11.2</span> Sourcing in-band text tracks</a><li><a href=#sourcing-out-of-band-text-tracks><span class=secno>4.8.12.11.3</span> Sourcing out-of-band text tracks</a><li><a href=#guidelines-for-exposing-cues-in-various-formats-as-text-track-cues><span class=secno>4.8.12.11.4</span> Guidelines for exposing cues in various formats as text track cues</a><li><a href=#text-track-api><span class=secno>4.8.12.11.5</span> Text track API</a><li><a href=#cue-events><span class=secno>4.8.12.11.6</span> Event handlers for objects of the text track APIs</a><li><a href=#best-practices-for-metadata-text-tracks><span class=secno>4.8.12.11.7</span> Best practices for metadata text tracks</a></ol><li><a href=#identifying-a-track-kind-through-a-url><span class=secno>4.8.12.12</span> Identifying a track kind through a URL</a><li><a href=#user-interface><span class=secno>4.8.12.13</span> User interface</a><li><a href=#time-ranges><span class=secno>4.8.12.14</span> Time ranges</a><li><a href=#the-trackevent-interface><span class=secno>4.8.12.15</span> The <code>TrackEvent</code> interface</a><li><a href=#mediaevents><span class=secno>4.8.12.16</span> Events summary</a><li><a href=#security-and-privacy-considerations><span class=secno>4.8.12.17</span> Security and privacy considerations</a><li><a href=#best-practices-for-authors-using-media-elements><span class=secno>4.8.12.18</span> Best practices for authors using media elements</a><li><a href=#best-practices-for-implementers-of-media-elements><span class=secno>4.8.12.19</span> Best practices for implementers of media elements</a></ol><li><a href=#the-map-element><span class=secno>4.8.13</span> The <code>map</code> element</a><li><a href=#the-area-element><span class=secno>4.8.14</span> The <code>area</code> element</a><li><a href=#image-maps><span class=secno>4.8.15</span> Image maps</a><ol><li><a href=#authoring><span class=secno>4.8.15.1</span> Authoring</a><li><a href=#image-map-processing-model><span class=secno>4.8.15.2</span> Processing model</a></ol><li><a href=#mathml><span class=secno>4.8.16</span> MathML</a><li><a href=#svg-0><span class=secno>4.8.17</span> SVG</a><li><a href=#dimension-attributes><span class=secno>4.8.18</span> Dimension attributes</a></ol><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><a href=#table-layout-techniques><span class=secno>4.9.1.2</span> Techniques for table design</a></ol><li><a href=#the-caption-element><span class=secno>4.9.2</span> The <code>caption</code> element</a><li><a href=#the-colgroup-element><span class=secno>4.9.3</span> The <code>colgroup</code> element</a><li><a href=#the-col-element><span class=secno>4.9.4</span> The <code>col</code> element</a><li><a href=#the-tbody-element><span class=secno>4.9.5</span> The <code>tbody</code> element</a><li><a href=#the-thead-element><span class=secno>4.9.6</span> The <code>thead</code> element</a><li><a href=#the-tfoot-element><span class=secno>4.9.7</span> The <code>tfoot</code> element</a><li><a href=#the-tr-element><span class=secno>4.9.8</span> The <code>tr</code> element</a><li><a href=#the-td-element><span class=secno>4.9.9</span> The <code>td</code> element</a><li><a href=#the-th-element><span class=secno>4.9.10</span> The <code>th</code> element</a><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><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><a href=#header-and-data-cell-semantics><span class=secno>4.9.12.2</span> Forming relationships between data cells and header cells</a></ol><li><a href=#table-examples><span class=secno>4.9.13</span> Examples</a></ol><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><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><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><a href=#client-side-form-validation><span class=secno>4.10.1.4</span> Client-side form validation</a><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><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><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><a href=#input-author-notes><span class=secno>4.10.1.8</span> Date, time, and number formats</a></ol><li><a href=#categories><span class=secno>4.10.2</span> Categories</a><li><a href=#the-form-element><span class=secno>4.10.3</span> The <code>form</code> element</a><li><a href=#the-label-element><span class=secno>4.10.4</span> The <code>label</code> element</a><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><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><a href="#telephone-state-(type=tel)"><span class=secno>4.10.5.1.3</span> Telephone state (<code>type=tel</code>)</a><li><a href="#url-state-(type=url)"><span class=secno>4.10.5.1.4</span> URL state (<code>type=url</code>)</a><li><a href="#e-mail-state-(type=email)"><span class=secno>4.10.5.1.5</span> E-mail state (<code>type=email</code>)</a><li><a href="#password-state-(type=password)"><span class=secno>4.10.5.1.6</span> Password state (<code>type=password</code>)</a><li><a href="#date-state-(type=date)"><span class=secno>4.10.5.1.7</span> Date state (<code>type=date</code>)</a><li><a href="#month-state-(type=month)"><span class=secno>4.10.5.1.8</span> Month state (<code>type=month</code>)</a><li><a href="#week-state-(type=week)"><span class=secno>4.10.5.1.9</span> Week state (<code>type=week</code>)</a><li><a href="#time-state-(type=time)"><span class=secno>4.10.5.1.10</span> Time state (<code>type=time</code>)</a><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><a href="#number-state-(type=number)"><span class=secno>4.10.5.1.12</span> Number state (<code>type=number</code>)</a><li><a href="#range-state-(type=range)"><span class=secno>4.10.5.1.13</span> Range state (<code>type=range</code>)</a><li><a href="#color-state-(type=color)"><span class=secno>4.10.5.1.14</span> Color state (<code>type=color</code>)</a><li><a href="#checkbox-state-(type=checkbox)"><span class=secno>4.10.5.1.15</span> Checkbox state (<code>type=checkbox</code>)</a><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><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><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><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><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><a href="#button-state-(type=button)"><span class=secno>4.10.5.1.21</span> Button state (<code>type=button</code>)</a></ol><li><a href=#input-impl-notes><span class=secno>4.10.5.2</span> Implementation notes regarding localization of form controls</a><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><a href=#the-size-attribute><span class=secno>4.10.5.3.2</span> The <code>size</code> attribute</a><li><a href=#the-readonly-attribute><span class=secno>4.10.5.3.3</span> The <code>readonly</code> attribute</a><li><a href=#the-required-attribute><span class=secno>4.10.5.3.4</span> The <code>required</code> attribute</a><li><a href=#the-multiple-attribute><span class=secno>4.10.5.3.5</span> The <code>multiple</code> attribute</a><li><a href=#the-pattern-attribute><span class=secno>4.10.5.3.6</span> The <code>pattern</code> attribute</a><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><a href=#the-step-attribute><span class=secno>4.10.5.3.8</span> The <code>step</code> attribute</a><li><a href=#the-list-attribute><span class=secno>4.10.5.3.9</span> The <code>list</code> attribute</a><li><a href=#the-placeholder-attribute><span class=secno>4.10.5.3.10</span> The <code>placeholder</code> attribute</a></ol><li><a href=#common-input-element-apis><span class=secno>4.10.5.4</span> Common <code>input</code> element APIs</a><li><a href=#common-input-element-events><span class=secno>4.10.5.5</span> Common event behaviors</a></ol><li><a href=#the-button-element><span class=secno>4.10.6</span> The <code>button</code> element</a><li><a href=#the-select-element><span class=secno>4.10.7</span> The <code>select</code> element</a><li><a href=#the-datalist-element><span class=secno>4.10.8</span> The <code>datalist</code> element</a><li><a href=#the-optgroup-element><span class=secno>4.10.9</span> The <code>optgroup</code> element</a><li><a href=#the-option-element><span class=secno>4.10.10</span> The <code>option</code> element</a><li><a href=#the-textarea-element><span class=secno>4.10.11</span> The <code>textarea</code> element</a><li><a href=#the-output-element><span class=secno>4.10.12</span> The <code>output</code> element</a><li><a href=#the-progress-element><span class=secno>4.10.13</span> The <code>progress</code> element</a><li><a href=#the-meter-element><span class=secno>4.10.14</span> The <code>meter</code> element</a><li><a href=#the-fieldset-element><span class=secno>4.10.15</span> The <code>fieldset</code> element</a><li><a href=#the-legend-element><span class=secno>4.10.16</span> The <code>legend</code> element</a><li><a href=#form-control-infrastructure><span class=secno>4.10.17</span> Form control infrastructure</a><ol><li><a href="#a-form-control's-value"><span class=secno>4.10.17.1</span> A form control's value</a><li><a href=#mutability><span class=secno>4.10.17.2</span> Mutability</a><li><a href=#association-of-controls-and-forms><span class=secno>4.10.17.3</span> Association of controls and forms</a></ol><li><a href=#attributes-common-to-form-controls><span class=secno>4.10.18</span> Attributes common to form controls</a><ol><li><a href=#naming-form-controls:-the-name-attribute><span class=secno>4.10.18.1</span> Naming form controls: the <code>name</code> attribute</a><li><a href=#submitting-element-directionality:-the-dirname-attribute><span class=secno>4.10.18.2</span> Submitting element directionality: the <code>dirname</code> attribute</a><li><a href=#limiting-user-input-length:-the-maxlength-attribute><span class=secno>4.10.18.3</span> Limiting user input length: the <code>maxlength</code> attribute</a><li><a href=#setting-minimum-input-length-requirements:-the-minlength-attribute><span class=secno>4.10.18.4</span> Setting minimum input length requirements: the <code>minlength</code> attribute</a><li><a href=#enabling-and-disabling-form-controls:-the-disabled-attribute><span class=secno>4.10.18.5</span> Enabling and disabling form controls: the <code>disabled</code> attribute</a><li><a href=#form-submission><span class=secno>4.10.18.6</span> Form submission</a><ol><li><a href=#autofocusing-a-form-control:-the-autofocus-attribute><span class=secno>4.10.18.6.1</span> Autofocusing a form control: the <code>autofocus</code> attribute</a></ol><li><a href=#autofill><span class=secno>4.10.18.7</span> Autofill</a><ol><li><a href=#autofilling-form-controls:-the-autocomplete-attribute><span class=secno>4.10.18.7.1</span> Autofilling form controls: the <code>autocomplete</code> attribute</a><li><a href=#autofill-processing-model><span class=secno>4.10.18.7.2</span> Processing model</a></ol></ol><li><a href=#textFieldSelection><span class=secno>4.10.19</span> APIs for the text control selections</a><li><a href=#constraints><span class=secno>4.10.20</span> Constraints</a><ol><li><a href=#definitions><span class=secno>4.10.20.1</span> Definitions</a><li><a href=#constraint-validation><span class=secno>4.10.20.2</span> Constraint validation</a><li><a href=#the-constraint-validation-api><span class=secno>4.10.20.3</span> The constraint validation API</a><li><a href=#security-forms><span class=secno>4.10.20.4</span> Security</a></ol><li><a href=#form-submission-2><span class=secno>4.10.21</span> Form submission</a><ol><li><a href=#introduction-5><span class=secno>4.10.21.1</span> Introduction</a><li><a href=#implicit-submission><span class=secno>4.10.21.2</span> Implicit submission</a><li><a href=#form-submission-algorithm><span class=secno>4.10.21.3</span> Form submission algorithm</a><li><a href=#constructing-form-data-set><span class=secno>4.10.21.4</span> Constructing the entry list</a><li><a href=#selecting-a-form-submission-encoding><span class=secno>4.10.21.5</span> Selecting a form submission encoding</a><li><a href=#url-encoded-form-data><span class=secno>4.10.21.6</span> URL-encoded form data</a><li><a href=#multipart-form-data><span class=secno>4.10.21.7</span> Multipart form data</a><li><a href=#plain-text-form-data><span class=secno>4.10.21.8</span> Plain text form data</a></ol><li><a href=#resetting-a-form><span class=secno>4.10.22</span> Resetting a form</a></ol><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><a href=#the-summary-element><span class=secno>4.11.2</span> The <code>summary</code> element</a><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><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><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><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><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><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><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></ol><li><a href=#the-dialog-element><span class=secno>4.11.4</span> The <code>dialog</code> element</a></ol><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><a href=#scriptingLanguages><span class=secno>4.12.1.2</span> Scripting languages</a><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><a href=#inline-documentation-for-external-scripts><span class=secno>4.12.1.4</span> Inline documentation for external scripts</a><li><a href=#scriptTagXSLT><span class=secno>4.12.1.5</span> Interaction of <code>script</code> elements and XSLT</a></ol><li><a href=#the-noscript-element><span class=secno>4.12.2</span> The <code>noscript</code> element</a><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></ol><li><a href=#the-slot-element><span class=secno>4.12.4</span> The <code>slot</code> element</a><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><a href=#the-canvas-state><span class=secno>4.12.5.1.2</span> The canvas state</a><li><a href=#line-styles><span class=secno>4.12.5.1.3</span> Line styles</a><li><a href=#text-styles><span class=secno>4.12.5.1.4</span> Text styles</a><li><a href=#building-paths><span class=secno>4.12.5.1.5</span> Building paths</a><li><a href=#path2d-objects><span class=secno>4.12.5.1.6</span> <code>Path2D</code> objects</a><li><a href=#transformations><span class=secno>4.12.5.1.7</span> Transformations</a><li><a href=#image-sources-for-2d-rendering-contexts><span class=secno>4.12.5.1.8</span> Image sources for 2D rendering contexts</a><li><a href=#fill-and-stroke-styles><span class=secno>4.12.5.1.9</span> Fill and stroke styles</a><li><a href=#drawing-rectangles-to-the-bitmap><span class=secno>4.12.5.1.10</span> Drawing rectangles to the bitmap</a><li><a href=#drawing-text-to-the-bitmap><span class=secno>4.12.5.1.11</span> Drawing text to the bitmap</a><li><a href=#drawing-paths-to-the-canvas><span class=secno>4.12.5.1.12</span> Drawing paths to the canvas</a><li><a href=#drawing-focus-rings-and-scrolling-paths-into-view><span class=secno>4.12.5.1.13</span> Drawing focus rings and scrolling paths into view</a><li><a href=#drawing-images><span class=secno>4.12.5.1.14</span> Drawing images</a><li><a href=#pixel-manipulation><span class=secno>4.12.5.1.15</span> Pixel manipulation</a><li><a href=#compositing><span class=secno>4.12.5.1.16</span> Compositing</a><li><a href=#image-smoothing><span class=secno>4.12.5.1.17</span> Image smoothing</a><li><a href=#shadows><span class=secno>4.12.5.1.18</span> Shadows</a><li><a href=#filters><span class=secno>4.12.5.1.19</span> Filters</a><li><a href=#working-with-externally-defined-svg-filters><span class=secno>4.12.5.1.20</span> Working with externally-defined SVG filters</a><li><a href=#drawing-model><span class=secno>4.12.5.1.21</span> Drawing model</a><li><a href=#best-practices><span class=secno>4.12.5.1.22</span> Best practices</a><li><a href=#examples><span class=secno>4.12.5.1.23</span> Examples</a></ol><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><a href=#the-imagebitmaprenderingcontext-interface><span class=secno>4.12.5.2.2</span> The <code>ImageBitmapRenderingContext</code> interface</a></ol><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></ol><li><a href=#colour-spaces-and-colour-correction><span class=secno>4.12.5.4</span> Color spaces and color correction</a><li><a href=#serialising-bitmaps-to-a-file><span class=secno>4.12.5.5</span> Serializing bitmaps to a file</a><li><a href=#security-with-canvas-elements><span class=secno>4.12.5.6</span> Security with <code>canvas</code> elements</a></ol></ol><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><a href=#custom-elements-customized-builtin-example><span class=secno>4.13.1.2</span> Creating a customized built-in element</a><li><a href=#custom-elements-autonomous-drawbacks><span class=secno>4.13.1.3</span> Drawbacks of autonomous custom elements</a><li><a href=#custom-elements-upgrades-examples><span class=secno>4.13.1.4</span> Upgrading elements after their creation</a></ol><li><a href=#custom-element-conformance><span class=secno>4.13.2</span> Requirements for custom element constructors</a><li><a href=#custom-elements-core-concepts><span class=secno>4.13.3</span> Core concepts</a><li><a href=#custom-elements-api><span class=secno>4.13.4</span> The <code>CustomElementRegistry</code> interface</a><li><a href=#upgrades><span class=secno>4.13.5</span> Upgrades</a><li><a href=#custom-element-reactions><span class=secno>4.13.6</span> Custom element reactions</a></ol><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> Bread crumb navigation</a><li><a href=#tag-clouds><span class=secno>4.14.2</span> Tag clouds</a><li><a href=#conversations><span class=secno>4.14.3</span> Conversations</a><li><a href=#footnotes><span class=secno>4.14.4</span> Footnotes</a></ol><li><a href=#disabled-elements><span class=secno>4.15</span> Disabled elements</a><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><a href=#case-sensitivity-of-selectors><span class=secno>4.16.2</span> Case-sensitivity of selectors</a><li><a href=#pseudo-classes><span class=secno>4.16.3</span> Pseudo-classes</a></ol></ol><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><a href=#the-basic-syntax><span class=secno>5.1.2</span> The basic syntax</a><li><a href=#typed-items><span class=secno>5.1.3</span> Typed items</a><li><a href=#global-identifiers-for-items><span class=secno>5.1.4</span> Global identifiers for items</a><li><a href=#selecting-names-when-defining-vocabularies><span class=secno>5.1.5</span> Selecting names when defining vocabularies</a></ol><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><a href=#items><span class=secno>5.2.2</span> Items</a><li><a href=#names:-the-itemprop-attribute><span class=secno>5.2.3</span> Names: the <code>itemprop</code> attribute</a><li><a href=#values><span class=secno>5.2.4</span> Values</a><li><a href=#associating-names-with-items><span class=secno>5.2.5</span> Associating names with items</a><li><a href=#microdata-and-other-namespaces><span class=secno>5.2.6</span> Microdata and other namespaces</a></ol><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><a href=#examples-2><span class=secno>5.3.1.2</span> Examples</a></ol><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><a href=#examples-3><span class=secno>5.3.2.2</span> Examples</a></ol><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></ol></ol><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></ol></ol><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><a href=#inert-subtrees><span class=secno>6.2</span> Inert subtrees</a><li><a href=#activation><span class=secno>6.3</span> Activation</a><li><a href=#focus><span class=secno>6.4</span> Focus</a><ol><li><a href=#introduction-8><span class=secno>6.4.1</span> Introduction</a><li><a href=#data-model><span class=secno>6.4.2</span> Data model</a><li><a href=#the-tabindex-attribute><span class=secno>6.4.3</span> The <code>tabindex</code> attribute</a><li><a href=#focus-processing-model><span class=secno>6.4.4</span> Processing model</a><li><a href=#sequential-focus-navigation><span class=secno>6.4.5</span> Sequential focus navigation</a><li><a href=#focus-management-apis><span class=secno>6.4.6</span> Focus management APIs</a></ol><li><a href=#assigning-keyboard-shortcuts><span class=secno>6.5</span> Assigning keyboard shortcuts</a><ol><li><a href=#introduction-9><span class=secno>6.5.1</span> Introduction</a><li><a href=#the-accesskey-attribute><span class=secno>6.5.2</span> The <code>accesskey</code> attribute</a><li><a href=#keyboard-shortcuts-processing-model><span class=secno>6.5.3</span> Processing
  model</a></ol><li><a href=#editing-2><span class=secno>6.6</span> Editing</a><ol><li><a href=#contenteditable><span class=secno>6.6.1</span> Making document regions editable: The <code>contenteditable</code> content attribute</a><li><a href=#making-entire-documents-editable:-the-designmode-idl-attribute><span class=secno>6.6.2</span> Making entire documents editable: the <code>designMode</code>
  IDL attribute</a><li><a href=#best-practices-for-in-page-editors><span class=secno>6.6.3</span> Best practices for in-page editors</a><li><a href=#editing-apis><span class=secno>6.6.4</span> Editing APIs</a><li><a href=#spelling-and-grammar-checking><span class=secno>6.6.5</span> Spelling and grammar checking</a><li><a href=#autocapitalization><span class=secno>6.6.6</span> Autocapitalization</a><li><a href=#input-modalities:-the-inputmode-attribute><span class=secno>6.6.7</span> Input modalities: the <code>inputmode</code> attribute</a><li><a href=#input-modalities:-the-enterkeyhint-attribute><span class=secno>6.6.8</span> Input modalities: the <code>enterkeyhint</code>
  attribute</a></ol><li><a href=#dnd><span class=secno>6.7</span> Drag and drop</a><ol><li><a href=#event-drag><span class=secno>6.7.1</span> Introduction</a><li><a href=#the-drag-data-store><span class=secno>6.7.2</span> The drag data store</a><li><a href=#the-datatransfer-interface><span class=secno>6.7.3</span> The <code>DataTransfer</code> interface</a><ol><li><a href=#the-datatransferitemlist-interface><span class=secno>6.7.3.1</span> The <code>DataTransferItemList</code> interface</a><li><a href=#the-datatransferitem-interface><span class=secno>6.7.3.2</span> The <code>DataTransferItem</code> interface</a></ol><li><a href=#the-dragevent-interface><span class=secno>6.7.4</span> The <code>DragEvent</code> interface</a><li><a href=#drag-and-drop-processing-model><span class=secno>6.7.5</span> Processing model</a><li><a href=#dndevents><span class=secno>6.7.6</span> Events summary</a><li><a href=#the-draggable-attribute><span class=secno>6.7.7</span> The <code>draggable</code> attribute</a><li><a href=#security-risks-in-the-drag-and-drop-model><span class=secno>6.7.8</span> Security risks in the drag-and-drop model</a></ol></ol><li id=toc-browsers><a href=#browsers><span class=secno>7</span> Loading Web pages</a><ol><li><a href=#windows><span class=secno>7.1</span> Browsing contexts</a><ol><li><a href=#nested-browsing-contexts><span class=secno>7.1.1</span> Nested browsing contexts</a><ol><li><a href=#navigating-nested-browsing-contexts-in-the-dom><span class=secno>7.1.1.1</span> Navigating nested browsing contexts in the DOM</a></ol><li><a href=#auxiliary-browsing-contexts><span class=secno>7.1.2</span> Auxiliary browsing contexts</a><ol><li><a href=#navigating-auxiliary-browsing-contexts-in-the-dom><span class=secno>7.1.2.1</span> Navigating auxiliary browsing contexts in the DOM</a></ol><li><a href=#security-nav><span class=secno>7.1.3</span> Security</a><li><a href=#groupings-of-browsing-contexts><span class=secno>7.1.4</span> Groupings of browsing contexts</a><li><a href=#browsing-context-names><span class=secno>7.1.5</span> Browsing context names</a></ol><li><a href=#cross-origin-objects><span class=secno>7.2</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</span> Integration with IDL</a><li><a href=#shared-internal-slot:-crossoriginpropertydescriptormap><span class=secno>7.2.2</span> Shared internal slot: [[CrossOriginPropertyDescriptorMap]]</a><li><a href=#shared-abstract-operations><span class=secno>7.2.3</span> Shared abstract operations</a><ol><li><a href=#crossoriginproperties-(-o-)><span class=secno>7.2.3.1</span> CrossOriginProperties ( <var>O</var> )</a><li><a href=#isplatformobjectsameorigin-(-o-)><span class=secno>7.2.3.2</span> IsPlatformObjectSameOrigin ( <var>O</var> )</a><li><a href=#crossorigingetownpropertyhelper-(-o,-p-)><span class=secno>7.2.3.3</span> CrossOriginGetOwnPropertyHelper ( <var>O</var>, <var>P</var> )</a><li><a href=#crossoriginget-(-o,-p,-receiver-)><span class=secno>7.2.3.4</span> CrossOriginGet ( <var>O</var>, <var>P</var>, <var>Receiver</var> )</a><li><a href=#crossoriginset-(-o,-p,-v,-receiver-)><span class=secno>7.2.3.5</span> CrossOriginSet ( <var>O</var>, <var>P</var>, <var>V</var>,
  <var>Receiver</var> )</a><li><a href=#crossoriginownpropertykeys-(-o-)><span class=secno>7.2.3.6</span> CrossOriginOwnPropertyKeys ( <var>O</var> )</a></ol></ol><li><a href=#the-window-object><span class=secno>7.3</span> The <code>Window</code> object</a><ol><li><a href=#apis-for-creating-and-navigating-browsing-contexts-by-name><span class=secno>7.3.1</span> APIs for creating and navigating browsing contexts by name</a><li><a href=#accessing-other-browsing-contexts><span class=secno>7.3.2</span> Accessing other browsing contexts</a><li><a href=#named-access-on-the-window-object><span class=secno>7.3.3</span> Named access on the <code>Window</code> object</a><li><a href=#garbage-collection-and-browsing-contexts><span class=secno>7.3.4</span> Garbage collection and browsing contexts</a><li><a href=#closing-browsing-contexts><span class=secno>7.3.5</span> Closing browsing contexts</a><li><a href=#browser-interface-elements><span class=secno>7.3.6</span> Browser interface elements</a><li><a href=#script-settings-for-window-objects><span class=secno>7.3.7</span> Script settings for <code>Window</code> objects</a></ol><li><a href=#the-windowproxy-exotic-object><span class=secno>7.4</span> The <code>WindowProxy</code> exotic object</a><ol><li><a href=#windowproxy-getprototypeof><span class=secno>7.4.1</span> [[GetPrototypeOf]] ( )</a><li><a href=#windowproxy-setprototypeof><span class=secno>7.4.2</span> [[SetPrototypeOf]] ( <var>V</var> )</a><li><a href=#windowproxy-isextensible><span class=secno>7.4.3</span> [[IsExtensible]] ( )</a><li><a href=#windowproxy-preventextensions><span class=secno>7.4.4</span> [[PreventExtensions]] ( )</a><li><a href=#windowproxy-getownproperty><span class=secno>7.4.5</span> [[GetOwnProperty]] ( <var>P</var> )</a><li><a href=#windowproxy-defineownproperty><span class=secno>7.4.6</span> [[DefineOwnProperty]] ( <var>P</var>, <var>Desc</var>
  )</a><li><a href=#windowproxy-get><span class=secno>7.4.7</span> [[Get]] ( <var>P</var>, <var>Receiver</var> )</a><li><a href=#windowproxy-set><span class=secno>7.4.8</span> [[Set]] ( <var>P</var>, <var>V</var>, <var>Receiver</var> )</a><li><a href=#windowproxy-delete><span class=secno>7.4.9</span> [[Delete]] ( <var>P</var> )</a><li><a href=#windowproxy-ownpropertykeys><span class=secno>7.4.10</span> [[OwnPropertyKeys]] ( )</a></ol><li><a href=#origin><span class=secno>7.5</span> Origin</a><ol><li><a href=#relaxing-the-same-origin-restriction><span class=secno>7.5.1</span> Relaxing the same-origin restriction</a></ol><li><a href=#sandboxing><span class=secno>7.6</span> Sandboxing</a><li><a href=#history><span class=secno>7.7</span> Session history and navigation</a><ol><li><a href=#the-session-history-of-browsing-contexts><span class=secno>7.7.1</span> The session history of browsing contexts</a><li><a href=#the-history-interface><span class=secno>7.7.2</span> The <code>History</code> interface</a><li><a href=#history-notes><span class=secno>7.7.3</span> Implementation notes for session history</a><li><a href=#the-location-interface><span class=secno>7.7.4</span> The <code>Location</code> interface</a><ol><li><a href=#location-getprototypeof><span class=secno>7.7.4.1</span> [[GetPrototypeOf]] ( )</a><li><a href=#location-setprototypeof><span class=secno>7.7.4.2</span> [[SetPrototypeOf]] ( <var>V</var> )</a><li><a href=#location-isextensible><span class=secno>7.7.4.3</span> [[IsExtensible]] ( )</a><li><a href=#location-preventextensions><span class=secno>7.7.4.4</span> [[PreventExtensions]] ( )</a><li><a href=#location-getownproperty><span class=secno>7.7.4.5</span> [[GetOwnProperty]] ( <var>P</var> )</a><li><a href=#location-defineownproperty><span class=secno>7.7.4.6</span> [[DefineOwnProperty]] ( <var>P</var>, <var>Desc</var> )</a><li><a href=#location-get><span class=secno>7.7.4.7</span> [[Get]] ( <var>P</var>, <var>Receiver</var> )</a><li><a href=#location-set><span class=secno>7.7.4.8</span> [[Set]] ( <var>P</var>, <var>V</var>, <var>Receiver</var> )</a><li><a href=#location-delete><span class=secno>7.7.4.9</span> [[Delete]] ( <var>P</var> )</a><li><a href=#location-ownpropertykeys><span class=secno>7.7.4.10</span> [[OwnPropertyKeys]] ( )</a></ol></ol><li><a href=#browsing-the-web><span class=secno>7.8</span> Browsing the Web</a><ol><li><a href=#navigating-across-documents><span class=secno>7.8.1</span> Navigating across documents</a><li><a href=#read-html><span class=secno>7.8.2</span> Page load processing model for HTML files</a><li><a href=#read-xml><span class=secno>7.8.3</span> Page load processing model for XML files</a><li><a href=#read-text><span class=secno>7.8.4</span> Page load processing model for text files</a><li><a href=#read-multipart-x-mixed-replace><span class=secno>7.8.5</span> Page load processing model for <code>multipart/x-mixed-replace</code> resources</a><li><a href=#read-media><span class=secno>7.8.6</span> Page load processing model for media</a><li><a href=#read-plugin><span class=secno>7.8.7</span> Page load processing model for content that uses plugins</a><li><a href=#read-ua-inline><span class=secno>7.8.8</span> Page load processing model for inline
  content that doesn't have a DOM</a><li><a href=#scroll-to-fragid><span class=secno>7.8.9</span> Navigating to a fragment</a><li><a href=#history-traversal><span class=secno>7.8.10</span> History traversal</a><ol><li><a href=#persisted-user-state-restoration><span class=secno>7.8.10.1</span> Persisted user state restoration</a><li><a href=#the-popstateevent-interface><span class=secno>7.8.10.2</span> The <code>PopStateEvent</code> interface</a><li><a href=#the-hashchangeevent-interface><span class=secno>7.8.10.3</span> The <code>HashChangeEvent</code> interface</a><li><a href=#the-pagetransitionevent-interface><span class=secno>7.8.10.4</span> The <code>PageTransitionEvent</code> interface</a></ol><li><a href=#unloading-documents><span class=secno>7.8.11</span> Unloading documents</a><ol><li><a href=#the-beforeunloadevent-interface><span class=secno>7.8.11.1</span> The <code>BeforeUnloadEvent</code> interface</a></ol><li><a href=#aborting-a-document-load><span class=secno>7.8.12</span> Aborting a document load</a></ol><li><a href=#offline><span class=secno>7.9</span> Offline Web applications</a><ol><li><a href=#introduction-10><span class=secno>7.9.1</span> Introduction</a><ol><li><a href=#supporting-offline-caching-for-legacy-applications><span class=secno>7.9.1.1</span> Supporting offline caching for legacy applications</a><li><a href=#appcacheevents><span class=secno>7.9.1.2</span> Events summary</a></ol><li><a href=#appcache><span class=secno>7.9.2</span> Application caches</a><li><a href=#manifests><span class=secno>7.9.3</span> The cache manifest syntax</a><ol><li><a href=#some-sample-manifests><span class=secno>7.9.3.1</span> Some sample manifests</a><li><a href=#writing-cache-manifests><span class=secno>7.9.3.2</span> Writing cache manifests</a><li><a href=#parsing-cache-manifests><span class=secno>7.9.3.3</span> Parsing cache manifests</a></ol><li><a href=#downloading-or-updating-an-application-cache><span class=secno>7.9.4</span> Downloading or updating an application cache</a><li><a href=#the-application-cache-selection-algorithm><span class=secno>7.9.5</span> The application cache selection algorithm</a><li><a href=#changesToNetworkingModel><span class=secno>7.9.6</span> Changes to the networking model</a><li><a href=#expiring-application-caches><span class=secno>7.9.7</span> Expiring application caches</a><li><a href=#disk-space><span class=secno>7.9.8</span> Disk space</a><li><a href=#security-concerns-with-offline-applications-caches><span class=secno>7.9.9</span> Security concerns with offline applications caches</a><li><a href=#application-cache-api><span class=secno>7.9.10</span> Application cache API</a><li><a href=#navigator.online><span class=secno>7.9.11</span> Browser state</a></ol></ol><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><a href=#enabling-and-disabling-scripting><span class=secno>8.1.2</span> Enabling and disabling scripting</a><li><a href=#scripting-processing-model><span class=secno>8.1.3</span> Processing model</a><ol><li><a href=#definitions-2><span class=secno>8.1.3.1</span> Definitions</a><li><a href=#fetching-scripts><span class=secno>8.1.3.2</span> Fetching scripts</a><li><a href=#creating-scripts><span class=secno>8.1.3.3</span> Creating scripts</a><li><a href=#calling-scripts><span class=secno>8.1.3.4</span> Calling scripts</a><li><a href=#realms-settings-objects-global-objects><span class=secno>8.1.3.5</span> Realms, settings objects, and global objects</a><ol><li><a href=#entry><span class=secno>8.1.3.5.1</span> Entry</a><li><a href=#incumbent><span class=secno>8.1.3.5.2</span> Incumbent</a><li><a href=#current><span class=secno>8.1.3.5.3</span> Current</a><li><a href=#relevant><span class=secno>8.1.3.5.4</span> Relevant</a></ol><li><a href=#killing-scripts><span class=secno>8.1.3.6</span> Killing scripts</a><li><a href=#integration-with-the-javascript-job-queue><span class=secno>8.1.3.7</span> Integration with the JavaScript job queue</a><ol><li><a href=#enqueuejob(queuename,-job,-arguments)><span class=secno>8.1.3.7.1</span> EnqueueJob(<var>queueName</var>, <var>job</var>, <var>arguments</var>)</a></ol><li><a href=#integration-with-the-javascript-module-system><span class=secno>8.1.3.8</span> Integration with the JavaScript module system</a><ol><li><a href=#hostresolveimportedmodule(referencingscriptormodule,-specifier)><span class=secno>8.1.3.8.1</span> HostResolveImportedModule(<var>referencingScriptOrModule</var>,
  <var>specifier</var>)</a><li><a href=#hostimportmoduledynamically(referencingscriptormodule,-specifier,-promisecapability)><span class=secno>8.1.3.8.2</span> HostImportModuleDynamically(<var>referencingScriptOrModule</var>,
  <var>specifier</var>, <var>promiseCapability</var>)</a><li><a href=#hostgetimportmetaproperties><span class=secno>8.1.3.8.3</span> HostGetImportMetaProperties(<var>moduleRecord</var>)</a></ol><li><a href=#integration-with-the-javascript-agent-formalism><span class=secno>8.1.3.9</span> Integration with the JavaScript agent formalism</a><li><a href=#integration-with-the-javascript-agent-cluster-formalism><span class=secno>8.1.3.10</span> Integration with the JavaScript agent cluster formalism</a><li><a href=#runtime-script-errors><span class=secno>8.1.3.11</span> Runtime script errors</a><ol><li><a href=#runtime-script-errors-in-documents><span class=secno>8.1.3.11.1</span> Runtime script errors in documents</a><li><a href=#the-errorevent-interface><span class=secno>8.1.3.11.2</span> The <code>ErrorEvent</code> interface</a></ol><li><a href=#unhandled-promise-rejections><span class=secno>8.1.3.12</span> Unhandled promise rejections</a><ol><li><a href=#the-hostpromiserejectiontracker-implementation><span class=secno>8.1.3.12.1</span> HostPromiseRejectionTracker(<var>promise</var>, <var>operation</var>)</a><li><a href=#the-promiserejectionevent-interface><span class=secno>8.1.3.12.2</span> The <code>PromiseRejectionEvent</code> interface</a></ol><li><a href=#hostensurecancompilestrings(callerrealm,-calleerealm)><span class=secno>8.1.3.13</span> HostEnsureCanCompileStrings(<var>callerRealm</var>, <var>calleeRealm</var>)</a></ol><li><a href=#event-loops><span class=secno>8.1.4</span> Event loops</a><ol><li><a href=#definitions-3><span class=secno>8.1.4.1</span> Definitions</a><li><a href=#event-loop-processing-model><span class=secno>8.1.4.2</span> Processing model</a><li><a href=#generic-task-sources><span class=secno>8.1.4.3</span> Generic task sources</a><li><a href=#event-loop-for-spec-authors><span class=secno>8.1.4.4</span> Dealing with the event loop from other specifications</a></ol><li><a href=#events><span class=secno>8.1.5</span> Events</a><ol><li><a href=#event-handler-attributes><span class=secno>8.1.5.1</span> Event handlers</a><li><a href=#event-handlers-on-elements,-document-objects,-and-window-objects><span class=secno>8.1.5.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.5.2.1</span> IDL definitions</a></ol><li><a href=#event-firing><span class=secno>8.1.5.3</span> Event firing</a></ol></ol><li><a href=#windoworworkerglobalscope-mixin><span class=secno>8.2</span> The <code>WindowOrWorkerGlobalScope</code> mixin</a><li><a href=#atob><span class=secno>8.3</span> Base64 utility methods</a><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><a href=#closing-the-input-stream><span class=secno>8.4.2</span> Closing the input stream</a><li><a href=#document.write()><span class=secno>8.4.3</span> <code>document.write()</code></a><li><a href=#document.writeln()><span class=secno>8.4.4</span> <code>document.writeln()</code></a></ol><li><a href=#timers><span class=secno>8.5</span> Timers</a><li><a href=#microtask-queuing><span class=secno>8.6</span> Microtask queuing</a><li><a href=#user-prompts><span class=secno>8.7</span> User prompts</a><ol><li><a href=#simple-dialogs><span class=secno>8.7.1</span> Simple dialogs</a><li><a href=#printing><span class=secno>8.7.2</span> Printing</a></ol><li><a href=#system-state-and-capabilities><span class=secno>8.8</span> System state and capabilities</a><ol><li><a href=#the-navigator-object><span class=secno>8.8.1</span> The <code>Navigator</code> object</a><ol><li><a href=#client-identification><span class=secno>8.8.1.1</span> Client identification</a><li><a href=#language-preferences><span class=secno>8.8.1.2</span> Language preferences</a><li><a href=#custom-handlers><span class=secno>8.8.1.3</span> Custom scheme handlers: the <code>registerProtocolHandler()</code> method</a><ol><li><a href=#security-and-privacy><span class=secno>8.8.1.3.1</span> Security and privacy</a></ol><li><a href=#cookies><span class=secno>8.8.1.4</span> Cookies</a><li><a href=#plugins-2><span class=secno>8.8.1.5</span> Plugins</a></ol></ol><li><a href=#images-2><span class=secno>8.9</span> Images</a><li><a href=#animation-frames><span class=secno>8.10</span> Animation frames</a></ol><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><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><a href=#the-eventsource-interface><span class=secno>9.2.2</span> The <code>EventSource</code> interface</a><li><a href=#sse-processing-model><span class=secno>9.2.3</span> Processing model</a><li><a href=#parsing-an-event-stream><span class=secno>9.2.4</span> Parsing an event stream</a><li><a href=#event-stream-interpretation><span class=secno>9.2.5</span> Interpreting an event stream</a><li><a href=#authoring-notes><span class=secno>9.2.6</span> Authoring notes</a><li><a href=#eventsource-push><span class=secno>9.2.7</span> Connectionless push and other features</a><li><a href=#garbage-collection-2><span class=secno>9.2.8</span> Garbage collection</a><li><a href=#implementation-advice><span class=secno>9.2.9</span> Implementation advice</a></ol><li><a href=#network><span class=secno>9.3</span> Web sockets</a><ol><li><a href=#network-intro><span class=secno>9.3.1</span> Introduction</a><li><a href=#the-websocket-interface><span class=secno>9.3.2</span> The <code>WebSocket</code> interface</a><li><a href=#feedback-from-the-protocol><span class=secno>9.3.3</span> Feedback from the protocol</a><li><a href=#ping-and-pong-frames><span class=secno>9.3.4</span> Ping and Pong frames</a><li><a href=#the-closeevent-interface><span class=secno>9.3.5</span> The <code>CloseEvent</code> interface</a><li><a href=#garbage-collection-3><span class=secno>9.3.6</span> Garbage collection</a></ol><li><a href=#web-messaging><span class=secno>9.4</span> Cross-document messaging</a><ol><li><a href=#introduction-12><span class=secno>9.4.1</span> Introduction</a><li><a href=#security-postmsg><span class=secno>9.4.2</span> Security</a><ol><li><a href=#authors><span class=secno>9.4.2.1</span> Authors</a><li><a href=#user-agents><span class=secno>9.4.2.2</span> User agents</a></ol><li><a href=#posting-messages><span class=secno>9.4.3</span> Posting messages</a></ol><li><a href=#channel-messaging><span class=secno>9.5</span> Channel messaging</a><ol><li><a href=#introduction-13><span class=secno>9.5.1</span> Introduction</a><ol><li><a href=#examples-5><span class=secno>9.5.1.1</span> Examples</a><li><a href=#ports-as-the-basis-of-an-object-capability-model-on-the-web><span class=secno>9.5.1.2</span> Ports as the basis of an object-capability model on the Web</a><li><a href=#ports-as-the-basis-of-abstracting-out-service-implementations><span class=secno>9.5.1.3</span> Ports as the basis of abstracting out service implementations</a></ol><li><a href=#message-channels><span class=secno>9.5.2</span> Message channels</a><li><a href=#message-ports><span class=secno>9.5.3</span> Message ports</a><li><a href=#broadcasting-to-many-ports><span class=secno>9.5.4</span> Broadcasting to many ports</a><li><a href=#ports-and-garbage-collection><span class=secno>9.5.5</span> Ports and garbage collection</a></ol><li><a href=#broadcasting-to-other-browsing-contexts><span class=secno>9.6</span> Broadcasting to other browsing contexts</a></ol><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><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><a href=#module-worker-example><span class=secno>10.1.2.2</span> Using a JavaScript module as a worker</a><li><a href=#shared-workers-introduction><span class=secno>10.1.2.3</span> Shared workers introduction</a><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><a href=#delegation><span class=secno>10.1.2.5</span> Delegation</a><li><a href=#providing-libraries><span class=secno>10.1.2.6</span> Providing libraries</a></ol><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><a href=#communicating-with-a-dedicated-worker><span class=secno>10.1.3.2</span> Communicating with a dedicated worker</a><li><a href=#shared-workers><span class=secno>10.1.3.3</span> Shared workers</a></ol></ol><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><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><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></ol><li><a href=#worker-event-loop><span class=secno>10.2.2</span> The event loop</a><li><a href="#the-worker's-lifetime"><span class=secno>10.2.3</span> The worker's lifetime</a><li><a href=#worker-processing-model><span class=secno>10.2.4</span> Processing model</a><li><a href=#runtime-script-errors-2><span class=secno>10.2.5</span> Runtime script errors</a><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><a href=#script-settings-for-workers><span class=secno>10.2.6.2</span> Script settings for workers</a><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><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></ol><li><a href=#navigator.hardwareconcurrency><span class=secno>10.2.7</span> Concurrent hardware capabilities</a></ol><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><a href=#the-workernavigator-object><span class=secno>10.3.2</span> The <code>WorkerNavigator</code> interface</a><li><a href=#worker-locations><span class=secno>10.3.3</span> The <code>WorkerLocation</code> interface</a></ol></ol><li id=toc-webstorage><a href=#webstorage><span class=secno>11</span> Web storage</a><ol><li><a href=#introduction-15><span class=secno>11.1</span> Introduction</a><li><a href=#storage><span class=secno>11.2</span> The API</a><ol><li><a href=#the-storage-interface><span class=secno>11.2.1</span> The <code>Storage</code> interface</a><li><a href=#the-sessionstorage-attribute><span class=secno>11.2.2</span> The <code>sessionStorage</code> attribute</a><li><a href=#the-localstorage-attribute><span class=secno>11.2.3</span> The <code>localStorage</code> attribute</a><li><a href=#the-storage-event><span class=secno>11.2.4</span> The <code>storage</code> event</a><ol><li><a href=#the-storageevent-interface><span class=secno>11.2.4.1</span> The <code>StorageEvent</code> interface</a></ol></ol><li><a href=#disk-space-2><span class=secno>11.3</span> Disk space</a><li><a href=#privacy><span class=secno>11.4</span> Privacy</a><ol><li><a href=#user-tracking><span class=secno>11.4.1</span> User tracking</a><li><a href=#sensitivity-of-data><span class=secno>11.4.2</span> Sensitivity of data</a></ol><li><a href=#security-storage><span class=secno>11.5</span> Security</a><ol><li><a href=#dns-spoofing-attacks><span class=secno>11.5.1</span> DNS spoofing attacks</a><li><a href=#cross-directory-attacks><span class=secno>11.5.2</span> Cross-directory attacks</a><li><a href=#implementation-risks><span class=secno>11.5.3</span> Implementation risks</a></ol></ol><li id=toc-syntax><a href=#syntax><span class=secno>12</span> The HTML syntax</a><ol><li><a href=#writing><span class=secno>12.1</span> Writing HTML documents</a><ol><li><a href=#the-doctype><span class=secno>12.1.1</span> The DOCTYPE</a><li><a href=#elements-2><span class=secno>12.1.2</span> Elements</a><ol><li><a href=#start-tags><span class=secno>12.1.2.1</span> Start tags</a><li><a href=#end-tags><span class=secno>12.1.2.2</span> End tags</a><li><a href=#attributes-2><span class=secno>12.1.2.3</span> Attributes</a><li><a href=#optional-tags><span class=secno>12.1.2.4</span> Optional tags</a><li><a href=#element-restrictions><span class=secno>12.1.2.5</span> Restrictions on content models</a><li><a href=#cdata-rcdata-restrictions><span class=secno>12.1.2.6</span> Restrictions on the contents of raw text and escapable raw text elements</a></ol><li><a href=#text-2><span class=secno>12.1.3</span> Text</a><ol><li><a href=#newlines><span class=secno>12.1.3.1</span> Newlines</a></ol><li><a href=#character-references><span class=secno>12.1.4</span> Character references</a><li><a href=#cdata-sections><span class=secno>12.1.5</span> CDATA sections</a><li><a href=#comments><span class=secno>12.1.6</span> Comments</a></ol><li><a href=#parsing><span class=secno>12.2</span> Parsing HTML documents</a><ol><li><a href=#overview-of-the-parsing-model><span class=secno>12.2.1</span> Overview of the parsing model</a><li><a href=#parse-errors><span class=secno>12.2.2</span> Parse errors</a><li><a href=#the-input-byte-stream><span class=secno>12.2.3</span> The input byte stream</a><ol><li><a href=#parsing-with-a-known-character-encoding><span class=secno>12.2.3.1</span> Parsing with a known character encoding</a><li><a href=#determining-the-character-encoding><span class=secno>12.2.3.2</span> Determining the character encoding</a><li><a href=#character-encodings><span class=secno>12.2.3.3</span> Character encodings</a><li><a href=#changing-the-encoding-while-parsing><span class=secno>12.2.3.4</span> Changing the encoding while parsing</a><li><a href=#preprocessing-the-input-stream><span class=secno>12.2.3.5</span> Preprocessing the input stream</a></ol><li><a href=#parse-state><span class=secno>12.2.4</span> Parse state</a><ol><li><a href=#the-insertion-mode><span class=secno>12.2.4.1</span> The insertion mode</a><li><a href=#the-stack-of-open-elements><span class=secno>12.2.4.2</span> The stack of open elements</a><li><a href=#the-list-of-active-formatting-elements><span class=secno>12.2.4.3</span> The list of active formatting elements</a><li><a href=#the-element-pointers><span class=secno>12.2.4.4</span> The element pointers</a><li><a href=#other-parsing-state-flags><span class=secno>12.2.4.5</span> Other parsing state flags</a></ol><li><a href=#tokenization><span class=secno>12.2.5</span> Tokenization</a><ol><li><a href=#data-state><span class=secno>12.2.5.1</span> Data state</a><li><a href=#rcdata-state><span class=secno>12.2.5.2</span> RCDATA state</a><li><a href=#rawtext-state><span class=secno>12.2.5.3</span> RAWTEXT state</a><li><a href=#script-data-state><span class=secno>12.2.5.4</span> Script data state</a><li><a href=#plaintext-state><span class=secno>12.2.5.5</span> PLAINTEXT state</a><li><a href=#tag-open-state><span class=secno>12.2.5.6</span> Tag open state</a><li><a href=#end-tag-open-state><span class=secno>12.2.5.7</span> End tag open state</a><li><a href=#tag-name-state><span class=secno>12.2.5.8</span> Tag name state</a><li><a href=#rcdata-less-than-sign-state><span class=secno>12.2.5.9</span> RCDATA less-than sign state</a><li><a href=#rcdata-end-tag-open-state><span class=secno>12.2.5.10</span> RCDATA end tag open state</a><li><a href=#rcdata-end-tag-name-state><span class=secno>12.2.5.11</span> RCDATA end tag name state</a><li><a href=#rawtext-less-than-sign-state><span class=secno>12.2.5.12</span> RAWTEXT less-than sign state</a><li><a href=#rawtext-end-tag-open-state><span class=secno>12.2.5.13</span> RAWTEXT end tag open state</a><li><a href=#rawtext-end-tag-name-state><span class=secno>12.2.5.14</span> RAWTEXT end tag name state</a><li><a href=#script-data-less-than-sign-state><span class=secno>12.2.5.15</span> Script data less-than sign state</a><li><a href=#script-data-end-tag-open-state><span class=secno>12.2.5.16</span> Script data end tag open state</a><li><a href=#script-data-end-tag-name-state><span class=secno>12.2.5.17</span> Script data end tag name state</a><li><a href=#script-data-escape-start-state><span class=secno>12.2.5.18</span> Script data escape start state</a><li><a href=#script-data-escape-start-dash-state><span class=secno>12.2.5.19</span> Script data escape start dash state</a><li><a href=#script-data-escaped-state><span class=secno>12.2.5.20</span> Script data escaped state</a><li><a href=#script-data-escaped-dash-state><span class=secno>12.2.5.21</span> Script data escaped dash state</a><li><a href=#script-data-escaped-dash-dash-state><span class=secno>12.2.5.22</span> Script data escaped dash dash state</a><li><a href=#script-data-escaped-less-than-sign-state><span class=secno>12.2.5.23</span> Script data escaped less-than sign state</a><li><a href=#script-data-escaped-end-tag-open-state><span class=secno>12.2.5.24</span> Script data escaped end tag open state</a><li><a href=#script-data-escaped-end-tag-name-state><span class=secno>12.2.5.25</span> Script data escaped end tag name state</a><li><a href=#script-data-double-escape-start-state><span class=secno>12.2.5.26</span> Script data double escape start state</a><li><a href=#script-data-double-escaped-state><span class=secno>12.2.5.27</span> Script data double escaped state</a><li><a href=#script-data-double-escaped-dash-state><span class=secno>12.2.5.28</span> Script data double escaped dash state</a><li><a href=#script-data-double-escaped-dash-dash-state><span class=secno>12.2.5.29</span> Script data double escaped dash dash state</a><li><a href=#script-data-double-escaped-less-than-sign-state><span class=secno>12.2.5.30</span> Script data double escaped less-than sign state</a><li><a href=#script-data-double-escape-end-state><span class=secno>12.2.5.31</span> Script data double escape end state</a><li><a href=#before-attribute-name-state><span class=secno>12.2.5.32</span> Before attribute name state</a><li><a href=#attribute-name-state><span class=secno>12.2.5.33</span> Attribute name state</a><li><a href=#after-attribute-name-state><span class=secno>12.2.5.34</span> After attribute name state</a><li><a href=#before-attribute-value-state><span class=secno>12.2.5.35</span> Before attribute value state</a><li><a href=#attribute-value-(double-quoted)-state><span class=secno>12.2.5.36</span> Attribute value (double-quoted) state</a><li><a href=#attribute-value-(single-quoted)-state><span class=secno>12.2.5.37</span> Attribute value (single-quoted) state</a><li><a href=#attribute-value-(unquoted)-state><span class=secno>12.2.5.38</span> Attribute value (unquoted) state</a><li><a href=#after-attribute-value-(quoted)-state><span class=secno>12.2.5.39</span> After attribute value (quoted) state</a><li><a href=#self-closing-start-tag-state><span class=secno>12.2.5.40</span> Self-closing start tag state</a><li><a href=#bogus-comment-state><span class=secno>12.2.5.41</span> Bogus comment state</a><li><a href=#markup-declaration-open-state><span class=secno>12.2.5.42</span> Markup declaration open state</a><li><a href=#comment-start-state><span class=secno>12.2.5.43</span> Comment start state</a><li><a href=#comment-start-dash-state><span class=secno>12.2.5.44</span> Comment start dash state</a><li><a href=#comment-state><span class=secno>12.2.5.45</span> Comment state</a><li><a href=#comment-less-than-sign-state><span class=secno>12.2.5.46</span> Comment less-than sign state</a><li><a href=#comment-less-than-sign-bang-state><span class=secno>12.2.5.47</span> Comment less-than sign bang state</a><li><a href=#comment-less-than-sign-bang-dash-state><span class=secno>12.2.5.48</span> Comment less-than sign bang dash state</a><li><a href=#comment-less-than-sign-bang-dash-dash-state><span class=secno>12.2.5.49</span> Comment less-than sign bang dash dash state</a><li><a href=#comment-end-dash-state><span class=secno>12.2.5.50</span> Comment end dash state</a><li><a href=#comment-end-state><span class=secno>12.2.5.51</span> Comment end state</a><li><a href=#comment-end-bang-state><span class=secno>12.2.5.52</span> Comment end bang state</a><li><a href=#doctype-state><span class=secno>12.2.5.53</span> DOCTYPE state</a><li><a href=#before-doctype-name-state><span class=secno>12.2.5.54</span> Before DOCTYPE name state</a><li><a href=#doctype-name-state><span class=secno>12.2.5.55</span> DOCTYPE name state</a><li><a href=#after-doctype-name-state><span class=secno>12.2.5.56</span> After DOCTYPE name state</a><li><a href=#after-doctype-public-keyword-state><span class=secno>12.2.5.57</span> After DOCTYPE public keyword state</a><li><a href=#before-doctype-public-identifier-state><span class=secno>12.2.5.58</span> Before DOCTYPE public identifier state</a><li><a href=#doctype-public-identifier-(double-quoted)-state><span class=secno>12.2.5.59</span> DOCTYPE public identifier (double-quoted) state</a><li><a href=#doctype-public-identifier-(single-quoted)-state><span class=secno>12.2.5.60</span> DOCTYPE public identifier (single-quoted) state</a><li><a href=#after-doctype-public-identifier-state><span class=secno>12.2.5.61</span> After DOCTYPE public identifier state</a><li><a href=#between-doctype-public-and-system-identifiers-state><span class=secno>12.2.5.62</span> Between DOCTYPE public and system identifiers state</a><li><a href=#after-doctype-system-keyword-state><span class=secno>12.2.5.63</span> After DOCTYPE system keyword state</a><li><a href=#before-doctype-system-identifier-state><span class=secno>12.2.5.64</span> Before DOCTYPE system identifier state</a><li><a href=#doctype-system-identifier-(double-quoted)-state><span class=secno>12.2.5.65</span> DOCTYPE system identifier (double-quoted) state</a><li><a href=#doctype-system-identifier-(single-quoted)-state><span class=secno>12.2.5.66</span> DOCTYPE system identifier (single-quoted) state</a><li><a href=#after-doctype-system-identifier-state><span class=secno>12.2.5.67</span> After DOCTYPE system identifier state</a><li><a href=#bogus-doctype-state><span class=secno>12.2.5.68</span> Bogus DOCTYPE state</a><li><a href=#cdata-section-state><span class=secno>12.2.5.69</span> CDATA section state</a><li><a href=#cdata-section-bracket-state><span class=secno>12.2.5.70</span> CDATA section bracket state</a><li><a href=#cdata-section-end-state><span class=secno>12.2.5.71</span> CDATA section end state</a><li><a href=#character-reference-state><span class=secno>12.2.5.72</span> Character reference state</a><li><a href=#named-character-reference-state><span class=secno>12.2.5.73</span> Named character reference state</a><li><a href=#ambiguous-ampersand-state><span class=secno>12.2.5.74</span> Ambiguous ampersand state</a><li><a href=#numeric-character-reference-state><span class=secno>12.2.5.75</span> Numeric character reference state</a><li><a href=#hexadecimal-character-reference-start-state><span class=secno>12.2.5.76</span> Hexadecimal character reference start state</a><li><a href=#decimal-character-reference-start-state><span class=secno>12.2.5.77</span> Decimal character reference start state</a><li><a href=#hexadecimal-character-reference-state><span class=secno>12.2.5.78</span> Hexadecimal character reference state</a><li><a href=#decimal-character-reference-state><span class=secno>12.2.5.79</span> Decimal character reference state</a><li><a href=#numeric-character-reference-end-state><span class=secno>12.2.5.80</span> Numeric character reference end state</a></ol><li><a href=#tree-construction><span class=secno>12.2.6</span> Tree construction</a><ol><li><a href=#creating-and-inserting-nodes><span class=secno>12.2.6.1</span> Creating and inserting nodes</a><li><a href=#parsing-elements-that-contain-only-text><span class=secno>12.2.6.2</span> Parsing elements that contain only text</a><li><a href=#closing-elements-that-have-implied-end-tags><span class=secno>12.2.6.3</span> Closing elements that have implied end tags</a><li><a href=#parsing-main-inhtml><span class=secno>12.2.6.4</span> The rules for parsing tokens in HTML content</a><ol><li><a href=#the-initial-insertion-mode><span class=secno>12.2.6.4.1</span> The "initial" insertion mode</a><li><a href=#the-before-html-insertion-mode><span class=secno>12.2.6.4.2</span> The "before html" insertion mode</a><li><a href=#the-before-head-insertion-mode><span class=secno>12.2.6.4.3</span> The "before head" insertion mode</a><li><a href=#parsing-main-inhead><span class=secno>12.2.6.4.4</span> The "in head" insertion mode</a><li><a href=#parsing-main-inheadnoscript><span class=secno>12.2.6.4.5</span> The "in head noscript" insertion mode</a><li><a href=#the-after-head-insertion-mode><span class=secno>12.2.6.4.6</span> The "after head" insertion mode</a><li><a href=#parsing-main-inbody><span class=secno>12.2.6.4.7</span> The "in body" insertion mode</a><li><a href=#parsing-main-incdata><span class=secno>12.2.6.4.8</span> The "text" insertion mode</a><li><a href=#parsing-main-intable><span class=secno>12.2.6.4.9</span> The "in table" insertion mode</a><li><a href=#parsing-main-intabletext><span class=secno>12.2.6.4.10</span> The "in table text" insertion mode</a><li><a href=#parsing-main-incaption><span class=secno>12.2.6.4.11</span> The "in caption" insertion mode</a><li><a href=#parsing-main-incolgroup><span class=secno>12.2.6.4.12</span> The "in column group" insertion mode</a><li><a href=#parsing-main-intbody><span class=secno>12.2.6.4.13</span> The "in table body" insertion mode</a><li><a href=#parsing-main-intr><span class=secno>12.2.6.4.14</span> The "in row" insertion mode</a><li><a href=#parsing-main-intd><span class=secno>12.2.6.4.15</span> The "in cell" insertion mode</a><li><a href=#parsing-main-inselect><span class=secno>12.2.6.4.16</span> The "in select" insertion mode</a><li><a href=#parsing-main-inselectintable><span class=secno>12.2.6.4.17</span> The "in select in table" insertion mode</a><li><a href=#parsing-main-intemplate><span class=secno>12.2.6.4.18</span> The "in template" insertion mode</a><li><a href=#parsing-main-afterbody><span class=secno>12.2.6.4.19</span> The "after body" insertion mode</a><li><a href=#parsing-main-inframeset><span class=secno>12.2.6.4.20</span> The "in frameset" insertion mode</a><li><a href=#parsing-main-afterframeset><span class=secno>12.2.6.4.21</span> The "after frameset" insertion mode</a><li><a href=#the-after-after-body-insertion-mode><span class=secno>12.2.6.4.22</span> The "after after body" insertion mode</a><li><a href=#the-after-after-frameset-insertion-mode><span class=secno>12.2.6.4.23</span> The "after after frameset" insertion mode</a></ol><li><a href=#parsing-main-inforeign><span class=secno>12.2.6.5</span> The rules for parsing tokens in foreign content</a></ol><li><a href=#the-end><span class=secno>12.2.7</span> The end</a><li><a href=#coercing-an-html-dom-into-an-infoset><span class=secno>12.2.8</span> Coercing an HTML DOM into an infoset</a><li><a href=#an-introduction-to-error-handling-and-strange-cases-in-the-parser><span class=secno>12.2.9</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>12.2.9.1</span> Misnested tags: &lt;b>&lt;i>&lt;/b>&lt;/i></a><li><a href=#misnested-tags:-b-p-/b-/p><span class=secno>12.2.9.2</span> Misnested tags: &lt;b>&lt;p>&lt;/b>&lt;/p></a><li><a href=#unexpected-markup-in-tables><span class=secno>12.2.9.3</span> Unexpected markup in tables</a><li><a href=#scripts-that-modify-the-page-as-it-is-being-parsed><span class=secno>12.2.9.4</span> Scripts that modify the page as it is being parsed</a><li><a href=#the-execution-of-scripts-that-are-moving-across-multiple-documents><span class=secno>12.2.9.5</span> The execution of scripts that are moving across multiple documents</a><li><a href=#unclosed-formatting-elements><span class=secno>12.2.9.6</span> Unclosed formatting elements</a></ol></ol><li><a href=#serialising-html-fragments><span class=secno>12.3</span> Serializing HTML fragments</a><li><a href=#parsing-html-fragments><span class=secno>12.4</span> Parsing HTML fragments</a><li><a href=#named-character-references><span class=secno>12.5</span> Named character references</a></ol><li id=toc-the-xhtml-syntax><a href=#the-xhtml-syntax><span class=secno>13</span> The XML syntax</a><ol><li><a href=#writing-xhtml-documents><span class=secno>13.1</span> Writing documents in the XML syntax</a><li><a href=#parsing-xhtml-documents><span class=secno>13.2</span> Parsing XML documents</a><li><a href=#serialising-xhtml-fragments><span class=secno>13.3</span> Serializing XML fragments</a><li><a href=#parsing-xhtml-fragments><span class=secno>13.4</span> Parsing XML fragments</a></ol><li id=toc-rendering><a href=#rendering><span class=secno>14</span> Rendering</a><ol><li><a href=#introduction-16><span class=secno>14.1</span> Introduction</a><li><a href=#the-css-user-agent-style-sheet-and-presentational-hints><span class=secno>14.2</span> The CSS user agent style sheet and presentational hints</a><li><a href=#non-replaced-elements><span class=secno>14.3</span> Non-replaced elements</a><ol><li><a href=#hidden-elements><span class=secno>14.3.1</span> Hidden elements</a><li><a href=#the-page><span class=secno>14.3.2</span> The page</a><li><a href=#flow-content-3><span class=secno>14.3.3</span> Flow content</a><li><a href=#phrasing-content-3><span class=secno>14.3.4</span> Phrasing content</a><li><a href=#bidi-rendering><span class=secno>14.3.5</span> Bidirectional text</a><li><a href=#quotes><span class=secno>14.3.6</span> Quotes</a><li><a href=#sections-and-headings><span class=secno>14.3.7</span> Sections and headings</a><li><a href=#lists><span class=secno>14.3.8</span> Lists</a><li><a href=#tables-2><span class=secno>14.3.9</span> Tables</a><li><a href=#margin-collapsing-quirks><span class=secno>14.3.10</span> Margin collapsing quirks</a><li><a href=#form-controls><span class=secno>14.3.11</span> Form controls</a><li><a href=#the-hr-element-2><span class=secno>14.3.12</span> The <code>hr</code> element</a><li><a href=#the-fieldset-and-legend-elements><span class=secno>14.3.13</span> The <code>fieldset</code> and <code>legend</code> elements</a></ol><li><a href=#replaced-elements><span class=secno>14.4</span> Replaced elements</a><ol><li><a href=#embedded-content-rendering-rules><span class=secno>14.4.1</span> Embedded content</a><li><a href=#images-3><span class=secno>14.4.2</span> Images</a><li><a href=#attributes-for-embedded-content-and-images><span class=secno>14.4.3</span> Attributes for embedded content and images</a><li><a href=#image-maps-2><span class=secno>14.4.4</span> Image maps</a></ol><li><a href=#widgets><span class=secno>14.5</span> Widgets</a><ol><li><a href=#introduction-17><span class=secno>14.5.1</span> Introduction</a><li><a href=#the-button-element-2><span class=secno>14.5.2</span> The <code>button</code> element</a><li><a href=#the-details-and-summary-elements><span class=secno>14.5.3</span> The <code>details</code> and <code>summary</code> elements</a><li><a href=#the-input-element-as-a-text-entry-widget><span class=secno>14.5.4</span> The <code>input</code> element as a text entry widget</a><li><a href=#the-input-element-as-domain-specific-widgets><span class=secno>14.5.5</span> The <code>input</code> element as domain-specific widgets</a><li><a href=#the-input-element-as-a-range-control><span class=secno>14.5.6</span> The <code>input</code> element as a range control</a><li><a href=#the-input-element-as-a-colour-well><span class=secno>14.5.7</span> The <code>input</code> element as a color
  well</a><li><a href=#the-input-element-as-a-checkbox-and-radio-button-widgets><span class=secno>14.5.8</span> The <code>input</code> element as a checkbox and radio button widgets</a><li><a href=#the-input-element-as-a-file-upload-control><span class=secno>14.5.9</span> The <code>input</code> element as a file upload control</a><li><a href=#the-input-element-as-a-button><span class=secno>14.5.10</span> The <code>input</code> element as a button</a><li><a href=#the-marquee-element-2><span class=secno>14.5.11</span> The <code>marquee</code> element</a><li><a href=#the-meter-element-2><span class=secno>14.5.12</span> The <code>meter</code> element</a><li><a href=#the-progress-element-2><span class=secno>14.5.13</span> The <code>progress</code> element</a><li><a href=#the-select-element-2><span class=secno>14.5.14</span> The <code>select</code> element</a><li><a href=#the-textarea-element-2><span class=secno>14.5.15</span> The <code>textarea</code> element</a></ol><li><a href=#frames-and-framesets><span class=secno>14.6</span> Frames and framesets</a><li><a href=#interactive-media><span class=secno>14.7</span> Interactive media</a><ol><li><a href=#links,-forms,-and-navigation><span class=secno>14.7.1</span> Links, forms, and navigation</a><li><a href=#the-title-attribute-2><span class=secno>14.7.2</span> The <code>title</code> attribute</a><li><a href=#editing-hosts><span class=secno>14.7.3</span> Editing hosts</a><li><a href=#text-rendered-in-native-user-interfaces><span class=secno>14.7.4</span> Text rendered in native user interfaces</a></ol><li><a href=#print-media><span class=secno>14.8</span> Print media</a><li><a href=#unstyled-xml-documents><span class=secno>14.9</span> Unstyled XML documents</a></ol><li id=toc-obsolete><a href=#obsolete><span class=secno>15</span> Obsolete features</a><ol><li><a href=#obsolete-but-conforming-features><span class=secno>15.1</span> Obsolete but conforming features</a><ol><li><a href=#warnings-for-obsolete-but-conforming-features><span class=secno>15.1.1</span> Warnings for obsolete but conforming features</a></ol><li><a href=#non-conforming-features><span class=secno>15.2</span> Non-conforming features</a><li><a href=#requirements-for-implementations><span class=secno>15.3</span> Requirements for implementations</a><ol><li><a href=#the-marquee-element><span class=secno>15.3.1</span> The <code>marquee</code> element</a><li><a href=#frames><span class=secno>15.3.2</span> Frames</a><li><a href=#other-elements,-attributes-and-apis><span class=secno>15.3.3</span> Other elements, attributes and APIs</a></ol></ol><li id=toc-iana><a href=#iana><span class=secno>16</span> IANA considerations</a><ol><li><a href=#text/html><span class=secno>16.1</span> <code>text/html</code></a><li><a href=#multipart/x-mixed-replace><span class=secno>16.2</span> <code>multipart/x-mixed-replace</code></a><li><a href=#application/xhtml+xml><span class=secno>16.3</span> <code>application/xhtml+xml</code></a><li><a href=#text/cache-manifest><span class=secno>16.4</span> <code>text/cache-manifest</code></a><li><a href=#text/ping><span class=secno>16.5</span> <code>text/ping</code></a><li><a href=#application/microdata+json><span class=secno>16.6</span> <code>application/microdata+json</code></a><li><a href=#text/event-stream><span class=secno>16.7</span> <code>text/event-stream</code></a><li><a href=#ping-from><span class=secno>16.8</span> `<code>Ping-From</code>`</a><li><a href=#ping-to><span class=secno>16.9</span> `<code>Ping-To</code>`</a><li><a href=#refresh><span class=secno>16.10</span> `<code>Refresh</code>`</a><li><a href=#last-event-id><span class=secno>16.11</span> `<code>Last-Event-ID</code>`</a><li><a href=#web+-scheme-prefix><span class=secno>16.12</span> <code>web+</code> scheme prefix</a></ol><li id=toc-index><a href=#index>Index</a><ol><li><a href=#elements-3>Elements</a><li><a href=#element-content-categories>Element content categories</a><li><a href=#attributes-3>Attributes</a><li><a href=#element-interfaces>Element Interfaces</a><li><a href=#all-interfaces>All Interfaces</a><li><a href=#events-2>Events</a><li><a href=#mime-types-2>MIME Types</a></ol><li id=toc-references><a href=#references>References</a><li id=toc-acknowledgments><a href=#acknowledgments>Acknowledgments</a></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, MQ, DOM, Unicode, Web IDL, MIME, URL, XML, JavaScript, and Encodings; below presentation-layer technologies like CSS, SVG, MathML, and NPAPI; and to the side of technologies like Geo, Fetch, CSP, JPEG, GIF, and PNG.">
   <rect width=398 height=80></rect>
   <text class=top x=199 y=45>CSS SVG MathML NPAPI</text>
   <rect width=67 y=85 height=177></rect>
   <text transform="translate(25 251) rotate(-90)" class=left>Geo Fetch CSP</text>
   <text transform="translate(50 250) rotate(-90)" class=left>JPEG GIF 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=bottom x=15 y=300>HTTP TLS MQ DOM Unicode Web IDL</text>
   <text class=bottom x=18 y=330>MIME URL XML JavaScript Encodings</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
  specification index</a>.</p>

  <p class=note>Although we have asked them to stop doing so, the W3C also republishes some parts
  of this specification as separate documents.</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 (e-mail 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>Since then, the WHATWG has been working on this specification (amongst others), and the W3C has
  been copying fixes made by the WHATWG into their fork of the document (which also has other
  changes).</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 <a href=#browsing-context id=serialisability-of-script-execution:browsing-context>browsing contexts</a>.</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.github.io/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.github.io/ecma262/#sec-sharedarraybuffer-objects>SharedArrayBuffer</a></code> objects, it can in fact be observed that scripts in
  other <a href=https://tc39.github.io/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=compliance-with-other-specifications><span class=secno>1.7.2</span> Compliance with other specifications<a href=#compliance-with-other-specifications class=self-link></a></h4>

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

  <p>This specification interacts with and relies on a wide variety of other specifications. In
  certain circumstances, unfortunately, conflicting needs have led to this specification violating
  the requirements of these other specifications. Whenever this has occurred, the transgressions
  have each been noted as a "<dfn id=willful-violation>willful violation</dfn>", and the reason for the violation has
  been noted.</p>



  <h4 id=extensibility><span class=secno>1.7.3</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.<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.<li><p>Authors can use the <code id=extensibility:the-meta-element><a href=#the-meta-element>&lt;meta name="" content=""></a></code> mechanism to
   include page-wide metadata.<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.<li><p>Authors can embed raw data using the <code id=extensibility:the-script-element><a href=#the-script-element>&lt;script type=""></a></code>
   mechanism with a custom type, for further handling by inline or server-side scripts.<li><p>Authors can create <a href=#plugin id=extensibility:plugin>plugins</a> and invoke them using the
   <code id=extensibility:the-embed-element><a href=#the-embed-element>embed</a></code> element. This is how Flash works.<li><p>Authors can extend APIs using the JavaScript prototyping mechanism. This is widely used by
   script libraries, for instance.<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.</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>--></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><dd>Non-normative materials providing a context for the HTML standard.<dt><a href=#infrastructure>Common infrastructure</a><dd>The conformance classes, algorithms, definitions, and the common underpinnings of the rest of
   the specification.<dt><a href=#dom>Semantics, structure, and APIs of HTML documents</a><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.<dt><a href=#semantics>The elements of HTML</a><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.<dt><a href=#microdata>Microdata</a><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.<dt><a href=#editing>User interaction</a><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.<dt><a href=#browsers>Loading Web pages</a><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 and offline
   caching of Web applications.<dt><a href=#webappapis>Web application APIs</a><dd>This section introduces basic features for scripting of applications in HTML.<dt><a href=#workers>Web workers</a><dd>This section defines an API for background threads in JavaScript.<dt><a href=#comms>The communication APIs</a><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.

   <dt><a href=#webstorage>Web storage</a><dd>This section defines a client-side storage mechanism based on name-value pairs.<dt><a href=#syntax>The HTML syntax</a><dt><a href=#xhtml>The XML syntax</a><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.<dt><a href=#rendering>Rendering</a><dd>This section defines the default rendering rules for Web browsers.</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><var>variable</var> = <var>object</var> . <code id=typographic-conventions:x-that><a href=#x-that>method</a></code>( [ <var>optionalArgument</var> ] )<dd>

    <p>This is a note to authors describing the usage of an interface.</p>

   </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>This is another condition
   <dd>This is the requirement that applies to the conditions above.

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

  </dl>



  <h3 id=fingerprint><span class=secno>1.10</span> Privacy concerns<a href=#fingerprint class=self-link></a></h3>

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

  <p>Some features of HTML trade user convenience for a measure of user privacy.</p>

  <p>In general, due to the Internet's architecture, a user can be distinguished from another by the
  user's IP address. IP addresses do not perfectly match to a user; as a user moves from device to
  device, or from network to network, their IP address will change; similarly, NAT routing, proxy
  servers, and shared computers enable packets that appear to all come from a single IP address to
  actually map to multiple users. Technologies such as onion routing can be used to further
  anonymize requests so that requests from a single user at one node on the Internet appear to come
  from many disparate parts of the network.</p>

  <p>However, the IP address used for a user's requests is not the only mechanism by which a user's
  requests could be related to each other. Cookies, for example, are designed specifically to enable
  this, and are the basis of most of the Web's session features that enable you to log into a site
  with which you have an account.</p>

  <p>There are other mechanisms that are more subtle. Certain characteristics of a user's system can
  be used to distinguish groups of users from each other; by collecting enough such information, an
  individual user's browser's "digital fingerprint" can be computed, which can be as good as, if not
  better than, an IP address in ascertaining which requests are from the same user.</p>

  <p>Grouping requests in this manner, especially across multiple sites, can be used for both benign
  (and even arguably positive) purposes, as well as for malevolent purposes. An example of a
  reasonably benign purpose would be determining whether a particular person seems to prefer sites
  with dog illustrations as opposed to sites with cat illustrations (based on how often they visit
  the sites in question) and then automatically using the preferred illustrations on subsequent
  visits to participating sites. Malevolent purposes, however, could include governments combining
  information such as the person's home address (determined from the addresses they use when getting
  driving directions on one site) with their apparent political affiliations (determined by
  examining the forum sites that they participate in) to determine whether the person should be
  prevented from voting in an election.</p>

  <p>Since the malevolent purposes can be remarkably evil, user agent implementers are encouraged to
  consider how to provide their users with tools to minimize leaking information that could be used
  to fingerprint a user.</p>

  <p>Unfortunately, as the first paragraph in this section implies, sometimes there is great benefit
  to be derived from exposing the very information that can also be used for fingerprinting
  purposes, so it's not as easy as simply blocking all possible leaks. For instance, the ability to
  log into a site to post under a specific identity requires that the user's requests be
  identifiable as all being from the same user, more or less by definition. More subtly, though,
  information such as how wide text is, which is necessary for many effects that involve drawing
  text onto a canvas (e.g. any effect that involves drawing a border around the text) also leaks
  information that can be used to group a user's requests. (In this case, by potentially exposing,
  via a brute force search, which fonts a user has installed, information which can vary
  considerably from user to user.)</p>

  <p>Features in this specification which can be <dfn id=fingerprinting-vector>used to
  fingerprint the user</dfn> are marked as this paragraph is.
  <a href=#fingerprinting-vector id=fingerprint:fingerprinting-vector class=fingerprint title="There is a potential fingerprinting vector here."><img alt="(This is a fingerprinting vector.)" src=/images/fingerprint.png width=46 height=64></a>
  </p>

  <p>Other features in the platform can be used for the same purpose, though, including, though not
  limited to:</p>

  <ul><li>The exact list of which features a user agents supports.<li>The maximum allowed stack depth for recursion in script.<li>Features that describe the user's environment, like Media Queries and the <code id=fingerprint:screen><a data-x-internal=screen href=https://drafts.csswg.org/cssom-view/#the-screen-interface>Screen</a></code>
   object. <a href=#refsMQ>[MQ]</a> <a href=#refsCSSOMVIEW>[CSSOMVIEW]</a><li>The user's time zone.</ul>


  <h4 id=fingerprint-postMessage><span class=secno>1.10.1</span> Cross-site communication<a href=#fingerprint-postMessage class=self-link></a></h4>

  <p>The <code id=fingerprint-postMessage:dom-window-postmessage><a href=#dom-window-postmessage>postMessage()</a></code> API provides a mechanism by
  which two sites can communicate directly. At first glance, this might appear to open a new way by
  which the problems described above can occur. However, in practice, multiple mechanisms exist by
  which two sites can communicate that predate this API: a site embedding another can send data via
  an <code id=fingerprint-postMessage:the-iframe-element><a href=#the-iframe-element>iframe</a></code> element's dimensions; a site can use a cross-site image request with a
  unique identifier known to the server to initiate a server-side data exchange; or indeed the
  fingerprinting techniques described above can be used by two sites to uniquely identify a visitor
  such that information can then be exchanged on the server side.</p>

  <p>Fundamentally, users that do not trust a site to treat their information with respect have to
  avoid visiting that site at all.</p>




  <h3 id=a-quick-introduction-to-html><span class=secno>1.11</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>&quot;en&quot;</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>&quot;demo.html&quot;</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></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></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>&quot;demo.html&quot;</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>></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>&quot;&quot;</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>&apos;200&apos;</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>&quot;200&quot;</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 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 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></ul><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></ul><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 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 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></ul><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 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 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></ul><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></ul><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 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 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></ul></ul></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>&quot;main&quot;</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>&quot;result&quot;</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>&apos;Hello World&apos;</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- mi>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>&apos;sample.html&apos;</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>&apos;https&apos;</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>&apos;href&apos;</c-><c- p>,</c-> <c- t>&apos;https://example.com/&apos;</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>&quot;en&quot;</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.11.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>Cross-site scripting (XSS)<dt>SQL injection<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>&quot;message.cgi?say=Hello&quot;</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>&quot;message.cgi?say=Welcome&quot;</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>&quot;message.cgi?say=Kittens&quot;</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>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:javascript-protocol><a href=#javascript-protocol>javascript:</a></code>", but user agents can
     implement (and indeed, have historically implemented) others.<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.</ul>

   <dt>Cross-site request forgery (CSRF)<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>

   <dt>Clickjacking<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>

   </dl>



  <h4 id=common-pitfalls-to-avoid-when-using-the-scripting-apis><span class=secno>1.11.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>&quot;games.png&quot;</c-> <c- e>alt</c-><c- o>=</c-><c- s>&quot;Games&quot;</c-> <c- e>onload</c-><c- o>=</c-><c- s>&quot;gamesLogoHasLoaded(event)&quot;</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>&apos;games.png&apos;</c-><c- p>;</c->
 img<c- p>.</c->alt <c- o>=</c-> <c- t>&apos;Games&apos;</c-><c- p>;</c->
 img<c- p>.</c->onload <c- o>=</c-> gamesLogoHasLoaded<c- p>;</c->
 <c- c1>// img.addEventListener(&apos;load&apos;, 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>&quot;games&quot;</c-> <c- e>src</c-><c- o>=</c-><c- s>&quot;games.png&quot;</c-> <c- e>alt</c-><c- o>=</c-><c- s>&quot;Games&quot;</c-><c- p>&gt;</c->
 <c- c>&lt;!-- the &apos;load&apos; 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>&apos;games&apos;</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.11.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.12</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.12.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<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>

   <dt>Higher cost of maintenance<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 color=""></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>

   <dt>Larger document sizes<dd>

    <p>Presentational markup tends to be much more redundant, and thus results in larger document
    sizes.</p>

   </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:the-style-attribute><a href=#the-style-attribute>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:the-style-attribute-2><a href=#the-style-attribute>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.12.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<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>

   <dt>Errors with optional error recovery<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>

   <dt>Errors where the error-handling behavior is not compatible with streaming user agents<dd>

    <p>Some error-handling behavior, such as the behavior for the <code>&lt;table>&lt;hr>...</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>

   <dt>Errors that can result in infoset coercion<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>

   <dt>Errors that result in disproportionately poor performance<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></ul></ul><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></ul></ul></ul><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></ul></ul></ul></ul><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></ul></ul></ul></ul></ul></ul>

    </div>

   <dt>Errors involving fragile syntax constructs<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>&quot;?bill&amp;ted&quot;</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>&quot;?art&amp;copy&quot;</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>&quot;?bill&amp;ted&quot;</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&apos;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>&quot;?art&amp;amp;copy&quot;</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>

   <dt>Errors involving known interoperability problems in legacy user agents<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>

   <dt>Errors that risk exposing authors to security attacks<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>

   <dt>Cases where the author's intent is unclear<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>

   <dt>Cases that are likely to be typos<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></code> instead of <code>&lt;caption></code>, this would be flagged as an error and the author could correct
     the typo immediately.</p>

    </div>

   <dt>Errors that could interfere with new syntax in the future<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>

   </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.12.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<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>

   <dt>Errors that involve a conflict in expressed semantics<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>&quot;cell&quot;</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>

   <dt>Cases where the default styles are likely to lead to confusion<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/visuren.html#x9 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/visuren.html#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/visuren.html#x9 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/visuren.html#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/visuren.html#x9 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/visuren.html#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>

   <dt>Errors that indicate a likely misunderstanding of the specification<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>

   <dt>Errors involving limits that have been imposed merely to simplify the language<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>

   <dt>Errors that involve peculiarities of the parser<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>

   <dt>Errors that would likely result in scripts failing in hard-to-debug ways<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>

   <dt>Errors that waste authoring time<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>

   <dt>Errors that involve areas that affect authors migrating between the HTML and XML
   syntaxes<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 href=#attr-xml-lang>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>

   <dt>Errors that involve areas reserved for future expansion<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>

   <dt>Errors that indicate a mis-use of other specifications<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>

   </dl>



  <h3 id=suggested-reading><span class=secno>1.13</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><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.</blockquote><dt><cite>Unicode Security Considerations</cite> <a href=#refsUTR36>[UTR36]</a><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.</blockquote><dt><cite>Web Content Accessibility Guidelines (WCAG) 2.0</cite> <a href=#refsWCAG>[WCAG]</a><dd><blockquote><p>Web Content Accessibility Guidelines (WCAG) 2.0 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.</blockquote><dt><cite>Authoring Tool Accessibility Guidelines (ATAG) 2.0</cite> <a href=#refsATAG>[ATAG]</a><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.</blockquote><dt><cite>User Agent Accessibility Guidelines (UAAG) 2.0</cite> <a href=#refsUAAG>[UAAG]</a><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.</blockquote></dl>



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

  <p>This specification depends on the WHATWG Infra standard. <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>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 the DOM
  specification, 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>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>

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

  <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>.<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>dequeueing</a> from
       <var>parallelQueue</var>'s <a href=#algorithm-queue id=parallelism:algorithm-queue-2>algorithm queue</a>.<li><p>If <var>steps</var> is not nothing, then run <var>steps</var>.<li><p>Assert: 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.</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>
     </ol>
   <li><p>Return <var>parallelQueue</var>.</ol>

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

   <ol><li><p>Let <var>p</var> be a new promise.<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>,
      reject <var>p</var> with a <code id=parallelism:typeerror><a data-x-internal=typeerror href=https://tc39.github.io/ecma262/#sec-native-error-types-used-in-this-standard-typeerror>TypeError</a></code> and abort these steps.<li><p>Do some potentially lengthy work.<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>.<li><p>Resolve <var>p</var> with undefined.</ol>
    <li><p>Return <var>p</var>.</ol>

   <p>Two invocations of the above could run simultaneously, meaning <var>name</var> isn't in
   <var>nameList</var> during step 2.1, but it <em>might be added</em> before step 2.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>

   <ol><li><p>Let <var>p</var> be a new promise.<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>,
      reject <var>p</var> with a <code id=parallelism:typeerror-2><a data-x-internal=typeerror href=https://tc39.github.io/ecma262/#sec-native-error-types-used-in-this-standard-typeerror>TypeError</a></code> and abort these steps.<li><p>Do some potentially lengthy work.<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>.<li><p>Resolve <var>p</var> with undefined.</ol>
    <li><p>Return <var>p</var>.</ol>

   <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 specification, 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>


  <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, UAs 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>

  <p>Attribute names are said to be <dfn id=xml-compatible>XML-compatible</dfn> if they match the <code id=xml:xml-name><a data-x-internal=xml-name href=https://www.w3.org/TR/xml/#NT-Name>Name</a></code> production defined in XML and they contain no U+003A COLON
  characters (:). <a href=#refsXML>[XML]</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 length 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>A <dfn id=nodes-are-inserted>node <var>A</var> is inserted</dfn> into a node <var>B</var>
  when 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> are invoked with
  <var>A</var> as the argument and <var>A</var>'s new parent is <var>B</var>. Similarly, a <dfn id=nodes-are-removed>node <var>A</var> is removed</dfn> from a node <var>B</var> when 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> are invoked with <var>A</var> as the
  <var>removedNode</var> argument and <var>B</var> as the <var>oldParent</var> argument.</p>

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

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

  <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>
  has a <a href=#concept-document-bc id=dom-trees:concept-document-bc>browsing context</a>. 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> no longer has a <a href=#concept-document-bc id=dom-trees:concept-document-bc-2>browsing context</a>.


  <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 a user-agent defined 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-browsing-context id=plugins:child-browsing-context>child browsing contexts</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://tools.ietf.org/html/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://tools.ietf.org/html/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=#browsing-context id=plugins:browsing-context>browsing context</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>A plugin can be <dfn id=concept-plugin-secure>secured</dfn> if it honors the semantics of
  the <code id=plugins:attr-iframe-sandbox><a href=#attr-iframe-sandbox>sandbox</a></code> attribute.</p>

  <p class=example>For example, a secured plugin would prevent its contents from creating pop-up
  windows when the plugin is instantiated inside a sandboxed <code id=plugins:the-iframe-element><a href=#the-iframe-element>iframe</a></code>.</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>Since different users having different sets of <a href=#plugin id=plugins:plugin-3>plugins</a> provides a
  fingerprinting 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.
  <a href=#fingerprinting-vector id=plugins:fingerprinting-vector class=fingerprint title="There is a potential fingerprinting vector here."><img alt="(This is a fingerprinting vector.)" src=/images/fingerprint.png width=46 height=64></a>
  </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 the WHATWG Encoding standard. 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>

  <p>A <dfn id=utf-16-encoding>UTF-16 encoding</dfn> is <a id=encoding-terminology:utf-16be href=https://encoding.spec.whatwg.org/#utf-16be data-x-internal=utf-16be>UTF-16BE</a> or <a id=encoding-terminology:utf-16le href=https://encoding.spec.whatwg.org/#utf-16le data-x-internal=utf-16le>UTF-16LE</a>. <a href=#refsENCODING>[ENCODING]</a></p>

  <p>An <dfn id=ascii-compatible-encoding>ASCII-compatible encoding</dfn> is any <a id=encoding-terminology:encoding-2 href=https://encoding.spec.whatwg.org/#encoding data-x-internal=encoding>encoding</a> that is not a
  <a href=#utf-16-encoding id=encoding-terminology:utf-16-encoding>UTF-16 encoding</a>. <a href=#refsENCODING>[ENCODING]</a></p>

  <p class=note>Since support for encodings that are not defined in the WHATWG Encoding standard
  is prohibited, <a href=#utf-16-encoding id=encoding-terminology:utf-16-encoding-2>UTF-16 encodings</a> are the only encodings that
  this specification needs to treat as not being <a href=#ascii-compatible-encoding id=encoding-terminology:ascii-compatible-encoding>ASCII-compatible encodings</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<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 the Web IDL specification. <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>

   <dt id=non-interactive>Non-interactive presentation user agents<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>

   <dt id=renderingUA>Visual user agents that support the suggested default rendering<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>

   <dt id=non-scripted>User agents with no scripting support<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>

   <dt>Conformance checkers<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>Criteria that cannot be expressed by a DTD, but can still be checked by a machine.<li>Criteria that can only be checked by a human.</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>
   <dt>Data mining tools<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 each
    section would not be conforming.</p>

   <dt id=editors>Authoring tools and markup generators<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:the-style-attribute><a href=#the-style-attribute>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>

   </dl>

  <p id=hardwareLimitations>User agents may impose implementation-specific limits on otherwise
  unconstrained inputs, e.g. to prevent denial of service attacks, to guard against running out of
  memory, or to work around platform-specific limitations.
  <a href=#fingerprinting-vector id=conformance-classes:fingerprinting-vector class=fingerprint title="There is a potential fingerprinting vector here."><img alt="(This is a fingerprinting vector.)" src=/images/fingerprint.png width=46 height=64></a>
  </p>

  <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<dd>
    <p>The following terms are defined in the WHATWG Infra standard: <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><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><dfn id=surrogate><a href=https://infra.spec.whatwg.org/#surrogate>surrogate</a></dfn><li><dfn id=scalar-value><a href=https://infra.spec.whatwg.org/#scalar-value>scalar value</a></dfn><li><dfn id=noncharacter><a href=https://infra.spec.whatwg.org/#noncharacter>noncharacter</a></dfn><li><dfn id=javascript-string><a href=https://infra.spec.whatwg.org/#javascript-string>JavaScript string</a></dfn>,
         <dfn id=code-unit><a href=https://infra.spec.whatwg.org/#code-unit>code unit</a></dfn>, and
         <dfn id=javascript-string-length><a href=https://infra.spec.whatwg.org/#javascript-string-length>JavaScript string length</a></dfn><li><dfn id=scalar-value-string><a href=https://infra.spec.whatwg.org/#scalar-value-string>scalar value string</a></dfn><li><dfn id=string-length><a href=https://infra.spec.whatwg.org/#string-length>string length</a></dfn><li><dfn id=space-characters><a href=https://infra.spec.whatwg.org/#ascii-whitespace>ASCII whitespace</a></dfn><li><dfn id=control><a href=https://infra.spec.whatwg.org/#control>control</a></dfn><li><dfn id=ascii-digits><a href=https://infra.spec.whatwg.org/#ascii-digit>ASCII digit</a></dfn><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><dfn id=lowercase-ascii-hex-digits><a href=https://infra.spec.whatwg.org/#ascii-lower-hex-digit>ASCII lower hex digit</a></dfn><li><dfn id=ascii-hex-digits><a href=https://infra.spec.whatwg.org/#ascii-hex-digit>ASCII hex digit</a></dfn><li><dfn id=uppercase-ascii-letters><a href=https://infra.spec.whatwg.org/#ascii-upper-alpha>ASCII upper alpha</a></dfn><li><dfn id=lowercase-ascii-letters><a href=https://infra.spec.whatwg.org/#ascii-lower-alpha>ASCII lower alpha</a></dfn><li><dfn id=ascii-letters><a href=https://infra.spec.whatwg.org/#ascii-alpha>ASCII alpha</a></dfn><li><dfn id=alphanumeric-ascii-characters><a href=https://infra.spec.whatwg.org/#ascii-alphanumeric>ASCII alphanumeric</a></dfn><li><dfn id=isomorphic-decode><a href=https://infra.spec.whatwg.org/#isomorphic-decode>isomorphic decode</a></dfn><li><dfn id=converted-to-ascii-lowercase><a href=https://infra.spec.whatwg.org/#ascii-lowercase>ASCII lowercase</a></dfn><li><dfn id=converted-to-ascii-uppercase><a href=https://infra.spec.whatwg.org/#ascii-uppercase>ASCII uppercase</a></dfn><li><dfn id=ascii-case-insensitive><a href=https://infra.spec.whatwg.org/#ascii-case-insensitive>ASCII case-insensitive</a></dfn><li><dfn id=strip-newlines><a href=https://infra.spec.whatwg.org/#strip-newlines>strip newlines</a></dfn><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><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><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><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><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><dfn id=skip-ascii-whitespace><a href=https://infra.spec.whatwg.org/#skip-ascii-whitespace>skip ASCII whitespace</a></dfn><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-value><a href=https://infra.spec.whatwg.org/#map-value>value</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>, and
             <dfn id=map-iterate><a href=https://infra.spec.whatwg.org/#map-iterate>iterate</a></dfn><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-replace><a href=https://infra.spec.whatwg.org/#list-remove>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=list-is-empty><a href=https://infra.spec.whatwg.org/#list-is-empty>is empty</a></dfn>, and
             <dfn id=list-iterate><a href=https://infra.spec.whatwg.org/#list-iterate>iterate</a></dfn><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>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>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><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>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><dfn id=html-namespace-2><a href=https://infra.spec.whatwg.org/#html-namespace>HTML namespace</a></dfn><li><dfn id=mathml-namespace><a href=https://infra.spec.whatwg.org/#mathml-namespace>MathML namespace</a></dfn><li><dfn id=svg-namespace><a href=https://infra.spec.whatwg.org/#svg-namespace>SVG namespace</a></dfn><li><dfn id=xlink-namespace><a href=https://infra.spec.whatwg.org/#xlink-namespace>XLink namespace</a></dfn><li><dfn id=xml-namespace><a href=https://infra.spec.whatwg.org/#xml-namespace>XML namespace</a></dfn><li><dfn id=xmlns-namespace><a href=https://infra.spec.whatwg.org/#xmlns-namespace>XMLNS namespace</a></dfn></ul>

   <dt>Unicode and Encoding<dd>

    <p>The Unicode character set is used to represent textual data, and the WHATWG Encoding standard
    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 the WHATWG Encoding standard: <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><dfn id=get-an-output-encoding><a href=https://encoding.spec.whatwg.org/#get-an-output-encoding>Get an output
     encoding</a></dfn><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>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>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>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>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</ul>

   <dt>XML and related specifications<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 tag name <dfn id=attr-xml-space><code>xml:space</code></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 the XML specification. <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 the XML specification. <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?></code></a></dfn>
    processing instruction, defined in the <cite>Associating Style Sheets with XML documents</cite>
    specification. <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>

   <dt>URLs<dd>

    <p>The following terms are defined in the WHATWG URL standard: <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><dfn id=public-suffix><a href=https://url.spec.whatwg.org/#host-public-suffix>public suffix</a></dfn><li><dfn id=concept-domain><a href=https://url.spec.whatwg.org/#concept-domain>domain</a></dfn><li><dfn id=ipv4-address><a href=https://url.spec.whatwg.org/#concept-ipv4>IPv4 address</a></dfn><li><dfn id=ipv6-address><a href=https://url.spec.whatwg.org/#concept-ipv6>IPv6 address</a></dfn><li><dfn id=url><a href=https://url.spec.whatwg.org/#concept-url>URL</a></dfn><li><dfn data-dfn-for=url id=concept-url-origin><a href=https://url.spec.whatwg.org/#concept-url-origin>Origin</a></dfn> of URLs<li><dfn id=absolute-url><a href=https://url.spec.whatwg.org/#syntax-url-absolute>Absolute URL</a></dfn><li><dfn id=relative-url><a href=https://url.spec.whatwg.org/#syntax-url-relative>Relative URL</a></dfn><li>
      The <dfn id=url-parser><a href=https://url.spec.whatwg.org/#concept-url-parser>URL parser</a></dfn> and
      <dfn id=basic-url-parser><a href=https://url.spec.whatwg.org/#concept-basic-url-parser>basic URL
      parser</a></dfn> 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><dfn id=host-state><a href=https://url.spec.whatwg.org/#host-state>host state</a></dfn><li><dfn id=hostname-state><a href=https://url.spec.whatwg.org/#hostname-state>hostname state</a></dfn><li><dfn id=port-state><a href=https://url.spec.whatwg.org/#port-state>port state</a></dfn><li><dfn id=path-start-state><a href=https://url.spec.whatwg.org/#path-start-state>path start state</a></dfn><li><dfn id=query-state><a href=https://url.spec.whatwg.org/#query-state>query state</a></dfn><li><dfn id=fragment-state><a href=https://url.spec.whatwg.org/#fragment-state>fragment state</a></dfn></ul>
     <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><dfn id=concept-url-username><a href=https://url.spec.whatwg.org/#concept-url-username>username</a></dfn><li><dfn id=concept-url-password><a href=https://url.spec.whatwg.org/#concept-url-password>password</a></dfn><li><dfn id=concept-url-host><a href=https://url.spec.whatwg.org/#concept-url-host>host</a></dfn><li><dfn id=concept-url-port><a href=https://url.spec.whatwg.org/#concept-url-port>port</a></dfn><li><dfn id=concept-url-path><a href=https://url.spec.whatwg.org/#concept-url-path>path</a></dfn><li><dfn id=concept-url-query><a href=https://url.spec.whatwg.org/#concept-url-query>query</a></dfn><li><dfn id=concept-url-fragment><a href=https://url.spec.whatwg.org/#concept-url-fragment>fragment</a></dfn><li><dfn id=cannot-be-a-base-url-flag><a href=https://url.spec.whatwg.org/#url-cannot-be-a-base-url-flag>cannot-be-a-base-URL flag</a></dfn><li><dfn id=concept-url-object><a href=https://url.spec.whatwg.org/#concept-url-object>object</a></dfn></ul>
     <li><dfn id=valid-url-string><a href=https://url.spec.whatwg.org/#valid-url-string>valid URL string</a></dfn><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>The <dfn id=concept-url-serializer><a href=https://url.spec.whatwg.org/#concept-url-serializer>URL serializer</a></dfn><li>The <dfn id=host-parser><a href=https://url.spec.whatwg.org/#concept-host-parser>host parser</a></dfn><li>The <dfn id=host-serializer><a href=https://url.spec.whatwg.org/#concept-host-serializer>host serializer</a></dfn><li><dfn id=host-equals><a href=https://url.spec.whatwg.org/#concept-host-equals>Host equals</a></dfn><li><dfn id=concept-url-equals><a href=https://url.spec.whatwg.org/#concept-url-equals>URL equals</a></dfn><li><dfn id=serialize-an-integer><a href=https://url.spec.whatwg.org/#serialize-an-integer>serialize an integer</a></dfn><li><dfn id=default-encode-set><a href=https://url.spec.whatwg.org/#default-encode-set>Default encode set</a></dfn><li><dfn id=utf-8-percent-encode><a href=https://url.spec.whatwg.org/#utf-8-percent-encode>UTF-8 percent encode</a></dfn><li><dfn id=string-percent-decode><a href=https://url.spec.whatwg.org/#string-percent-decode>String percent decode</a></dfn><li><dfn id=set-the-username><a href=https://url.spec.whatwg.org/#set-the-username>set the username</a></dfn><li><dfn id=set-the-password><a href=https://url.spec.whatwg.org/#set-the-password>set the password</a></dfn><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>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></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://tools.ietf.org/html/rfc6694#section-2><code>about:</code></a></dfn> scheme <a href=#refsABOUT>[ABOUT]</a><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>The <dfn id=data-protocol><a href=https://tools.ietf.org/html/rfc2397#section-2><code>data:</code></a></dfn> scheme <a href=#refsRFC2397>[RFC2397]</a><li>The <dfn id=http-protocol><a href=https://tools.ietf.org/html/rfc7230#section-2.7.1><code>http:</code></a></dfn> scheme <a href=#refsHTTP>[HTTP]</a><li>The <dfn id=https-protocol><a href=https://tools.ietf.org/html/rfc7230#section-2.7.2><code>https:</code></a></dfn> scheme <a href=#refsHTTP>[HTTP]</a><li>The <dfn id=mailto-protocol><a href=https://tools.ietf.org/html/rfc6068#section-2><code>mailto:</code></a></dfn> scheme <a href=#refsMAILTO>[MAILTO]</a><li>The <dfn id=sms-protocol><a href=https://tools.ietf.org/html/rfc5724#section-2><code>sms:</code></a></dfn> scheme <a href=#refsSMS>[SMS]</a><li>The <dfn id=urn-protocol><a href=https://tools.ietf.org/html/rfc2141#section-2><code>urn:</code></a></dfn> scheme <a href=#refsURN>[URN]</a></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 the <cite>Media Fragments URI</cite> specification. <a href=#refsMEDIAFRAG>[MEDIAFRAG]</a></p>
   <dt>HTTP and related specifications<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://tools.ietf.org/html/rfc7231#section-5.3.2><code>Accept</code></a></dfn>` header<li>`<dfn id=http-accept-language><a href=https://tools.ietf.org/html/rfc7231#section-5.3.5><code>Accept-Language</code></a></dfn>` header<li>`<dfn id=http-cache-control><a href=https://tools.ietf.org/html/rfc7234#section-5.2><code>Cache-Control</code></a></dfn>` header<li>`<dfn id=http-content-disposition><a href=https://tools.ietf.org/html/rfc6266><code>Content-Disposition</code></a></dfn>` header<li>`<dfn id=http-content-language><a href=https://tools.ietf.org/html/rfc7231#section-3.1.3.2><code>Content-Language</code></a></dfn>` header<li>`<dfn id=http-last-modified><a href=https://tools.ietf.org/html/rfc7232#section-2.2><code>Last-Modified</code></a></dfn>` header<li>`<dfn id=http-referer><a href=https://tools.ietf.org/html/rfc7231#section-5.5.2><code>Referer</code></a></dfn>` header</ul>

    <p>The following terms are defined in the Cookie specification: <a href=#refsCOOKIES>[COOKIES]</a></p>

    <ul class=brief><li><dfn id=cookie-string>cookie-string</dfn><li><dfn id=receives-a-set-cookie-string>receives a set-cookie-string</dfn><li>`<dfn id=http-cookie><code>Cookie</code></dfn>` header</ul>

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

    <ul class=brief><li>`<dfn id=http-link><a href=https://tools.ietf.org/html/rfc5988#section-5><code>Link</code></a></dfn>` header</ul>

    <p>The following terms are defined in the WHATWG MIME Sniffing standard: <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><dfn id=valid-mime-type-string><a href=https://mimesniff.spec.whatwg.org/#valid-mime-type>valid MIME type string</a></dfn><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><dfn id=html-mime-type><a href=https://mimesniff.spec.whatwg.org/#html-mime-type>HTML MIME type</a></dfn><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><dfn id=json-mime-type><a href=https://mimesniff.spec.whatwg.org/#json-mime-type>JSON MIME type</a></dfn><li><dfn id=xml-mime-type><a href=https://mimesniff.spec.whatwg.org/#xml-mime-type>XML MIME type</a></dfn></ul>

   <dt>Fetch<dd>

    <p>The following terms are defined in the WHATWG Fetch standard: <a href=#refsFETCH>[FETCH]</a></p>

    <ul class=brief><li><dfn id=about:blank><code>about:blank</code></dfn><li>An <dfn id=http(s)-scheme><a href=https://fetch.spec.whatwg.org/#http-scheme>HTTP(S) scheme</a></dfn><li>A <dfn id=network-scheme><a href=https://fetch.spec.whatwg.org/#network-scheme>network scheme</a></dfn><li>A <dfn id=fetch-scheme><a href=https://fetch.spec.whatwg.org/#fetch-scheme>fetch scheme</a></dfn><li><dfn id=https-state-value><a href=https://fetch.spec.whatwg.org/#concept-https-state-value>HTTPS state value</a></dfn><li><dfn id=cors-protocol><a href=https://fetch.spec.whatwg.org/#http-cors-protocol>CORS protocol</a></dfn><li><dfn id=default-user-agent-value><a href=https://fetch.spec.whatwg.org/#default-user-agent-value>default `<code>User-Agent</code>` value</a></dfn><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><dfn id=concept-fetch><a href=https://fetch.spec.whatwg.org/#concept-fetch>fetch</a></dfn><li><dfn id=http-redirect-fetch><a href=https://fetch.spec.whatwg.org/#concept-http-redirect-fetch>HTTP-redirect fetch</a></dfn><li><dfn id=ok-status><a href=https://fetch.spec.whatwg.org/#ok-status>ok status</a></dfn><li><dfn id=navigation-request><a href=https://fetch.spec.whatwg.org/#navigation-request>navigation request</a></dfn><li><dfn id=network-error><a href=https://fetch.spec.whatwg.org/#concept-network-error>network error</a></dfn><li>`<dfn id=http-origin data-dfn-type=http-header><a href=https://fetch.spec.whatwg.org/#http-origin><code>Origin</code></a></dfn>` header<li><dfn id=process-response><a href=https://fetch.spec.whatwg.org/#process-response>process response</a></dfn><li><dfn id=concept-header-list-set><a href=https://fetch.spec.whatwg.org/#concept-header-list-set>set</a></dfn><li><dfn id=concept-fetch-terminate><a href=https://fetch.spec.whatwg.org/#concept-fetch-terminate>terminate</a></dfn><li>the <dfn id=requestcredentials><a href=https://fetch.spec.whatwg.org/#requestcredentials><code>RequestCredentials</code></a></dfn> enumeration<li>the <dfn id=requestdestination><a href=https://fetch.spec.whatwg.org/#requestdestination><code>RequestDestination</code></a></dfn> enumeration<li>the <dfn id=fetch()><a href=https://fetch.spec.whatwg.org/#dom-global-fetch><code>fetch()</code></a></dfn> method<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><dfn id=concept-response-url><a href=https://fetch.spec.whatwg.org/#concept-response-url>url</a></dfn><li><dfn id=concept-response-url-list><a href=https://fetch.spec.whatwg.org/#concept-response-url-list>url list</a></dfn><li><dfn id=concept-response-status><a href=https://fetch.spec.whatwg.org/#concept-response-status>status</a></dfn><li><dfn id=concept-response-header-list><a href=https://fetch.spec.whatwg.org/#concept-response-header-list>header list</a></dfn><li><dfn id=concept-response-body><a href=https://fetch.spec.whatwg.org/#concept-response-body>body</a></dfn><li><dfn id=concept-internal-response><a href=https://fetch.spec.whatwg.org/#concept-internal-response>internal response</a></dfn><li><dfn id=concept-response-csp-list><a href=https://fetch.spec.whatwg.org/#concept-response-csp-list>CSP list</a></dfn><li><dfn id=concept-response-https-state><a href=https://fetch.spec.whatwg.org/#concept-response-https-state>HTTPS state</a></dfn><li><dfn id=concept-response-location-url><a href=https://fetch.spec.whatwg.org/#concept-response-location-url>location URL</a></dfn></ul>
     <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><dfn id=concept-request-method><a href=https://fetch.spec.whatwg.org/#concept-request-method>method</a></dfn><li><dfn id=concept-request-header-list><a href=https://fetch.spec.whatwg.org/#concept-request-header-list>header list</a></dfn><li><dfn id=concept-request-body><a href=https://fetch.spec.whatwg.org/#concept-request-body>body</a></dfn><li><dfn id=concept-request-client><a href=https://fetch.spec.whatwg.org/#concept-request-client>client</a></dfn><li><dfn id=concept-request-reserved-client><a href=https://fetch.spec.whatwg.org/#concept-request-reserved-client>reserved client</a></dfn><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><dfn id=concept-request-initiator><a href=https://fetch.spec.whatwg.org/#concept-request-initiator>initiator</a></dfn><li><dfn id=concept-request-destination><a href=https://fetch.spec.whatwg.org/#concept-request-destination>destination</a></dfn><li><dfn id=concept-potential-destination><a href=https://fetch.spec.whatwg.org/#concept-potential-destination>potential destination</a></dfn><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><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><dfn id=concept-request-priority><a href=https://fetch.spec.whatwg.org/#concept-request-priority>priority</a></dfn><li><dfn data-dfn-for=request id=concept-request-origin><a href=https://fetch.spec.whatwg.org/#concept-request-origin>origin</a></dfn><li><dfn id=concept-request-referrer><a href=https://fetch.spec.whatwg.org/#concept-request-referrer>referrer</a></dfn><li><dfn id=synchronous-flag><a href=https://fetch.spec.whatwg.org/#synchronous-flag>synchronous flag</a></dfn><li><dfn id=concept-request-mode><a href=https://fetch.spec.whatwg.org/#concept-request-mode>mode</a></dfn><li><dfn id=concept-request-credentials-mode><a href=https://fetch.spec.whatwg.org/#concept-request-credentials-mode>credentials mode</a></dfn><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><dfn id=unsafe-request-flag><a href=https://fetch.spec.whatwg.org/#unsafe-request-flag>unsafe-request flag</a></dfn><li><dfn id=concept-request-cache-mode><a href=https://fetch.spec.whatwg.org/#concept-request-cache-mode>cache mode</a></dfn><li><dfn id=concept-request-redirect-mode><a href=https://fetch.spec.whatwg.org/#concept-request-redirect-mode>redirect mode</a></dfn><li><dfn id=concept-request-referrer-policy><a href=https://fetch.spec.whatwg.org/#concept-request-referrer-policy>referrer policy</a></dfn><li><dfn id=concept-request-nonce-metadata><a href=https://fetch.spec.whatwg.org/#concept-request-nonce-metadata>cryptographic nonce metadata</a></dfn><li><dfn id=concept-request-integrity-metadata><a href=https://fetch.spec.whatwg.org/#concept-request-integrity-metadata>integrity metadata</a></dfn><li><dfn id=concept-request-parser-metadata><a href=https://fetch.spec.whatwg.org/#concept-request-parser-metadata>parser metadata</a></dfn><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><dfn id=concept-request-history-navigation-flag><a href=https://fetch.spec.whatwg.org/#concept-request-history-navigation-flag>history-navigation flag</a></dfn></ul>
     </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>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>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>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>no-referrer-when-downgrade</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</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></ul>

    <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></ul>

   <dt>Web IDL<dd>

    <p>The IDL fragments in this specification must be interpreted as required for conforming IDL
    fragments, as described in the Web IDL specification. <a href=#refsWEBIDL>[WEBIDL]</a></p>

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

    <ul class=brief><li><dfn id=extended-attribute><a href=https://heycam.github.io/webidl/#dfn-extended-attribute>extended attribute</a></dfn><li><dfn id=named-constructor><a href=https://heycam.github.io/webidl/#dfn-named-constructor>named constructor</a></dfn><li><dfn id=array-index-property-name><a href=https://heycam.github.io/webidl/#dfn-array-index-property-name>array index property name</a></dfn><li><dfn id=supported-property-indices><a href=https://heycam.github.io/webidl/#dfn-supported-property-indices>supported property indices</a></dfn><li><dfn id=determine-the-value-of-an-indexed-property><a href=https://heycam.github.io/webidl/#dfn-determine-the-value-of-an-indexed-property>determine the value of an indexed property</a></dfn><li><dfn id=set-the-value-of-an-existing-indexed-property><a href=https://heycam.github.io/webidl/#dfn-set-the-value-of-an-existing-indexed-property>set the value of an existing indexed property</a></dfn><li><dfn id=set-the-value-of-a-new-indexed-property><a href=https://heycam.github.io/webidl/#dfn-set-the-value-of-a-new-indexed-property>set the value of a new indexed property</a></dfn><li><dfn id=support-named-properties><a href=https://heycam.github.io/webidl/#dfn-support-named-properties>support named properties</a></dfn><li><dfn id=supported-property-names><a href=https://heycam.github.io/webidl/#dfn-supported-property-names>supported property names</a></dfn><li><dfn id=determine-the-value-of-a-named-property><a href=https://heycam.github.io/webidl/#dfn-determine-the-value-of-a-named-property>determine the value of a named property</a></dfn><li><dfn id=set-the-value-of-an-existing-named-property><a href=https://heycam.github.io/webidl/#dfn-set-the-value-of-an-existing-named-property>set the value of an existing named property</a></dfn><li><dfn id=set-the-value-of-a-new-named-property><a href=https://heycam.github.io/webidl/#dfn-set-the-value-of-a-new-named-property>set the value of a new named property</a></dfn><li><dfn id=delete-an-existing-named-property><a href=https://heycam.github.io/webidl/#dfn-delete-an-existing-named-property>delete an existing named property</a></dfn><li><dfn id=perform-a-security-check><a href=https://heycam.github.io/webidl/#dfn-perform-a-security-check>perform a security check</a></dfn><li><dfn id=platform-object><a href=https://heycam.github.io/webidl/#dfn-platform-object>platform object</a></dfn><li><dfn id=legacy-platform-object><a href=https://heycam.github.io/webidl/#dfn-legacy-platform-object>legacy platform object</a></dfn><li><dfn id=primary-interface><a href=https://heycam.github.io/webidl/#dfn-primary-interface>primary interface</a></dfn><li><dfn id=interface-object><a href=https://heycam.github.io/webidl/#dfn-interface-object>interface object</a></dfn><li><dfn id=interface-prototype-object><a href=https://heycam.github.io/webidl/#dfn-interface-prototype-object>interface prototype object</a></dfn><li><dfn id=global-environment-associated-with><a href=https://heycam.github.io/webidl/#es-platform-objects>global environment associated with</a></dfn> a platform object<li><dfn id=callback-context><a href=https://heycam.github.io/webidl/#dfn-callback-context>callback context</a></dfn><li><dfn id=frozen-array><a href=https://heycam.github.io/webidl/#dfn-frozen-array-type>frozen array</a></dfn> and
         <dfn id=creating-a-frozen-array><a href=https://heycam.github.io/webidl/#dfn-create-frozen-array>creating a frozen array</a></dfn><li><dfn id=dfn-callback-this-value><a href=https://heycam.github.io/webidl/#dfn-callback-this-value>callback this value</a></dfn><li><dfn id=concept-idl-convert><a href=https://heycam.github.io/webidl/#es-type-mapping>converting</a></dfn> between Web IDL types and JS types<li><dfn id=es-invoking-callback-functions><a href=https://heycam.github.io/webidl/#invoke-a-callback-function>invoking</a></dfn> and
         <dfn id=es-constructing-callback-functions><a href=https://heycam.github.io/webidl/#construct-a-callback-function>constructing</a></dfn> callback functions<li><dfn id=converting-to-a-sequence-of-unicode-scalar-values><a href=https://heycam.github.io/webidl/#dfn-obtain-unicode>converting to a
     sequence of Unicode scalar values</a></dfn><li><dfn id=overload-resolution-algorithm><a href=https://heycam.github.io/webidl/#dfn-overload-resolution-algorithm>overload resolution algorithm</a></dfn></ul>

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

    <ul class=brief><li><dfn id=idl-arraybuffer><a href=https://heycam.github.io/webidl/#idl-ArrayBuffer><code>ArrayBuffer</code></a></dfn><li><dfn id=idl-arraybufferview><a href=https://heycam.github.io/webidl/#common-ArrayBufferView><code>ArrayBufferView</code></a></dfn><li><dfn id=idl-boolean><a href=https://heycam.github.io/webidl/#idl-boolean><code>boolean</code></a></dfn><li><dfn id=idl-domstring><a href=https://heycam.github.io/webidl/#idl-DOMString><code>DOMString</code></a></dfn><li><dfn id=idl-double><a href=https://heycam.github.io/webidl/#idl-double><code>double</code></a></dfn><li><dfn id=idl-enumeration><a href=https://heycam.github.io/webidl/#idl-enums>enumeration</a></dfn><li><dfn id=idl-error><a href=https://heycam.github.io/webidl/#idl-Error><code>Error</code></a></dfn><li><dfn id=idl-function><a href=https://heycam.github.io/webidl/#common-Function><code>Function</code></a></dfn><li><dfn id=idl-long><a href=https://heycam.github.io/webidl/#idl-long><code>long</code></a></dfn><li><dfn id=idl-object><a href=https://heycam.github.io/webidl/#idl-object><code>object</code></a></dfn><li><dfn id=idl-uint8clampedarray><a href=https://heycam.github.io/webidl/#idl-Uint8ClampedArray><code>Uint8ClampedArray</code></a></dfn><li><dfn id=idl-unrestricted-double><a href=https://heycam.github.io/webidl/#idl-unrestricted-double><code>unrestricted double</code></a></dfn><li><dfn id=idl-unsigned-long><a href=https://heycam.github.io/webidl/#idl-unsigned-long><code>unsigned long</code></a></dfn><li><dfn id=idl-usvstring><a href=https://heycam.github.io/webidl/#idl-USVString><code>USVString</code></a></dfn><li><dfn id=idl-voidfunction><a href=https://heycam.github.io/webidl/#VoidFunction><code>VoidFunction</code></a></dfn></ul>

    <p>The term <dfn id=throw><a href=https://heycam.github.io/webidl/#dfn-throw>throw</a></dfn> in this
    specification is used as defined in the Web IDL specification. The <dfn id=domexception><a href=https://heycam.github.io/webidl/#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://heycam.github.io/webidl/#indexsizeerror>"<code>IndexSizeError</code>"</a></dfn><li><dfn id=hierarchyrequesterror><a href=https://heycam.github.io/webidl/#hierarchyrequesterror>"<code>HierarchyRequestError</code>"</a></dfn><li><dfn id=invalidcharactererror><a href=https://heycam.github.io/webidl/#invalidcharactererror>"<code>InvalidCharacterError</code>"</a></dfn><li><dfn id=notfounderror><a href=https://heycam.github.io/webidl/#notfounderror>"<code>NotFoundError</code>"</a></dfn><li><dfn id=notsupportederror><a href=https://heycam.github.io/webidl/#notsupportederror>"<code>NotSupportedError</code>"</a></dfn><li><dfn id=invalidstateerror><a href=https://heycam.github.io/webidl/#invalidstateerror>"<code>InvalidStateError</code>"</a></dfn><li><dfn id=syntaxerror><a href=https://heycam.github.io/webidl/#syntaxerror>"<code>SyntaxError</code>"</a></dfn><li><dfn id=invalidaccesserror><a href=https://heycam.github.io/webidl/#invalidaccesserror>"<code>InvalidAccessError</code>"</a></dfn><li><dfn id=securityerror><a href=https://heycam.github.io/webidl/#securityerror>"<code>SecurityError</code>"</a></dfn><li><dfn id=networkerror><a href=https://heycam.github.io/webidl/#networkerror>"<code>NetworkError</code>"</a></dfn><li><dfn id=aborterror><a href=https://heycam.github.io/webidl/#aborterror>"<code>AbortError</code>"</a></dfn><li><dfn id=quotaexceedederror><a href=https://heycam.github.io/webidl/#quotaexceedederror>"<code>QuotaExceededError</code>"</a></dfn><li><dfn id=datacloneerror><a href=https://heycam.github.io/webidl/#datacloneerror>"<code>DataCloneError</code>"</a></dfn><li><dfn id=encodingerror><a href=https://heycam.github.io/webidl/#encodingerror>"<code>EncodingError</code>"</a></dfn><li><dfn id=notallowederror><a href=https://heycam.github.io/webidl/#notallowederror>"<code>NotAllowedError</code>"</a></dfn></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.github.io/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.github.io/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.github.io/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>

   <dt>JavaScript<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>Users agents that support JavaScript must also implement the <cite>ECMAScript
    Internationalization API Specification</cite>. <a href=#refsJSINTL>[JSINTL]</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. Similarly, the <a id=dependencies:mime-type href=https://mimesniff.spec.whatwg.org/#mime-type data-x-internal=mime-type>MIME
    type</a> used to refer to JavaScript in this specification is <code>text/javascript</code>, since that is the most commonly used type, <a href=#willful-violation id=dependencies:willful-violation>despite it being an officially obsoleted type</a> according to RFC
    4329. <a href=#refsRFC4329>[RFC4329]</a></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.github.io/ecma262/#active-function-object>active function object</a></dfn><li><dfn id=agent><a href=https://tc39.github.io/ecma262/#sec-agents>agent</a></dfn> and
         <dfn id=agent-cluster><a href=https://tc39.github.io/ecma262/#sec-agent-clusters>agent cluster</a></dfn><li><dfn id=automatic-semicolon-insertion><a href=https://tc39.github.io/ecma262/#sec-automatic-semicolon-insertion>automatic semicolon insertion</a></dfn><li>The <dfn id=current-realm-record><a href=https://tc39.github.io/ecma262/#current-realm>current Realm Record</a></dfn><li><dfn id=early-error><a href=https://tc39.github.io/ecma262/#early-error-rule>early error</a></dfn><li><dfn id=directive-prologue><a href=https://tc39.github.io/ecma262/#directive-prologue>Directive Prologue</a></dfn><li><dfn id=invariants-of-the-essential-internal-methods><a href=https://tc39.github.io/ecma262/#sec-invariants-of-the-essential-internal-methods>invariants of the essential internal methods</a></dfn><li><dfn id=javascript-execution-context><a href=https://tc39.github.io/ecma262/#sec-execution-contexts>JavaScript execution context</a></dfn><li><dfn id=javascript-execution-context-stack><a href=https://tc39.github.io/ecma262/#execution-context-stack>JavaScript execution context stack</a></dfn><li><dfn id=javascript-realm><a href=https://tc39.github.io/ecma262/#sec-code-realms>JavaScript realm</a></dfn><li><dfn id=running-javascript-execution-context><a href=https://tc39.github.io/ecma262/#running-execution-context>running JavaScript execution context</a></dfn><li><dfn id=use-strict-directive><a href=https://tc39.github.io/ecma262/#use-strict-directive>Use Strict Directive</a></dfn><li><dfn id=well-known-symbols><a href=https://tc39.github.io/ecma262/#sec-well-known-symbols>Well-Known Symbols</a></dfn>, including
         <dfn id=@@hasinstance>@@hasInstance</dfn>,
         <dfn id=@@isconcatspreadable>@@isConcatSpreadable</dfn>,
         <dfn id=@@toprimitive>@@toPrimitive</dfn>, and
         <dfn id=@@tostringtag>@@toStringTag</dfn><li><dfn id=well-known-intrinsic-objects><a href=https://tc39.github.io/ecma262/#sec-well-known-intrinsic-objects>Well-Known Intrinsic Objects</a></dfn>, including
         <dfn id=arraybuffer><a href=https://tc39.github.io/ecma262/#sec-arraybuffer-constructor>%ArrayBuffer%</a></dfn>,
         <dfn id=arrayprototype><a href=https://tc39.github.io/ecma262/#sec-properties-of-the-array-prototype-object>%ArrayPrototype%</a></dfn>, and
         <dfn id=objproto_valueof><a href=https://tc39.github.io/ecma262/#sec-object.prototype.valueof>%ObjProto_valueOf%</a></dfn><li>The <dfn id=js-prod-functionbody><a href=https://tc39.github.io/ecma262/#prod-FunctionBody><i>FunctionBody</i></a></dfn> production<li>The <dfn id=js-prod-module><a href=https://tc39.github.io/ecma262/#prod-Module><i>Module</i></a></dfn> production<li>The <dfn id=js-prod-pattern><a href=https://tc39.github.io/ecma262/#prod-Pattern><i>Pattern</i></a></dfn> production<li>The <dfn id=js-prod-script><a href=https://tc39.github.io/ecma262/#prod-Script><i>Script</i></a></dfn> production<li>The <dfn id=js-type><a href=https://tc39.github.io/ecma262/#sec-ecmascript-data-types-and-values>Type</a></dfn> notation<li>The <dfn id=abrupt-completion><a href=https://tc39.github.io/ecma262/#sec-completion-record-specification-type>Completion Record</a></dfn> specification type<li>The <dfn id=js-list><a href=https://tc39.github.io/ecma262/#sec-list-and-record-specification-type>List</a></dfn> and
             <dfn id=record><a href=https://tc39.github.io/ecma262/#sec-list-and-record-specification-type>Record</a></dfn> specification types<li>The <dfn id=propertydescriptor><a href=https://tc39.github.io/ecma262/#sec-property-descriptor-specification-type>Property Descriptor</a></dfn> specification type<li>The <dfn id=script-record><a href=https://tc39.github.io/ecma262/#sec-script-records>Script Record</a></dfn> specification type<li>The <dfn id=source-text-module-record><a href=https://tc39.github.io/ecma262/#sec-source-text-module-records>Source Text Module Record</a></dfn> specification type and its
             <dfn id=js-evaluate><a href=https://tc39.github.io/ecma262/#sec-moduleevaluation>Evaluate</a></dfn> and
             <dfn id=js-instantiate><a href=https://tc39.github.io/ecma262/#sec-moduledeclarationinstantiation>Instantiate</a></dfn> methods<li>The <dfn id=arraycreate><a href=https://tc39.github.io/ecma262/#sec-arraycreate>ArrayCreate</a></dfn> abstract operation<li>The <dfn id=call><a href=https://tc39.github.io/ecma262/#sec-call>Call</a></dfn> abstract operation<li>The <dfn id=construct><a href=https://tc39.github.io/ecma262/#sec-construct>Construct</a></dfn> abstract operation<li>The <dfn id=copydatablockbytes><a href=https://tc39.github.io/ecma262/#sec-copydatablockbytes>CopyDataBlockBytes</a></dfn> abstract operation<li>The <dfn id=createbytedatablock><a href=https://tc39.github.io/ecma262/#sec-createbytedatablock>CreateByteDataBlock</a></dfn> abstract operation<li>The <dfn id=createdataproperty><a href=https://tc39.github.io/ecma262/#sec-createdataproperty>CreateDataProperty</a></dfn> abstract operation<li>The <dfn id=detacharraybuffer><a href=https://tc39.github.io/ecma262/#sec-detacharraybuffer>DetachArrayBuffer</a></dfn> abstract operation<li>The <dfn id=js-enqueuejob><a href=https://tc39.github.io/ecma262/#sec-enqueuejob>EnqueueJob</a></dfn> abstract operation<li>The <dfn id=enumerableownproperties><a href=https://tc39.github.io/ecma262/#sec-enumerableownproperties>EnumerableOwnProperties</a></dfn> abstract operation<li>The <dfn id=js-functioncreate><a href=https://tc39.github.io/ecma262/#sec-functioncreate>FunctionCreate</a></dfn> abstract operation<li>The <dfn id=js-get><a href=https://tc39.github.io/ecma262/#sec-get-o-p>Get</a></dfn> abstract operation<li>The <dfn id=getactivescriptormodule><a href=https://tc39.github.io/ecma262/#sec-getactivescriptormodule>GetActiveScriptOrModule</a></dfn> abstract operation<li>The <dfn id=getfunctionrealm><a href=https://tc39.github.io/ecma262/#sec-getfunctionrealm>GetFunctionRealm</a></dfn> abstract operation<li>The <dfn id=hasownproperty><a href=https://tc39.github.io/ecma262/#sec-hasownproperty>HasOwnProperty</a></dfn> abstract operation<li>The <dfn id=js-hostensurecancompilestrings><a href=https://tc39.github.io/ecma262/#sec-hostensurecancompilestrings>HostEnsureCanCompileStrings</a></dfn> abstract operation<li>The <dfn id=js-hostpromiserejectiontracker><a href=https://tc39.github.io/ecma262/#sec-host-promise-rejection-tracker>HostPromiseRejectionTracker</a></dfn> abstract operation<li>The <dfn id=js-hostresolveimportedmodule><a href=https://tc39.github.io/ecma262/#sec-hostresolveimportedmodule>HostResolveImportedModule</a></dfn> abstract operation<li>The <dfn id=js-initializehostdefinedrealm><a href=https://tc39.github.io/ecma262/#sec-initializehostdefinedrealm>InitializeHostDefinedRealm</a></dfn> abstract operation<li>The <dfn id=isaccessordescriptor><a href=https://tc39.github.io/ecma262/#sec-isaccessordescriptor>IsAccessorDescriptor</a></dfn> abstract operation<li>The <dfn id=iscallable><a href=https://tc39.github.io/ecma262/#sec-iscallable>IsCallable</a></dfn> abstract operation<li>The <dfn id=isconstructor><a href=https://tc39.github.io/ecma262/#sec-isconstructor>IsConstructor</a></dfn> abstract operation<li>The <dfn id=isdatadescriptor><a href=https://tc39.github.io/ecma262/#sec-isdatadescriptor>IsDataDescriptor</a></dfn> abstract operation<li>The <dfn id=isdetachedbuffer><a href=https://tc39.github.io/ecma262/#sec-isdetachedbuffer>IsDetachedBuffer</a></dfn> abstract operation<li>The <dfn id=issharedarraybuffer><a href=https://tc39.github.io/ecma262/#sec-issharedarraybuffer>IsSharedArrayBuffer</a></dfn> abstract operation<li>The <dfn id=js-newobjectenvironment><a href=https://tc39.github.io/ecma262/#sec-newobjectenvironment>NewObjectEnvironment</a></dfn> abstract operation<li>The <dfn id=normalcompletion><a href=https://tc39.github.io/ecma262/#sec-normalcompletion>NormalCompletion</a></dfn> abstract operation<li>The <dfn id=ordinarygetprototypeof><a href=https://tc39.github.io/ecma262/#sec-ordinarygetprototypeof>OrdinaryGetPrototypeOf</a></dfn> abstract operation<li>The <dfn id=ordinarysetprototypeof><a href=https://tc39.github.io/ecma262/#sec-ordinarysetprototypeof>OrdinarySetPrototypeOf</a></dfn> abstract operation<li>The <dfn id=ordinaryisextensible><a href=https://tc39.github.io/ecma262/#sec-ordinaryisextensible>OrdinaryIsExtensible</a></dfn> abstract operation<li>The <dfn id=ordinarypreventextensions><a href=https://tc39.github.io/ecma262/#sec-ordinarypreventextensions>OrdinaryPreventExtensions</a></dfn> abstract operation<li>The <dfn id=ordinarygetownproperty><a href=https://tc39.github.io/ecma262/#sec-ordinarygetownproperty>OrdinaryGetOwnProperty</a></dfn> abstract operation<li>The <dfn id=ordinarydefineownproperty><a href=https://tc39.github.io/ecma262/#sec-ordinarydefineownproperty>OrdinaryDefineOwnProperty</a></dfn> abstract operation<li>The <dfn id=ordinaryget><a href=https://tc39.github.io/ecma262/#sec-ordinaryget>OrdinaryGet</a></dfn> abstract operation<li>The <dfn id=ordinaryset><a href=https://tc39.github.io/ecma262/#sec-ordinaryset>OrdinarySet</a></dfn> abstract operation<li>The <dfn id=ordinarydelete><a href=https://tc39.github.io/ecma262/#sec-ordinarydelete>OrdinaryDelete</a></dfn> abstract operation<li>The <dfn id=ordinaryownpropertykeys><a href=https://tc39.github.io/ecma262/#sec-ordinaryownpropertykeys>OrdinaryOwnPropertyKeys</a></dfn> abstract operation<li>The <dfn id=js-parsemodule><a href=https://tc39.github.io/ecma262/#sec-parsemodule>ParseModule</a></dfn> abstract operation<li>The <dfn id=js-parsescript><a href=https://tc39.github.io/ecma262/#sec-parse-script>ParseScript</a></dfn> abstract operation<li>The <dfn id=runjobs><a href=https://tc39.github.io/ecma262/#sec-runjobs>RunJobs</a></dfn> abstract operation<li>The <dfn id=samevalue><a href=https://tc39.github.io/ecma262/#sec-samevalue>SameValue</a></dfn> abstract operation<li>The <dfn id=js-scriptevaluation><a href=https://tc39.github.io/ecma262/#sec-runtime-semantics-scriptevaluation>ScriptEvaluation</a></dfn> abstract operation<li>The <dfn id=setimmutableprototype><a href=https://tc39.github.io/ecma262/#sec-set-immutable-prototype>SetImmutablePrototype</a></dfn> abstract operation<li>The <dfn id=js-toboolean><a href=https://tc39.github.io/ecma262/#sec-toboolean>ToBoolean</a></dfn> abstract operation<li>The <dfn id=tostring><a href=https://tc39.github.io/ecma262/#sec-tostring>ToString</a></dfn> abstract operation<li>The <dfn id=touint32><a href=https://tc39.github.io/ecma262/#sec-touint32>ToUint32</a></dfn> abstract operation<li>The <dfn id=typedarraycreate><a href=https://tc39.github.io/ecma262/#typedarray-create>TypedArrayCreate</a></dfn> abstract operation<li>The <dfn id=js-abstract-equality><a href=https://tc39.github.io/ecma262/#sec-abstract-equality-comparison>Abstract Equality Comparison</a></dfn> algorithm<li>The <dfn id=js-strict-equality><a href=https://tc39.github.io/ecma262/#sec-strict-equality-comparison>Strict Equality Comparison</a></dfn> algorithm<li>The <dfn id=date><a href=https://tc39.github.io/ecma262/#sec-date-objects><code>Date</code></a></dfn> class<li>The <dfn id=sharedarraybuffer><a href=https://tc39.github.io/ecma262/#sec-sharedarraybuffer-objects><code>SharedArrayBuffer</code></a></dfn> class<li>The <dfn id=typeerror><a href=https://tc39.github.io/ecma262/#sec-native-error-types-used-in-this-standard-typeerror><code>TypeError</code></a></dfn> class<li>The <dfn id=js-rangeerror><a href=https://tc39.github.io/ecma262/#sec-native-error-types-used-in-this-standard-rangeerror><code>RangeError</code></a></dfn> class<li>The <dfn id=eval()><a href=https://tc39.github.io/ecma262/#sec-eval-x><code>eval()</code></a></dfn> function<li>The <dfn id=ishtmldda><a href=https://tc39.github.io/ecma262/#sec-IsHTMLDDA-internal-slot>[[IsHTMLDDA]]</a></dfn> internal slot<li>The <dfn id=js-typeof><a href=https://tc39.github.io/ecma262/#sec-typeof-operator><code>typeof</code></a></dfn> operator<li>The <dfn id=delete><a href=https://tc39.github.io/ecma262/#sec-delete-operator><code>delete</code></a></dfn> operator<li><dfn id=the-typedarray-constructors><a href=https://tc39.github.io/ecma262/#table-49>The <var>TypedArray</var> Constructors</a></dfn> table</ul>

    <p>User agents that support JavaScript must also implement the <cite>import()</cite> proposal.
    The following terms are defined there, and used in this specification: <a href=#refsJSIMPORT>[JSIMPORT]</a></p>

    <ul class=brief><li><dfn id=import()><a href=https://tc39.github.io/proposal-dynamic-import/#sec-import-calls><code>import()</code></a></dfn><li>The <dfn id=js-hostimportmoduledynamically><a href=https://tc39.github.io/proposal-dynamic-import/#sec-hostimportmoduledynamically>HostImportModuleDynamically</a></dfn> abstract operation<li>The <dfn id=finishdynamicimport><a href=https://tc39.github.io/proposal-dynamic-import/#sec-finishdynamicimport>FinishDynamicImport</a></dfn> abstract operation</ul>

    <p>User agents that support JavaScript must also implement the <cite>import.meta</cite>
    proposal. The following term is defined there, and used in this specification: <a href=#refsJSIMPORTMETA>[JSIMPORTMETA]</a></p>

    <ul class=brief><li>The <dfn id=js-hostgetimportmetaproperties><a href=https://tc39.github.io/proposal-import-meta/#sec-hostgetimportmetaproperties>HostGetImportMetaProperties</a></dfn> abstract operation</ul>

    <p>User agents that support JavaScript must also implement the <cite>BigInt</cite> proposal. <a href=#refsJSBIGINT>[JSBIGINT]</a></p>
   <dt>DOM<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 the WHATWG DOM standard: <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><dfn id=comment-2><a href=https://dom.spec.whatwg.org/#interface-comment><code>Comment</code></a></dfn> interface<li><dfn id=domimplementation><a href=https://dom.spec.whatwg.org/#interface-domimplementation><code>DOMImplementation</code></a></dfn> interface<li><dfn id=dom-document><a href=https://dom.spec.whatwg.org/#interface-document><code>Document</code></a></dfn> interface<li><dfn id=documentfragment><a href=https://dom.spec.whatwg.org/#interface-documentfragment><code>DocumentFragment</code></a></dfn> interface<li><dfn id=documenttype><a href=https://dom.spec.whatwg.org/#interface-documenttype><code>DocumentType</code></a></dfn> interface<li><dfn id=childnode><a href=https://dom.spec.whatwg.org/#interface-childnode><code>ChildNode</code></a></dfn> interface<li><dfn id=element><a href=https://dom.spec.whatwg.org/#interface-element><code>Element</code></a></dfn> interface<li><dfn id=node><a href=https://dom.spec.whatwg.org/#interface-node><code>Node</code></a></dfn> interface<li><dfn id=nodelist><a href=https://dom.spec.whatwg.org/#interface-nodelist><code>NodeList</code></a></dfn> interface<li><dfn id=processinginstruction><a href=https://dom.spec.whatwg.org/#interface-processinginstruction><code>ProcessingInstruction</code></a></dfn> interface<li><dfn id=shadowroot><a href=https://dom.spec.whatwg.org/#interface-shadowroot><code>ShadowRoot</code></a></dfn> interface<li><dfn id=text><a href=https://dom.spec.whatwg.org/#interface-text><code>Text</code></a></dfn> interface<li><dfn id=node-document><a href=https://dom.spec.whatwg.org/#concept-node-document>node document</a></dfn> concept<li><dfn id=concept-documentfragment-host><a href=https://dom.spec.whatwg.org/#concept-documentfragment-host>host</a></dfn> concept<li><dfn id=shadow-root><a href=https://dom.spec.whatwg.org/#concept-shadow-root>shadow root</a></dfn> concept<li><dfn id=htmlcollection><a href=https://dom.spec.whatwg.org/#interface-htmlcollection><code>HTMLCollection</code></a></dfn> interface<li><dfn id=dom-htmlcollection-length><a href=https://dom.spec.whatwg.org/#dom-htmlcollection-length><code>HTMLCollection.length</code></a></dfn> attribute<li><dfn id=dom-htmlcollection-item><a href=https://dom.spec.whatwg.org/#dom-htmlcollection-item><code>HTMLCollection.item()</code></a></dfn> method<li><dfn id=dom-htmlcollection-nameditem><a href=https://dom.spec.whatwg.org/#dom-htmlcollection-nameditem><code>HTMLCollection.namedItem()</code></a></dfn> method<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><dfn id=domtokenlist><a href=https://dom.spec.whatwg.org/#interface-domtokenlist><code>DOMTokenList</code></a></dfn> interface<li><dfn id=dom-domtokenlist-value><a href=https://dom.spec.whatwg.org/#dom-domtokenlist-value><code>DOMTokenList.value</code></a></dfn> attribute<li><dfn id=dom-domimplementation-createdocument><a href=https://dom.spec.whatwg.org/#dom-domimplementation-createdocument><code>createDocument()</code></a></dfn> method<li><dfn id=dom-domimplementation-createhtmldocument><a href=https://dom.spec.whatwg.org/#dom-domimplementation-createhtmldocument><code>createHTMLDocument()</code></a></dfn> method<li><dfn id=dom-document-createelement><a href=https://dom.spec.whatwg.org/#dom-document-createelement><code>createElement()</code></a></dfn> method<li><dfn id=dom-document-createelementns><a href=https://dom.spec.whatwg.org/#dom-document-createelementns><code>createElementNS()</code></a></dfn> method<li><dfn id=dom-document-getelementbyid><a href=https://dom.spec.whatwg.org/#dom-nonelementparentnode-getelementbyid><code>getElementById()</code></a></dfn> method<li><dfn id=dom-document-getelementsbyclassname><a href=https://dom.spec.whatwg.org/#dom-document-getelementsbyclassname><code>getElementsByClassName()</code></a></dfn> method<li><dfn id=dom-node-appendchild><a href=https://dom.spec.whatwg.org/#dom-node-appendchild><code>appendChild()</code></a></dfn> method<li><dfn id=dom-node-clonenode><a href=https://dom.spec.whatwg.org/#dom-node-clonenode><code>cloneNode()</code></a></dfn> method<li><dfn id=dom-document-importnode><a href=https://dom.spec.whatwg.org/#dom-document-importnode><code>importNode()</code></a></dfn> method<li><dfn id=dom-event-preventdefault><a href=https://dom.spec.whatwg.org/#dom-event-preventdefault><code>preventDefault()</code></a></dfn> method<li><dfn id=dom-element-id><a href=https://dom.spec.whatwg.org/#dom-element-id><code>id</code></a></dfn> attribute<li><dfn id=textcontent><a href=https://dom.spec.whatwg.org/#dom-node-textcontent><code>textContent</code></a></dfn> attribute<li>The <dfn id=tree><a href=https://dom.spec.whatwg.org/#concept-tree>tree</a></dfn> and <dfn id=shadow-tree><a href=https://dom.spec.whatwg.org/#concept-shadow-tree>shadow tree</a></dfn> concepts<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>The <dfn id=concept-tree-child><a href=https://dom.spec.whatwg.org/#concept-tree-child>child</a></dfn> concept<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>The <dfn id=inclusive-ancestor><a href=https://dom.spec.whatwg.org/#concept-tree-inclusive-ancestor>inclusive ancestor</a></dfn>,
             <dfn id=shadow-including-descendant><a href=https://dom.spec.whatwg.org/#concept-shadow-including-descendant>shadow-including descendant</a></dfn>, and
             <dfn id=shadow-including-inclusive-descendant><a href=https://dom.spec.whatwg.org/#concept-shadow-including-inclusive-descendant>shadow-including inclusive descendant</a></dfn> concepts<li>The <dfn id=first-child><a href=https://dom.spec.whatwg.org/#concept-tree-first-child>first child</a></dfn> and <dfn id=next-sibling><a href=https://dom.spec.whatwg.org/#concept-tree-next-sibling>next sibling</a></dfn> concepts<li>The <dfn id=document-element><a href=https://dom.spec.whatwg.org/#document-element>document element</a></dfn> concept<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>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>The <dfn id=finding-flattened-slotables><a href=https://dom.spec.whatwg.org/#find-flattened-slotables>find flattened slotables</a></dfn> algorithm<li>The <dfn id=assign-a-slot><a href=https://dom.spec.whatwg.org/#assign-a-slot>assign a slot</a></dfn> algorithm<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=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>The <dfn id=concept-node-insert-ext><a href=https://dom.spec.whatwg.org/#concept-node-insert-ext>insertion 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-adopt-ext><a href=https://dom.spec.whatwg.org/#concept-node-adopt-ext>adopting steps</a></dfn>, and
             <dfn id=child-text-content-change-steps><a href=https://dom.spec.whatwg.org/#concept-node-text-change-ext>child text content change steps</a></dfn> hooks for elements<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>, and <dfn id=concept-element-attributes-set-value><a href=https://dom.spec.whatwg.org/#concept-element-attributes-set-value>set value</a></dfn> algorithms for attributes<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>The <dfn id=attribute-list><a href=https://dom.spec.whatwg.org/#concept-element-attribute>attribute list</a></dfn> concept<li>The <dfn id=concept-cd-data><a href=https://dom.spec.whatwg.org/#concept-cd-data>data</a></dfn> of a text node<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><dfn id=event><a href=https://dom.spec.whatwg.org/#interface-event><code>Event</code></a></dfn> interface<li><dfn id=eventtarget><a href=https://dom.spec.whatwg.org/#interface-eventtarget><code>EventTarget</code></a></dfn> interface<li>The <dfn id=activation-behaviour><a href=https://dom.spec.whatwg.org/#eventtarget-activation-behavior>activation behavior</a></dfn> hook<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>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>The <dfn id=creating-an-event><a href=https://dom.spec.whatwg.org/#concept-event-create>create an event</a></dfn> algorithm<li>The <dfn id=concept-event-fire><a href=https://dom.spec.whatwg.org/#concept-event-fire>fire an event</a></dfn> algorithm<li>The <dfn id=canceled-flag><a href=https://dom.spec.whatwg.org/#canceled-flag>canceled flag</a></dfn><li>The <dfn id=concept-event-dispatch><a href=https://dom.spec.whatwg.org/#concept-event-dispatch>dispatch</a></dfn> algorithm<li><dfn id=eventinit><a href=https://dom.spec.whatwg.org/#dictdef-eventinit><code>EventInit</code></a></dfn> dictionary type<li><dfn id=dom-event-type><a href=https://dom.spec.whatwg.org/#dom-event-type><code>type</code></a></dfn> attribute<li><dfn id=dom-event-target><a href=https://dom.spec.whatwg.org/#dom-event-target><code>target</code></a></dfn> attribute<li><dfn id=dom-event-currenttarget><a href=https://dom.spec.whatwg.org/#dom-event-currenttarget><code>currentTarget</code></a></dfn> attribute<li><dfn id=dom-event-bubbles><a href=https://dom.spec.whatwg.org/#dom-event-bubbles><code>bubbles</code></a></dfn> attribute<li><dfn id=dom-event-cancelable><a href=https://dom.spec.whatwg.org/#dom-event-cancelable><code>cancelable</code></a></dfn> attribute<li><dfn id=composed-flag><a href=https://dom.spec.whatwg.org/#composed-flag>composed flag</a></dfn><li><dfn id=dom-event-istrusted><a href=https://dom.spec.whatwg.org/#dom-event-istrusted><code>isTrusted</code></a></dfn> attribute<li><dfn id=dom-event-initevent><a href=https://dom.spec.whatwg.org/#dom-event-initevent><code>initEvent()</code></a></dfn> method<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><dfn id=dom-eventtarget-addeventlistener><a href=https://dom.spec.whatwg.org/#dom-eventtarget-addeventlistener><code>addEventListener()</code></a></dfn> method<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><dfn id=dom-eventlistener><a href=https://dom.spec.whatwg.org/#callbackdef-eventlistener><code>EventListener</code></a></dfn> callback interface<li>The <dfn id=concept-event-type><a href=https://dom.spec.whatwg.org/#dom-event-type>type</a></dfn> of an event<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>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>) 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>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>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>The algorithm to <dfn id=concept-node-clone><a href=https://dom.spec.whatwg.org/#concept-node-clone>clone</a></dfn> a <code id=dependencies:node><a data-x-internal=node href=https://dom.spec.whatwg.org/#interface-node>Node</a></code>, 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> used by that algorithm<li>The concept of <dfn id=base-url-change-steps>base URL change steps</dfn> and the definition of what happens when an element is <dfn id=affected-by-a-base-url-change>affected by a base URL change</dfn><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>The concept of an element's <dfn id=concept-class><a href=https://dom.spec.whatwg.org/#concept-class>classes</a></dfn><li>The term <dfn id=concept-supported-tokens><a href=https://dom.spec.whatwg.org/#concept-supported-tokens>supported tokens</a></dfn><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><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>The <dfn id=create-an-element><a href=https://dom.spec.whatwg.org/#concept-create-element>create an element</a></dfn> algorithm<li>The <dfn id=element-interface><a href=https://dom.spec.whatwg.org/#concept-element-interface>element interface</a></dfn> concept<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>An element's <dfn id=concept-element-custom-element-definition><a href=https://dom.spec.whatwg.org/#concept-element-custom-element-definition>custom element definition</a></dfn><li>An element's <dfn id=concept-element-is-value><a href=https://dom.spec.whatwg.org/#concept-element-is-value><code>is</code> value</a></dfn><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</ul>

    <p>The following features are defined in the UI Events specification: <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>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><dfn id=mouseeventinit><a href=https://w3c.github.io/uievents/#dictdef-mouseeventinit><code>MouseEventInit</code></a></dfn> dictionary type<li>The <dfn id=focusevent><a href=https://w3c.github.io/uievents/#focusevent><code>FocusEvent</code></a></dfn> interface<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>The <dfn id=uievent><a href=https://w3c.github.io/uievents/#uievent><code>UIEvent</code></a></dfn> interface<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><dfn id=event-auxclick><a href=https://w3c.github.io/uievents/#event-type-auxclick><code>auxclick</code></a></dfn> event<li><dfn id=event-click><a href=https://w3c.github.io/uievents/#event-type-click><code>click</code></a></dfn> event<li><dfn id=event-dblclick><a href=https://w3c.github.io/uievents/#event-type-dblclick><code>dblclick</code></a></dfn> event<li><dfn id=event-mousedown><a href=https://w3c.github.io/uievents/#event-type-mousedown><code>mousedown</code></a></dfn> event<li><dfn id=event-mouseenter><a href=https://w3c.github.io/uievents/#event-type-mouseenter><code>mouseenter</code></a></dfn> event<li><dfn id=event-mouseleave><a href=https://w3c.github.io/uievents/#event-type-mouseleave><code>mouseleave</code></a></dfn> event<li><dfn id=event-mousemove><a href=https://w3c.github.io/uievents/#event-type-mousemove><code>mousemove</code></a></dfn> event<li><dfn id=event-mouseout><a href=https://w3c.github.io/uievents/#event-type-mouseout><code>mouseout</code></a></dfn> event<li><dfn id=event-mouseover><a href=https://w3c.github.io/uievents/#event-type-mouseover><code>mouseover</code></a></dfn> event<li><dfn id=event-mouseup><a href=https://w3c.github.io/uievents/#event-type-mouseup><code>mouseup</code></a></dfn> event<li><dfn id=event-wheel><a href=https://w3c.github.io/uievents/#event-type-wheel><code>wheel</code></a></dfn> event<li><dfn id=event-keydown><a href=https://w3c.github.io/uievents/#event-type-keydown><code>keydown</code></a></dfn> event<li><dfn id=event-keypress><a href=https://w3c.github.io/uievents/#event-type-keypress><code>keypress</code></a></dfn> event<li><dfn id=event-keyup><a href=https://w3c.github.io/uievents/#event-type-keyup><code>keyup</code></a></dfn> event</ul>

    <p>The following features are defined in the Touch Events specification: <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><dfn id=touch-point><a href=https://w3c.github.io/touch-events/#dfn-touch-point>Touch point</a></dfn> concept<li><dfn id=event-touchend><a href=https://w3c.github.io/touch-events/#event-touchend><code>touchend</code></a></dfn> event</ul>

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

    <ul class=brief><li><dfn id=event-pointerup><a href=https://w3c.github.io/pointerevents/#the-pointerup-event><code>pointerup</code></a></dfn> event</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 the <cite>DOM Parsing and Serialization</cite>
    specification: <a href=#refsDOMPARSING>[DOMPARSING]</a></p>

    <ul class=brief><li><dfn id=domparser><a href=https://w3c.github.io/DOM-Parsing/#the-domparser-interface><code>DOMParser</code></a></dfn><li><dfn id=dom-innerhtml><a href=https://w3c.github.io/DOM-Parsing/#dom-element-innerhtml><code>innerHTML</code></a></dfn><li><dfn id=dom-outerhtml><a href=https://w3c.github.io/DOM-Parsing/#dom-element-outerhtml><code>outerHTML</code></a></dfn></ul>

    <p>The <dfn id=selection><a href=https://w3c.github.io/selection-api/#selection-interface><code>Selection</code></a></dfn>
    interface is defined in the <cite>Selection API</cite> specification. <a href=#refsSELECTION>[SELECTION]</a></p>

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

    <p>The following parts of the WHATWG Fullscreen API standard are referenced from this
    specification, in part to define the rendering of <code id=dependencies:the-dialog-element><a href=#the-dialog-element>dialog</a></code> elements, and also to
    define how the Fullscreen API interacts with HTML: <a href=#refsFULLSCREEN>[FULLSCREEN]</a></p>

    <ul class=brief><li><dfn id=top-layer><a href=https://fullscreen.spec.whatwg.org/#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>) and its
         <dfn id=top-layer-add><a href=https://fullscreen.spec.whatwg.org/#top-layer-add>add</a></dfn>
         operation<li><dfn id=dom-element-requestfullscreen><a href=https://fullscreen.spec.whatwg.org/#dom-element-requestfullscreen><code>requestFullscreen()</code></a></dfn><li><dfn id=run-the-fullscreen-steps><a href=https://fullscreen.spec.whatwg.org/#run-the-fullscreen-steps>run the fullscreen steps</a></dfn></ul>

    <p>The <cite>High Resolution Time</cite> specification provides the <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> and the <dfn id=domhighrestimestamp><a href=https://w3c.github.io/hr-time/#dom-domhighrestimestamp><code>DOMHighResTimeStamp</code></a></dfn>
    typedef. <a href=#refsHRT>[HRT]</a></p>

   <dt>File API<dd>

    <p>This specification uses the following features defined in the File API specification: <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>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>The <dfn id=filelist><a href=https://w3c.github.io/FileAPI/#filelist-section><code>FileList</code></a></dfn> interface<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>The concept of <dfn id=file-error-read>read errors</dfn><li><dfn id=blob-url-store><a href=https://w3c.github.io/FileAPI/#BlobURLStore>Blob URL Store</a></dfn></ul>

   <dt>Indexed Database API<dd><p>This specification uses <dfn id=cleanup-indexed-database-transactions><a href=https://w3c.github.io/IndexedDB/#cleanup-indexed-database-transactions>cleanup
   Indexed Database transactions</a></dfn> defined by the Indexed Database API specification. <a href=#refsINDEXEDDB>[INDEXEDDB]</a></p>



   <dt>Media Source Extensions<dd>

    <p>The following terms are defined in the Media Source Extensions specification: <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><dfn id=detaching-from-a-media-element><a href=https://w3c.github.io/media-source/#mediasource-detach>detaching from a media element</a></dfn></ul>

   <dt>Media Capture and Streams<dd>

    <p>The following terms are defined in the Media Capture and Streams specification: <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><dfn id=dom-mediadevices-getusermedia><a href=https://w3c.github.io/mediacapture-main/#dom-mediadevices-getusermedia><code>getUserMedia()</code></a></dfn> method</ul>

   <dt>XMLHttpRequest<dd>

    <p>The following features and terms are defined in the XMLHttpRequest specification:
    <a href=#refsXHR>[XHR]</a></p>

    <ul class=brief><li><dfn id=xmlhttprequest><a href=https://xhr.spec.whatwg.org/#xmlhttprequest><code>XMLHttpRequest</code></a></dfn> interface<li><dfn id=dom-xmlhttprequest-responsexml><a href=https://xhr.spec.whatwg.org/#dom-xmlhttprequest-responsexml><code>XMLHttpRequest.responseXML</code></a></dfn> attribute<li><dfn id=progressevent><a href=https://xhr.spec.whatwg.org/#interface-progressevent><code>ProgressEvent</code></a></dfn> interface<li><dfn id=dom-progressevent-lengthcomputable><a href=https://xhr.spec.whatwg.org/#dom-progressevent-lengthcomputable><code>ProgressEvent.lengthComputable</code></a></dfn> attribute<li><dfn id=dom-progressevent-loaded><a href=https://xhr.spec.whatwg.org/#dom-progressevent-loaded><code>ProgressEvent.loaded</code></a></dfn> attribute<li><dfn id=dom-progressevent-total><a href=https://xhr.spec.whatwg.org/#dom-progressevent-total><code>ProgressEvent.total</code></a></dfn> attribute<li><dfn id=fire-a-progress-event><a href=https://xhr.spec.whatwg.org/#concept-event-fire-progress>Fire a progress event named <var>e</var></a></dfn><li>The concept of <dfn id=formdata-entry><a href=https://xhr.spec.whatwg.org/#concept-formdata-entry>entry</a></dfn><li><dfn id=create-an-entry><a href=https://xhr.spec.whatwg.org/#create-an-entry>create an entry</a></dfn></ul>

   <dt>Battery Status<dd>

    <p>The following features are defined in the <cite>Battery Status API</cite> specification: <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</ul>

   <dt>Media Queries<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></a></dfn>
    feature is defined therein. <a href=#refsMQ>[MQ]</a></p>

   <dt>CSS modules<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 the <cite>CSS Syntax</cite>
    specification 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>To <dfn id=parsed-as-a-css-color-value>parse a CSS &lt;color> value</dfn>, given a string
    <var>input</var> with an optional element <var>element</var>, run these steps:</p>

    <ol><li><p>Let <var>color</var> be the result of <a href=https://drafts.csswg.org/css-syntax/#parse-grammar id=dependencies:parse-something-according-to-a-css-grammar data-x-internal=parse-something-according-to-a-css-grammar>parsing</a> <var>input</var> as a CSS <a id=dependencies:color href=https://drafts.csswg.org/css-color/#typedef-color data-x-internal=color>&lt;color></a>. <a href=#refsCSSCOLOR>[CSSCOLOR]</a><li><p>If <var>color</var> is failure, then return failure.<li>
      <p>If <var>color</var> is <a id=dependencies:currentcolor href=https://drafts.csswg.org/css-color/#valdef-color-currentcolor data-x-internal=currentcolor>'currentcolor'</a>, then:</p>

      <ol><li><p>If <var>element</var> is not given, then set <var>color</var> to <a id=dependencies:opaque-black href=https://drafts.csswg.org/css-color/#opaque-black data-x-internal=opaque-black>opaque
       black</a>.<li><p>Otherwise, set <var>color</var> to the computed value of the <a id="dependencies:'color'" href=https://drafts.csswg.org/css-color/#the-color-property data-x-internal="'color'">'color'</a>
       property of <var>element</var>.</ol>
     <li><p>Return <var>color</var>.</ol>

    <p>The following terms and features are defined in the CSS specification: <a href=#refsCSS>[CSS]</a></p>

    <ul class=brief><li><dfn id=viewport><a href=https://drafts.csswg.org/css2/visuren.html#viewport>viewport</a></dfn><li><dfn id=line-box><a href=https://drafts.csswg.org/css2/visuren.html#line-box>line box</a></dfn><li><dfn id=out-of-flow><a href=https://drafts.csswg.org/css2/visuren.html#x24>out-of-flow</a></dfn><li><dfn id=in-flow><a href=https://drafts.csswg.org/css2/visuren.html#x25>in-flow</a></dfn><li><dfn id=replaced-element><a href=https://drafts.csswg.org/css2/conform.html#replaced-element>replaced element</a></dfn><li><dfn id=intrinsic-dimensions><a href=https://drafts.csswg.org/css2/conform.html#intrinsic>intrinsic dimensions</a></dfn><li><dfn id=content-area><a href=https://drafts.csswg.org/css2/box.html#box-content-area>content area</a></dfn><li><dfn id=content-box><a href=https://drafts.csswg.org/css2/box.html#x10>content box</a></dfn><li><dfn id=border-box><a href=https://drafts.csswg.org/css2/box.html#x14>border box</a></dfn><li><dfn id=margin-box><a href=https://drafts.csswg.org/css2/box.html#x17>margin box</a></dfn><li><dfn id=border-edge><a href=https://drafts.csswg.org/css2/box.html#border-edge>border edge</a></dfn><li><dfn id=margin-edge><a href=https://drafts.csswg.org/css2/box.html#margin-edge>margin edge</a></dfn><li><dfn id=collapsing-margins><a href=https://drafts.csswg.org/css2/box.html#collapsing-margins>collapsing margins</a></dfn><li><dfn id=containing-block><a href=https://drafts.csswg.org/css2/visudet.html#containing-block-details>containing block</a></dfn><li><dfn id=inline-box><a href=https://drafts.csswg.org/css2/visuren.html#inline-box>inline box</a></dfn><li><dfn id=block-box><a href=https://drafts.csswg.org/css2/visuren.html#x9>block box</a></dfn><li>The <dfn id="'margin-top'"><a href=https://drafts.csswg.org/css2/box.html#propdef-margin-top>'margin-top'</a></dfn>,
              <dfn id="'margin-bottom'"><a href=https://drafts.csswg.org/css2/box.html#propdef-margin-bottom>'margin-bottom'</a></dfn>,
              <dfn id="'margin-left'"><a href=https://drafts.csswg.org/css2/box.html#propdef-margin-left>'margin-left'</a></dfn>, and
              <dfn id="'margin-right'"><a href=https://drafts.csswg.org/css2/box.html#propdef-margin-right>'margin-right'</a></dfn> properties<li>The <dfn id="'padding-top'"><a href=https://drafts.csswg.org/css2/box.html#propdef-padding-top>'padding-top'</a></dfn>,
              <dfn id="'padding-bottom'"><a href=https://drafts.csswg.org/css2/box.html#propdef-padding-bottom>'padding-bottom'</a></dfn>,
              <dfn id="'padding-left'"><a href=https://drafts.csswg.org/css2/box.html#propdef-padding-left>'padding-left'</a></dfn>, and
              <dfn id="'padding-right'"><a href=https://drafts.csswg.org/css2/box.html#propdef-padding-right>'padding-right'</a></dfn> properties<li>The <dfn id="'top'"><a href=https://drafts.csswg.org/css2/visuren.html#propdef-top>'top'</a></dfn>,
              <dfn id="'bottom'"><a href=https://drafts.csswg.org/css2/visuren.html#propdef-bottom>'bottom'</a></dfn>,
              <dfn id="'left'"><a href=https://drafts.csswg.org/css2/visuren.html#propdef-left>'left'</a></dfn>, and
              <dfn id="'right'"><a href=https://drafts.csswg.org/css2/visuren.html#propdef-right>'right'</a></dfn> properties<li>The <dfn id="'float'"><a href=https://drafts.csswg.org/css2/visuren.html#float-position>'float'</a></dfn> property<li>The <dfn id="'clear'"><a href=https://drafts.csswg.org/css2/visuren.html#flow-control>'clear'</a></dfn> property<li>The <dfn id="'width'"><a href=https://drafts.csswg.org/css2/visudet.html#the-width-property>'width'</a></dfn> property<li>The <dfn id="'height'"><a href=https://drafts.csswg.org/css2/visudet.html#the-height-property>'height'</a></dfn> property<li>The <dfn id="'line-height'"><a href=https://drafts.csswg.org/css2/visudet.html#propdef-line-height>'line-height'</a></dfn> property<li>The <dfn id="'vertical-align'"><a href=https://drafts.csswg.org/css2/visudet.html#propdef-vertical-align>'vertical-align'</a></dfn> property<li>The <dfn id="'content'"><a href=https://drafts.csswg.org/css2/generate.html#content>'content'</a></dfn> property<li>The <dfn id="'inline-block'"><a href=https://drafts.csswg.org/css2/visuren.html#value-def-inline-block>'inline-block'</a></dfn> value of the <a id="dependencies:'display'" href=https://drafts.csswg.org/css2/visuren.html#display-prop data-x-internal="'display'">'display'</a> property<li>The <dfn id="'visibility'"><a href=https://drafts.csswg.org/css2/visufx.html#propdef-visibility>'visibility'</a></dfn> property</ul>

    <p>The CSS specification also defines the following border properties: <a href=#refsCSS>[CSS]</a></p>

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

    <p>The terms <dfn id=intrinsic-width>intrinsic width</dfn> and <dfn id=intrinsic-height>intrinsic height</dfn> refer to the width dimension and the height
    dimension, respectively, of <a id=dependencies:intrinsic-dimensions href=https://drafts.csswg.org/css2/conform.html#intrinsic data-x-internal=intrinsic-dimensions>intrinsic dimensions</a>.</p>

    <p>The basic version of the <dfn id="'display'"><a href=https://drafts.csswg.org/css2/visuren.html#display-prop>'display'</a></dfn> property
    is defined in the <cite>CSS</cite> specification, 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 the <cite>CSS Logical Properties</cite>
    specification: <a href=#refsCSSLOGICAL>[CSSLOGICAL]</a></p>

    <ul class=brief><li>The <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-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>The <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-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>The <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> property<li>The <dfn id="'block-size'"><a href=https://drafts.csswg.org/css-logical/#propdef-block-size>'block-size'</a></dfn> property</ul>

    <p>The following terms and features are defined in the <cite>CSS Color</cite> specification:
    <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><dfn id=color><a href=https://drafts.csswg.org/css-color/#typedef-color>&lt;color></a></dfn><li>The <dfn id="'color'"><a href=https://drafts.csswg.org/css-color/#the-color-property>'color'</a></dfn> property<li>The <dfn id=currentcolor><a href=https://drafts.csswg.org/css-color/#valdef-color-currentcolor>'currentcolor'</a></dfn> value<li><dfn id=opaque-black><a href=https://drafts.csswg.org/css-color/#opaque-black>opaque black</a></dfn><li><dfn id=transparent-black><a href=https://drafts.csswg.org/css-color/#transparent-black>transparent black</a></dfn></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 the <cite>CSS Image Values and Replaced Content</cite>
    specification to define the interaction of certain HTML elements with the CSS 'element()'
    function. <a href=#refsCSSIMAGES>[CSSIMAGES]</a></p>

    <p>The term <dfn id=default-object-size><a href=https://drafts.csswg.org/css-images/#default-object-size>default
    object size</a></dfn> and the <dfn id="'object-fit'"><a href=https://drafts.csswg.org/css-images/#the-object-fit>'object-fit'</a></dfn> property
    are also defined in the <cite>CSS Image Values and Replaced Content</cite> specification. <a href=#refsCSSIMAGES>[CSSIMAGES]</a></p>

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

    <ul class=brief><li>The <dfn id="'background-color'"><a href=https://drafts.csswg.org/css-backgrounds/#the-background-color>'background-color'</a></dfn> property<li>The <dfn id="'background-image'"><a href=https://drafts.csswg.org/css-backgrounds/#the-background-image>'background-image'</a></dfn> property<li>The <dfn id="'border-radius'"><a href=https://drafts.csswg.org/css-backgrounds/#propdef-border-radius>'border-radius'</a></dfn> property</ul>

    <p>The following features are defined in the <cite>CSS Box Alignment</cite> specification. <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>The <dfn id="'align-items'"><a href=https://drafts.csswg.org/css-align/#propdef-align-items>'align-items'</a></dfn> property<li>The <dfn id="'justify-self'"><a href=https://drafts.csswg.org/css-align/#propdef-justify-self>'justify-self'</a></dfn> property<li>The <dfn id="'justify-content'"><a href=https://drafts.csswg.org/css-align/#propdef-propdef-justify-content>'justify-content'</a></dfn> property<li>The <dfn id="'justify-items'"><a href=https://drafts.csswg.org/css-align/#propdef-propdef-justify-items>'justify-items'</a></dfn> property</ul>

    <p>The term <dfn id=block-level><a href=https://drafts.csswg.org/css-display/#block-level>block-level</a></dfn> is defined in
    the <cite>CSS Display</cite> specification. <a href=#refsCSSDISPLAY>[CSSDISPLAY]</a></p>

    <p>The following features are defined in the <cite>CSS Flexible Box Layout</cite>
    specification: <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>The <dfn id="'flex-wrap'"><a href=https://drafts.csswg.org/css-flexbox/#propdef-flex-wrap>'flex-wrap'</a></dfn> property</ul>

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

    <ul class=brief><li>The <dfn id="'font-family'"><a href=https://drafts.csswg.org/css-fonts/#font-family-prop>'font-family'</a></dfn> property<li>The <dfn id="'font-weight'"><a href=https://drafts.csswg.org/css-fonts/#font-weight-prop>'font-weight'</a></dfn> property<li>The <dfn id="'font-size'"><a href=https://drafts.csswg.org/css-fonts/#font-size-prop>'font-size'</a></dfn> property<li>The <dfn id="'font'"><a href=https://drafts.csswg.org/css-fonts/#font-prop>'font'</a></dfn> property</ul>

    <p>The following features are defined in the <cite>CSS Grid Layout</cite> specification: <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>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>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>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>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>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>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>The <dfn id="'grid-template-rows'"><a href=https://drafts.csswg.org/css-grid/#propdef-grid-template-rows>'grid-template-rows'</a></dfn> property</ul>

    <p>The <dfn id="'list-style-type'"><a href=https://drafts.csswg.org/css-lists/#propdef-list-style-type>'list-style-type'</a></dfn>
    property is defined in the <cite>CSS Lists and Counters</cite> specification. <a href=#refsCSSLISTS>[CSSLISTS]</a></p>

    <p>The following features are defined in the <cite>CSS Overflow</cite> specification. <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>The <dfn id="'text-overflow'"><a href=https://drafts.csswg.org/css-overflow/#propdef-text-overflow>'text-overflow'</a></dfn> property</ul>

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

    <ul class=brief><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</ul>

    <p>The following features are defined in the <cite>CSS Multi-column Layout</cite>
    specification. <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>The <dfn id="'column-fill'"><a href=https://drafts.csswg.org/css-multicol/#propdef-column-fill>'column-fill'</a></dfn> property<li>The <dfn id="'column-gap'"><a href=https://drafts.csswg.org/css-multicol/#propdef-column-gap>'column-gap'</a></dfn> property<li>The <dfn id="'column-rule'"><a href=https://drafts.csswg.org/css-multicol/#propdef-column-rule>'column-rule'</a></dfn> property<li>The <dfn id="'column-width'"><a href=https://drafts.csswg.org/css-multicol/#propdef-column-width>'column-width'</a></dfn> property</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/visuren.html#display-prop data-x-internal="'display'">'display'</a> property is defined in the <cite>CSS Ruby Layout</cite>
    specification. <a href=#refsCSSRUBY>[CSSRUBY]</a></p>

    <p>The following features are defined in the <cite>CSS Table</cite> specification: <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>The <dfn id="'border-collapse'"><a href=https://drafts.csswg.org/css-tables/#border-collapse-property>'border-collapse'</a></dfn> property<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/visuren.html#display-prop data-x-internal="'display'">'display'</a> property</ul>

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

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

    <p>The following features are defined in the <cite>CSS Writing Modes</cite> specification: <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>The <dfn id="'unicode-bidi'"><a href=https://drafts.csswg.org/css-writing-modes/#unicode-bidi>'unicode-bidi'</a></dfn> property<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-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</ul>

    <p>The following features are defined in the <cite>CSS Basic User Interface</cite>
    specification: <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>The <dfn id="'cursor'"><a href=https://drafts.csswg.org/css-ui/#cursor>'cursor'</a></dfn> property<li>The <dfn id="'appearance'"><a href=https://drafts.csswg.org/css-ui-4/#appearance-switching>'appearance'</a></dfn> property</ul>

    <p>The algorithm to <dfn id=update-animations-and-send-events><a href=https://drafts.csswg.org/web-animations/#update-animations-and-send-events>update
    animations and send events</a></dfn> is defined in the <cite>Web Animations</cite> specification. <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>

    <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><dfn id=linkstyle><a href=https://drafts.csswg.org/cssom/#the-linkstyle-interface><code>LinkStyle</code></a></dfn> interface<li><dfn id=cssstyledeclaration><a href=https://drafts.csswg.org/cssom/#the-cssstyledeclaration-interface><code>CSSStyleDeclaration</code></a></dfn> interface<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><dfn id=stylesheet><a href=https://drafts.csswg.org/cssom/#the-stylesheet-interface><code>StyleSheet</code></a></dfn> interface<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><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><dfn id=associated-css-style-sheet><a href=https://drafts.csswg.org/cssom/#associated-css-style-sheet>associated CSS style sheet</a></dfn><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><dfn id=concept-css-style-sheet-location><a href=https://drafts.csswg.org/cssom/#concept-css-style-sheet-location>location</a></dfn><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><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><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><dfn id=concept-css-style-sheet-media><a href=https://drafts.csswg.org/cssom/#concept-css-style-sheet-media>media</a></dfn><li><dfn id=concept-css-style-sheet-title><a href=https://drafts.csswg.org/cssom/#concept-css-style-sheet-title>title</a></dfn><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><dfn id=concept-css-style-sheet-disabeld-flag><a href=https://drafts.csswg.org/cssom/#concept-css-style-sheet-disabled-flag>disabled flag</a></dfn><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><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></ul>
     <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><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><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><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><dfn id=serializing-a-css-value><a href=https://drafts.csswg.org/cssom/#serialize-a-css-value>Serializing a CSS value</a></dfn><li><dfn id=run-the-resize-steps><a href=https://drafts.csswg.org/cssom-view/#run-the-resize-steps>run the resize steps</a></dfn><li><dfn id=run-the-scroll-steps><a href=https://drafts.csswg.org/cssom-view/#run-the-scroll-steps>run the scroll steps</a></dfn><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><dfn id=scroll-an-element-into-view><a href=https://drafts.csswg.org/cssom-view/#scroll-an-element-into-view>Scroll an element into view</a></dfn><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>The <dfn id=event-resize><a href=https://drafts.csswg.org/cssom-view/#eventdef-window-resize><code>resize</code></a></dfn> event<li>The <dfn id=event-scroll><a href=https://drafts.csswg.org/cssom-view/#eventdef-document-scroll><code>scroll</code></a></dfn> event<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></ul>

    <p>The following features and terms are defined in the <cite>CSS Syntax</cite> specifications:
    <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><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><dfn id=component-value><a href=https://drafts.csswg.org/css-syntax/#component-value>component value</a></dfn><li><dfn id=environment-encoding><a href=https://drafts.csswg.org/css-syntax/#environment-encoding>environment encoding</a></dfn><li><dfn id=whitespace-token><a href=https://drafts.csswg.org/css-syntax/#typedef-whitespace-token>&lt;whitespace-token></a></dfn></ul>

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

    <ul class=brief><li><dfn id=type-selector><a href=https://drafts.csswg.org/selectors/#type-selector>type selector</a></dfn><li><dfn id=attribute-selector><a href=https://drafts.csswg.org/selectors/#attribute-selector>attribute selector</a></dfn><li><dfn id=pseudo-class><a href=https://drafts.csswg.org/selectors/#pseudo-class>pseudo-class</a></dfn></ul>

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

    <ul class=brief><li><dfn id=length><a href=https://drafts.csswg.org/css-values/#lengths>&lt;length></a></dfn><li>The <dfn id="'em'"><a href=https://drafts.csswg.org/css-values/#em>'em'</a></dfn> unit<li>The <dfn id="'ex'"><a href=https://drafts.csswg.org/css-values/#ex>'ex'</a></dfn> unit<li>The <dfn id="'vw'"><a href=https://drafts.csswg.org/css-values/#vw>'vw'</a></dfn> unit<li>The <dfn id="'in'"><a href=https://drafts.csswg.org/css-values/#in>'in'</a></dfn> unit<li>The <dfn id="'px'"><a href=https://drafts.csswg.org/css-values/#px>'px'</a></dfn> unit<li>The <dfn id="'attr()'"><a href=https://drafts.csswg.org/css-values/#funcdef-attr>'attr()'</a></dfn> function<li>The <dfn id=math-functions><a href=https://drafts.csswg.org/css-values/#math-function>math functions</a></dfn></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 the <cite>CSS Style Attributes</cite> specification. <a href=#refsCSSATTR>[CSSATTR]</a></p>

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

    <ul class=brief><li><dfn id=specified-value><a href=https://drafts.csswg.org/css-cascade/#specified-value>specified value</a></dfn><li><dfn id=computed-value><a href=https://drafts.csswg.org/css-cascade/#computed-value>computed value</a></dfn><li><dfn id=used-value><a href=https://drafts.csswg.org/css-cascade/#used-value>used value</a></dfn></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 the Geometry Interfaces Module specification: <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><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>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></ul>

   <dt>Intersection Observer<dd>

    <p>The following term is defined in the Intersection Observer specification: <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></ul>

   <dt>WebGL<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><dfn id=webgl2renderingcontext><a href=https://www.khronos.org/registry/webgl/specs/latest/2.0/#WebGL2RenderingContext><code>WebGL2RenderingContext</code></a></dfn> interface</ul>

   <dt>WebVTT<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 the WebVTT specification:</p>

    <ul class=brief><li><dfn id=webvtt-file><a href=https://w3c.github.io/webvtt/#webvtt-file>WebVTT file</a></dfn><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><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><dfn id=webvtt-parser><a href=https://w3c.github.io/webvtt/#webvtt-parser>WebVTT parser</a></dfn><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>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><dfn id=vttcue><a href=https://w3c.github.io/webvtt/#vttcue><code>VTTCue</code></a></dfn> interface</ul>

   <dt>The WebSocket protocol<dd>
    <p>The following terms are defined in the WHATWG Fetch standard: <a href=#refsFETCH>[FETCH]</a></p>

    <ul class=brief><li><dfn id=concept-websocket-establish><a href=https://fetch.spec.whatwg.org/#concept-websocket-establish>establish a WebSocket connection</a></dfn></ul>

    <p>The following terms are defined in the WebSocket protocol specification: <a href=#refsWSP>[WSP]</a></p>

    <ul class=brief><li><dfn id=concept-websocket-established>the WebSocket connection is established</dfn><li><dfn id=concept-websockets-active-extensions>extensions in use</dfn><li><dfn id=concept-websocket-subprotocol>subprotocol in use</dfn><li><dfn id=concept-websocket-message-received>a WebSocket message has been received</dfn><li><dfn id=concept-websocket-send>send a WebSocket Message</dfn><li><dfn id=concept-websocket-fail>fail the WebSocket connection</dfn><li><dfn id=concept-websocket-close>close the WebSocket connection</dfn><li><dfn id=concept-websocket-start-closing-handshake>start the WebSocket closing handshake</dfn><li><dfn id=concept-websocket-closing-handshake>the WebSocket closing handshake is started</dfn><li><dfn id=concept-websocket-closed>the WebSocket connection is closed</dfn> (possibly <i>cleanly</i>)<li><dfn id=concept-websocket-close-code>the WebSocket connection close code</dfn><li><dfn id=concept-websocket-close-reason>the WebSocket connection close reason</dfn><li><dfn id=http-sec-websocket-protocol><code>Sec-WebSocket-Protocol</code></dfn> field</ul>

   <dt>ARIA<dd>

    <p>The <dfn id=attr-aria-role><code>role</code></dfn> attribute is defined in the ARIA
    specification, 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/aria/aria.html#button><code>button</code></a></dfn><li><dfn id=attr-aria-role-presentation><a href=https://w3c.github.io/aria/aria/aria.html#presentation><code>presentation</code></a></dfn></ul>

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

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

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

    <ul class=brief><li><dfn id=concept-accessible-name><a href=https://w3c.github.io/aria/aria/aria.html#dfn-accessible-name>accessible name</a></dfn></ul>

   <dt>Content Security Policy<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><dfn id=content-security-policy-directive><a href=https://w3c.github.io/webappsec-csp/#directives>Content Security Policy directive</a></dfn><li><dfn id=concept-csp-list><a href=https://w3c.github.io/webappsec-csp/#csp-list>CSP list</a></dfn><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><dfn id=enforce-the-policy><a href=https://w3c.github.io/webappsec-csp/#enforced>enforce the policy</a></dfn><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>The <dfn id="initialize-a-global-object's-csp-list"><a href=https://w3c.github.io/webappsec-csp/#initialize-global-object-csp>Initialize a global object's CSP list</a></dfn> algorithm<li>The <dfn id="initialize-a-document's-csp-list"><a href=https://w3c.github.io/webappsec-csp/#initialize-document-csp>Initialize a Document's CSP list</a></dfn> algorithm<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>The <dfn id=should-navigation-request-of-type-from-source-in-target-be-blocked-by-content-security-policy><a href=https://w3c.github.io/webappsec-csp/#should-block-navigation-request>Should navigation request of type from source in target be blocked by Content Security Policy?</a></dfn> algorithm<li>The <dfn id=should-navigation-response-to-navigation-request-of-type-from-source-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 from source in target be blocked by Content Security Policy?</a></dfn> algorithm<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>The <dfn id=csp-ensurecspdoesnotblockstringcompilation><a href=https://w3c.github.io/webappsec-csp/#can-compile-strings>EnsureCSPDoesNotBlockStringCompilation</a></dfn> abstract operation<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>The <dfn id=frame-ancestors-directive><a href=https://w3c.github.io/webappsec-csp/#frame-ancestors><code>frame-ancestors</code> directive</a></dfn><li>The <dfn id=sandbox-directive><a href=https://w3c.github.io/webappsec-csp/#sandbox><code>sandbox</code> directive</a></dfn><li>The <dfn id=should-element-be-blocked-a-priori-by-content-security-policy><a href=https://w3c.github.io/webappsec-csp/#should-plugin-element-be-blocked-a-priori-by-content-security-policy>Should element be blocked <i lang=la>a priori</i> by Content Security Policy?</a></dfn> algorithm<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.</ul>

   <dt>Service Workers<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><dfn id=dfn-client-message-queue><a href=https://w3c.github.io/ServiceWorker/#dfn-client-message-queue>client message queue</a></dfn><li><dfn id=dfn-control><a href=https://w3c.github.io/ServiceWorker/#dfn-control>control</a></dfn><li><dfn id=on-fetch-request-algorithm><a href=https://w3c.github.io/ServiceWorker/#on-fetch-request-algorithm>handle fetch</a></dfn><li><dfn id=scope-match-algorithm><a href=https://w3c.github.io/ServiceWorker/#scope-match-algorithm>match service worker registration</a></dfn><li><dfn id=dfn-service-worker><a href=https://w3c.github.io/ServiceWorker/#dfn-service-worker>service worker</a></dfn><li><dfn id=serviceworkercontainer-service-worker-client><a href=https://w3c.github.io/ServiceWorker/#serviceworkercontainer-service-worker-client>service worker client</a></dfn><li><dfn id=serviceworker><a href=https://w3c.github.io/ServiceWorker/#serviceworker><code>ServiceWorker</code></a></dfn> interface<li><dfn id=serviceworkercontainer><a href=https://w3c.github.io/ServiceWorker/#serviceworkercontainer><code>ServiceWorkerContainer</code></a></dfn> interface<li><dfn id=serviceworkerglobalscope><a href=https://w3c.github.io/ServiceWorker/#serviceworkerglobalscope><code>ServiceWorkerGlobalScope</code></a></dfn> interface</ul>

   <dt>Secure Contexts<dd>
    <p>The following algorithm is defined in <cite>Secure Contexts</cite>: <a href=#refsSECURE-CONTEXTS>[SECURE-CONTEXTS]</a></p>

    <ul class=brief><li><dfn id=is-environment-settings-object-a-secure-context><a href=https://w3c.github.io/webappsec-secure-contexts/#settings-object>Is environment settings object a secure context?</a></dfn></ul>
   <dt>Feature Policy<dd>
    <p>The following terms are defined in <cite>Feature Policy</cite>: <a href=#refsFEATUREPOLICY>[FEATUREPOLICY]</a></p>

    <ul class=brief><li><dfn id=concept-policy-controlled-feature><a href=https://wicg.github.io/feature-policy/#policy-controlled-feature>feature policy</a></dfn><li><dfn id=concept-feature-policy><a href=https://wicg.github.io/feature-policy/#feature-policy>feature policy</a></dfn><li><dfn id=concept-container-policy><a href=https://wicg.github.io/feature-policy/#container-policy>container policy</a></dfn><li><dfn id=concept-serialized-feature-policy><a href=https://wicg.github.io/feature-policy/#serialized-feature-policy>serialized feature policy</a></dfn><li><dfn id=concept-default-allowlist><a href=https://wicg.github.io/feature-policy/#default-allowlist>default allowlist</a></dfn><li>The <dfn id=initialize-document’s-feature-policy><a href=https://wicg.github.io/feature-policy/#initialize-for-document>Initialize document’s feature policy</a></dfn> algorithm<li>The <dfn id=initialize-document’s-feature-policy-from-response><a href=https://wicg.github.io/feature-policy/#initialize-from-response>Initialize document’s feature policy from response</a></dfn> algorithm<li>The <dfn id=is-feature-enabled><a href=https://wicg.github.io/feature-policy/#is-feature-enabled>Is feature enabled by policy for origin</a></dfn> algorithm<li>The <dfn id=process-feature-policy-attributes><a href=https://wicg.github.io/feature-policy/#process-feature-policy-attributes>Process feature policy attributes</a></dfn> algorithm</ul>
   <dt>Payment Request API<dd>
    <p>The following feature is defined in the <cite>Payment Request API</cite> specification:
    <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</ul>
   <dt>MathML<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 the MathML specification:</p>

    <ul class=brief><li><dfn id=mathml-annotation-xml><a href=https://www.w3.org/Math/draft-spec/chapter5.html#mixing.elements.annotation.xml>MathML <code>annotation-xml</code></a></dfn> element<li><dfn id=mathml-math><a href=https://www.w3.org/Math/draft-spec/chapter2.html#interf.toplevel>MathML <code>math</code></a></dfn> element<li><dfn id=mathml-merror><a href=https://www.w3.org/Math/draft-spec/chapter3.html#presm.merror>MathML <code>merror</code></a></dfn> element<li><dfn id=mathml-mi><a href=https://www.w3.org/Math/draft-spec/chapter3.html#presm.mi>MathML <code>mi</code></a></dfn> element<li><dfn id=mathml-mn><a href=https://www.w3.org/Math/draft-spec/chapter3.html#presm.mn>MathML <code>mn</code></a></dfn> element<li><dfn id=mathml-mo><a href=https://www.w3.org/Math/draft-spec/chapter3.html#presm.mo>MathML <code>mo</code></a></dfn> element<li><dfn id=mathml-ms><a href=https://www.w3.org/Math/draft-spec/chapter3.html#presm.ms>MathML <code>ms</code></a></dfn> element<li><dfn id=mathml-mtext><a href=https://www.w3.org/Math/draft-spec/chapter3.html#presm.mtext>MathML <code>mtext</code></a></dfn> element</ul>
   <dt>SVG<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><dfn id=svgimageelement><a href=https://svgwg.org/svg2-draft/embedded.html#InterfaceSVGImageElement><code>SVGImageElement</code></a></dfn> interface<li><dfn id=svgscriptelement><a href=https://svgwg.org/svg2-draft/interact.html#InterfaceSVGScriptElement><code>SVGScriptElement</code></a></dfn> interface<li><dfn id=svgsvgelement><a href=https://svgwg.org/svg2-draft/struct.html#InterfaceSVGSVGElement><code>SVGSVGElement</code></a></dfn> interface<li><dfn id=svg-desc><a href=https://svgwg.org/svg2-draft/struct.html#DescElement>SVG <code>desc</code></a></dfn> element<li><dfn id=svg-foreignobject><a href=https://svgwg.org/svg2-draft/embedded.html#ForeignObjectElement>SVG <code>foreignObject</code></a></dfn> element<li><dfn id=svg-image><a href=https://svgwg.org/svg2-draft/embedded.html#ImageElement>SVG <code>image</code></a></dfn> element<li><dfn id=svg-script><a href=https://svgwg.org/svg2-draft/interact.html#ScriptElement>SVG <code>script</code></a></dfn> element<li><dfn id=svg-svg><a href=https://svgwg.org/svg2-draft/struct.html#SVGElement>SVG <code>svg</code></a></dfn> element<li><dfn id=svg-title><a href=https://svgwg.org/svg2-draft/struct.html#TitleElement>SVG <code>title</code></a></dfn> element<li><dfn id=svg-use><a href=https://svgwg.org/svg2-draft/struct.html#UseElement>SVG <code>use</code></a></dfn> element</ul>
   <dt>Filter Effects<dd>
    <p>The following feature is defined in the <cite>Filter Effects</cite> specification:
    <a href=#refsFILTERS>[FILTERS]</a></p>

    <ul class=brief><li><dfn id=filter-function-list><a href=https://drafts.fxtf.org/filter-effects/#typedef-filter-function-list>&lt;filter-function-list></a></dfn></ul>
   <dt>Worklets<dd>
    <p>The following feature is defined in the <cite>Worklets</cite> specification: <a href=#refsWORKLETS>[WORKLETS]</a></p>

    <ul class=brief><li><dfn id=workletglobalscope><a href=https://drafts.css-houdini.org/worklets/#workletglobalscope><code>WorkletGlobalScope</code></a></dfn></ul>
   <dt>Cooperative Scheduling of Background Tasks<dd>
    <p>The following feature is defined in the <cite>Cooperative Scheduling of Background
    Tasks</cite> specification: <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></ul>
   </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>Otherwise, the default element namespace URI is null.</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 href=#willful-violation id=interactions-with-xpath-and-xslt: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 href=#willful-violation id=interactions-with-xpath-and-xslt:willful-violation-2>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 set the <a href=#current-document-readiness id=interactions-with-xpath-and-xslt:current-document-readiness>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=case-sensitivity-and-string-comparison><span class=secno>2.2</span> Case-sensitivity and string comparison<a href=#case-sensitivity-and-string-comparison class=self-link></a></h3>

  <p>Comparing two strings in a <dfn id=case-sensitive data-export="">case-sensitive</dfn> manner means comparing them
  exactly, code point for code point.</p>

  <p>Except where otherwise stated, string comparisons must be performed in a
  <a href=#case-sensitive id=case-sensitivity-and-string-comparison:case-sensitive>case-sensitive</a> manner.</p>

  <p>A string <var>pattern</var> is a <dfn id=prefix-match>prefix match</dfn> for a string <var>s</var> when
  <var>pattern</var> is not longer than <var>s</var> and truncating <var>s</var> to
  <var>pattern</var>'s length leaves the two strings as matches of each other.</p>


  <h3 id=policy-controlled-features><span class=secno>2.3</span> Policy-controlled features<a href=#policy-controlled-features class=self-link></a></h3>

  <p>This document defines the following <a href=https://wicg.github.io/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>

  <ul><li>"<dfn id=autoplay-feature><code>autoplay</code></dfn>", which has a <a href=https://wicg.github.io/feature-policy/#default-allowlist id=policy-controlled-features:concept-default-allowlist data-x-internal=concept-default-allowlist>default allowlist</a> of <code>'self'</code>.</ul>


  <h3 id=common-microsyntaxes><span class=secno>2.4</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>Implementors 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.4.1</span> Common parser idioms<a href=#common-parser-idioms class=self-link></a></h4>

  

  <p>The <dfn id=white_space>White_Space characters</dfn> are those that have the Unicode
  property "White_Space" in the Unicode <code>PropList.txt</code> data file. <a href=#refsUNICODE>[UNICODE]</a></p>

  <p class=note>This is not to be confused with the "White_Space" value (abbreviated "WS") of the
  "Bidi_Class" property in the <code>Unicode.txt</code> data file.</p>

  

  <p>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.4.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:

   <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>&apos;checkbox&apos;</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>&quot;&quot;</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.4.3</span> Keywords and enumerated attributes<a href=#keywords-and-enumerated-attributes class=self-link></a></h4>

  <p>Some attributes are defined as taking one of a finite set of keywords. Such attributes are
  called <dfn id=enumerated-attribute>enumerated attributes</dfn>. The keywords are each
  defined to map to a particular <em>state</em> (several keywords might map to the same state, in
  which case some of the keywords are synonyms of each other; additionally, some of the keywords can
  be said to be non-conforming, and are only in the specification for historical reasons). In
  addition, two default states can be given. The first is the <dfn id=invalid-value-default><i>invalid value default</i></dfn>, the
  second is the <dfn id=missing-value-default><i>missing value default</i></dfn>.</p>

  <p>If an enumerated attribute is specified, the attribute's value must be 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 given keywords that are not said to be
  non-conforming, with no leading or trailing whitespace.</p>

  <p>When the attribute is specified, if its value is 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 given keywords then that keyword's state is the state that the attribute
  represents. If the attribute value matches none of the given keywords, but the attribute has an
  <i id=keywords-and-enumerated-attributes:invalid-value-default><a href=#invalid-value-default>invalid value default</a></i>, then the attribute represents that
  state. Otherwise, there is no default, and invalid values mean that there is no state
  represented.</p>

  <p>When the attribute is <em>not</em> specified, if there is a <i id=keywords-and-enumerated-attributes:missing-value-default><a href=#missing-value-default>missing value default</a></i> state
  defined, then that is the state represented by the (missing) attribute. Otherwise, the absence of
  the attribute means that there is no state represented.</p>

  <p class=note>The empty string can be a valid keyword.</p>


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

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

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

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

  

  <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.<li><p>Let <var>position</var> be a pointer into <var>input</var>, initially pointing at the
   start of the string.<li><p>Let <var>sign</var> have the value "positive".<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>.<li><p>If <var>position</var> is past the end of <var>input</var>, return an error.<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>Advance <var>position</var> to the next character.<li>If <var>position</var> is past the end of <var>input</var>, return an error.</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>If <var>position</var> is past the end of <var>input</var>, return an error.</ol>

   <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.<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.<li><p>If <var>sign</var> is "positive", return <var>value</var>, otherwise return the result of
   subtracting <var>value</var> from zero.</ol>

  


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

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

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

  

  <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.<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>.<li><p>If <var>value</var> is an error, return an error.<li><p>If <var>value</var> is less than zero, return an error.<li><p>Return <var>value</var>.</ol>

  

  


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

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

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

    <ol><li>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>.<li>Both of the following, in the given order:

      <ol><li>A single U+002E FULL STOP character (.).<li>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>.</ol>

     </ol>

   <li>Optionally:

    <ol><li>Either a U+0065 LATIN SMALL LETTER E character (e) or a U+0045 LATIN CAPITAL LETTER E
     character (E).<li>Optionally, a U+002D HYPHEN-MINUS character (-) or U+002B PLUS SIGN character (+).<li>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>.</ol>

   </ol>

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

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

  <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.github.io/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.github.io/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.github.io/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>

  <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.<li><p>Let <var>position</var> be a pointer into <var>input</var>, initially pointing at the
   start of the string.<li><p>Let <var>value</var> have the value 1.<li><p>Let <var>divisor</var> have the value 1.<li><p>Let <var>exponent</var> have the value 1.<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>.<li><p>If <var>position</var> is past the end of <var>input</var>, return an error.<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>Advance <var>position</var> to the next character.<li>If <var>position</var> is past the end of <var>input</var>, return an error.</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>If <var>position</var> is past the end of <var>input</var>, return an error.</ol>

   <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><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.<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.<li>If <var>position</var> is past the end of <var>input</var>, jump to the step labeled
   <i>conversion</i>.<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.<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>.<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><p><i>Fraction loop</i>: Multiply <var>divisor</var> by ten.<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><p>Advance <var>position</var> to the next character.<li><p>If <var>position</var> is past the end of <var>input</var>, then jump to the step
     labeled <i>conversion</i>.<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.</ol>

   <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.<li><p>If <var>position</var> is past the end of <var>input</var>, then jump to the step
     labeled <i>conversion</i>.<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>Advance <var>position</var> to the next character.<li><p>If <var>position</var> is past the end of <var>input</var>, then jump to the step
       labeled <i>conversion</i>.</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><p>If <var>position</var> is past the end of <var>input</var>, then jump to the step
       labeled <i>conversion</i>.</ol>

     <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>.<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.<li><p>Multiply <var>value</var> by ten raised to the <var>exponent</var>th power.</ol>

   <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>.<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.)<li><p>If <var>rounded-value</var> is 2<sup>1024</sup> or −2<sup>1024</sup>, return an error.<li><p>Return <var>rounded-value</var>.</ol>

  



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

  <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 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.<li><p>Let <var>position</var> be a pointer into <var>input</var>, initially pointing at the
   start of the string.<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>.<li><p>If <var>position</var> is past the end of <var>input</var>, return an error.<li><p>If the character indicated by <var>position</var> is a U+002B PLUS SIGN character (+),
   advance <var>position</var> to the next character.<li><p>If <var>position</var> is past the end of <var>input</var>, return an error.<li><p>If the character indicated by <var>position</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 an error.<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.<li><p>If <var>position</var> is past the end of <var>input</var>, return <var>value</var> as a
   length.<li>

    <p>If the character indicated by <var>position</var> is a U+002E FULL STOP character (.):</p>

    <ol><li><p>Advance <var>position</var> to the next character.<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=percentages-and-dimensions:ascii-digits-3 data-x-internal=ascii-digits>ASCII digit</a>, then
     return <var>value</var> as a length.<li><p>Let <var>divisor</var> have the value 1.<li><p><i>Fraction loop</i>: Multiply <var>divisor</var> by ten.<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><p>Advance <var>position</var> to the next character.<li><p>If <var>position</var> is past the end of <var>input</var>, then return <var>value</var>
     as a length.<li><p>If the character indicated by <var>position</var> is 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>, return to the step labeled <i>fraction loop</i> in these
     substeps.</ol>

   <li><p>If <var>position</var> is past the end of <var>input</var>, return <var>value</var> as a
   length.<li><p>If the character indicated by <var>position</var> is a U+0025 PERCENT SIGN character (%),
   return <var>value</var> as a percentage.<li><p>Return <var>value</var> as a length.</ol>

  <h5 id=non-zero-percentages-and-lengths><span class=secno>2.4.4.5</span> Non-zero percentages and lengths<a href=#non-zero-percentages-and-lengths class=self-link></a></h5>

  <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.<li><p>Let <var>value</var> be the result of parsing <var>input</var> using the <a href=#rules-for-parsing-dimension-values id=non-zero-percentages-and-lengths:rules-for-parsing-dimension-values>rules for
   parsing dimension values</a>.<li><p>If <var>value</var> is an error, return an error.<li><p>If <var>value</var> is zero, return an error.<li><p>If <var>value</var> is a percentage, return <var>value</var> as a percentage.<li><p>Return <var>value</var> as a length.</ol>

  


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

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

  

  <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.<li><p>Let <var>position</var> be a pointer into <var>input</var>, initially pointing at the
   start of the string.<li><p>Let <var>numbers</var> be an initially empty list of floating-point numbers. This list
   will be the result of this algorithm.<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.<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.<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.<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>.<li><p>If <var>number</var> is an error, set <var>number</var> to zero.<li><p>Append <var>number</var> to <var>numbers</var>.<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.</ol>

   <li><p>Return <var>numbers</var>.</ol>

  

  

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

  

  <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.<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>.<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.<li><p>Let <var>result</var> be an empty list of number/unit pairs.<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.<li><p>Let <var>position</var> be a pointer into <var>input</var>,
     initially pointing at the start of the string.<li><p>Let <var>value</var> be the number 0.<li><p>Let <var>unit</var> be <i>absolute</i>.<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.<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.<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.<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>.<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).<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>.<li><p>Increment <var>value</var> by <var>fraction</var>.</ol>

       </ol>

     <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>.<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><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>.</ol>

   <li><p>Return the list <var>result</var>.</ol>

  


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

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

  <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.
  Implementors 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.4.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>

  <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> > 0<li>A U+002D HYPHEN-MINUS character (-)<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 ≤ <var>month</var> ≤ 12</ol>

  

  <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.<li><p>Let <var>position</var> be a pointer into <var>input</var>, initially
   pointing at the start of the string.<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><p>If <var>position</var> is <em>not</em> beyond the
   end of <var>input</var>, then fail.<li><p>Return <var>year</var> and <var>month</var>.</ol>

  <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 that number be the <var>year</var>.<li><p>If <var>year</var> is not a number greater than zero, then fail.<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.<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 that number be the <var>month</var>.<li><p>If <var>month</var> is not a number in the range 1 ≤ <var>month</var> ≤ 12, then fail.<li><p>Return <var>year</var> and <var>month</var>.</ol>

  


  <h5 id=dates><span class=secno>2.4.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>

  <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>A U+002D HYPHEN-MINUS character (-)<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 ≤ <var>day</var> ≤ <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></ol>

  

  <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.<li><p>Let <var>position</var> be a pointer into <var>input</var>, initially
   pointing at the start of the string.<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><p>If <var>position</var> is <em>not</em> beyond the end of <var>input</var>, then fail.<li><p>Let <var>date</var> be the date with year <var>year</var>, month <var>month</var>, and day <var>day</var>.<li><p>Return <var>date</var>.</ol>

  <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.<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>.<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.<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 that number be the <var>day</var>.<li><p>If <var>day</var> is not a number in the range 1 ≤ <var>day</var> ≤ <var>maxday</var>, then fail.<li><p>Return <var>year</var>, <var>month</var>, and <var>day</var>.</ol>

  


  <h5 id=yearless-dates><span class=secno>2.4.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>

  <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>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 ≤ <var>month</var> ≤ 12<li>A U+002D HYPHEN-MINUS character (-)<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 ≤ <var>day</var> ≤ <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)</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>

  

  <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.<li><p>Let <var>position</var> be a pointer into <var>input</var>, initially
   pointing at the start of the string.<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><p>If <var>position</var> is <em>not</em> beyond the end of <var>input</var>, then fail.<li><p>Return <var>month</var> and <var>day</var>.</ol>

  <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.<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 that number be the <var>month</var>.<li><p>If <var>month</var> is not a number in the range 1 ≤ <var>month</var> ≤ 12, then fail.<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).<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.<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 that number be the <var>day</var>.<li><p>If <var>day</var> is not a number in the range 1 ≤ <var>day</var> ≤ <var>maxday</var>, then fail.<li><p>Return <var>month</var> and <var>day</var>.</ol>

  


  <h5 id=times><span class=secno>2.4.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>

  <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 ≤ <var>hour</var> ≤ 23<li>A U+003A COLON character (:)<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 ≤ <var>minute</var> ≤ 59<li>If <var>second</var> is nonzero, or optionally if <var>second</var> is
   zero:

    <ol><li>A U+003A COLON character (:)<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 ≤ <var>s</var> ≤ 59<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>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></ol>

     </ol>

   </ol>

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

  

  <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.<li><p>Let <var>position</var> be a pointer into <var>input</var>, initially
   pointing at the start of the string.<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><p>If <var>position</var> is <em>not</em> beyond the end of <var>input</var>, then fail.<li><p>Let <var>time</var> be the time with hour <var>hour</var>, minute <var>minute</var>, and second <var>second</var>.<li><p>Return <var>time</var>.</ol>

  <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 that number be the <var>hour</var>.<li>If <var>hour</var> is not a number in the range 0 ≤ <var>hour</var> ≤ 23, then fail.<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.<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 that number be the <var>minute</var>.<li>If <var>minute</var> is not a number in the range 0 ≤ <var>minute</var> ≤ 59, then fail.<li><p>Let <var>second</var> be 0.<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>.<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.<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.<li><p>If <var>second</var> is not a number in the range
     0 ≤ <var>second</var> &lt; 60, then fail.</ol>

   <li><p>Return <var>hour</var>, <var>minute</var>, and <var>second</var>.</ol>

  


  <h5 id=local-dates-and-times><span class=secno>2.4.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>

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

  <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>A U+0054 LATIN CAPITAL LETTER T character (T)<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)</ol>

  

  <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.<li><p>Let <var>position</var> be a pointer into <var>input</var>, initially
   pointing at the start of the string.<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><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.<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><p>If <var>position</var> is <em>not</em> beyond the end of <var>input</var>, then fail.<li><p>Let <var>date</var> be the date with year <var>year</var>, month <var>month</var>, and day <var>day</var>.<li><p>Let <var>time</var> be the time with hour <var>hour</var>, minute <var>minute</var>, and second <var>second</var>.<li><p>Return <var>date</var> and <var>time</var>.</ol>

  


  <h5 id=time-zones><span class=secno>2.4.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>

  <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<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>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 ≤ <var>hour</var> ≤ 23<li>Optionally, a U+003A COLON character (:)<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 ≤ <var>minute</var> ≤ 59</ol>

   </ul>

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

  

  <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.<li><p>Let <var>position</var> be a pointer into <var>input</var>, initially
   pointing at the start of the string.<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><p>If <var>position</var> is <em>not</em> beyond the end of <var>input</var>, then fail.<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.</ol>

  <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.<li><p>Let <var>timezone<sub>minutes</sub></var> be 0.<li><p>Advance <var>position</var> to the next character in <var>input</var>.</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".<li><p>Advance <var>position</var> to the next character in <var>input</var>.<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.<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 that number be the <var>timezone<sub>hours</sub></var>.<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.<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 that number be the <var>timezone<sub>minutes</sub></var>.</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
       that number be the <var>timezone<sub>hours</sub></var>.<li><p>Interpret the last two characters of <var>s</var> as a base-ten integer. Let
       that number be the <var>timezone<sub>minutes</sub></var>.</ol>

      <p>Otherwise, fail.</p>

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

    <p>Otherwise, fail.</p>

   <li><p>Return <var>timezone<sub>hours</sub></var> and <var>timezone<sub>minutes</sub></var>.</ol>

  


  <h5 id=global-dates-and-times><span class=secno>2.4.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>

  <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>A U+0054 LATIN CAPITAL LETTER T character (T) or a U+0020 SPACE character<li>A <a href=#valid-time-string id=global-dates-and-times:valid-time-string>valid time string</a> representing the time<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</ol>

  <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>"<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.<dt>"<code>1979-10-14T12:00:00.001-04:00</code>"<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.<dt>"<code>8592-01-01T02:09+02:09</code>"<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.</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>If the "<code>T</code>" is replaced by a space, it must be a single space
    character. The string "<code>2001-12-21  12:00Z</code>" (with two spaces
    between the components) would not be parsed successfully.<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>The time and time-zone offset components are not optional.<li>Dates before the year one can't be represented as a datetime in this version of HTML.<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>Time-zone offsets differ based on daylight saving time.</ul>

  </div>

  

  <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.<li><p>Let <var>position</var> be a pointer into <var>input</var>, initially
   pointing at the start of the string.<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><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.<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><p>If <var>position</var> is beyond the end of <var>input</var>, then
   fail.<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><p>If <var>position</var> is <em>not</em> beyond the end of <var>input</var>, then fail.<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.<li><p>Let <var>timezone</var> be <var>timezone<sub>hours</sub></var>
   hours and <var>timezone<sub>minutes</sub></var> minutes from UTC.<li><p>Return <var>time</var> and <var>timezone</var>.</ol>

  


  <h5 id=weeks><span class=secno>2.4.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>

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

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

  <p 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>

  <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> > 0<li>A U+002D HYPHEN-MINUS character (-)<li>A U+0057 LATIN CAPITAL LETTER W character (W)<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 ≤ <var>week</var> ≤ <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></ol>

  

  <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.<li><p>Let <var>position</var> be a pointer into <var>input</var>, initially
   pointing at the start of the string.<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 that number be the <var>year</var>.<li><p>If <var>year</var> is not a number greater than zero, then fail.<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.<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.<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 that number be the <var>week</var>.<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>.<li><p>If <var>week</var> is not a number in the range 1 ≤ <var>week</var> ≤ <var>maxweek</var>, then fail.<li><p>If <var>position</var> is <em>not</em> beyond the end of <var>input</var>, then fail.<li><p>Return the week-year number <var>year</var> and the week number <var>week</var>.</ol>

  


  <h5 id=durations><span class=secno>2.4.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>

  <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.<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.<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.<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.<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.<li><p>A U+0053 LATIN CAPITAL LETTER S character.</ol>

       </ol>

     </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>

    <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>.<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.<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.<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>.<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>U+0077 LATIN SMALL LETTER W character<dd>Weeks. The scale is 604800.<dt>U+0044 LATIN CAPITAL LETTER D character<dt>U+0064 LATIN SMALL LETTER D character<dd>Days. The scale is 86400.<dt>U+0048 LATIN CAPITAL LETTER H character<dt>U+0068 LATIN SMALL LETTER H character<dd>Hours. The scale is 3600.<dt>U+004D LATIN CAPITAL LETTER M character<dt>U+006D LATIN SMALL LETTER M character<dd>Minutes. The scale is 60.<dt>U+0053 LATIN CAPITAL LETTER S character<dt>U+0073 LATIN SMALL LETTER S character<dd>Seconds. The scale is 1.</dl>

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

   </ul>

  

  <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.<li><p>Let <var>position</var> be a pointer into <var>input</var>, initially
   pointing at the start of the string.<li><p>Let <var>months</var>, <var>seconds</var>, and <var>component
   count</var> all be zero.<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><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>.<li><p>If <var>position</var> is past the end of <var>input</var>, then
   fail.<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>.<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>.<li><p>Let <var>next character</var> be undefined. It is used to process characters
     from the <var>input</var>.<li><p>If <var>position</var> is past the end of <var>input</var>, then break.<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 continue.<li><p>Set <var>next character</var> to the character in <var>input</var>
     pointed to by <var>position</var>.<li>

      <p>If <var>next character</var> is a U+002E FULL STOP character (.), then let <var>N</var> equal zero. (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><p>If <var>position</var> is past the end of <var>input</var>, then
     fail.<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.)<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.<li><p>If <var>s</var> is the empty string, then fail.<li><p>Let <var>length</var> be the number of characters in <var>s</var>.<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>.<li><p>Increment <var>N</var> by <var>fraction</var>.<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>.<li><p>If <var>position</var> is past the end of <var>input</var>, then
       fail.<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.<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.<li><p>Set <var>units</var> to <i>seconds</i>.</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.<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>

       </ol>

     <li><p>Increment <var>component count</var>.<li><p>Let <var>multiplier</var> be 1.<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>.<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>.<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>.<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>.<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>.<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>.</ol>

     <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>.</ol>

   <li><p>If <var>component count</var> is zero,
   fail.<li><p>If <var>months</var> is not zero, fail.<li><p>Return the <a href=#concept-duration id=durations:concept-duration-4>duration</a> consisting of <var>seconds</var> seconds.</ol>

  


  <h5 id=vaguer-moments-in-time><span class=secno>2.4.5.10</span> Vaguer moments in time<a href=#vaguer-moments-in-time class=self-link></a></h5>

  <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>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></ul>

  

  <hr>

  <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.<li><p>Let <var>position</var> be a pointer into <var>input</var>, initially
   pointing at the start of the string.<li><p>Set <var>start position</var> to the same position as <var>position</var>.<li><p>Set the <var>date present</var> and <var>time present</var> flags to
   true.<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>

    <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><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.<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.<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><p>If <var>position</var> is <em>not</em> beyond the end of <var>input</var>, then fail.<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>

   </ol>

  


  <h4 id=colours><span class=secno>2.4.6</span> Colors<a href=#colours class=self-link></a></h4>

  <p>A <dfn id=simple-colour>simple color</dfn> consists of three 8-bit numbers in the
  range 0..255, representing the red, green, and blue components of the color respectively, in the
  sRGB color space. <a href=#refsSRGB>[SRGB]</a></p>

  <p>A string is a <dfn id=valid-simple-colour>valid simple color</dfn> if it is
  exactly seven characters long, and the first character is a U+0023 NUMBER SIGN character (#), and
  the remaining six characters 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>, with the first two digits
  representing the red component, the middle two digits representing the green component, and the
  last two digits representing the blue component, in hexadecimal.</p>

  <p>A string is a <dfn id=valid-lowercase-simple-colour>valid lowercase simple
  color</dfn> if it is a <a href=#valid-simple-colour id=colours:valid-simple-colour>valid simple color</a> and doesn't use any characters in the range
  U+0041 LATIN CAPITAL LETTER A to U+0046 LATIN CAPITAL LETTER F.</p>

  

  <p>The <dfn id=rules-for-parsing-simple-colour-values>rules for parsing simple color
  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 <a href=#simple-colour id=colours:simple-colour>simple color</a> or an error.</p>

  <ol><li><p>Let <var>input</var> be the string being parsed.<li><p>If <var>input</var> is not exactly seven characters long, then return an
   error.<li><p>If the first character in <var>input</var> is not a U+0023 NUMBER SIGN character
   (#), then return an error.<li><p>If the last six characters of <var>input</var> are not all <a id=colours:ascii-hex-digits-2 href=https://infra.spec.whatwg.org/#ascii-hex-digit data-x-internal=ascii-hex-digits>ASCII hex
   digits</a>, then return an error.<li><p>Let <var>result</var> be a <a href=#simple-colour id=colours:simple-colour-2>simple color</a>.</p>

   <li><p>Interpret the second and third characters as a hexadecimal number and let the result be
   the red component of <var>result</var>.</p>

   <li><p>Interpret the fourth and fifth characters as a hexadecimal number and let the result be
   the green component of <var>result</var>.</p>

   <li><p>Interpret the sixth and seventh characters as a hexadecimal number and let the result be
   the blue component of <var>result</var>.</p>

   <li><p>Return <var>result</var>.</p>

  </ol>

  <p>The <dfn id=rules-for-serialising-simple-colour-values>rules for serializing
  simple color values</dfn> given a <a href=#simple-colour id=colours:simple-colour-3>simple color</a> are as given in the following
  algorithm:</p>

  <ol><li><p>Let <var>result</var> be a string consisting of a single U+0023 NUMBER SIGN
   character (#).<li><p>Convert the red, green, and blue components in turn to two-digit hexadecimal numbers using
   <a href=https://infra.spec.whatwg.org/#ascii-lower-hex-digit id=colours:lowercase-ascii-hex-digits data-x-internal=lowercase-ascii-hex-digits>ASCII lower hex digits</a>, zero-padding if necessary,
   and append these numbers to <var>result</var>, in the order red, green, blue.</p>

   <li><p>Return <var>result</var>, which will be a <a href=#valid-lowercase-simple-colour id=colours:valid-lowercase-simple-colour>valid lowercase simple
   color</a>.</ol>

  <hr>

  <p>Some obsolete legacy attributes parse colors in a more complicated manner, using the
  <dfn id=rules-for-parsing-a-legacy-colour-value>rules for parsing a legacy color
  value</dfn>, which are 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 <a href=#simple-colour id=colours:simple-colour-4>simple color</a> or an error.</p>

  <ol><li><p>Let <var>input</var> be the string being parsed.<li><p>If <var>input</var> is the empty string, then return an error.<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>.<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 the
   string "<code>transparent</code>", then return an error.<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 <a href=#simple-colour id=colours:simple-colour-5>simple
    color</a> 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>

    <p>If <var>input</var> is four characters long, 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-3 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 <a href=#simple-colour id=colours:simple-colour-6>simple color</a>.</p>

     <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><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><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><p>Return <var>result</var>.</p>

    </ol>

   <li><p>Replace any characters in <var>input</var> that have a code point greater than U+FFFF
   (i.e., any characters that are not in the basic multilingual plane) with the two-character string
   "<code>00</code>".<li><p>If <var>input</var> is longer than 128 characters, truncate <var>input</var>, leaving only the first 128 characters.<li><p>If the first character in <var>input</var> is a U+0023 NUMBER SIGN character (#),
   remove it.<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-4 data-x-internal=ascii-hex-digits>ASCII hex digit</a> with the character U+0030 DIGIT ZERO (0).<li><p>While <var>input</var>'s length is zero or not a multiple of three, append a
   U+0030 DIGIT ZERO (0) character to <var>input</var>.<li><p>Split <var>input</var> into three strings of equal length, to obtain three
   components. Let <var>length</var> be the length of those components (one third the
   length of <var>input</var>).<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.<li><p>While <var>length</var> is greater than two and the first character in each
   component is a U+0030 DIGIT ZERO (0) character, remove that character and reduce <var>length</var> by one.<li><p>If <var>length</var> is <em>still</em> greater than two, truncate each component,
   leaving only the first two characters in each.<li><p>Let <var>result</var> be a <a href=#simple-colour id=colours:simple-colour-7>simple color</a>.</p>

   <li><p>Interpret the first component as a hexadecimal number; let the red component of <var>result</var> be the resulting number.<li><p>Interpret the second component as a hexadecimal number; let the green component of <var>result</var> be the resulting number.<li><p>Interpret the third component as a hexadecimal number; let the blue component of <var>result</var> be the resulting number.<li><p>Return <var>result</var>.</p>

  </ol>

  

  <hr>

  <p class=note>The <a href=#canvas-context-2d id=colours:canvas-context-2d>2D graphics context</a> has a separate
  color syntax that also handles opacity.</p>



  <h4 id=space-separated-tokens><span class=secno>2.4.7</span> Space-separated tokens<a href=#space-separated-tokens class=self-link></a></h4>

  <p>A <dfn id=set-of-space-separated-tokens>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>

  <p>An <dfn id=unordered-set-of-unique-space-separated-tokens>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>

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

  <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.4.8</span> Comma-separated tokens<a href=#comma-separated-tokens class=self-link></a></h4>

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

  <p class=example>For instance, the string "<code> a ,b,,d d </code>" consists of four tokens: "a", "b", the empty
  string, and "d 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.4.9</span> References<a href=#syntax-references class=self-link></a></h4>

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

  

  <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.<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.<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>
   </ol>

  


  <h4 id=mq><span class=secno>2.4.10</span> Media queries<a href=#mq class=self-link></a></h4>

  <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></code> production of the Media Queries specification. <a href=#refsMQ>[MQ]</a></p>

  <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 the Media Queries specification. <a href=#refsMQ>[MQ]</a></p>




  <h3 id=urls><span class=secno>2.5</span> URLs<a href=#urls class=self-link></a></h3>

  <h4 id=terminology-2><span class=secno>2.5.1</span> Terminology<a href=#terminology-2 class=self-link></a></h4>

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

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

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

  <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://tools.ietf.org/html/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://tools.ietf.org/html/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://tools.ietf.org/html/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>

  <p>The <dfn id=fallback-base-url>fallback base URL</dfn> of a <code id=terminology-2:document><a href=#document>Document</a></code> object <var>document</var> is the
  <a id=terminology-2: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> is <a href=#an-iframe-srcdoc-document id=terminology-2:an-iframe-srcdoc-document-2>an <code>iframe</code> <code>srcdoc</code> document</a>, then return the <a href=#document-base-url id=terminology-2:document-base-url>document base
   URL</a> of <var>document</var>'s <a href=#concept-document-bc id=terminology-2:concept-document-bc>browsing context</a>'s
   <a href=#browsing-context-container id=terminology-2:browsing-context-container>browsing context container</a>'s <a id=terminology-2:node-document href=https://dom.spec.whatwg.org/#concept-node-document data-x-internal=node-document>node document</a>.<li>

    

    

    <p>If <var>document</var>'s <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> is
    <code id=terminology-2:about:blank><a href=#about:blank>about:blank</a></code>, and <var>document</var>'s <a href=#concept-document-bc id=terminology-2:concept-document-bc-2>browsing
    context</a> has a <a href=#creator-browsing-context id=terminology-2:creator-browsing-context>creator browsing context</a>, then return the <a href=#creator-base-url id=terminology-2:creator-base-url>creator base
    URL</a>.</p>

   <li><p>Return <var>document</var>'s <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>.</ol>

  <p>The <dfn id=document-base-url data-export="">document base URL</dfn> of a <code id=terminology-2:document-2><a href=#document>Document</a></code> object is the
  <a id=terminology-2:absolute-url href=https://url.spec.whatwg.org/#syntax-url-absolute data-x-internal=absolute-url>absolute URL</a> obtained by running these steps:</p>

  <ol><li><p>If there is no <code id=terminology-2:the-base-element><a href=#the-base-element>base</a></code> element that has an <code id=terminology-2:attr-base-href><a href=#attr-base-href>href</a></code> attribute in the <code id=terminology-2:document-3><a href=#document>Document</a></code>, then return the
   <code id=terminology-2:document-4><a href=#document>Document</a></code>'s <a href=#fallback-base-url id=terminology-2:fallback-base-url>fallback base URL</a>.<li><p>Otherwise, return the <a href=#frozen-base-url id=terminology-2:frozen-base-url>frozen base URL</a> of the first <code id=terminology-2:the-base-element-2><a href=#the-base-element>base</a></code> element
   in the <code id=terminology-2:document-5><a href=#document>Document</a></code> that has an <code id=terminology-2:attr-base-href-2><a href=#attr-base-href>href</a></code> attribute, in
   <a id=terminology-2:tree-order href=https://dom.spec.whatwg.org/#concept-tree-order data-x-internal=tree-order>tree order</a>.</ol>


  

  <h4 id=resolving-urls><span class=secno>2.5.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 the WHATWG URL standard, the HTML standard defines
  a wrapper for convenience. <a href=#refsURL>[URL]</a></p>

  <p class=note>This wrapper is only useful when the character encoding for the URL parser has to
  match that of the document or environment settings object for legacy reasons. When that is not the
  case 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 be used directly.</p>

  <p id=resolve-a-url>To <dfn id=parse-a-url>parse a URL</dfn> <var>url</var>, relative to either a
  <var>document</var> or <var>environment settings object</var>, the user agent must use the
  following steps. Parsing a URL either results in failure or a <a href=#resulting-url-string id=resolving-urls:resulting-url-string>resulting URL string</a>
  and <a href=#resulting-url-record id=resolving-urls:resulting-url-record>resulting URL record</a>.</p>

  <ol><li><p>Let <var>encoding</var> be <var>document</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>, if <var>document</var> was given, and <var>environment
   settings object</var>'s <a href=#api-url-character-encoding id=resolving-urls:api-url-character-encoding>API URL character encoding</a> otherwise.<li><p>Let <var>baseURL</var> be <var>document</var>'s <a href=#document-base-url id=resolving-urls:document-base-url>base
   URL</a>, if <var>document</var> was given, and <var>environment settings object</var>'s
   <a href=#api-base-url id=resolving-urls:api-base-url>API base URL</a> otherwise.<li><p>Let <var>urlRecord</var> be 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> and <var>encoding</var>.<li><p>If <var>urlRecord</var> is failure, then return failure.<li><p>Let <var>urlString</var> be 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>urlRecord</var>.<li><p>Return <var>urlString</var> as the <dfn id=resulting-url-string>resulting URL string</dfn> and
   <var>urlRecord</var> as the <dfn id=resulting-url-record>resulting URL record</dfn>.</ol>

  



  

  <h4 id=dynamic-changes-to-base-urls><span class=secno>2.5.3</span> Dynamic changes to base URLs<a href=#dynamic-changes-to-base-urls class=self-link></a></h4>

  <p>When a document's <a href=#document-base-url id=dynamic-changes-to-base-urls:document-base-url>document base URL</a> changes, all elements in that document are
  <a href=#affected-by-a-base-url-change id=dynamic-changes-to-base-urls:affected-by-a-base-url-change>affected by a base URL change</a>.</p>

  <p>The following are <a href=#base-url-change-steps id=dynamic-changes-to-base-urls:base-url-change-steps>base URL change steps</a>, which run when an element is
  <a href=#affected-by-a-base-url-change id=dynamic-changes-to-base-urls:affected-by-a-base-url-change-2>affected by a base URL change</a> (as defined by the DOM specification):</p>

  <dl class=switch><dt>If the element creates a <a href=#hyperlink id=dynamic-changes-to-base-urls:hyperlink>hyperlink</a><dd>

    <p>If the <a id=dynamic-changes-to-base-urls:url href=https://url.spec.whatwg.org/#concept-url data-x-internal=url>URL</a> identified by the hyperlink is being shown to the user, or if any
    data derived from that <a id=dynamic-changes-to-base-urls:url-2 href=https://url.spec.whatwg.org/#concept-url data-x-internal=url>URL</a> is affecting the display, then the <code id=dynamic-changes-to-base-urls:attr-hyperlink-href><a href=#attr-hyperlink-href>href</a></code> attribute should be <a href=#parse-a-url id=dynamic-changes-to-base-urls:parse-a-url>reparsed</a> relative to the element's <a id=dynamic-changes-to-base-urls:node-document href=https://dom.spec.whatwg.org/#concept-node-document data-x-internal=node-document>node document</a> and the UI updated
    appropriately.</p>

    <p class=example>For example, the CSS <code id=dynamic-changes-to-base-urls:selector-link><a href=#selector-link>:link</a></code>/<code id=dynamic-changes-to-base-urls:selector-visited><a href=#selector-visited>:visited</a></code> <a href=https://drafts.csswg.org/selectors/#pseudo-class id=dynamic-changes-to-base-urls:pseudo-class data-x-internal=pseudo-class>pseudo-classes</a>
    might have been affected.</p>

    <p>If the hyperlink has a <code id=dynamic-changes-to-base-urls:ping><a href=#ping>ping</a></code> attribute and its
    <a href=https://url.spec.whatwg.org/#concept-url id=dynamic-changes-to-base-urls:url-3 data-x-internal=url>URL(s)</a> are being shown to the user, then the <code id=dynamic-changes-to-base-urls:ping-2><a href=#ping>ping</a></code> attribute's tokens should be <a href=#parse-a-url id=dynamic-changes-to-base-urls:parse-a-url-2>reparsed</a> relative to the element's <a id=dynamic-changes-to-base-urls:node-document-2 href=https://dom.spec.whatwg.org/#concept-node-document data-x-internal=node-document>node document</a> and the UI updated
    appropriately.</p>

   <dt>If the element is a <code id=dynamic-changes-to-base-urls:the-q-element><a href=#the-q-element>q</a></code>, <code id=dynamic-changes-to-base-urls:the-blockquote-element><a href=#the-blockquote-element>blockquote</a></code>, <code id=dynamic-changes-to-base-urls:the-ins-element><a href=#the-ins-element>ins</a></code>, or
   <code id=dynamic-changes-to-base-urls:the-del-element><a href=#the-del-element>del</a></code> element with a <code>cite</code> attribute<dd>

    <p>If the <a id=dynamic-changes-to-base-urls:url-4 href=https://url.spec.whatwg.org/#concept-url data-x-internal=url>URL</a> identified by the <code>cite</code> attribute is being
    shown to the user, or if any data derived from that <a id=dynamic-changes-to-base-urls:url-5 href=https://url.spec.whatwg.org/#concept-url data-x-internal=url>URL</a> is affecting the display,
    then the <a id=dynamic-changes-to-base-urls:url-6 href=https://url.spec.whatwg.org/#concept-url data-x-internal=url>URL</a> should be <a href=#parse-a-url id=dynamic-changes-to-base-urls:parse-a-url-3>reparsed</a> relative to the
    element's <a id=dynamic-changes-to-base-urls:node-document-3 href=https://dom.spec.whatwg.org/#concept-node-document data-x-internal=node-document>node document</a> and the UI updated appropriately.</p>

   <dt>Otherwise<dd>

    <p>The element is not directly affected.</p>

    <p class=example>For instance, changing the base URL doesn't affect the image displayed by
    <code id=dynamic-changes-to-base-urls:the-img-element><a href=#the-img-element>img</a></code> elements, although subsequent accesses of the <code id=dynamic-changes-to-base-urls:dom-img-src><a href=#dom-img-src>src</a></code> IDL attribute from script will return a new <a id=dynamic-changes-to-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>

   </dl>

  


  

  <h3 id=fetching-resources><span class=secno>2.6</span> Fetching resources<a href=#fetching-resources class=self-link></a></h3>

  <h4 id=terminology-3><span class=secno>2.6.1</span> Terminology<a href=#terminology-3 class=self-link></a></h4>

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

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

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

  <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.<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>".<li><p>Let <var>credentialsMode</var> be "<code>include</code>".<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>".<li><p>Let <var>request</var> be 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.</ol>


  <h4 id=content-type-sniffing><span class=secno>2.6.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 the WHATWG MIME Sniffing standard.
  <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 the WHATWG MIME
  Sniffing standard. <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 the WHATWG MIME Sniffing
  standard. 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 the WHATWG MIME Sniffing standard 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 the WHATWG MIME Sniffing
  standard. <a href=#refsMIMESNIFF>[MIMESNIFF]</a></p>


  <h4 id=extracting-character-encodings-from-meta-elements><span class=secno>2.6.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>

  <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 either returns 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.<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.<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).<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>.<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).<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>If it is a U+0027 APOSTROPHE character (') and there is a later U+0027 APOSTROPHE character (') in <var>s</var><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.<dt>If it is an unmatched U+0022 QUOTATION MARK character (")<dt>If it is an unmatched U+0027 APOSTROPHE character (')<dt>If there is no next character<dd>Return nothing.<dt>Otherwise<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.</dl>

   </ol>

  <p class=note>This algorithm is distinct from those in the HTTP specification (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.6.4</span> CORS settings attributes<a href=#cors-settings-attributes class=self-link></a></h4>

  <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>. The following
  table lists the keywords and states for the attribute — the keywords in the left column map
  to the states in the cell in the second column on the same row as the keyword.</p>

  <table><thead><tr><th> Keyword
     <th> State
     <th> Brief description
   <tbody><tr><td><dfn id=attr-crossorigin-anonymous-keyword><code>anonymous</code></dfn>
     <td><dfn id=attr-crossorigin-anonymous>Anonymous</dfn>
     <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>".
    <tr><td><dfn id=attr-crossorigin-use-credentials-keyword><code>use-credentials</code></dfn>
     <td><dfn id=attr-crossorigin-use-credentials>Use Credentials</dfn>
     <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>".
  </table>

  <p>The empty string is also a valid keyword, and maps to the <a href=#attr-crossorigin-anonymous id=cors-settings-attributes:attr-crossorigin-anonymous>Anonymous</a> state. The attribute's <i id=cors-settings-attributes:invalid-value-default><a href=#invalid-value-default>invalid value default</a></i> is the <a href=#attr-crossorigin-anonymous id=cors-settings-attributes:attr-crossorigin-anonymous-2>Anonymous</a> state. For the
  purposes of <a href=#reflect id=cors-settings-attributes:reflect>reflection</a>, the canonical case for the <a href=#attr-crossorigin-anonymous id=cors-settings-attributes:attr-crossorigin-anonymous-3>Anonymous</a> state is the <code id=cors-settings-attributes:attr-crossorigin-anonymous-keyword><a href=#attr-crossorigin-anonymous-keyword>anonymous</a></code> keyword. The <i id=cors-settings-attributes:missing-value-default><a href=#missing-value-default>missing value default</a></i>, used when the attribute is omitted, is the <dfn id=attr-crossorigin-none>No
  CORS</dfn> state.</p>

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

  <p>For <a href=#module-script id=cors-settings-attributes:module-script>module scripts</a>, 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> (since the <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>"). To perform
  this translation, we define the <dfn id=module-script-credentials-mode>module script 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><dd>"<code>omit</code>"<dt><a href=#attr-crossorigin-anonymous id=cors-settings-attributes:attr-crossorigin-anonymous-4>Anonymous</a><dd>"<code>same-origin</code>"<dt><a href=#attr-crossorigin-none id=cors-settings-attributes:attr-crossorigin-none-2>Use Credentials</a><dd>"<code>include</code>"</dl>


  <h4 id=referrer-policy-attributes><span class=secno>2.6.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>

  <p>The attribute's <i id=referrer-policy-attributes:invalid-value-default><a href=#invalid-value-default>invalid value default</a></i> and <i id=referrer-policy-attributes:missing-value-default><a href=#missing-value-default>missing value default</a></i> are both the empty string state.</p>

  <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
  the WHATWG Fetch standard, 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;<li><p>Then, the value of a <a href=#referrer-policy-attribute id=referrer-policy-attributes:referrer-policy-attribute-2>referrer policy attribute</a>;<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>.<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.</ol>
  </div>

  <h4 id=nonce-attributes><span class=secno>2.6.6</span> Nonce attributes<a href=#nonce-attributes class=self-link></a></h4>

  <p>A <dfn data-dfn-for=htmlsvg-global id=attr-nonce data-dfn-type=element-attr data-export="">nonce</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
  crytographic nonce is only exposed to script (and not to side-channels like CSS attribute
  selectors) by extracting the value from the content attribute, moving it into an internal slot
  named <dfn data-dfn-for=HTMLOrSVGElement id=cryptographicnonce data-dfn-type=attribute data-export="">[[CryptographicNonce]]</dfn>, and exposing it to script via the
  <code id=nonce-attributes:htmlorsvgelement><a href=#htmlorsvgelement>HTMLOrSVGElement</a></code> interface mixin. Unless otherwise specified, the slot's value
  is the empty string.</p>

  <dl class=domintro><dt><var>element</var> . <code>nonce</code><dd>
    <p>Returns the value of the element's <a href=#cryptographicnonce id=nonce-attributes:cryptographicnonce>[[CryptographicNonce]]</a> internal slot.</p>
    <p>Can be set, to update that slot's value.</p>
   </dl>

  <p>The <dfn data-dfn-for=HTMLOrSVGElement id=dom-noncedelement-nonce data-dfn-type=attribute data-export=""><code>nonce</code></dfn> IDL
  attribute must, on getting, return the value of this element's
  <a href=#cryptographicnonce id=nonce-attributes:cryptographicnonce-2>[[CryptographicNonce]]</a>; and on setting, set this element's
  <a href=#cryptographicnonce id=nonce-attributes:cryptographicnonce-3>[[CryptographicNonce]]</a> to the given value.</p>

  <p id=nonce-does-not-update-dom class=note>Note how the setter for the <code id=nonce-attributes:dom-noncedelement-nonce><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-2><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>

  <p>Whenever an element including <code id=nonce-attributes:htmlorsvgelement-2><a href=#htmlorsvgelement>HTMLOrSVGElement</a></code> has its <code id=nonce-attributes:attr-nonce-3><a href=#attr-nonce>nonce</a></code> attribute is set or changed, set this element's
  <a href=#cryptographicnonce id=nonce-attributes:cryptographicnonce-4>[[CryptographicNonce]]</a> to the given value.</p>

  <p>Whenever an element including <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-csp-list id=nonce-attributes:concept-document-csp-list>CSP
   list</a>.<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-4><a href=#attr-nonce>nonce</a></code> content attribute
    <var>attr</var> whose value is not the empty string, then:</p>

    <ol><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-5><a href=#attr-nonce>nonce</a></code>" and the empty
     string.</ol>
   </ol>

  <p class=note>As each <code id=nonce-attributes:document><a href=#document>Document</a></code>'s <a href=#concept-document-csp-list id=nonce-attributes:concept-document-csp-list-2>CSP
  list</a> is append-only, user agents can optimize away the <a id=nonce-attributes:contains-a-header-delivered-content-security-policy-2 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> check by, for example, holding a flag on the <code id=nonce-attributes:document-2><a href=#document>Document</a></code>,
  set during <a href=#initialise-the-document-object id=nonce-attributes:initialise-the-document-object><code>Document</code>
  initialization</a>.</p>

  <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 include
  <code id=nonce-attributes:htmlorsvgelement-4><a href=#htmlorsvgelement>HTMLOrSVGElement</a></code> must set the <a href=#cryptographicnonce id=nonce-attributes:cryptographicnonce-5>[[CryptographicNonce]]</a> slot on the copy
  to the value of the slot on the element being cloned.</p>


  <h3 id=common-dom-interfaces><span class=secno>2.7</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.7.1</span> Reflecting content attributes in IDL attributes<a href=#reflecting-content-attributes-in-idl-attributes class=self-link></a></h4>

  <p>Some IDL attributes are defined to <dfn id=reflect>reflect</dfn> a particular content attribute. This
  means that on getting, the IDL attribute returns the current value of the content attribute, and
  on setting, the IDL attribute changes the value of the content attribute to the given value.</p>

  

  <p>In general, on getting, if the content attribute is not present, the IDL attribute must act as
  if the content attribute's value is the empty string; and on setting, if the content attribute is
  not present, it must first be added.</p>

  <p>If a reflecting IDL attribute is a <code id=reflecting-content-attributes-in-idl-attributes:idl-usvstring><a data-x-internal=idl-usvstring href=https://heycam.github.io/webidl/#idl-USVString>USVString</a></code> attribute
  whose content attribute is defined to contain a <a id=reflecting-content-attributes-in-idl-attributes:url href=https://url.spec.whatwg.org/#concept-url data-x-internal=url>URL</a>, then on getting, if the
  content attribute is absent, the IDL attribute must return the empty string. Otherwise, the IDL
  attribute must <a href=#parse-a-url id=reflecting-content-attributes-in-idl-attributes:parse-a-url>parse</a> the value of the content attribute relative
  to the element'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> and if that is successful, return the <a href=#resulting-url-string id=reflecting-content-attributes-in-idl-attributes:resulting-url-string>resulting
  URL string</a>. If parsing fails, then the value of the content attribute must be returned
  instead, <a href=https://heycam.github.io/webidl/#es-type-mapping id=reflecting-content-attributes-in-idl-attributes:concept-idl-convert data-x-internal=concept-idl-convert>converted</a> to a <code id=reflecting-content-attributes-in-idl-attributes:idl-usvstring-2><a data-x-internal=idl-usvstring href=https://heycam.github.io/webidl/#idl-USVString>USVString</a></code>. On setting, the content attribute must be set to the
  specified new value.</p>

  <p>If a reflecting IDL attribute is a <code id=reflecting-content-attributes-in-idl-attributes:idl-domstring><a data-x-internal=idl-domstring href=https://heycam.github.io/webidl/#idl-DOMString>DOMString</a></code> attribute
  whose content attribute is an <a href=#enumerated-attribute id=reflecting-content-attributes-in-idl-attributes:enumerated-attribute>enumerated attribute</a>, and the IDL attribute is
  <dfn id=limited-to-only-known-values>limited to only known values</dfn>, then, on getting, the IDL attribute must return the
  conforming value associated with the state the attribute is in (in its canonical case), if any, or
  the empty string if the attribute is in a state that has no associated keyword value or if the
  attribute is not in a defined state (e.g. the attribute is missing 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>). On setting, the content attribute must
  be set to the specified new value.</p>

  <p>If a reflecting IDL attribute is a nullable <code id=reflecting-content-attributes-in-idl-attributes:idl-domstring-2><a data-x-internal=idl-domstring href=https://heycam.github.io/webidl/#idl-DOMString>DOMString</a></code>
  attribute whose content attribute is an <a href=#enumerated-attribute id=reflecting-content-attributes-in-idl-attributes:enumerated-attribute-2>enumerated attribute</a>, then, on getting, if
  the corresponding content attribute is in its <i>missing value default</i> then the IDL attribute
  must return null, otherwise, the IDL attribute must return the conforming value associated with
  the state the attribute is in (in its canonical case). On setting, if the new value is null, the
  content attribute must be removed, and otherwise, the content attribute must be set to the
  specified new value.</p>

  <p>If a reflecting IDL attribute is a <code id=reflecting-content-attributes-in-idl-attributes:idl-domstring-3><a data-x-internal=idl-domstring href=https://heycam.github.io/webidl/#idl-DOMString>DOMString</a></code> or <code id=reflecting-content-attributes-in-idl-attributes:idl-usvstring-3><a data-x-internal=idl-usvstring href=https://heycam.github.io/webidl/#idl-USVString>USVString</a></code> attribute but doesn't fall into any of the above
  categories, then the getting and setting must be done in a transparent, case-preserving manner.</p>

  <p>If a reflecting IDL attribute is a <code id=reflecting-content-attributes-in-idl-attributes:idl-boolean><a data-x-internal=idl-boolean href=https://heycam.github.io/webidl/#idl-boolean>boolean</a></code> attribute, then on
  getting the IDL attribute must return true if the content attribute is set, and false if it is
  absent. On setting, the content attribute must be removed if the IDL attribute is set to false,
  and must be set to the empty string if the IDL attribute is set to true. (This corresponds to the
  rules for <a href=#boolean-attribute id=reflecting-content-attributes-in-idl-attributes:boolean-attribute>boolean content attributes</a>.)</p>

  <p>If a reflecting IDL attribute has a signed integer type (<code id=reflecting-content-attributes-in-idl-attributes:idl-long><a data-x-internal=idl-long href=https://heycam.github.io/webidl/#idl-long>long</a></code>)
  then, on getting, the content attribute must be parsed according to the <a href=#rules-for-parsing-integers id=reflecting-content-attributes-in-idl-attributes:rules-for-parsing-integers>rules for parsing signed integers</a>, and if that is successful, and the
  value is in the range of the IDL attribute's type, the resulting value must be returned. If, on
  the other hand, it fails or returns an out of range value, or if the attribute is absent, then the
  default value must be returned instead, or 0 if there is no default value. On setting, the given
  value must be 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> and then that string must be used as the new content attribute value.</p>

  <p>If a reflecting IDL attribute has a signed integer type (<code id=reflecting-content-attributes-in-idl-attributes:idl-long-2><a data-x-internal=idl-long href=https://heycam.github.io/webidl/#idl-long>long</a></code>)
  that is <dfn id=limited-to-only-non-negative-numbers>limited to only non-negative numbers</dfn> then, on getting, the content attribute
  must be parsed according to the <a href=#rules-for-parsing-non-negative-integers id=reflecting-content-attributes-in-idl-attributes:rules-for-parsing-non-negative-integers>rules for parsing non-negative integers</a>, and if that
  is successful, and the value is in the range of the IDL attribute's type, the resulting value must
  be returned. If, on the other hand, it fails or returns an out of range value, or if the attribute
  is absent, the default value must be returned instead, or −1 if there is no default value.
  On setting, if the value is negative, the user agent must throw an
  <a id=reflecting-content-attributes-in-idl-attributes:indexsizeerror href=https://heycam.github.io/webidl/#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://heycam.github.io/webidl/#dfn-DOMException>DOMException</a></code>. Otherwise, the given value
  must be 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> and then that string must be used as the new content attribute
  value.</p>

  <p>If a reflecting IDL attribute has an <em>unsigned</em> integer type (<code id=reflecting-content-attributes-in-idl-attributes:idl-unsigned-long><a data-x-internal=idl-unsigned-long href=https://heycam.github.io/webidl/#idl-unsigned-long>unsigned long</a></code>) then, on getting, the content attribute must be
  parsed according to the <a href=#rules-for-parsing-non-negative-integers id=reflecting-content-attributes-in-idl-attributes:rules-for-parsing-non-negative-integers-2>rules for parsing non-negative integers</a>, and if that is
  successful, and the value is in the range 0 to 2147483647 inclusive, the resulting value must be
  returned. If, on the other hand, it fails or returns an out of range value, or if the attribute is
  absent, the default value must be returned instead, or 0 if there is no default value. On setting,
  first, if the new value is in the range 0 to 2147483647, then let <var>n</var> be the new value,
  otherwise let <var>n</var> be the default value, or 0 if there is no default value; then,
  <var>n</var> must be 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-2>valid non-negative integer</a> and that string must be used as the new content attribute
  value.</p>
  

  <p>If a reflecting IDL attribute has an unsigned integer type (<code id=reflecting-content-attributes-in-idl-attributes:idl-unsigned-long-2><a data-x-internal=idl-unsigned-long href=https://heycam.github.io/webidl/#idl-unsigned-long>unsigned long</a></code>) that is <dfn id=limited-to-only-non-negative-numbers-greater-than-zero>limited to only non-negative numbers
  greater than zero</dfn>, then the behavior is similar to the previous case, but zero is not
  allowed. On getting, the content attribute must first be parsed according to the <a href=#rules-for-parsing-non-negative-integers id=reflecting-content-attributes-in-idl-attributes:rules-for-parsing-non-negative-integers-3>rules for
  parsing non-negative integers</a>, and if that is successful, and the value is in the range 1
  to 2147483647 inclusive, the resulting value must be returned. If, on the other hand, it fails or
  returns an out of range value, or if the attribute is absent, the default value must be returned
  instead, or 1 if there is no default value. On setting, if the value is zero, the user agent must
  throw an <a id=reflecting-content-attributes-in-idl-attributes:indexsizeerror-2 href=https://heycam.github.io/webidl/#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://heycam.github.io/webidl/#dfn-DOMException>DOMException</a></code>. Otherwise, first,
  if the new value is in the range 1 to 2147483647, then let <var>n</var> be the new value,
  otherwise let <var>n</var> be the default value, or 1 if there is no default value; then,
  <var>n</var> must be 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-3>valid non-negative integer</a> and that string must be used as the new content attribute
  value.</p> 

  <p>If a reflecting IDL attribute has an unsigned integer type (<code id=reflecting-content-attributes-in-idl-attributes:idl-unsigned-long-3><a data-x-internal=idl-unsigned-long href=https://heycam.github.io/webidl/#idl-unsigned-long>unsigned long</a></code>) that is <dfn id=limited-to-only-non-negative-numbers-greater-than-zero-with-fallback>limited to only non-negative numbers
  greater than zero with fallback</dfn>, then the behavior is similar to the previous case, but
  disallowed values are converted to the default value. On getting, the content attribute must first
  be parsed according to the <a href=#rules-for-parsing-non-negative-integers id=reflecting-content-attributes-in-idl-attributes:rules-for-parsing-non-negative-integers-4>rules for parsing non-negative integers</a>, and if that is
  successful, and the value is in the range 1 to 2147483647 inclusive, the resulting value must be
  returned. If, on the other hand, it fails or returns an out of range value, or if the attribute is
  absent, the default value must be returned instead. On setting, first, if the new value is in the
  range 1 to 2147483647, then let <var>n</var> be the new value, otherwise let <var>n</var> be the
  default value; then, <var>n</var> must be 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-4>valid non-negative integer</a> and that string must be used as the new
  content attribute value.</p> 

  <p>If a reflecting IDL attribute has an unsigned integer type (<code id=reflecting-content-attributes-in-idl-attributes:idl-unsigned-long-4><a data-x-internal=idl-unsigned-long href=https://heycam.github.io/webidl/#idl-unsigned-long>unsigned long</a></code>) that is <dfn id=clamped-to-the-range>clamped to the range</dfn>
  [<var>min</var>, <var>max</var>], then on getting, the content attribute must first be parsed
  according to the <a href=#rules-for-parsing-non-negative-integers id=reflecting-content-attributes-in-idl-attributes:rules-for-parsing-non-negative-integers-5>rules for parsing non-negative integers</a>, and if that is successful,
  and the value is between <var>min</var> and <var>max</var> inclusive, the resulting value must be
  returned. If it fails, the default value must be returned. If it succeeds but the value is less
  than <var>min</var>, <var>min</var> must be returned. If it succeeds but the value is greater than
  <var>max</var>, <var>max</var> must be returned. On setting, it behaves the same as setting a
  regular reflected unsigned integer.</p>

  <p>If a reflecting IDL attribute has a floating-point number type (<code id=reflecting-content-attributes-in-idl-attributes:idl-double><a data-x-internal=idl-double href=https://heycam.github.io/webidl/#idl-double>double</a></code> or <code id=reflecting-content-attributes-in-idl-attributes:idl-unrestricted-double><a data-x-internal=idl-unrestricted-double href=https://heycam.github.io/webidl/#idl-unrestricted-double>unrestricted
  double</a></code>), then, on getting, the content attribute must be parsed according to the
  <a href=#rules-for-parsing-floating-point-number-values id=reflecting-content-attributes-in-idl-attributes:rules-for-parsing-floating-point-number-values>rules for parsing floating-point number values</a>, and if that is successful, the
  resulting value must be returned. If, on the other hand, it fails, or if the attribute is absent,
  the default value must be returned instead, or 0.0 if there is no default value. On setting, the
  given value must be 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> and then that string must be used as the new content attribute value.</p>

  <p>If a reflecting IDL attribute has a floating-point number type (<code id=reflecting-content-attributes-in-idl-attributes:idl-double-2><a data-x-internal=idl-double href=https://heycam.github.io/webidl/#idl-double>double</a></code> or <code id=reflecting-content-attributes-in-idl-attributes:idl-unrestricted-double-2><a data-x-internal=idl-unrestricted-double href=https://heycam.github.io/webidl/#idl-unrestricted-double>unrestricted
  double</a></code>) that is <dfn id=limited-to-numbers-greater-than-zero>limited to numbers greater than zero</dfn>, then the behavior is
  similar to the previous case, but zero and negative values are not allowed. On getting, the
  content attribute must be parsed according to the <a href=#rules-for-parsing-floating-point-number-values id=reflecting-content-attributes-in-idl-attributes:rules-for-parsing-floating-point-number-values-2>rules for parsing floating-point number
  values</a>, and if that is successful and the value is greater than 0.0, the resulting value
  must be returned. If, on the other hand, it fails or returns an out of range value, or if the
  attribute is absent, the default value must be returned instead, or 0.0 if there is no default
  value. On setting, if the value is less than or equal to zero, then the value must be ignored.
  Otherwise, the given value must be 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-2>best representation of the number as a
  floating-point number</a> and then that string must be used as the new content attribute
  value.</p>

  <p class=note>The values Infinity and Not-a-Number (NaN) values throw an exception on setting,
  as defined in the Web IDL specification. <a href=#refsWEBIDL>[WEBIDL]</a></p>

  <p>If a reflecting IDL attribute 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 on getting it must
  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 the element in question and
  whose associated attribute's local name is the name of the attribute in question.</p>

  


  <h4 id=collections><span class=secno>2.7.2</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.7.2.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://heycam.github.io/webidl/#dfn-legacy-platform-object id=the-htmlallcollection-interface:legacy-platform-object data-x-internal=legacy-platform-object>legacy platform objects</a> with an additonal [[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.github.io/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.github.io/ecma262/#sec-IsHTMLDDA-internal-slot data-x-internal=ishtmldda>[[IsHTMLDDA]]</a> internal slot:</p>

   <ul><li><p>The <a href=https://tc39.github.io/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.<li><p>The <a href=https://tc39.github.io/ecma262/#sec-abstract-equality-comparison id=the-htmlallcollection-interface:js-abstract-equality data-x-internal=js-abstract-equality>Abstract Equality Comparison</a> algorithm,
    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.github.io/ecma262/#sec-strict-equality-comparison id=the-htmlallcollection-interface:js-strict-equality data-x-internal=js-strict-equality>Strict Equality Comparison</a>
    algorithm, and Abstract Equality comparisons to other values such as strings or objects, are
    unaffected.)<li><p>The <code id=the-htmlallcollection-interface:js-typeof><a data-x-internal=js-typeof href=https://tc39.github.io/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.</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->,
 <c- g>LegacyUnenumerableNamedProperties</c->]
<c- b>interface</c-> <dfn id='htmlallcollection'><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 href='https://dom.spec.whatwg.org/#interface-element' data-x-internal='element' id='the-htmlallcollection-interface:element'><c- n>Element</c-></a> (<c- b>unsigned</c-> <c- b>long</c-> <c- g>index</c->);
  <c- b>getter</c-> (<a href='https://dom.spec.whatwg.org/#interface-htmlcollection' data-x-internal='htmlcollection' id='the-htmlallcollection-interface:htmlcollection-2'><c- n>HTMLCollection</c-></a> <c- b>or</c-> <a href='https://dom.spec.whatwg.org/#interface-element' data-x-internal='element' id='the-htmlallcollection-interface:element-2'><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 href='https://dom.spec.whatwg.org/#interface-htmlcollection' data-x-internal='htmlcollection' id='the-htmlallcollection-interface:htmlcollection-3'><c- n>HTMLCollection</c-></a> <c- b>or</c-> <a href='https://dom.spec.whatwg.org/#interface-element' data-x-internal='element' id='the-htmlallcollection-interface:element-3'><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 href='https://tc39.github.io/ecma262/#sec-IsHTMLDDA-internal-slot' data-x-internal='ishtmldda' id='the-htmlallcollection-interface:ishtmldda-3'>[[IsHTMLDDA]]</a> internal slot.
};</code></pre>

  <dl class=domintro><dt><var>collection</var> . <code id=dom-htmlallcollection-length-dev><a href=#dom-htmlallcollection-length>length</a></code><dd>
    <p>Returns the number of elements in the collection.</p>
   <dt><var>element</var> = <var>collection</var> . <code id=dom-htmlallcollection-item-dev><a href=#dom-htmlallcollection-item>item</a></code>(<var>index</var>)<dt><var>element</var> = <var>collection</var>(<var>index</var>)<dt><var>element</var> = <var>collection</var>[<var>index</var>]<dd>
    <p>Returns the item with index <var>index</var> from the collection (determined by <a id=the-htmlallcollection-interface:tree-order href=https://dom.spec.whatwg.org/#concept-tree-order data-x-internal=tree-order>tree order</a>).</p>
   <dt><var>element</var> = <var>collection</var> . <code id=the-htmlallcollection-interface:dom-htmlallcollection-item-2><a href=#dom-htmlallcollection-item>item</a></code>(<var>name</var>)<dt><var>collection</var> = <var>collection</var> . <code id=the-htmlallcollection-interface:dom-htmlallcollection-item-3><a href=#dom-htmlallcollection-item>item</a></code>(<var>name</var>)<dt><var>element</var> = <var>collection</var> . <code id=dom-htmlallcollection-nameditem-dev><a href=#dom-htmlallcollection-nameditem>namedItem</a></code>(<var>name</var>)<dt><var>collection</var> = <var>collection</var> . <code id=the-htmlallcollection-interface:dom-htmlallcollection-nameditem-2><a href=#dom-htmlallcollection-nameditem>namedItem</a></code>(<var>name</var>)<dt><var>element</var> = <var>collection</var>(<var>name</var>)<dt><var>collection</var> = <var>collection</var>(<var>name</var>)<dt><var>element</var> = <var>collection</var>[<var>name</var>]<dt><var>collection</var> = <var>collection</var>[<var>name</var>]<dd>
    <p>Returns the item with <a href=https://dom.spec.whatwg.org/#concept-id id=the-htmlallcollection-interface:concept-id data-x-internal=concept-id>ID</a> or name <var>name</var> from the collection.</p>
    <p>If there are multiple matching items, then an <code id=the-htmlallcollection-interface:htmlcollection-4><a data-x-internal=htmlcollection href=https://dom.spec.whatwg.org/#interface-htmlcollection>HTMLCollection</a></code> object containing all those elements is returned.</p>
    
    <p>Only <code id=the-htmlallcollection-interface:the-button-element><a href=#the-button-element>button</a></code>, <code id=the-htmlallcollection-interface:the-form-element><a href=#the-form-element>form</a></code>, <code id=the-htmlallcollection-interface:the-iframe-element><a href=#the-iframe-element>iframe</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> elements can have a name for the purpose of this
    method; their name is given by the value of their <code>name</code> attribute.</p>
   </dl>

  

  <p>The object's <a id=the-htmlallcollection-interface:supported-property-indices href=https://heycam.github.io/webidl/#dfn-supported-property-indices data-x-internal=supported-property-indices>supported property indices</a> are as defined for
  <code id=the-htmlallcollection-interface:htmlcollection-5><a data-x-internal=htmlcollection href=https://dom.spec.whatwg.org/#interface-htmlcollection>HTMLCollection</a></code> objects.</p>

  <p>The <a id=the-htmlallcollection-interface:supported-property-names href=https://heycam.github.io/webidl/#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-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-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>

  <p>On getting, the <dfn id=dom-htmlallcollection-length><code>length</code></dfn>
  attribute must 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>

  <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 this
  <code id=the-htmlallcollection-interface:htmlallcollection-10><a href=#htmlallcollection>HTMLAllCollection</a></code> given the passed index.</p>

  <p>The <dfn id=dom-htmlallcollection-nameditem><code>namedItem(<var>name</var>)</code></dfn>
  method must 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 this <code id=the-htmlallcollection-interface:htmlallcollection-11><a href=#htmlallcollection>HTMLAllCollection</a></code> given <var>name</var>.</p>

  <p>The <dfn id=dom-htmlallcollection-item><code>item(<var>nameOrIndex</var>)</code></dfn>
  method must perform the following steps:</p>

  <ol><li><p>If <var>nameOrIndex</var> was not provided, return null.<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 this <code id=the-htmlallcollection-interface:htmlallcollection-12><a href=#htmlallcollection>HTMLAllCollection</a></code>, given
   <var>nameOrIndex</var>.</ol>

  <hr>

  
  <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-2><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-2><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-2><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-2><a href=#the-input-element>input</a></code>,
   
   <code id=the-htmlallcollection-interface:the-map-element-2><a href=#the-map-element>map</a></code>, 
   <code id=the-htmlallcollection-interface:the-meta-element-2><a href=#the-meta-element>meta</a></code>, 
   <code id=the-htmlallcollection-interface:the-object-element-2><a href=#the-object-element>object</a></code>,
   <code id=the-htmlallcollection-interface:the-select-element-2><a href=#the-select-element>select</a></code>, and
   <code id=the-htmlallcollection-interface:the-textarea-element-2><a href=#the-textarea-element>textarea</a></code> 
  </p>

  <p>To <dfn id=concept-get-all-indexed>get the "all"-indexed element</dfn> from an
  <code id=the-htmlallcollection-interface:htmlallcollection-13><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>

  <p>To <dfn id=concept-get-all-named>get the "all"-named element(s)</dfn> from an
  <code id=the-htmlallcollection-interface:htmlallcollection-14><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.<li>
    <p>Let <var>subCollection</var> be an <code id=the-htmlallcollection-interface:htmlcollection-6><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,<li><p>elements with an <a href=https://dom.spec.whatwg.org/#concept-id id=the-htmlallcollection-interface:concept-id-2 data-x-internal=concept-id>ID</a> equal to <var>name</var>.</ul>
   <li><p>If there is exactly one element in <var>subCollection</var>, then return that
   element.<li><p>Otherwise, if <var>subCollection</var> is empty, return null.<li><p>Otherwise, return <var>subCollection</var>.</ol>

  <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-15><a href=#htmlallcollection>HTMLAllCollection</a></code> <var>collection</var> given
  <var>nameOrIndex</var>:

  <ol><li><p>If <var>nameOrIndex</var>, <a href=https://heycam.github.io/webidl/#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://heycam.github.io/webidl/#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 this
   <code id=the-htmlallcollection-interface:htmlallcollection-16><a href=#htmlallcollection>HTMLAllCollection</a></code> given the number represented by <var>nameOrIndex</var>.<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 this <code id=the-htmlallcollection-interface:htmlallcollection-17><a href=#htmlallcollection>HTMLAllCollection</a></code> given
   <var>nameOrIndex</var>.</ol>

  <h6 id=HTMLAllCollection-call><span class=secno>2.7.2.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.<li><p>Let <var>nameOrIndex</var> be the result of <a href=https://heycam.github.io/webidl/#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://heycam.github.io/webidl/#idl-DOMString>DOMString</a></code>.<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>.<li><p>Return the result of <a href=https://heycam.github.io/webidl/#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.</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>

  


  <h5 id=the-htmlformcontrolscollection-interface><span class=secno>2.7.2.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>

  <pre><code class='idl'>[<c- g>Exposed</c->=<c- n>Window</c->]
<c- b>interface</c-> <dfn id='htmlformcontrolscollection'><c- g>HTMLFormControlsCollection</c-></dfn> : <a href='https://dom.spec.whatwg.org/#interface-htmlcollection' data-x-internal='htmlcollection' id='the-htmlformcontrolscollection-interface:htmlcollection'><c- n>HTMLCollection</c-></a> {
  // inherits <a href='https://dom.spec.whatwg.org/#dom-htmlcollection-length' data-x-internal='dom-htmlcollection-length' id='the-htmlformcontrolscollection-interface:dom-htmlcollection-length'>length</a> and <a href='https://dom.spec.whatwg.org/#dom-htmlcollection-item' data-x-internal='dom-htmlcollection-item' id='the-htmlformcontrolscollection-interface: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 href='https://dom.spec.whatwg.org/#interface-element' data-x-internal='element' id='the-htmlformcontrolscollection-interface: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' data-x-internal='dom-htmlcollection-nameditem' id='the-htmlformcontrolscollection-interface:dom-htmlcollection-nameditem'>namedItem()</a>
};

[<c- g>Exposed</c->=<c- n>Window</c->]
<c- b>interface</c-> <dfn id='radionodelist'><c- g>RadioNodeList</c-></dfn> : <a href='https://dom.spec.whatwg.org/#interface-nodelist' data-x-internal='nodelist' id='the-htmlformcontrolscollection-interface: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><var>collection</var> . <code id=dom-htmlcollection-length-dev><a data-x-internal=dom-htmlcollection-length href=https://dom.spec.whatwg.org/#dom-htmlcollection-length>length</a></code><dd>
    <p>Returns the number of elements in the collection.</p>
   <dt><var>element</var> = <var>collection</var> . <code id=dom-htmlcollection-item-dev><a data-x-internal=dom-htmlcollection-item href=https://dom.spec.whatwg.org/#dom-htmlcollection-item>item</a></code>(<var>index</var>)<dt><var>element</var> = <var>collection</var>[<var>index</var>]<dd>
    <p>Returns the item with index <var>index</var> from the collection. 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>
   <dt><var>element</var> = <var>collection</var> . <code id=dom-htmlformcontrolscollection-nameditem-dev><a href=#dom-htmlformcontrolscollection-nameditem>namedItem</a></code>(<var>name</var>)<dt><var>radioNodeList</var> = <var>collection</var> . <code id=the-htmlformcontrolscollection-interface:dom-htmlformcontrolscollection-nameditem-2><a href=#dom-htmlformcontrolscollection-nameditem>namedItem</a></code>(<var>name</var>)<dt><var>element</var> = <var>collection</var>[<var>name</var>]<dt><var>radioNodeList</var> = <var>collection</var>[<var>name</var>]<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 the collection.</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>
   <dt><var>radioNodeList</var> . <var>value</var> [ = <var>value</var> ]<dd>
    <p>Returns the value of the first checked radio button represented by the object.</p>
    <p>Can be set, to check the first radio button with the given value represented by the object.</p>
   </dl>

  

  <p>The object's <a id=the-htmlformcontrolscollection-interface:supported-property-indices href=https://heycam.github.io/webidl/#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>

  <p>The <a id=the-htmlformcontrolscollection-interface:supported-property-names href=https://heycam.github.io/webidl/#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>

  <p>The <dfn id=dom-htmlformcontrolscollection-nameditem><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>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>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>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>Return that <code id=the-htmlformcontrolscollection-interface:radionodelist-6><a href=#radionodelist>RadioNodeList</a></code> object.</ol>

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

  <p>The <dfn id=dom-radionodelist-value><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.<li><p>If <var>element</var> is null, return the empty string.<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>".<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.</ol>

  <p>On setting, the <code id=the-htmlformcontrolscollection-interface:dom-radionodelist-value-2><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.<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>

  </ol>



  


  <h5 id=the-htmloptionscollection-interface><span class=secno>2.7.2.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>

  <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'><c- g>HTMLOptionsCollection</c-></dfn> : <a href='https://dom.spec.whatwg.org/#interface-htmlcollection' data-x-internal='htmlcollection' id='the-htmloptionscollection-interface:htmlcollection'><c- n>HTMLCollection</c-></a> {
  // inherits <a href='https://dom.spec.whatwg.org/#dom-htmlcollection-item' data-x-internal='dom-htmlcollection-item' id='the-htmloptionscollection-interface:dom-htmlcollection-item'>item</a>(), <a href='https://dom.spec.whatwg.org/#dom-htmlcollection-nameditem' data-x-internal='dom-htmlcollection-nameditem' id='the-htmloptionscollection-interface: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' data-x-internal='dom-htmlcollection-length' id='the-htmloptionscollection-interface: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>void</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>void</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>void</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><var>collection</var> . <code id=dom-htmloptionscollection-length-dev><a href=#dom-htmloptionscollection-length>length</a></code> [ = <var>value</var> ]<dd>
    <p>Returns the number of elements in the collection.</p>
    <p>When set to a smaller number, truncates the number of <code id=the-htmloptionscollection-interface:the-option-element-2><a href=#the-option-element>option</a></code> elements in the corresponding container.</p>
    <p>When set to a greater number, adds new blank <code id=the-htmloptionscollection-interface:the-option-element-3><a href=#the-option-element>option</a></code> elements to that container.</p>
   <dt><var>element</var> = <var>collection</var> . <code id=the-htmloptionscollection-interface:dom-htmlcollection-item-2><a data-x-internal=dom-htmlcollection-item href=https://dom.spec.whatwg.org/#dom-htmlcollection-item>item</a></code>(<var>index</var>)<dt><var>element</var> = <var>collection</var>[<var>index</var>]<dd>
    <p>Returns the item with index <var>index</var> from the collection. 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>
   <dt><var>collection</var>[<var>index</var>] = <var>element</var><dd>
    <p>When <var>index</var> is a greater number than the number of items in the collection, 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>When set to null, removes the item at index <var>index</var> from the collection.</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>
    from the collection.</p>
   <dt><var>element</var> = <var>collection</var> . <code id=dom-htmlcollection-nameditem-dev><a data-x-internal=dom-htmlcollection-nameditem href=https://dom.spec.whatwg.org/#dom-htmlcollection-nameditem>namedItem</a></code>(<var>name</var>)<dt><var>element</var> = <var>collection</var>[<var>name</var>]<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 the collection.</p>
    <p>If there are multiple matching items, then the first is returned.</p>
   <dt><var>collection</var> . <code id=dom-htmloptionscollection-add-dev><a href=#dom-htmloptionscollection-add>add</a></code>(<var>element</var> [, <var>before</var> ] )<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
    collection, 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-htmloptionscollection-interface:hierarchyrequesterror href=https://heycam.github.io/webidl/#hierarchyrequesterror data-x-internal=hierarchyrequesterror>"<code>HierarchyRequestError</code>"</a> <code id=the-htmloptionscollection-interface:domexception><a data-x-internal=domexception href=https://heycam.github.io/webidl/#dfn-DOMException>DOMException</a></code> if
    <var>element</var> is an ancestor of the element into which it is to be inserted.</p>
   <dt><var>collection</var> . <code id=dom-htmloptionscollection-remove-dev><a href=#dom-htmloptionscollection-remove>remove</a></code>(<var>index</var>)<dd>
    <p>Removes the item with index <var>index</var> from the collection.</p>
   <dt><var>collection</var> . <code id=dom-htmloptionscollection-selectedindex-dev><a href=#dom-htmloptionscollection-selectedindex>selectedIndex</a></code> [ = <var>value</var> ]<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>

   </dl>

  

  <p>The object's <a id=the-htmloptionscollection-interface:supported-property-indices href=https://heycam.github.io/webidl/#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>

  <p>On getting, the <dfn id=dom-htmloptionscollection-length><code>length</code></dfn>
  attribute must 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>

  <p>On setting, the behavior depends on whether the new value is equal to, greater than, or less
  than 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> at that time. If the number is
  the same, then setting the attribute must do nothing. If the new value is greater, then <var>n</var> new <code id=the-htmloptionscollection-interface:the-option-element-6><a href=#the-option-element>option</a></code> elements with no attributes and no child nodes must be
  appended to the <code id=the-htmloptionscollection-interface:the-select-element-2><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, where <var>n</var> is the difference between the two numbers (new value minus old
  value). Mutation events must be fired as if a <code id=the-htmloptionscollection-interface:documentfragment><a data-x-internal=documentfragment href=https://dom.spec.whatwg.org/#interface-documentfragment>DocumentFragment</a></code> containing the new
  <code id=the-htmloptionscollection-interface:the-option-element-7><a href=#the-option-element>option</a></code> elements had been inserted. If the new value is lower, then the last <var>n</var> nodes in the collection must be removed from their parent nodes, where <var>n</var> is the difference between the two numbers (old value minus new value).</p>

  <p class=note>Setting <code id=the-htmloptionscollection-interface:dom-htmloptionscollection-length-2><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>

  <p>The <a id=the-htmloptionscollection-interface:supported-property-names href=https://heycam.github.io/webidl/#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>

  <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://heycam.github.io/webidl/#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://heycam.github.io/webidl/#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.<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>.<li><p>Let <var>n</var> be <var>index</var> minus <var>length</var>.<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-2><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-4><a href=#htmloptionscollection>HTMLOptionsCollection</a></code>
   is rooted.<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>.</ol>

  <p>The <dfn id=dom-htmloptionscollection-add><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-5><a href=#htmloptionscollection>HTMLOptionsCollection</a></code> is rooted, then throw a
   <a id=the-htmloptionscollection-interface:hierarchyrequesterror-2 href=https://heycam.github.io/webidl/#hierarchyrequesterror data-x-internal=hierarchyrequesterror>"<code>HierarchyRequestError</code>"</a> <code id=the-htmloptionscollection-interface:domexception-2><a data-x-internal=domexception href=https://heycam.github.io/webidl/#dfn-DOMException>DOMException</a></code>.<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-6><a href=#htmloptionscollection>HTMLOptionsCollection</a></code> is rooted, then throw
   a <a id=the-htmloptionscollection-interface:notfounderror href=https://heycam.github.io/webidl/#notfounderror data-x-internal=notfounderror>"<code>NotFoundError</code>"</a> <code id=the-htmloptionscollection-interface:domexception-3><a data-x-internal=domexception href=https://heycam.github.io/webidl/#dfn-DOMException>DOMException</a></code>.<li><p>If <var>element</var> and <var>before</var> are the same element, then
   return.<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.<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-7><a href=#htmloptionscollection>HTMLOptionsCollection</a></code> is rooted.<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>

  </ol>

  <p>The <dfn id=dom-htmloptionscollection-remove><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.<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.<li><p>Let <var>element</var> be the <var>index</var>th element in the
   collection.<li><p>Remove <var>element</var> from its parent node.</ol>

  <p>The <dfn id=dom-htmloptionscollection-selectedindex><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-8><a href=#htmloptionscollection>HTMLOptionsCollection</a></code> is rooted</p>

  

  


  <h4 id=the-domstringlist-interface><span class=secno>2.7.3</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>

  <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'><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></code> or
  equivalent rather than <code id=the-domstringlist-interface:domstringlist-3><a href=#domstringlist>DOMStringList</a></code>.</p>

  <dl class=domintro><dt><var>strings</var> . <code id=dom-domstringlist-length-dev><a href=#dom-domstringlist-length>length</a></code><dd><p>Returns the number of strings in <var>strings</var>.<dt><var>strings</var>[<var>index</var>]<dt><var>strings</var> . <code id=dom-domstringlist-item-dev><a href=#dom-domstringlist-item>item</a></code>(<var>index</var>)<dd><p>Returns the string with index <var>index</var> from <var>strings</var>.<dt><var>strings</var> . <code id=dom-domstringlist-contains-dev><a href=#dom-domstringlist-contains>contains</a></code>(<var>string</var>)<dd><p>Returns true if <var>strings</var> contains <var>string</var>, and false
   otherwise.</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>

  <p>The <a id=the-domstringlist-interface:supported-property-indices href=https://heycam.github.io/webidl/#dfn-supported-property-indices data-x-internal=supported-property-indices>supported property indices</a> for a <code id=the-domstringlist-interface:domstringlist-5><a href=#domstringlist>DOMStringList</a></code> object are the
  numbers zero to the 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> minus one. If its
  associated list <a href=https://infra.spec.whatwg.org/#list-is-empty id=the-domstringlist-interface:list-is-empty data-x-internal=list-is-empty>is empty</a>, it has no <a id=the-domstringlist-interface:supported-property-indices-2 href=https://heycam.github.io/webidl/#dfn-supported-property-indices data-x-internal=supported-property-indices>supported property
  indices</a>.</p>

  <p>The <dfn id=dom-domstringlist-length><code>length</code></dfn> attribute's getter must
  return this <code id=the-domstringlist-interface:domstringlist-6><a href=#domstringlist>DOMStringList</a></code> object'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>

  <p>The <dfn id=dom-domstringlist-item><code>item(<var>index</var>)</code></dfn> method, when
  invoked, must return the <var>index</var>th item in this <code id=the-domstringlist-interface:domstringlist-7><a href=#domstringlist>DOMStringList</a></code> object's
  associated list, or null if <var>index</var> plus one is greater than this <code id=the-domstringlist-interface:domstringlist-8><a href=#domstringlist>DOMStringList</a></code>
  object's associated list's <a href=https://infra.spec.whatwg.org/#list-size id=the-domstringlist-interface:list-size-3 data-x-internal=list-size>size</a>.</p>

  <p>The <dfn id=dom-domstringlist-contains><code>contains(<var>string</var>)</code></dfn>
  method, when invoked, must return true if this <code id=the-domstringlist-interface:domstringlist-9><a href=#domstringlist>DOMStringList</a></code> object'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>

  


  

  <h4 id=garbage-collection><span class=secno>2.7.4</span> Garbage collection<a href=#garbage-collection class=self-link></a></h4>

  <p>There is an <dfn id=implied-strong-reference>implied strong reference</dfn> from any IDL attribute that returns a
  pre-existing object to that object.</p>

  <div class=example>

   <p>For example, the <code id=garbage-collection:dom-document-2><a href=#dom-document-2>window.document</a></code> attribute means that there
   is a strong reference from a <code id=garbage-collection:window><a href=#window>Window</a></code> object to its <code id=garbage-collection:document><a href=#document>Document</a></code> object.
   Similarly, there is always a strong reference from a <code id=garbage-collection:document-2><a href=#document>Document</a></code> to any
   descendant nodes, and from any node to its <a id=garbage-collection:node-document href=https://dom.spec.whatwg.org/#concept-node-document data-x-internal=node-document>node document</a>.</p>

  </div>

  


  

  <h3 id=safe-passing-of-structured-data><span class=secno>2.8</span> Safe passing of structured data<a href=#safe-passing-of-structured-data class=self-link></a></h3>

  <p>This section uses the terminology and typographic conventions from the JavaScript
  specification. <a href=#refsJAVASCRIPT>[JAVASCRIPT]</a></p>

  <h4 id=serializable-objects><span class=secno>2.8.1</span> <dfn>Serializable objects</dfn><a href=#serializable-objects class=self-link></a></h4>

  <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:javascript-realm href=https://tc39.github.io/ecma262/#sec-code-realms data-x-internal=javascript-realm>JavaScript Realm</a>. This allows them to be stored on
  disk and later restored, or cloned across document and worker boundaries (including across
  documents of different <a href=#concept-origin id=serializable-objects:concept-origin>origins</a> or in different <a href=#event-loop id=serializable-objects:event-loop>event loops</a>).</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://heycam.github.io/webidl/#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 they implement only interfaces decorated with the <dfn id=serializable data-dfn-type=extended-attribute data-lt=Serializable data-export=""><code>[Serializable]</code></dfn> IDL <a id=serializable-objects:extended-attribute href=https://heycam.github.io/webidl/#dfn-extended-attribute data-x-internal=extended-attribute>extended attribute</a>. Such
  interfaces must also define the following algorithms:</p>

  <dl><dt><dfn id=serialization-steps data-export="">serialization steps</dfn>, taking a <a id=serializable-objects:platform-object-2 href=https://heycam.github.io/webidl/#dfn-platform-object data-x-internal=platform-object>platform object</a>
   <var>value</var>, a <a id=serializable-objects:record href=https://tc39.github.io/ecma262/#sec-list-and-record-specification-type data-x-internal=record>Record</a> <var>serialized</var>, and a boolean
   <var>forStorage</var><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:javascript-realm-2 href=https://tc39.github.io/ecma262/#sec-code-realms data-x-internal=javascript-realm>JavaScript 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>
   <dt><dfn id=deserialization-steps data-export="">deserialization steps</dfn>, taking a <a id=serializable-objects:record-2 href=https://tc39.github.io/ecma262/#sec-list-and-record-specification-type data-x-internal=record>Record</a>
   <var>serialized</var> and a <a id=serializable-objects:platform-object-3 href=https://heycam.github.io/webidl/#dfn-platform-object data-x-internal=platform-object>platform object</a> <var>value</var><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://heycam.github.io/webidl/#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>
   </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 not appear on anything other than an interface. It must appear only once on an
  interface. It must not be used on a callback interface. If it appears on a partial interface or an
  interface that is really a mixin, then it must also appear on the original or mixed-in-to
  interface, and any supplied <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> for the partial interface or mixin should be understood as being appended to those of
  the original or mixed-in-to interface.</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 class=brief><li>a name value, which is a string;<li>and a best friend value, which is either another <code>Person</code> instance or
    null</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-2><a href=#serializable>[Serializable]</a></code> <a id=serializable-objects:extended-attribute-2 href=https://heycam.github.io/webidl/#dfn-extended-attribute data-x-internal=extended-attribute>extended attribute</a>, and defining the
   following accompanying algorithms:</p>

   <dl><dt><a href=#serialization-steps id=serializable-objects:serialization-steps-2>serialization steps</a><dd>
     <ol><li><p>Set <var>serialized</var>.[[Name]] to <var>value</var>'s associated name
      value.<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.<li><p>Set <var>serialized</var>.[[BestFriend]] to <var>serializedBestFriend</var>.</ol>
    <dt><a href=#deserialization-steps id=serializable-objects:deserialization-steps-2>deserialization steps</a><dd>
     <ol><li><p>Set <var>value</var>'s associated name value to
      <var>serialized</var>.[[Name]].<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]].<li><p>Set <var>value</var>'s associated best friend value to
      <var>deserializedBestFriend</var>.</ol>
    </dl>
  </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>Originally, this specification defined the concept of
  "cloneable objects", which could be cloned from one <a id=serializable-objects:javascript-realm-3 href=https://tc39.github.io/ecma262/#sec-code-realms data-x-internal=javascript-realm>JavaScript 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.8.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=#event-loop id=transferable-objects:event-loop>event loops</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://heycam.github.io/webidl/#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 they implement only interfaces decorated with the <dfn id=transferable data-dfn-type=extended-attribute data-lt=Transferable data-export=""><code>[Transferable]</code></dfn> IDL <a id=transferable-objects:extended-attribute href=https://heycam.github.io/webidl/#dfn-extended-attribute data-x-internal=extended-attribute>extended attribute</a>. Such
  interfaces must also define the following algorithms:</p>

  <dl><dt><dfn id=transfer-steps data-export="">transfer steps</dfn>, taking a <a id=transferable-objects:platform-object-2 href=https://heycam.github.io/webidl/#dfn-platform-object data-x-internal=platform-object>platform object</a>
   <var>value</var> and a <a id=transferable-objects:record href=https://tc39.github.io/ecma262/#sec-list-and-record-specification-type data-x-internal=record>Record</a> <var>dataHolder</var><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:javascript-realm href=https://tc39.github.io/ecma262/#sec-code-realms data-x-internal=javascript-realm>JavaScript Realm</a>.</p>

    <p>These steps may throw an exception if transferral is not possible.</p>
   <dt><dfn id=transfer-receiving-steps data-export="">transfer-receiving steps</dfn>, taking a <a id=transferable-objects:record-2 href=https://tc39.github.io/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://heycam.github.io/webidl/#dfn-platform-object data-x-internal=platform-object>platform object</a> <var>value</var><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://heycam.github.io/webidl/#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>
   </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 not appear on anything other than an interface. It must appear only once on an
  interface. It must not be used on a callback interface. If it appears on a partial interface or an
  interface that is really a mixin, then it must also appear on the original or mixed-in-to
  interface, and any supplied <a href=#serialization-steps id=transferable-objects:serialization-steps>serialization steps</a> and <a href=#deserialization-steps id=transferable-objects:deserialization-steps>deserialization
  steps</a> for the partial interface or mixin should be understood as being appended to those of
  the original or mixed-in-to interface.</p>

  <p><a href=https://heycam.github.io/webidl/#dfn-platform-object id=transferable-objects:platform-object-5 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 data-export="">[[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>

  <h4 id=structuredserializeinternal data-dfn-type=abstract-op data-noexport="" data-lt=StructuredSerializeInternal><span class=secno>2.8.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 href=https://tc39.github.io/ecma262/#sec-code-realms id=structuredserializeinternal:javascript-realm data-x-internal=javascript-realm>Realm</a>-independent form, represented here as a <a id=structuredserializeinternal:record href=https://tc39.github.io/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><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>].<li><p>Let <var>deep</var> be false.<li><p>If <a href=https://tc39.github.io/ecma262/#sec-ecmascript-data-types-and-values id=structuredserializeinternal:js-type data-x-internal=js-type>Type</a>(<var>value</var>) is Undefined, Null, Boolean,
   Number, BigInt, or String, then return { [[Type]]: "primitive",
   [[Value]]: <var>value</var> }. <a href=#refsJSBIGINT>[JSBIGINT]</a><li><p>If <a href=https://tc39.github.io/ecma262/#sec-ecmascript-data-types-and-values id=structuredserializeinternal:js-type-2 data-x-internal=js-type>Type</a>(<var>value</var>) is Symbol, then throw a
   <a id=structuredserializeinternal:datacloneerror href=https://heycam.github.io/webidl/#datacloneerror data-x-internal=datacloneerror>"<code>DataCloneError</code>"</a> <code id=structuredserializeinternal:domexception><a data-x-internal=domexception href=https://heycam.github.io/webidl/#dfn-DOMException>DOMException</a></code>.<li><p>Let <var>serialized</var> be an uninitialized value.<li><p>If <var>value</var> has a [[BooleanData]] internal slot, then set <var>serialized</var> to
   { [[Type]]: "Boolean", [[BooleanData]]: <var>value</var>.[[BooleanData]] }.<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]]
   }.<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]] }. <a href=#refsJSBIGINT>[JSBIGINT]</a><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]]
   }.<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]]
   }.<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]] }.<li>
    <p>Otherwise, if <var>value</var> has an [[ArrayBufferData]] internal slot, then:</p>

    <ol><li><p>Let <var>size</var> be <var>value</var>.[[ArrayBufferByteLength]].<li>
      <p>If ! <a id=structuredserializeinternal:issharedarraybuffer href=https://tc39.github.io/ecma262/#sec-issharedarraybuffer data-x-internal=issharedarraybuffer>IsSharedArrayBuffer</a>(<var>value</var>) is true, then:

      <ol><li><p>If <var>forStorage</var> is true, then throw a
       <a id=structuredserializeinternal:datacloneerror-2 href=https://heycam.github.io/webidl/#datacloneerror data-x-internal=datacloneerror>"<code>DataCloneError</code>"</a> <code id=structuredserializeinternal:domexception-2><a data-x-internal=domexception href=https://heycam.github.io/webidl/#dfn-DOMException>DOMException</a></code>.<li><p>Set <var>serialized</var> to { [[Type]]: "SharedArrayBuffer", [[ArrayBufferData]]:
       <var>value</var>.[[ArrayBufferData]], [[ArrayBufferByteLength]]: <var>size</var>,
       [[AgentCluster]]: the <a id=structuredserializeinternal:current-realm-record href=https://tc39.github.io/ecma262/#current-realm data-x-internal=current-realm-record>current Realm Record</a>'s corresponding <a id=structuredserializeinternal:agent-cluster href=https://tc39.github.io/ecma262/#sec-agent-clusters data-x-internal=agent-cluster>agent
       cluster</a> }.</ol>
     <li>
      <p>Otherwise:</p>

      <ol><li><p>If ! <a id=structuredserializeinternal:isdetachedbuffer href=https://tc39.github.io/ecma262/#sec-isdetachedbuffer data-x-internal=isdetachedbuffer>IsDetachedBuffer</a>(<var>value</var>) is true, then throw a
       <a id=structuredserializeinternal:datacloneerror-3 href=https://heycam.github.io/webidl/#datacloneerror data-x-internal=datacloneerror>"<code>DataCloneError</code>"</a> <code id=structuredserializeinternal:domexception-3><a data-x-internal=domexception href=https://heycam.github.io/webidl/#dfn-DOMException>DOMException</a></code>.<li>
        <p>Let <var>dataCopy</var> be ? <a id=structuredserializeinternal:createbytedatablock href=https://tc39.github.io/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.github.io/ecma262/#sec-native-error-types-used-in-this-standard-rangeerror>RangeError</a></code> exception
        upon allocation failure.</p>
       <li><p>Perform ! <a id=structuredserializeinternal:copydatablockbytes href=https://tc39.github.io/ecma262/#sec-copydatablockbytes data-x-internal=copydatablockbytes>CopyDataBlockBytes</a>(<var>dataCopy</var>, 0,
       <var>value</var>.[[ArrayBufferData]], 0, <var>size</var>).<li><p>Set <var>serialized</var> to { [[Type]]: "ArrayBuffer", [[ArrayBufferData]]:
       <var>dataCopy</var>, [[ArrayBufferByteLength]]: <var>size</var> }.</ol>
     </ol>
   <li>
    <p>Otherwise, if <var>value</var> has a [[ViewedArrayBuffer]] internal slot, then:</p>

    <ol><li><p>Let <var>buffer</var> be the value of <var>value</var>'s [[ViewedArrayBuffer]] internal
     slot.<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>).<li><p>Assert: <var>bufferSerialized</var>.[[Type]] is "ArrayBuffer".<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]] }.<li>
      <p>Otherwise:</p>

      <ol><li><p>Assert: <var>value</var> has a [[TypedArrayName]] internal slot.<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]] }.</ol>
     </ol>
   <li>
    <p>Otherwise, if <var>value</var> has [[MapData]] internal slot, then:</p>

    <ol><li><p>Set <var>serialized</var> to { [[Type]]: "Map", [[MapData]]: a new empty <a href=https://tc39.github.io/ecma262/#sec-list-and-record-specification-type id=structuredserializeinternal:js-list data-x-internal=js-list>List</a> }.<li><p>Set <var>deep</var> to true.</ol>
   <li>
    <p>Otherwise, if <var>value</var> has [[SetData]] internal slot, then:</p>

    <ol><li><p>Set <var>serialized</var> to { [[Type]]: "Set", [[SetData]]: a new empty <a href=https://tc39.github.io/ecma262/#sec-list-and-record-specification-type id=structuredserializeinternal:js-list-2 data-x-internal=js-list>List</a> }.<li><p>Set <var>deep</var> to true.</ol>
   <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.github.io/ecma262/#sec-ordinarygetownproperty data-x-internal=ordinarygetownproperty>OrdinaryGetOwnProperty</a>(<var>value</var>, "<code>length</code>").<li><p>Let <var>valueLen</var> be <var>valueLenDescriptor</var>.[[Value]].<li><p>Set <var>serialized</var> to { [[Type]]: "Array", [[Length]]: <var>valueLen</var>,
     [[Properties]]: a new empty <a href=https://tc39.github.io/ecma262/#sec-list-and-record-specification-type id=structuredserializeinternal:js-list-3 data-x-internal=js-list>List</a> }.<li><p>Set <var>deep</var> to true.</ol>
   <li>
    <p>Otherwise, if <var>value</var> is a <a id=structuredserializeinternal:platform-object href=https://heycam.github.io/webidl/#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-4 href=https://heycam.github.io/webidl/#datacloneerror data-x-internal=datacloneerror>"<code>DataCloneError</code>"</a> <code id=structuredserializeinternal:domexception-4><a data-x-internal=domexception href=https://heycam.github.io/webidl/#dfn-DOMException>DOMException</a></code>.<li><p>Let <var>typeString</var> be the identifier of the <a id=structuredserializeinternal:primary-interface href=https://heycam.github.io/webidl/#dfn-primary-interface data-x-internal=primary-interface>primary interface</a> of
     <var>value</var>.<li><p>Set <var>serialized</var> to { [[Type]]: <var>typeString</var> }.<li><p>Set <var>deep</var> to true.</ol>
   <li><p>Otherwise, if <var>value</var> is a <a id=structuredserializeinternal:platform-object-2 href=https://heycam.github.io/webidl/#dfn-platform-object data-x-internal=platform-object>platform object</a>, then throw a
   <a id=structuredserializeinternal:datacloneerror-5 href=https://heycam.github.io/webidl/#datacloneerror data-x-internal=datacloneerror>"<code>DataCloneError</code>"</a> <code id=structuredserializeinternal:domexception-5><a data-x-internal=domexception href=https://heycam.github.io/webidl/#dfn-DOMException>DOMException</a></code>.<li><p>Otherwise, if <a id=structuredserializeinternal:iscallable href=https://tc39.github.io/ecma262/#sec-iscallable data-x-internal=iscallable>IsCallable</a>(<var>value</var>) is true, then throw a
   <a id=structuredserializeinternal:datacloneerror-6 href=https://heycam.github.io/webidl/#datacloneerror data-x-internal=datacloneerror>"<code>DataCloneError</code>"</a> <code id=structuredserializeinternal:domexception-6><a data-x-internal=domexception href=https://heycam.github.io/webidl/#dfn-DOMException>DOMException</a></code>.<li>
    <p>Otherwise, if <var>value</var> has any internal slot other than [[Prototype]] or
    [[Extensible]], then throw a <a id=structuredserializeinternal:datacloneerror-7 href=https://heycam.github.io/webidl/#datacloneerror data-x-internal=datacloneerror>"<code>DataCloneError</code>"</a>
    <code id=structuredserializeinternal:domexception-7><a data-x-internal=domexception href=https://heycam.github.io/webidl/#dfn-DOMException>DOMException</a></code>.</p>

    <p class=example>For instance, a [[PromiseState]] or [[WeakMapData]] internal slot.</p>
   <li>
    <p>Otherwise, if <var>value</var> is an exotic object, then throw a
    <a id=structuredserializeinternal:datacloneerror-8 href=https://heycam.github.io/webidl/#datacloneerror data-x-internal=datacloneerror>"<code>DataCloneError</code>"</a> <code id=structuredserializeinternal:domexception-8><a data-x-internal=domexception href=https://heycam.github.io/webidl/#dfn-DOMException>DOMException</a></code>.</p>

    <p class=example>For instance, a proxy object.</p>
   <li>
    <p>Otherwise:</p>

    <ol><li><p>Set <var>serialized</var> to { [[Type]]: "Object", [[Properties]]: a new empty <a href=https://tc39.github.io/ecma262/#sec-list-and-record-specification-type id=structuredserializeinternal:js-list-4 data-x-internal=js-list>List</a> }.<li><p>Set <var>deep</var> to true.</ol>
   <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>.<li>
    <p>If <var>deep</var> is true, then:</p>

    <ol><li>
      <p>If <var>value</var> has a [[MapData]] internal slot, then:

      <ol><li><p>Let <var>copiedList</var> be a new empty <a href=https://tc39.github.io/ecma262/#sec-list-and-record-specification-type id=structuredserializeinternal:js-list-5 data-x-internal=js-list>List</a>.

       <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.github.io/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.github.io/ecma262/#sec-list-and-record-specification-type data-x-internal=record>Record</a> { [[Key]]:
         <var>entry</var>.[[Key]], [[Value]]: <var>entry</var>.[[Value]] }.<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>.</ol>
       <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.github.io/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>).<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>).<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]].</ol>
       </ol>
     <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.github.io/ecma262/#sec-list-and-record-specification-type id=structuredserializeinternal:js-list-6 data-x-internal=js-list>List</a>.

       <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>.</ol>
       <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>).<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]].</ol>
       </ol>
     <li>
      <p>Otherwise, if <var>value</var> is a <a id=structuredserializeinternal:platform-object-3 href=https://heycam.github.io/webidl/#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 appropriate
      <a href=#serialization-steps id=structuredserializeinternal:serialization-steps>serialization steps</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>
      <p>Otherwise:

      <ol><li><p>Let <var>enumerableKeys</var> be a new empty <a href=https://tc39.github.io/ecma262/#sec-list-and-record-specification-type id=structuredserializeinternal:js-list-7 data-x-internal=js-list>List</a>.<li>
        <p>For each <var>key</var> in ! <var>value</var>.[[OwnPropertyKeys]]():</p>

        <ol><li>
          <p>If <a href=https://tc39.github.io/ecma262/#sec-ecmascript-data-types-and-values id=structuredserializeinternal:js-type-3 data-x-internal=js-type>Type</a>(<var>key</var>) is String, then:</p>

          <ol><li><p>Let <var>valueDesc</var> be !
           <var>value</var>.[[GetOwnProperty]](<var>key</var>).<li><p>If <var>valueDesc</var>.[[Enumerable]] is true, then <a href=https://infra.spec.whatwg.org/#list-append id=structuredserializeinternal:list-append-5 data-x-internal=list-append>append</a> <var>key</var> to <var>enumerableKeys</var>.</ol>
         </ol>
       <li>
        <p>For each <var>key</var> in <var>enumerableKeys</var>:</p>

        <ol><li>
          <p>If ! <a id=structuredserializeinternal:hasownproperty href=https://tc39.github.io/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>).<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>).<li><p><a href=https://infra.spec.whatwg.org/#list-append id=structuredserializeinternal:list-append-6 data-x-internal=list-append>Append</a> { [[Key]]: <var>key</var>, [[Value]]:
           <var>outputValue</var> } to <var>serialized</var>.[[Properties]].</ol>
         </ol>
       </ol>

      <p class=note>The key collection performed above is very similar to the JavaScript
      specification's <a id=structuredserializeinternal:enumerableownproperties href=https://tc39.github.io/ecma262/#sec-enumerableownproperties data-x-internal=enumerableownproperties>EnumerableOwnProperties</a> operation, but crucially it uses the
      deterministic ordering provided by the [[OwnPropertyKeys]] internal method, instead of
      reordering the keys in an unspecified manner as <a id=structuredserializeinternal:enumerableownproperties-2 href=https://tc39.github.io/ecma262/#sec-enumerableownproperties data-x-internal=enumerableownproperties>EnumerableOwnProperties</a> does.
      <a href=#refsJAVASCRIPT>[JAVASCRIPT]</a></p>
     </ol>
   <li><p>Return <var>serialized</var>.</ol>

  <div class=example>
   <p>It's important to realize that the <a href=https://tc39.github.io/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- kr>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></i>
    }
  »
}</samp></pre>
  </div>


  <h4 id=structuredserialize data-dfn-type=abstract-op data-lt=StructuredSerialize data-export=""><span class=secno>2.8.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).</ol>


  <h4 id=structuredserializeforstorage data-dfn-type=abstract-op data-lt=StructuredSerializeForStorage data-export=""><span class=secno>2.8.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).</ol>


  <h4 id=structureddeserialize data-dfn-type=abstract-op data-lt=StructuredDeserialize data-export=""><span class=secno>2.8.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.github.io/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><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>].<li><p>Let <var>deep</var> be false.<li><p>Let <var>value</var> be an uninitialized value.<li><p>If <var>serialized</var>.[[Type]] is "primitive", then set <var>value</var> to
   <var>serialized</var>.[[Value]].</p>

   <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]].<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]].<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]]. <a href=#refsJSBIGINT>[JSBIGINT]</a><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]].<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]].<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]].<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.github.io/ecma262/#sec-agent-clusters data-x-internal=agent-cluster>agent cluster</a> is not
     <var>serialized</var>.[[AgentCluster]], then then throw a
     <a id=structureddeserialize:datacloneerror href=https://heycam.github.io/webidl/#datacloneerror data-x-internal=datacloneerror>"<code>DataCloneError</code>"</a> <code id=structureddeserialize:domexception><a data-x-internal=domexception href=https://heycam.github.io/webidl/#dfn-DOMException>DOMException</a></code>.<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]].</ol>
   <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-2 href=https://heycam.github.io/webidl/#datacloneerror data-x-internal=datacloneerror>"<code>DataCloneError</code>"</a> <code id=structureddeserialize:domexception-2><a data-x-internal=domexception href=https://heycam.github.io/webidl/#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>
    <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>).<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]].<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]].</ol>
   <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.github.io/ecma262/#sec-list-and-record-specification-type id=structureddeserialize:js-list data-x-internal=js-list>List</a>.<li><p>Set <var>deep</var> to true.</ol>
   <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.github.io/ecma262/#sec-list-and-record-specification-type id=structureddeserialize:js-list-2 data-x-internal=js-list>List</a>.<li><p>Set <var>deep</var> to true.</ol>
   <li>
    <p>Otherwise, if <var>serialized</var>.[[Type]] is "Array", then:</p>

    <ol><li><p>Let <var>outputProto</var> be the <a id=structureddeserialize:arrayprototype href=https://tc39.github.io/ecma262/#sec-properties-of-the-array-prototype-object data-x-internal=arrayprototype>%ArrayPrototype%</a> intrinsic object in
     <var>targetRealm</var>.<li><p>Set <var>value</var> to ! <a id=structureddeserialize:arraycreate href=https://tc39.github.io/ecma262/#sec-arraycreate data-x-internal=arraycreate>ArrayCreate</a>(<var>serialized</var>.[[Length]],
     <var>outputProto</var>).<li><p>Set <var>deep</var> to true.</ol>
   <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>.<li><p>Set <var>deep</var> to true.</ol>
   <li>
    <p>Otherwise:</p>

    <ol><li><p>Let <var>interfaceName</var> be <var>serialized</var>.[[Type]].<li><p>If the interface identified by <var>interfaceName</var> is not exposed in
     <var>targetRealm</var>, then throw a <a id=structureddeserialize:datacloneerror-3 href=https://heycam.github.io/webidl/#datacloneerror data-x-internal=datacloneerror>"<code>DataCloneError</code>"</a>
     <code id=structureddeserialize:domexception-3><a data-x-internal=domexception href=https://heycam.github.io/webidl/#dfn-DOMException>DOMException</a></code>.<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><p>Set <var>deep</var> to true.</ol>
   <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>.<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.github.io/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>).<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>).<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]].</ol>
       </ol>
     <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>).<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]].</ol>
       </ol>
     <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.github.io/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>).<li><p>Let <var>result</var> be ! <a id=structureddeserialize:createdataproperty href=https://tc39.github.io/ecma262/#sec-createdataproperty data-x-internal=createdataproperty>CreateDataProperty</a>(<var>value</var>,
         <var>entry</var>.[[Key]], <var>deserializedValue</var>).<li><p>Assert: <var>result</var> is true.</ol>
       </ol>
     <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> and <var>value</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.github.io/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>
       </ol>
    </ol>
   <li><p>Return <var>value</var>.</ol>

  <h4 id=structuredserializewithtransfer data-dfn-type=abstract-op data-lt=StructuredSerializeWithTransfer data-export=""><span class=secno>2.8.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>
    <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://heycam.github.io/webidl/#datacloneerror data-x-internal=datacloneerror>"<code>DataCloneError</code>"</a> <code id=structuredserializewithtransfer:domexception><a data-x-internal=domexception href=https://heycam.github.io/webidl/#dfn-DOMException>DOMException</a></code>.<li><p>If <var>transferable</var> has an [[ArrayBufferData]] internal slot and !
     <a id=structuredserializewithtransfer:issharedarraybuffer href=https://tc39.github.io/ecma262/#sec-issharedarraybuffer data-x-internal=issharedarraybuffer>IsSharedArrayBuffer</a>(<var>transferable</var>) is true, then throw a
     <a id=structuredserializewithtransfer:datacloneerror-2 href=https://heycam.github.io/webidl/#datacloneerror data-x-internal=datacloneerror>"<code>DataCloneError</code>"</a> <code id=structuredserializewithtransfer:domexception-2><a data-x-internal=domexception href=https://heycam.github.io/webidl/#dfn-DOMException>DOMException</a></code>.<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://heycam.github.io/webidl/#datacloneerror data-x-internal=datacloneerror>"<code>DataCloneError</code>"</a> <code id=structuredserializewithtransfer:domexception-3><a data-x-internal=domexception href=https://heycam.github.io/webidl/#dfn-DOMException>DOMException</a></code>.<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>
     </ol>
   <li><p>Let <var>serialized</var> be ? <a href=#structuredserializeinternal id=structuredserializewithtransfer:structuredserializeinternal-4>StructuredSerializeInternal</a>(<var>value</var>,
   false, <var>memory</var>).<li><p>Let <var>transferDataHolders</var> be a new empty <a href=https://tc39.github.io/ecma262/#sec-list-and-record-specification-type id=structuredserializewithtransfer:js-list data-x-internal=js-list>List</a>.<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.github.io/ecma262/#sec-isdetachedbuffer data-x-internal=isdetachedbuffer>IsDetachedBuffer</a>(<var>transferable</var>) is true, then throw a
     <a id=structuredserializewithtransfer:datacloneerror-4 href=https://heycam.github.io/webidl/#datacloneerror data-x-internal=datacloneerror>"<code>DataCloneError</code>"</a> <code id=structuredserializewithtransfer:domexception-4><a data-x-internal=domexception href=https://heycam.github.io/webidl/#dfn-DOMException>DOMException</a></code>.<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://heycam.github.io/webidl/#datacloneerror data-x-internal=datacloneerror>"<code>DataCloneError</code>"</a> <code id=structuredserializewithtransfer:domexception-5><a data-x-internal=domexception href=https://heycam.github.io/webidl/#dfn-DOMException>DOMException</a></code>.<li><p>Let <var>dataHolder</var> be <var>memory</var>[<var>transferable</var>].<li>
      <p>If <var>transferable</var> has an [[ArrayBufferData]] internal slot, then:</p>

      <ol><li><p>Set <var>dataHolder</var>.[[Type]] to "ArrayBuffer".<li><p>Set <var>dataHolder</var>.[[ArrayBufferData]] to
       <var>transferable</var>.[[ArrayBufferData]].<li><p>Set <var>dataHolder</var>.[[ArrayBufferByteLength]] to
       <var>transferable</var>.[[ArrayBufferByteLength]].<li><p>Perform ! <a id=structuredserializewithtransfer:detacharraybuffer href=https://tc39.github.io/ecma262/#sec-detacharraybuffer data-x-internal=detacharraybuffer>DetachArrayBuffer</a>(<var>transferable</var>).</ol>
     <li>
      <p>Otherwise:</p>

      <ol><li><p>Assert: <var>transferable</var> is a <a id=structuredserializewithtransfer:platform-object href=https://heycam.github.io/webidl/#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>.<li><p>Let <var>interfaceName</var> be the identifier of the <a id=structuredserializewithtransfer:primary-interface href=https://heycam.github.io/webidl/#dfn-primary-interface data-x-internal=primary-interface>primary interface</a>
       of <var>transferable</var>.<li><p>Set <var>dataHolder</var>.[[Type]] to <var>interfaceName</var>.<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>.<li><p>Set <var>transferable</var>.<a href=#detached id=structuredserializewithtransfer:detached-4>[[Detached]]</a> to true.</ol>
     <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>.</ol>
   <li><p>Return { [[Serialized]]: <var>serialized</var>, [[TransferDataHolders]]:
   <var>transferDataHolders</var> }.</ol>

  <h4 id=structureddeserializewithtransfer data-dfn-type=abstract-op data-lt=StructuredDeserializeWithTransfer data-export=""><span class=secno>2.8.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><p>Let <var>transferredValues</var> be a new empty <a href=https://tc39.github.io/ecma262/#sec-list-and-record-specification-type id=structureddeserializewithtransfer:js-list data-x-internal=js-list>List</a>.<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.<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>
      <p>Otherwise:</p>

      <ol><li><p>Let <var>interfaceName</var> be <var>transferDataHolder</var>.[[Type]].<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://heycam.github.io/webidl/#datacloneerror data-x-internal=datacloneerror>"<code>DataCloneError</code>"</a>
       <code id=structureddeserializewithtransfer:domexception><a data-x-internal=domexception href=https://heycam.github.io/webidl/#dfn-DOMException>DOMException</a></code>.<li><p>Set <var>value</var> to a new instance of the interface identified by
       <var>interfaceName</var>, created in <var>targetRealm</var>.<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>.</ol>
     <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>.<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>.</ol>
   <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>).<li><p>Return { [[Deserialized]]: <var>deserialized</var>, [[TransferredValues]]:
   <var>transferredValues</var> }.</ol>


  <h4 id=performing-structured-clones-from-other-specifications><span class=secno>2.8.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><a href=#structureddeserializewithtransfer id=performing-structured-clones-from-other-specifications:structureddeserializewithtransfer>StructuredDeserializeWithTransfer</a><dd>
    <p>Cloning a value to another <a id=performing-structured-clones-from-other-specifications:javascript-realm href=https://tc39.github.io/ecma262/#sec-code-realms data-x-internal=javascript-realm>JavaScript 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>
   <dt><a href=#structuredserialize id=performing-structured-clones-from-other-specifications:structuredserialize>StructuredSerialize</a><dt><a href=#structuredserializeforstorage id=performing-structured-clones-from-other-specifications:structuredserializeforstorage>StructuredSerializeForStorage</a><dt><a href=#structureddeserialize id=performing-structured-clones-from-other-specifications:structureddeserialize>StructuredDeserialize</a><dd>
    <p>Creating a <a id=performing-structured-clones-from-other-specifications:javascript-realm-2 href=https://tc39.github.io/ecma262/#sec-code-realms data-x-internal=javascript-realm>JavaScript 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.github.io/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://heycam.github.io/webidl/#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>
   </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://heycam.github.io/webidl/#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>

  <p id=structuredclone class=note><span id=structured-clone></span>This specification used
  to define a "structured clone" algorithm, and more recently a StructuredClone abstract operation.
  However, in practice all known uses of it were better served by separate serialization and
  deserialization steps, so it was removed.</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>

  


  <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 data-x-for=Document id="the-document's-address"><a href=https://dom.spec.whatwg.org/#concept-document-url>URL</a></dfn> is defined in the WHATWG DOM standard. 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=#scroll-to-fragid id=documents:scroll-to-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>When a <code id=documents:document-6><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> the
  <code id=documents:document-7><a href=#document>Document</a></code> is both <a href=#ready-for-post-load-tasks id=documents:ready-for-post-load-tasks>ready for post-load tasks</a> and <a href=#completely-loaded id=documents:completely-loaded>completely
  loaded</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-8><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>

  <p>The WHATWG DOM standard 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'><c- g>DocumentReadyState</c-></dfn> { <c- s>&quot;loading&quot;</c->, <c- s>&quot;interactive&quot;</c->, <c- s>&quot;complete&quot;</c-> };
<c- b>typedef</c-> (<a href='#htmlscriptelement' id='the-document-object:htmlscriptelement'><c- n>HTMLScriptElement</c-></a> <c- b>or</c-> <a href='https://svgwg.org/svg2-draft/interact.html#InterfaceSVGScriptElement' data-x-internal='svgscriptelement' id='the-document-object:svgscriptelement'><c- n>SVGScriptElement</c-></a>) <dfn id='htmlorsvgscriptelement'><c- g>HTMLOrSVGScriptElement</c-></dfn>;

[<c- g>OverrideBuiltins</c->]
<c- b>partial</c-> <c- b>interface</c-> <dfn data-lt id='document'><c- g>Document</c-></dfn> {
  // <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>, <c- g>Unforgeable</c->] <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 href='https://dom.spec.whatwg.org/#interface-htmlcollection' data-x-internal='htmlcollection' id='the-document-object: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 href='https://dom.spec.whatwg.org/#interface-htmlcollection' data-x-internal='htmlcollection' id='the-document-object:htmlcollection-2'><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 href='https://dom.spec.whatwg.org/#interface-htmlcollection' data-x-internal='htmlcollection' id='the-document-object:htmlcollection-3'><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 href='https://dom.spec.whatwg.org/#interface-htmlcollection' data-x-internal='htmlcollection' id='the-document-object:htmlcollection-4'><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 href='https://dom.spec.whatwg.org/#interface-htmlcollection' data-x-internal='htmlcollection' id='the-document-object:htmlcollection-5'><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 href='https://dom.spec.whatwg.org/#interface-htmlcollection' data-x-internal='htmlcollection' id='the-document-object:htmlcollection-6'><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-2'><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>void</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>void</c-> <a href='#dom-document-write' id='the-document-object:dom-document-write'><c- g>write</c-></a>(<c- b>DOMString</c->... <c- g>text</c->);
  [<a href='#cereactions' id='the-document-object:cereactions-7'><c- g>CEReactions</c-></a>] <c- b>void</c-> <a href='#dom-document-writeln' id='the-document-object:dom-document-writeln'><c- g>writeln</c-></a>(<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>readonly</c-> <c- b>attribute</c-> <a href='https://dom.spec.whatwg.org/#interface-element' data-x-internal='element' id='the-document-object:element'><c- n>Element</c-></a>? <a href='#dom-document-activeelement' id='the-document-object:dom-document-activeelement'><c- g>activeElement</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/execCommand.html#execcommand%28%29' data-x-internal='execCommand' id='the-document-object: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-> = &quot;&quot;);
  <c- b>boolean</c-> <a href='https://w3c.github.io/editing/execCommand.html#querycommandenabled%28%29' data-x-internal='dom-document-querycommandenabled' id='the-document-object: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/execCommand.html#querycommandindeterm%28%29' data-x-internal='dom-document-querycommandindeterm' id='the-document-object: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/execCommand.html#querycommandstate%28%29' data-x-internal='dom-document-querycommandstate' id='the-document-object: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/execCommand.html#querycommandsupported%28%29' data-x-internal='dom-document-querycommandsupported' id='the-document-object: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/execCommand.html#querycommandvalue%28%29' data-x-internal='dom-document-querycommandvalue' id='the-document-object:dom-document-querycommandvalue'><c- g>queryCommandValue</c-></a>(<c- b>DOMString</c-> <c- g>commandId</c->);

  // 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
  [<c- g>LenientThis</c->] <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>;
};
<a href='#document' id='the-document-object:document-3'><c- n>Document</c-></a> <c- b>includes</c-> <a href='#globaleventhandlers' id='the-document-object:globaleventhandlers'><c- n>GlobalEventHandlers</c-></a>;
<a href='#document' id='the-document-object:document-4'><c- n>Document</c-></a> <c- b>includes</c-> <a href='#documentandelementeventhandlers' id='the-document-object:documentandelementeventhandlers'><c- n>DocumentAndElementEventHandlers</c-></a>;</code></pre>

  <p>The <code id=the-document-object:document-5><a href=#document>Document</a></code> has an <dfn data-dfn-for=Document id=concept-document-https-state data-export="">HTTPS state</dfn> (an <a id=the-document-object:https-state-value href=https://fetch.spec.whatwg.org/#concept-https-state-value data-x-internal=https-state-value>HTTPS state value</a>), initially "<code>none</code>", which represents the security properties of the network channel used to
  deliver the <code id=the-document-object:document-6><a href=#document>Document</a></code>'s data.</p>

  <p>The <code id=the-document-object:document-7><a href=#document>Document</a></code> has a <dfn data-dfn-for=Document id=concept-document-referrer-policy data-export="">referrer policy</dfn> (a <a id=the-document-object:referrer-policy href=https://w3c.github.io/webappsec-referrer-policy/#referrer-policy data-x-internal=referrer-policy>referrer policy</a>), initially the
  empty string, which represents the default <a id=the-document-object:referrer-policy-2 href=https://w3c.github.io/webappsec-referrer-policy/#referrer-policy data-x-internal=referrer-policy>referrer policy</a> used by <a href=https://fetch.spec.whatwg.org/#concept-fetch id=the-document-object:concept-fetch data-x-internal=concept-fetch>fetches</a> initiated by the <code id=the-document-object:document-8><a href=#document>Document</a></code>.</p>

  <p>The <code id=the-document-object:document-9><a href=#document>Document</a></code> has a <dfn data-dfn-for=Document id=concept-document-csp-list data-export="">CSP list</dfn>, which is a <a href=https://w3c.github.io/webappsec-csp/#csp-list id=the-document-object:concept-csp-list data-x-internal=concept-csp-list>CSP list</a>
  containing all of the <a id=the-document-object:content-security-policy href=https://w3c.github.io/webappsec-csp/#content-security-policy-object data-x-internal=content-security-policy>Content Security Policy</a> objects active for the document. The
  list is empty unless otherwise specified.</p>

  <p>The <code id=the-document-object:document-10><a href=#document>Document</a></code> has a <dfn data-dfn-for=Document id=concept-document-feature-policy data-export="">feature policy</dfn>, which is a <a href=https://wicg.github.io/feature-policy/#feature-policy id=the-document-object:concept-feature-policy data-x-internal=concept-feature-policy>feature policy</a>, which is initially empty.</p>

  <p>The <code id=the-document-object:document-11><a href=#document>Document</a></code> has a <dfn data-dfn-for=Document 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>


  <h4 id=resource-metadata-management><span class=secno>3.1.2</span> <dfn>Resource metadata management</dfn><a href=#resource-metadata-management class=self-link></a></h4>

  <dl class=domintro><dt><var>document</var> . <code id=dom-document-referrer-dev><a href=#dom-document-referrer>referrer</a></code><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>

   </dl>

  

  <p>The <dfn id=dom-document-referrer><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>

  

  <hr>

  <dl class=domintro><dt><var>document</var> . <code id=dom-document-cookie-dev><a href=#dom-document-cookie>cookie</a></code> [ = <var>value</var> ]<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 a
    unique 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://heycam.github.io/webidl/#securityerror data-x-internal=securityerror>"<code>SecurityError</code>"</a> <code id=resource-metadata-management:domexception><a data-x-internal=domexception href=https://heycam.github.io/webidl/#dfn-DOMException>DOMException</a></code> will be thrown on getting
    and setting.</p>

   </dl>

  

  <p>The <dfn id=dom-document-cookie><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>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> that has no <a href=#concept-document-bc id=resource-metadata-management:concept-document-bc>browsing
   context</a>.<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 a <a id=resource-metadata-management:network-scheme href=https://fetch.spec.whatwg.org/#network-scheme data-x-internal=network-scheme>network scheme</a>.</ul>

  

  <p id=sandboxCookies>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=#concept-origin id=resource-metadata-management:concept-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://heycam.github.io/webidl/#securityerror data-x-internal=securityerror>"<code>SecurityError</code>"</a>
  <code id=resource-metadata-management:domexception-2><a data-x-internal=domexception href=https://heycam.github.io/webidl/#dfn-DOMException>DOMException</a></code>. Otherwise, the user agent must return the <a href=#cookie-string id=resource-metadata-management: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><a href=#fingerprinting-vector id=resource-metadata-management:fingerprinting-vector class=fingerprint title="There is a potential fingerprinting vector here."><img alt="(This is a fingerprinting vector.)" src=/images/fingerprint.png width=46 height=64></a></p>

  <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=#concept-origin id=resource-metadata-management:concept-origin-2>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://heycam.github.io/webidl/#securityerror data-x-internal=securityerror>"<code>SecurityError</code>"</a> <code id=resource-metadata-management:domexception-3><a data-x-internal=domexception href=https://heycam.github.io/webidl/#dfn-DOMException>DOMException</a></code>. Otherwise, the user agent
  must act as it would when <a href=#receives-a-set-cookie-string id=resource-metadata-management: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>

  <p class=note>Since the <code id=resource-metadata-management:dom-document-cookie><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-2><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><var>document</var> . <code id=dom-document-lastmodified-dev><a href=#dom-document-lastmodified>lastModified</a></code><dd>
    <p>Returns the date of the last modification to the document, as reported by the server, in the
    form "<code>MM/DD/YYYY 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>
   </dl>

  

  <p>The <dfn id=dom-document-lastmodified><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> The month component of the date. <li> A U+002F SOLIDUS character (/). <li> The day component of the date. <li> A U+002F SOLIDUS character (/). <li> The year component of the date. <li> A U+0020 SPACE character. <li> The hours component of the time. <li> A U+003A COLON character (:). <li> The minutes component of the time. <li> A U+003A COLON character (:). <li> The seconds component of the time. </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>

  <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://tools.ietf.org/html/rfc7232#section-2.2>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>

  <hr>

  

  <dl class=domintro><dt><var>document</var> . <code id=dom-document-readystate-dev><a href=#dom-document-readystate>readyState</a></code><dd>
    <p>Returns "<code>loading</code>" while the <code id=resource-metadata-management:document-10><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=resource-metadata-management:event-readystatechange><a href=#event-readystatechange>readystatechange</a></code> event fires on the
    <code id=resource-metadata-management:document-11><a href=#document>Document</a></code> object when this value changes.</p>

    <p>The <code id=resource-metadata-management: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=resource-metadata-management:attr-script-async><a href=#attr-script-async>async</a></code> <code id=resource-metadata-management:the-script-element><a href=#the-script-element>script</a></code> elements have loaded.</p>
   </dl>

  

  <p>Each document has a <dfn id=current-document-readiness>current document readiness</dfn>. When a <code id=resource-metadata-management:document-12><a href=#document>Document</a></code> object
  is created, it must have its <a href=#current-document-readiness id=resource-metadata-management:current-document-readiness>current document readiness</a> set to the string "<code>loading</code>" if the document is associated with an <a href=#html-parser id=resource-metadata-management:html-parser>HTML parser</a>, an
  <a href=#xml-parser id=resource-metadata-management:xml-parser>XML parser</a>, or an XSLT processor, and to the string "<code>complete</code>"
  otherwise. Various algorithms during page loading affect this value. When the value is set, the
  user agent must <a href=https://dom.spec.whatwg.org/#concept-event-fire id=resource-metadata-management:concept-event-fire data-x-internal=concept-event-fire>fire an event</a> named <code id=resource-metadata-management:event-readystatechange-2><a href=#event-readystatechange>readystatechange</a></code> at the <code id=resource-metadata-management:document-13><a href=#document>Document</a></code> object.</p>

  <p>A <code id=resource-metadata-management:document-14><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=resource-metadata-management:html-parser-2>HTML parser</a> or an <a href=#xml-parser id=resource-metadata-management:xml-parser-2>XML parser</a> that has not yet been <a href=#stop-parsing id=resource-metadata-management:stop-parsing>stopped</a> or <a href=#abort-a-parser id=resource-metadata-management:abort-a-parser>aborted</a>.</p>

  <p>The <dfn id=dom-document-readystate><code>readyState</code></dfn> IDL attribute must, on
  getting, return the <a href=#current-document-readiness id=resource-metadata-management:current-document-readiness-2>current document readiness</a>.</p>

  



  <h4 id=dom-tree-accessors><span class=secno>3.1.3</span> <dfn>DOM tree accessors</dfn><a href=#dom-tree-accessors class=self-link></a></h4>

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

  <hr>

  <dl class=domintro><dt><var>document</var> . <code id=dom-document-head-dev><a href=#dom-document-head>head</a></code><dd>
    <p>Returns <a href=#the-head-element-2 id=dom-tree-accessors:the-head-element-2>the <code>head</code> element</a>.</p>
   </dl>

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

  

  <p>The <dfn id=dom-document-head><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).<div class=status><input onclick=toggleStatus(this) value=⋰ type=button><p class=support><strong>Support:</strong> documenthead<span class="and_chr yes"><span>Chrome for Android</span> <span>67+</span></span><span class="chrome yes"><span>Chrome</span> <span>4+</span></span><span class="ios_saf yes"><span>iOS Safari</span> <span>4.0+</span></span><span class="and_uc yes"><span>UC Browser for Android</span> <span>11.8+</span></span><span class="firefox yes"><span>Firefox</span> <span>4+</span></span><span class="ie yes"><span>IE</span> <span>9+</span></span><span class="op_mini yes"><span>Opera Mini</span> <span>all+</span></span><span class="safari yes"><span>Safari</span> <span>5.1+</span></span><span class="edge yes"><span>Edge</span> <span>12+</span></span><span class="samsung yes"><span>Samsung Internet</span> <span>4+</span></span><span class="opera yes"><span>Opera</span> <span>11+</span></span><span class="android yes"><span>Android Browser</span> <span>2.3+</span></span><p class=caniuse>Source: <a href="https://caniuse.com/#feat=documenthead">caniuse.com</a></div>

  

  <hr>

  <dl class=domintro><dt><var>document</var> . <code id=dom-document-title-dev><a href=#document.title>title</a></code> [ = <var>value</var> ]<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>

   </dl>

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

  

  <p>The <dfn id=document.title><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>.<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.<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>.<li><p>Return <var>value</var>.</ol>

  <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<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.<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 id=dom-tree-accessors:svg-title-4><a data-x-internal=svg-title href=https://svgwg.org/svg2-draft/struct.html#TitleElement>title</a></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><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>.</ol>
     <li><p>Act as if the <code id=dom-tree-accessors:textcontent><a data-x-internal=textcontent href=https://dom.spec.whatwg.org/#dom-node-textcontent>textContent</a></code> IDL attribute of <var>element</var> was
     set to the new value being assigned.</ol>

   <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><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.<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>.<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 id=dom-tree-accessors:the-title-element-3><a href=#the-title-element>title</a></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><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>.</ol>
     <li><p>Act as if the <code id=dom-tree-accessors:textcontent-2><a data-x-internal=textcontent href=https://dom.spec.whatwg.org/#dom-node-textcontent>textContent</a></code> IDL attribute of <var>element</var> was
     set to the new value being assigned.</ol>

   <dt>Otherwise<dd>

    <p>Do nothing.</p>

   </dl>

  

  <hr>

  <dl class=domintro><dt><var>document</var> . <code id=dom-document-body-dev><a href=#dom-document-body>body</a></code> [ = <var>value</var> ]<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://heycam.github.io/webidl/#hierarchyrequesterror data-x-internal=hierarchyrequesterror>"<code>HierarchyRequestError</code>"</a> <code id=dom-tree-accessors:domexception><a data-x-internal=domexception href=https://heycam.github.io/webidl/#dfn-DOMException>DOMException</a></code>.</p>

   </dl>

  <p><dfn id=the-body-element-2>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>

  

  <p>The <dfn id=dom-document-body><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://heycam.github.io/webidl/#hierarchyrequesterror data-x-internal=hierarchyrequesterror>"<code>HierarchyRequestError</code>"</a> <code id=dom-tree-accessors:domexception-2><a data-x-internal=domexception href=https://heycam.github.io/webidl/#dfn-DOMException>DOMException</a></code>.<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>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>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://heycam.github.io/webidl/#hierarchyrequesterror data-x-internal=hierarchyrequesterror>"<code>HierarchyRequestError</code>"</a> <code id=dom-tree-accessors:domexception-3><a data-x-internal=domexception href=https://heycam.github.io/webidl/#dfn-DOMException>DOMException</a></code>.<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>.</ol>

  <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>&quot;http://www.w3.org/2000/svg&quot;</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>&quot;http://www.w3.org/1999/xhtml&quot;</c-><c- p>,</c-> <c- u>&quot;body&quot;</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><var>document</var> . <code id=dom-document-images-dev><a href=#dom-document-images>images</a></code><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>
   <dt><var>document</var> . <code id=dom-document-embeds-dev><a href=#dom-document-embeds>embeds</a></code><dt><var>document</var> . <code id=dom-document-plugins-dev><a href=#dom-document-plugins>plugins</a></code><dd>
    <p>Return 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>
   <dt><var>document</var> . <code id=dom-document-links-dev><a href=#dom-document-links>links</a></code><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>
   <dt><var>document</var> . <code id=dom-document-forms-dev><a href=#dom-document-forms>forms</a></code><dd>
    <p>Return 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>
   <dt><var>document</var> . <code id=dom-document-scripts-dev><a href=#dom-document-scripts>scripts</a></code><dd>
    <p>Return 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>
   </dl>

  

  

  <p>The <dfn id=dom-document-images><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>

  <p>The <dfn id=dom-document-embeds><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>

  <p>The <dfn id=dom-document-plugins><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>

  <p>The <dfn id=dom-document-links><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>

  <p>The <dfn id=dom-document-forms><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>

  <p>The <dfn id=dom-document-scripts><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>

  <hr>

  

  <dl class=domintro><dt><var>collection</var> = <var>document</var> . <code id=dom-document-getelementsbyname-dev><a href=#dom-document-getelementsbyname>getElementsByName</a></code>(<var>name</var>)<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>

   </dl>

  

  <p>The <dfn id=dom-document-getelementsbyname><code>getElementsByName(<var>name</var>)</code></dfn> method takes a string <var>name</var>, and must
  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 equal to the <var>name</var> argument (in a <a href=#case-sensitive id=dom-tree-accessors:case-sensitive>case-sensitive</a> manner), 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>

  

  <hr>

  <dl class=domintro><dt><var>document</var> . <code id=dom-document-currentscript-dev><a href=#dom-document-currentscript>currentScript</a></code><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>

   </dl>

  

  <p>The <dfn id=dom-document-currentscript><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.<div class=status><input onclick=toggleStatus(this) value=⋰ type=button><p class=support><strong>Support:</strong> document-currentscript<span class="and_chr yes"><span>Chrome for Android</span> <span>67+</span></span><span class="chrome yes"><span>Chrome</span> <span>29+</span></span><span class="ios_saf yes"><span>iOS Safari</span> <span>8+</span></span><span class="and_uc yes"><span>UC Browser for Android</span> <span>11.8+</span></span><span class="firefox yes"><span>Firefox</span> <span>4+</span></span><span class="ie no"><span>IE</span> <span>None</span></span><span class="op_mini no"><span>Opera Mini</span> <span>None</span></span><span class="safari yes"><span>Safari</span> <span>8+</span></span><span class="edge yes"><span>Edge</span> <span>12+</span></span><span class="samsung yes"><span>Samsung Internet</span> <span>4+</span></span><span class="opera yes"><span>Opera</span> <span>16+</span></span><span class="android yes"><span>Android Browser</span> <span>4.4+</span></span><p class=caniuse>Source: <a href="https://caniuse.com/#feat=document-currentscript">caniuse.com</a></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 issue <a href=https://github.com/whatwg/html/issues/1013>#1013</a>.</p>

  

  <hr>

  <p id=dom-document-namedItem-which>The <code id=dom-tree-accessors:document-15><a href=#document>Document</a></code> interface <a href=https://heycam.github.io/webidl/#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://heycam.github.io/webidl/#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><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<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>.</ul>

  <p id=dom-document-nameditem>To <a id=dom-tree-accessors:determine-the-value-of-a-named-property href=https://heycam.github.io/webidl/#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, by definition.</p>

   <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=#nested-browsing-context id=dom-tree-accessors:nested-browsing-context>nested browsing context</a> is not
    null, then return the <code id=dom-tree-accessors:windowproxy><a href=#windowproxy>WindowProxy</a></code> object of the element's <a href=#nested-browsing-context id=dom-tree-accessors:nested-browsing-context-2>nested browsing
    context</a>.</p>

   <li>

    <p>Otherwise, if <var>elements</var> has only one element, return that element.</p>

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

   </ol>

  <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><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><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.</ul>

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

  

  <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:the-dir-attribute><a href=#the-dir-attribute>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>&quot;en&quot;</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 is intended 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>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->
 <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>&quot;en-GB&quot;</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>&quot;https://example.org/~ernest/&quot;</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>&quot;en-GB&quot;</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>&quot;https://example.org/~ernest/&quot;</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>&quot;carpet&quot;</c-> <c- e>name</c-><c- o>=</c-><c- s>&quot;c&quot;</c-> <c- e>texture</c-><c- o>=</c-><c- s>&quot;deep pile&quot;</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>&quot;text&quot;</c-> <c- e>class</c-><c- o>=</c-><c- s>&quot;carpet&quot;</c-> <c- e>name</c-><c- o>=</c-><c- s>&quot;c&quot;</c-> <c- e>data-texture</c-><c- o>=</c-><c- s>&quot;deep pile&quot;</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> does not have a
  <a href=#browsing-context id=semantics-2:browsing-context>browsing context</a> 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> does not have a <a href=#browsing-context id=semantics-2:browsing-context-2>browsing context</a>. 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>&quot;{{src}}&quot;</c-> <c- e>alt</c-><c- o>=</c-><c- s>&quot;{{alt}}&quot;</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></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=#scroll-to-fragid id=elements-in-the-dom:scroll-to-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>&quot;module-script-graph&quot;</c-><c- p>&gt;</c->
  <c- p>&lt;</c-><c- f>img</c-> <c- e>src</c-><c- o>=</c-><c- s>&quot;module-script-graph.svg&quot;</c->
       <c- e>alt</c-><c- o>=</c-><c- s>&quot;Module A depends on module B, which depends</c->
<c- s>            on modules C and D.&quot;</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>&quot;#module-script-graph&quot;</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..."<li><p>"In Figure 27..." (without a hyperlink)<li><p>"From the contents of the 'simple module graph' figure..."<li><p>"In the figure below..." (but <a href=#figure-note-about-references>this is
    discouraged</a>)</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>

  <pre><code class='idl'>[<c- g>Exposed</c->=<c- n>Window</c->,
 <a href='#htmlconstructor' id='elements-in-the-dom:htmlconstructor'><c- g>HTMLConstructor</c-></a>]
<c- b>interface</c-> <dfn id='htmlelement'><c- g>HTMLElement</c-></dfn> : <a href='https://dom.spec.whatwg.org/#interface-element' data-x-internal='element' id='elements-in-the-dom:element'><c- n>Element</c-></a> {
  // metadata attributes
  [<a href='#cereactions' id='elements-in-the-dom:cereactions'><c- g>CEReactions</c-></a>] <c- b>attribute</c-> <c- b>DOMString</c-> <a href='#dom-title' id='elements-in-the-dom:dom-title'><c- g>title</c-></a>;
  [<a href='#cereactions' id='elements-in-the-dom:cereactions-2'><c- g>CEReactions</c-></a>] <c- b>attribute</c-> <c- b>DOMString</c-> <a href='#dom-lang' id='elements-in-the-dom:dom-lang'><c- g>lang</c-></a>;
  [<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-> <a href='#dom-hidden' id='elements-in-the-dom:dom-hidden'><c- g>hidden</c-></a>;
  <c- b>void</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-6'><c- g>CEReactions</c-></a>] <c- b>attribute</c-> <c- b>DOMString</c-> <a href='#dom-accesskey' id='elements-in-the-dom:dom-accesskey'><c- g>accessKey</c-></a>;
  <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-7'><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-8'><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-9'><c- g>CEReactions</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-10'><c- g>CEReactions</c-></a>] <c- b>attribute</c-> [<c- g>TreatNullAs</c->=<c- n>EmptyString</c->] <c- b>DOMString</c-> <a href='#dom-innertext' id='elements-in-the-dom:dom-innertext'><c- g>innerText</c-></a>;
};

<a href='#htmlelement' id='elements-in-the-dom:htmlelement-2'><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-3'><c- n>HTMLElement</c-></a> <c- b>includes</c-> <a href='#documentandelementeventhandlers' id='elements-in-the-dom:documentandelementeventhandlers'><c- n>DocumentAndElementEventHandlers</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>;

// Note: <a href='#customized-built-in-element-restrictions'>intentionally</a> not [<a href='#htmlconstructor' id='elements-in-the-dom:htmlconstructor-2'>HTMLConstructor</a>]
[<c- g>Exposed</c->=<c- n>Window</c->]
<c- b>interface</c-> <dfn id='htmlunknownelement'><c- g>HTMLUnknownElement</c-></dfn> : <a href='#htmlelement' id='elements-in-the-dom:htmlelement-6'><c- n>HTMLElement</c-></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>

  <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>.<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>.<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>.<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.<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.<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><p>Return <code id=elements-in-the-dom:htmlunknownelement-2><a href=#htmlunknownelement>HTMLUnknownElement</a></code>.</ol>

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

  <pre><code class='idl'><c- b>interface</c-> <c- b>mixin</c-> <dfn id='htmlorsvgelement'><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-11'><c- g>CEReactions</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>void</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>void</c-> <a href='#dom-blur' id='elements-in-the-dom:dom-blur'><c- g>blur</c-></a>();
};</code></pre>

  

  <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 data-export=""><code>[HTMLConstructor]</code></dfn> IDL <a id=html-element-constructors:extended-attribute href=https://heycam.github.io/webidl/#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 not appear on anything other than an interface. It must appear only once on an
  interface, and the interface must not be annotated with the <code>[Constructor]</code>
  or <code>[NoInterfaceObject]</code> extended attributes. (However, the interface may be
  annotated with <code>[NamedConstructor]</code>; there is no conflict there.) It must not
  be used on a callback interface.</p>

  <p><a href=https://heycam.github.io/webidl/#dfn-interface-object id=html-element-constructors:interface-object data-x-internal=interface-object>Interface objects</a> for interfaces annotated with the
  <code id=html-element-constructors:htmlconstructor-2><a href=#htmlconstructor>[HTMLConstructor]</a></code> extended attribute must run the following
  steps as the function body behavior for both [[Call]] and [[Construct]] invocations of the
  corresponding JavaScript function object. When invoked with [[Call]], the NewTarget value is
  undefined, and so the algorithm below will immediately throw. When invoked with [[Construct]], the
  [[Construct]] <var>newTarget</var> parameter provides the NewTarget value.</p>

  <ol><li><p>Let <var>registry</var> be the <a href=#current-global-object id=html-element-constructors:current-global-object>current global object</a>'s
   <code id=html-element-constructors:customelementregistry><a href=#customelementregistry>CustomElementRegistry</a></code> object.<li>
    <p>If NewTarget is equal to the <a id=html-element-constructors:active-function-object href=https://tc39.github.io/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.github.io/ecma262/#sec-native-error-types-used-in-this-standard-typeerror>TypeError</a></code>.</p>

    <div class="example no-backref">
     <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>&quot;bad-1&quot;</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>&quot;bad-1&quot;</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.github.io/ecma262/#active-function-object data-x-internal=active-function-object>active function object</a> and NewTarget
     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>
    <p>Let <var>definition</var> be the entry in <var>registry</var> with <a href=#concept-custom-element-definition-constructor id=html-element-constructors:concept-custom-element-definition-constructor>constructor</a> equal to NewTarget. If
    there is no such definition, then throw a <code id=html-element-constructors:typeerror-2><a data-x-internal=typeerror href=https://tc39.github.io/ecma262/#sec-native-error-types-used-in-this-standard-typeerror>TypeError</a></code>.</p>

    <p class=note>Since there can be no entry in <var>registry</var> 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
    NewTarget will be undefined).</p>
   <li><p>Let <var>is value</var> be null.<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>), then:</p>

    <ol><li>
      <p>If the <a id=html-element-constructors:active-function-object-3 href=https://tc39.github.io/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.github.io/ecma262/#sec-native-error-types-used-in-this-standard-typeerror>TypeError</a></code>.</p>

      <div class="example no-backref">
       <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>&quot;bad-2&quot;</c-><c- p>,</c-> <c- kr>class</c-> Bad2 <c- kr>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.github.io/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>
     </ol>
   <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.github.io/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>.<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.github.io/ecma262/#sec-native-error-types-used-in-this-standard-typeerror>TypeError</a></code>.</p>

      <div class="example no-backref">
       <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>&quot;bad-3&quot;</c-><c- p>,</c-> <c- kr>class</c-> Bad3 <c- kr>extends</c-> HTMLQuoteElement <c- p>{},</c-> <c- p>{</c-> <c- kr>extends</c-><c- o>:</c-> <c- u>&quot;p&quot;</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><p>Set <var>is value</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>.</ol>
   <li><p>Let <var>prototype</var> be <a href=https://tc39.github.io/ecma262/#sec-get-o-p id=html-element-constructors:js-get data-x-internal=js-get>Get</a>(NewTarget, "prototype").
   Rethrow any exceptions.<li>
    <p>If <a href=https://tc39.github.io/ecma262/#sec-ecmascript-data-types-and-values id=html-element-constructors:js-type data-x-internal=js-type>Type</a>(<var>prototype</var>) is not Object, then:</p>

    <ol><li><p>Let <var>realm</var> be <a id=html-element-constructors:getfunctionrealm href=https://tc39.github.io/ecma262/#sec-getfunctionrealm data-x-internal=getfunctionrealm>GetFunctionRealm</a>(NewTarget).<li><p>Set <var>prototype</var> to the <a id=html-element-constructors:interface-prototype-object href=https://heycam.github.io/webidl/#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-6 href=https://tc39.github.io/ecma262/#active-function-object data-x-internal=active-function-object>active function
     object</a>.</ol>

    <p class=note>The realm of the <a id=html-element-constructors:active-function-object-7 href=https://tc39.github.io/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://heycam.github.io/webidl/#dfn-interface-object id=html-element-constructors:interface-object-2 data-x-internal=interface-object>interface
    objects</a>. This fallback behavior, including using the realm of NewTarget and looking up
    the appropriate prototype there, is designed to match analogous behavior for the JavaScript
    built-ins.</p>
   <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, then:</p>

    <ol><li><p>Let <var>element</var> be a new element that implements the interface to which the
     <a id=html-element-constructors:active-function-object-8 href=https://tc39.github.io/ecma262/#active-function-object data-x-internal=active-function-object>active function object</a> corresponds, with no attributes, namespace set 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>, local name set 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>, and <a id=html-element-constructors:node-document href=https://dom.spec.whatwg.org/#concept-node-document data-x-internal=node-document>node
     document</a> set 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>associated <code>Document</code></a>.<li><p>Perform <var>element</var>.[[SetPrototypeOf]](<var>prototype</var>). Rethrow any
     exceptions.<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>".<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>.<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>is value</var>.<li><p>Return <var>element</var>.</ol>

    <p class=note>This occurs when author script constructs a new custom element directly, e.g.
    via <code>new MyCustomElement()</code>.</p>
   <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>.<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 an <a id=html-element-constructors:invalidstateerror href=https://heycam.github.io/webidl/#invalidstateerror data-x-internal=invalidstateerror>"<code>InvalidStateError</code>"</a>
    <code id=html-element-constructors:domexception><a data-x-internal=domexception href=https://heycam.github.io/webidl/#dfn-DOMException>DOMException</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>false</c-><c- p>;</c->

<c- kr>class</c-> DontDoThis <c- kr>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 an &quot;InvalidStateError&quot; DOMException:</c->
    <c- kr>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:

     <pre><code class='js'><c- kr>class</c-> DontDoThisEither <c- kr>extends</c-> HTMLElement <c- p>{</c->
  constructor<c- p>()</c-> <c- p>{</c->
    <c- kr>super</c-><c- p>();</c->

    <c- c1>// This will throw, but not until it has already called into the HTMLElement constructor</c->
    <c- kr>super</c-><c- p>();</c->
  <c- p>}</c->
<c- p>}</c-></code></pre>
    </div>
   <li><p>Perform <var>element</var>.[[SetPrototypeOf]](<var>prototype</var>). Rethrow any
   exceptions.<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>.<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>
   </ol>

  <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://heycam.github.io/webidl/#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).

  <div class=example>
   <p>Named constructors for HTML elements can also be used in an <code>extends</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- kr>class</c-> AutoEmbiggenedImage <c- kr>extends</c-> Image <c- p>{</c->
  constructor<c- p>(</c->width<c- p>,</c-> height<c- p>)</c-> <c- p>{</c->
    <c- kr>super</c-><c- p>(</c->width <c- o>*</c-> <c- mi>10</c-><c- p>,</c-> height <c- o>*</c-> <c- mi>10</c-><c- p>);</c->
  <c- p>}</c->
<c- p>}</c->

customElements<c- p>.</c->define<c- p>(</c-><c- u>&quot;auto-embiggened&quot;</c-><c- p>,</c-> AutoEmbiggenedImage<c- p>,</c-> <c- p>{</c-> <c- kr>extends</c-><c- o>:</c-> <c- u>&quot;img&quot;</c-> <c- p>});</c->

<c- kr>const</c-> image <c- o>=</c-> <c- k>new</c-> AutoEmbiggenedImage<c- p>(</c-><c- mi>15</c-><c- p>,</c-> <c- mi>20</c-><c- p>);</c->
console<c- p>.</c->assert<c- p>(</c->image<c- p>.</c->width <c- o>===</c-> <c- mi>150</c-><c- p>);</c->
console<c- p>.</c->assert<c- p>(</c->image<c- p>.</c->height <c- o>===</c-> <c- mi>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><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.<dt><dfn id=concept-element-contexts>Contexts in which this element can be used</dfn><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>

    <p class=note>For simplicity, only the most specific expectations are listed. For example, an
    element that is both <a href=#flow-content-2 id=element-definitions:flow-content-2>flow content</a> and <a href=#phrasing-content-2 id=element-definitions:phrasing-content-2>phrasing content</a> can be used
    anywhere that either <a href=#flow-content-2 id=element-definitions:flow-content-2-2>flow content</a> or <a href=#phrasing-content-2 id=element-definitions:phrasing-content-2-2>phrasing content</a> is expected, but
    since anywhere that <a href=#flow-content-2 id=element-definitions:flow-content-2-3>flow content</a> is expected, <a href=#phrasing-content-2 id=element-definitions:phrasing-content-2-3>phrasing content</a> is also
    expected (since all <a href=#phrasing-content-2 id=element-definitions:phrasing-content-2-4>phrasing content</a> is <a href=#flow-content-2 id=element-definitions:flow-content-2-4>flow content</a>), only "where
    <a href=#phrasing-content-2 id=element-definitions:phrasing-content-2-5>phrasing content</a> is expected" will be listed.</p>

   <dt><dfn id=concept-element-content-model>Content model</dfn><dd><p>A normative description of what content must be included as children and descendants of
   the element.<dt><dfn id=concept-element-tag-omission>Tag omission in text/html</dfn><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.<dt><dfn id=concept-element-attributes>Content attributes</dfn><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.)<dt><dfn id=concept-element-dom>DOM interface</dfn><dd><p>A normative definition of a DOM interface that such elements must implement.</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 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>

  <div class=example>
   <p>For example, the Atom specification defines a <code>content</code> element. When its
   <code>type</code> attribute has the value <code>xhtml</code>, the Atom
   specification 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>
  </div>

  <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>&quot;Banana&quot;</c-><c- p>,</c->
  cell<c- o>:</c-> document<c- p>.</c->createElement<c- p>(</c-><c- t>&apos;td&apos;</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><a href=#flow-content-2 id=kinds-of-content:flow-content-2>Flow content</a><li><a href=#sectioning-content-2 id=kinds-of-content:sectioning-content-2>Sectioning content</a><li><a href=#heading-content-2 id=kinds-of-content:heading-content-2>Heading content</a><li><a href=#phrasing-content-2 id=kinds-of-content:phrasing-content-2>Phrasing content</a><li><a href=#embedded-content-category id=kinds-of-content:embedded-content-category>Embedded content</a><li><a href=#interactive-content-2 id=kinds-of-content:interactive-content-2>Interactive content</a></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><object width=1000 height=288 data=/images/content-venn.svg></object></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>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><code id=metadata-content:the-link-element><a href=#the-link-element>link</a></code><li><code id=metadata-content:the-meta-element><a href=#the-meta-element>meta</a></code><li><code id=metadata-content:the-noscript-element><a href=#the-noscript-element>noscript</a></code><li><code id=metadata-content:the-script-element><a href=#the-script-element>script</a></code><li><code id=metadata-content:the-style-element><a href=#the-style-element>style</a></code><li><code id=metadata-content:the-template-element><a href=#the-template-element>template</a></code><li><code id=metadata-content:the-title-element><a href=#the-title-element>title</a></code></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>&quot;http://www.w3.org/1999/xhtml&quot;</c->
      <c- e>xmlns:r</c-><c- o>=</c-><c- s>&quot;http://www.w3.org/1999/02/22-rdf-syntax-ns#&quot;</c-> <c- e>xml:lang</c-><c- o>=</c-><c- s>&quot;en&quot;</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&apos;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>&quot;http://www.w3.org/2000/10/swap/pim/contact#&quot;</c->
           <c- e>r:about</c-><c- o>=</c-><c- s>&quot;https://hedral.example.com/#&quot;</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>&quot;mailto:hedral@damowmow.com&quot;</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>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><code id=flow-content:the-abbr-element><a href=#the-abbr-element>abbr</a></code><li><code id=flow-content:the-address-element><a href=#the-address-element>address</a></code><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><code id=flow-content:the-article-element><a href=#the-article-element>article</a></code><li><code id=flow-content:the-aside-element><a href=#the-aside-element>aside</a></code><li><code id=flow-content:the-audio-element><a href=#the-audio-element>audio</a></code><li><code id=flow-content:the-b-element><a href=#the-b-element>b</a></code><li><code id=flow-content:the-bdi-element><a href=#the-bdi-element>bdi</a></code><li><code id=flow-content:the-bdo-element><a href=#the-bdo-element>bdo</a></code><li><code id=flow-content:the-blockquote-element><a href=#the-blockquote-element>blockquote</a></code><li><code id=flow-content:the-br-element><a href=#the-br-element>br</a></code><li><code id=flow-content:the-button-element><a href=#the-button-element>button</a></code><li><code id=flow-content:the-canvas-element><a href=#the-canvas-element>canvas</a></code><li><code id=flow-content:the-cite-element><a href=#the-cite-element>cite</a></code><li><code id=flow-content:the-code-element><a href=#the-code-element>code</a></code><li><code id=flow-content:the-data-element><a href=#the-data-element>data</a></code><li><code id=flow-content:the-datalist-element><a href=#the-datalist-element>datalist</a></code><li><code id=flow-content:the-del-element><a href=#the-del-element>del</a></code><li><code id=flow-content:the-details-element><a href=#the-details-element>details</a></code><li><code id=flow-content:the-dfn-element><a href=#the-dfn-element>dfn</a></code><li><code id=flow-content:the-dialog-element><a href=#the-dialog-element>dialog</a></code><li><code id=flow-content:the-div-element><a href=#the-div-element>div</a></code><li><code id=flow-content:the-dl-element><a href=#the-dl-element>dl</a></code><li><code id=flow-content:the-em-element><a href=#the-em-element>em</a></code><li><code id=flow-content:the-embed-element><a href=#the-embed-element>embed</a></code><li><code id=flow-content:the-fieldset-element><a href=#the-fieldset-element>fieldset</a></code><li><code id=flow-content:the-figure-element><a href=#the-figure-element>figure</a></code><li><code id=flow-content:the-footer-element><a href=#the-footer-element>footer</a></code><li><code id=flow-content:the-form-element><a href=#the-form-element>form</a></code><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><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><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><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><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><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><code id=flow-content:the-header-element><a href=#the-header-element>header</a></code><li><code id=flow-content:the-hgroup-element><a href=#the-hgroup-element>hgroup</a></code><li><code id=flow-content:the-hr-element><a href=#the-hr-element>hr</a></code><li><code id=flow-content:the-i-element><a href=#the-i-element>i</a></code><li><code id=flow-content:the-iframe-element><a href=#the-iframe-element>iframe</a></code><li><code id=flow-content:the-img-element><a href=#the-img-element>img</a></code><li><code id=flow-content:the-input-element><a href=#the-input-element>input</a></code><li><code id=flow-content:the-ins-element><a href=#the-ins-element>ins</a></code><li><code id=flow-content:the-kbd-element><a href=#the-kbd-element>kbd</a></code><li><code id=flow-content:the-label-element><a href=#the-label-element>label</a></code><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><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><code id=flow-content:the-map-element-2><a href=#the-map-element>map</a></code><li><code id=flow-content:the-mark-element><a href=#the-mark-element>mark</a></code><li><a id=flow-content:mathml-math href=https://www.w3.org/Math/draft-spec/chapter2.html#interf.toplevel data-x-internal=mathml-math>MathML <code>math</code></a><li><code id=flow-content:the-menu-element><a href=#the-menu-element>menu</a></code><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><code id=flow-content:the-meter-element><a href=#the-meter-element>meter</a></code><li><code id=flow-content:the-nav-element><a href=#the-nav-element>nav</a></code><li><code id=flow-content:the-noscript-element><a href=#the-noscript-element>noscript</a></code><li><code id=flow-content:the-object-element><a href=#the-object-element>object</a></code><li><code id=flow-content:the-ol-element><a href=#the-ol-element>ol</a></code><li><code id=flow-content:the-output-element><a href=#the-output-element>output</a></code><li><code id=flow-content:the-p-element><a href=#the-p-element>p</a></code><li><code id=flow-content:the-picture-element><a href=#the-picture-element>picture</a></code><li><code id=flow-content:the-pre-element><a href=#the-pre-element>pre</a></code><li><code id=flow-content:the-progress-element><a href=#the-progress-element>progress</a></code><li><code id=flow-content:the-q-element><a href=#the-q-element>q</a></code><li><code id=flow-content:the-ruby-element><a href=#the-ruby-element>ruby</a></code><li><code id=flow-content:the-s-element><a href=#the-s-element>s</a></code><li><code id=flow-content:the-samp-element><a href=#the-samp-element>samp</a></code><li><code id=flow-content:the-script-element><a href=#the-script-element>script</a></code><li><code id=flow-content:the-section-element><a href=#the-section-element>section</a></code><li><code id=flow-content:the-select-element><a href=#the-select-element>select</a></code><li><code id=flow-content:the-slot-element><a href=#the-slot-element>slot</a></code><li><code id=flow-content:the-small-element><a href=#the-small-element>small</a></code><li><code id=flow-content:the-span-element><a href=#the-span-element>span</a></code><li><code id=flow-content:the-strong-element><a href=#the-strong-element>strong</a></code><li><code id=flow-content:the-sub-and-sup-elements><a href=#the-sub-and-sup-elements>sub</a></code><li><code id=flow-content:the-sub-and-sup-elements-2><a href=#the-sub-and-sup-elements>sup</a></code><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><code id=flow-content:the-table-element><a href=#the-table-element>table</a></code><li><code id=flow-content:the-template-element><a href=#the-template-element>template</a></code><li><code id=flow-content:the-textarea-element><a href=#the-textarea-element>textarea</a></code><li><code id=flow-content:the-time-element><a href=#the-time-element>time</a></code><li><code id=flow-content:the-u-element><a href=#the-u-element>u</a></code><li><code id=flow-content:the-ul-element><a href=#the-ul-element>ul</a></code><li><code id=flow-content:the-var-element><a href=#the-var-element>var</a></code><li><code id=flow-content:the-video-element><a href=#the-video-element>video</a></code><li><code id=flow-content:the-wbr-element><a href=#the-wbr-element>wbr</a></code><li><a href=#autonomous-custom-element id=flow-content:autonomous-custom-element>autonomous custom elements</a><li><a href=#text-content id=flow-content:text-content>text</a></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>Sectioning content</dfn> is content that defines the scope of <a href=#heading-content-2 id=sectioning-content:heading-content-2>headings</a> and <a href=#the-footer-element id=sectioning-content:the-footer-element>footers</a>.</p>

  
  <ul class="brief category-list"><li><code id=sectioning-content:the-article-element><a href=#the-article-element>article</a></code><li><code id=sectioning-content:the-aside-element><a href=#the-aside-element>aside</a></code><li><code id=sectioning-content:the-nav-element><a href=#the-nav-element>nav</a></code><li><code id=sectioning-content:the-section-element><a href=#the-section-element>section</a></code></ul>

  <p>Each <a href=#sectioning-content-2 id=sectioning-content:sectioning-content-2>sectioning content</a> element potentially has a heading and an
  <a href=#outline id=sectioning-content:outline>outline</a>. See the section on <a href=#headings-and-sections id=sectioning-content:headings-and-sections>headings and sections</a> for further
  details.</p>

  <p class=note>There are also certain elements that are <a href=#sectioning-root id=sectioning-content:sectioning-root>sectioning
  roots</a>. These are distinct from <a href=#sectioning-content-2 id=sectioning-content:sectioning-content-2-2>sectioning content</a>, but they can also have an
  <a href=#outline id=sectioning-content:outline-2>outline</a>.</p>


  <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>Heading content</dfn> defines the header 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><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><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><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><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><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><code id=heading-content:the-hgroup-element><a href=#the-hgroup-element>hgroup</a></code></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>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><code id=phrasing-content:the-abbr-element><a href=#the-abbr-element>abbr</a></code><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><code id=phrasing-content:the-audio-element><a href=#the-audio-element>audio</a></code><li><code id=phrasing-content:the-b-element><a href=#the-b-element>b</a></code><li><code id=phrasing-content:the-bdi-element><a href=#the-bdi-element>bdi</a></code><li><code id=phrasing-content:the-bdo-element><a href=#the-bdo-element>bdo</a></code><li><code id=phrasing-content:the-br-element><a href=#the-br-element>br</a></code><li><code id=phrasing-content:the-button-element><a href=#the-button-element>button</a></code><li><code id=phrasing-content:the-canvas-element><a href=#the-canvas-element>canvas</a></code><li><code id=phrasing-content:the-cite-element><a href=#the-cite-element>cite</a></code><li><code id=phrasing-content:the-code-element><a href=#the-code-element>code</a></code><li><code id=phrasing-content:the-data-element><a href=#the-data-element>data</a></code><li><code id=phrasing-content:the-datalist-element><a href=#the-datalist-element>datalist</a></code><li><code id=phrasing-content:the-del-element><a href=#the-del-element>del</a></code><li><code id=phrasing-content:the-dfn-element><a href=#the-dfn-element>dfn</a></code><li><code id=phrasing-content:the-em-element><a href=#the-em-element>em</a></code><li><code id=phrasing-content:the-embed-element><a href=#the-embed-element>embed</a></code><li><code id=phrasing-content:the-i-element><a href=#the-i-element>i</a></code><li><code id=phrasing-content:the-iframe-element><a href=#the-iframe-element>iframe</a></code><li><code id=phrasing-content:the-img-element><a href=#the-img-element>img</a></code><li><code id=phrasing-content:the-input-element><a href=#the-input-element>input</a></code><li><code id=phrasing-content:the-ins-element><a href=#the-ins-element>ins</a></code><li><code id=phrasing-content:the-kbd-element><a href=#the-kbd-element>kbd</a></code><li><code id=phrasing-content:the-label-element><a href=#the-label-element>label</a></code><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><code id=phrasing-content:the-map-element-2><a href=#the-map-element>map</a></code><li><code id=phrasing-content:the-mark-element><a href=#the-mark-element>mark</a></code><li><a id=phrasing-content:mathml-math href=https://www.w3.org/Math/draft-spec/chapter2.html#interf.toplevel data-x-internal=mathml-math>MathML <code>math</code></a><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><code id=phrasing-content:the-meter-element><a href=#the-meter-element>meter</a></code><li><code id=phrasing-content:the-noscript-element><a href=#the-noscript-element>noscript</a></code><li><code id=phrasing-content:the-object-element><a href=#the-object-element>object</a></code><li><code id=phrasing-content:the-output-element><a href=#the-output-element>output</a></code><li><code id=phrasing-content:the-picture-element><a href=#the-picture-element>picture</a></code><li><code id=phrasing-content:the-progress-element><a href=#the-progress-element>progress</a></code><li><code id=phrasing-content:the-q-element><a href=#the-q-element>q</a></code><li><code id=phrasing-content:the-ruby-element><a href=#the-ruby-element>ruby</a></code><li><code id=phrasing-content:the-s-element><a href=#the-s-element>s</a></code><li><code id=phrasing-content:the-samp-element><a href=#the-samp-element>samp</a></code><li><code id=phrasing-content:the-script-element><a href=#the-script-element>script</a></code><li><code id=phrasing-content:the-select-element><a href=#the-select-element>select</a></code><li><code id=phrasing-content:the-slot-element><a href=#the-slot-element>slot</a></code><li><code id=phrasing-content:the-small-element><a href=#the-small-element>small</a></code><li><code id=phrasing-content:the-span-element><a href=#the-span-element>span</a></code><li><code id=phrasing-content:the-strong-element><a href=#the-strong-element>strong</a></code><li><code id=phrasing-content:the-sub-and-sup-elements><a href=#the-sub-and-sup-elements>sub</a></code><li><code id=phrasing-content:the-sub-and-sup-elements-2><a href=#the-sub-and-sup-elements>sup</a></code><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><code id=phrasing-content:the-template-element><a href=#the-template-element>template</a></code><li><code id=phrasing-content:the-textarea-element><a href=#the-textarea-element>textarea</a></code><li><code id=phrasing-content:the-time-element><a href=#the-time-element>time</a></code><li><code id=phrasing-content:the-u-element><a href=#the-u-element>u</a></code><li><code id=phrasing-content:the-var-element><a href=#the-var-element>var</a></code><li><code id=phrasing-content:the-video-element><a href=#the-video-element>video</a></code><li><code id=phrasing-content:the-wbr-element><a href=#the-wbr-element>wbr</a></code><li><a href=#autonomous-custom-element id=phrasing-content:autonomous-custom-element>autonomous custom elements</a><li><a href=#text-content id=phrasing-content:text-content>text</a></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>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><code id=embedded-content-2:the-canvas-element><a href=#the-canvas-element>canvas</a></code><li><code id=embedded-content-2:the-embed-element><a href=#the-embed-element>embed</a></code><li><code id=embedded-content-2:the-iframe-element><a href=#the-iframe-element>iframe</a></code><li><code id=embedded-content-2:the-img-element><a href=#the-img-element>img</a></code><li><a id=embedded-content-2:mathml-math href=https://www.w3.org/Math/draft-spec/chapter2.html#interf.toplevel data-x-internal=mathml-math>MathML <code>math</code></a><li><code id=embedded-content-2:the-object-element><a href=#the-object-element>object</a></code><li><code id=embedded-content-2:the-picture-element><a href=#the-picture-element>picture</a></code><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><code id=embedded-content-2:the-video-element><a href=#the-video-element>video</a></code></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>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><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><code id=interactive-content:the-button-element><a href=#the-button-element>button</a></code><li><code id=interactive-content:the-details-element><a href=#the-details-element>details</a></code><li><code id=interactive-content:the-embed-element><a href=#the-embed-element>embed</a></code><li><code id=interactive-content:the-iframe-element><a href=#the-iframe-element>iframe</a></code><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><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><code id=interactive-content:the-label-element><a href=#the-label-element>label</a></code><li><code id=interactive-content:the-object-element><a href=#the-object-element>object</a></code> (if the <code id=interactive-content:attr-hyperlink-usemap-2><a href=#attr-hyperlink-usemap>usemap</a></code> attribute is present)<li><code id=interactive-content:the-select-element><a href=#the-select-element>select</a></code><li><code id=interactive-content:the-textarea-element><a href=#the-textarea-element>textarea</a></code><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)</ul>

  <p>The <code id=interactive-content:attr-tabindex><a href=#attr-tabindex>tabindex</a></code> attribute can also make any element into
  <a href=#interactive-content-2 id=interactive-content:interactive-content-2>interactive content</a>.</p>



  <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>palpable content</dfn> and that does
  not have the <code id=palpable-content:the-hidden-attribute><a href=#the-hidden-attribute>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> or <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><code id=palpable-content:the-abbr-element><a href=#the-abbr-element>abbr</a></code><li><code id=palpable-content:the-address-element><a href=#the-address-element>address</a></code><li><code id=palpable-content:the-article-element><a href=#the-article-element>article</a></code><li><code id=palpable-content:the-aside-element><a href=#the-aside-element>aside</a></code><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><code id=palpable-content:the-b-element><a href=#the-b-element>b</a></code><li><code id=palpable-content:the-bdi-element><a href=#the-bdi-element>bdi</a></code><li><code id=palpable-content:the-bdo-element><a href=#the-bdo-element>bdo</a></code><li><code id=palpable-content:the-blockquote-element><a href=#the-blockquote-element>blockquote</a></code><li><code id=palpable-content:the-button-element><a href=#the-button-element>button</a></code><li><code id=palpable-content:the-canvas-element-2><a href=#the-canvas-element>canvas</a></code><li><code id=palpable-content:the-cite-element><a href=#the-cite-element>cite</a></code><li><code id=palpable-content:the-code-element><a href=#the-code-element>code</a></code><li><code id=palpable-content:the-data-element><a href=#the-data-element>data</a></code><li><code id=palpable-content:the-details-element><a href=#the-details-element>details</a></code><li><code id=palpable-content:the-dfn-element><a href=#the-dfn-element>dfn</a></code><li><code id=palpable-content:the-div-element><a href=#the-div-element>div</a></code><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><code id=palpable-content:the-em-element><a href=#the-em-element>em</a></code><li><code id=palpable-content:the-embed-element><a href=#the-embed-element>embed</a></code><li><code id=palpable-content:the-fieldset-element><a href=#the-fieldset-element>fieldset</a></code><li><code id=palpable-content:the-figure-element><a href=#the-figure-element>figure</a></code><li><code id=palpable-content:the-footer-element><a href=#the-footer-element>footer</a></code><li><code id=palpable-content:the-form-element><a href=#the-form-element>form</a></code><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><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><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><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><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><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><code id=palpable-content:the-header-element><a href=#the-header-element>header</a></code><li><code id=palpable-content:the-hgroup-element><a href=#the-hgroup-element>hgroup</a></code><li><code id=palpable-content:the-i-element><a href=#the-i-element>i</a></code><li><code id=palpable-content:the-iframe-element><a href=#the-iframe-element>iframe</a></code><li><code id=palpable-content:the-img-element-2><a href=#the-img-element>img</a></code><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><code id=palpable-content:the-ins-element><a href=#the-ins-element>ins</a></code><li><code id=palpable-content:the-kbd-element><a href=#the-kbd-element>kbd</a></code><li><code id=palpable-content:the-label-element><a href=#the-label-element>label</a></code><li><code id=palpable-content:the-main-element><a href=#the-main-element>main</a></code><li><code id=palpable-content:the-map-element><a href=#the-map-element>map</a></code><li><code id=palpable-content:the-mark-element><a href=#the-mark-element>mark</a></code><li><a id=palpable-content:mathml-math href=https://www.w3.org/Math/draft-spec/chapter2.html#interf.toplevel data-x-internal=mathml-math>MathML <code>math</code></a><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><code id=palpable-content:the-meter-element><a href=#the-meter-element>meter</a></code><li><code id=palpable-content:the-nav-element><a href=#the-nav-element>nav</a></code><li><code id=palpable-content:the-object-element><a href=#the-object-element>object</a></code><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><code id=palpable-content:the-output-element><a href=#the-output-element>output</a></code><li><code id=palpable-content:the-p-element><a href=#the-p-element>p</a></code><li><code id=palpable-content:the-pre-element><a href=#the-pre-element>pre</a></code><li><code id=palpable-content:the-progress-element><a href=#the-progress-element>progress</a></code><li><code id=palpable-content:the-q-element><a href=#the-q-element>q</a></code><li><code id=palpable-content:the-ruby-element><a href=#the-ruby-element>ruby</a></code><li><code id=palpable-content:the-s-element><a href=#the-s-element>s</a></code><li><code id=palpable-content:the-samp-element><a href=#the-samp-element>samp</a></code><li><code id=palpable-content:the-section-element><a href=#the-section-element>section</a></code><li><code id=palpable-content:the-select-element><a href=#the-select-element>select</a></code><li><code id=palpable-content:the-small-element><a href=#the-small-element>small</a></code><li><code id=palpable-content:the-span-element><a href=#the-span-element>span</a></code><li><code id=palpable-content:the-strong-element><a href=#the-strong-element>strong</a></code><li><code id=palpable-content:the-sub-and-sup-elements><a href=#the-sub-and-sup-elements>sub</a></code><li><code id=palpable-content:the-sub-and-sup-elements-2><a href=#the-sub-and-sup-elements>sup</a></code><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><code id=palpable-content:the-table-element><a href=#the-table-element>table</a></code><li><code id=palpable-content:the-textarea-element><a href=#the-textarea-element>textarea</a></code><li><code id=palpable-content:the-time-element><a href=#the-time-element>time</a></code><li><code id=palpable-content:the-u-element><a href=#the-u-element>u</a></code><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><code id=palpable-content:the-var-element><a href=#the-var-element>var</a></code><li><code id=palpable-content:the-video-element-2><a href=#the-video-element>video</a></code><li><a href=#autonomous-custom-element id=palpable-content:autonomous-custom-element>autonomous custom elements</a><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></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><code id=script-supporting-elements:the-template-element><a href=#the-template-element>template</a></code></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>param</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>&quot;/&quot;</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 part of the <code id=transparent-content-models:the-object-element><a href=#the-object-element>object</a></code>
   element's in which the <code id=transparent-content-models:the-ins-element-4><a href=#the-ins-element>ins</a></code> element is found. 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>h1</c-><c- p>&gt;</c->Example of paragraphs<c- p>&lt;/</c-><c- f>h1</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>h1</c-><c- p>&gt;</c->Example of paragraphs<c- p>&lt;/</c-><c- f>h1</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>

  

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

  <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://www.w3.org/Math/draft-spec/chapter2.html#interf.toplevel 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>&quot;about.html&quot;</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&apos;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>&quot;about.html&quot;</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>&quot;about.html&quot;</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>&quot;about.html&quot;</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&apos;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>h1</c-><c- p>&gt;</c->My Cats<c- p>&lt;/</c-><c- f>h1</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>&quot;cats.sim&quot;</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>&quot;cats.sim&quot;</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>&quot;https://sims.example.com/watch?v=LYds5xY4INU&quot;</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&apos;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>The paragraph that says "To see the cat simulator, use one of the following links:".<li>The paragraph that says "Download simulator file".<li>The paragraph that says "Use online simulator".<li>The paragraph that says "Alternatively, upgrade to the Mellblom Browser.".</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>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>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>&quot;cats.sim&quot;</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>&quot;cats.sim&quot;</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>&quot;https://sims.example.com/watch?v=LYds5xY4INU&quot;</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&apos;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>

  <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><code id=global-attributes:attr-autocapitalize><a href=#attr-autocapitalize>autocapitalize</a></code><li><code id=global-attributes:attr-contenteditable><a href=#attr-contenteditable>contenteditable</a></code><li><code id=global-attributes:the-dir-attribute><a href=#the-dir-attribute>dir</a></code><li><code id=global-attributes:the-draggable-attribute><a href=#the-draggable-attribute>draggable</a></code><li><code id=global-attributes:attr-enterkeyhint><a href=#attr-enterkeyhint>enterkeyhint</a></code><li><code id=global-attributes:the-hidden-attribute><a href=#the-hidden-attribute>hidden</a></code><li><code id=global-attributes:attr-inputmode><a href=#attr-inputmode>inputmode</a></code><li><code id=global-attributes:attr-is><a href=#attr-is>is</a></code><li><code id=global-attributes:attr-itemid><a href=#attr-itemid>itemid</a></code><li><code id=global-attributes:names:-the-itemprop-attribute><a href=#names:-the-itemprop-attribute>itemprop</a></code><li><code id=global-attributes:attr-itemref><a href=#attr-itemref>itemref</a></code><li><code id=global-attributes:attr-itemscope><a href=#attr-itemscope>itemscope</a></code><li><code id=global-attributes:attr-itemtype><a href=#attr-itemtype>itemtype</a></code><li><code id=global-attributes:attr-lang><a href=#attr-lang>lang</a></code><li><code id=global-attributes:attr-nonce><a href=#attr-nonce>nonce</a></code><li><code id=global-attributes:attr-spellcheck><a href=#attr-spellcheck>spellcheck</a></code><li><code id=global-attributes:the-style-attribute><a href=#the-style-attribute>style</a></code><li><code id=global-attributes:attr-tabindex><a href=#attr-tabindex>tabindex</a></code><li><code id=global-attributes:attr-title><a href=#attr-title>title</a></code><li><code id=global-attributes:attr-translate><a href=#attr-translate>translate</a></code></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:the-dir-attribute-2><a href=#the-dir-attribute>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>&quot;http://www.w3.org/1999/xhtml&quot;</c-> <c- e>dir</c-><c- o>=</c-><c- s>&quot;rtl&quot;</c-><c- p>&gt;</c->
 <c- p>&lt;</c-><c- f>bogus</c-> <c- e>xmlns</c-><c- o>=</c-><c- s>&quot;https://example.net/ns&quot;</c-> <c- e>dir</c-><c- o>=</c-><c- s>&quot;ltr&quot;</c-><c- p>&gt;</c->
  <c- p>&lt;</c-><c- f>span</c-> <c- e>xmlns</c-><c- o>=</c-><c- s>&quot;http://www.w3.org/1999/xhtml&quot;</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>

  <p>The WHATWG DOM standard defines the user agent requirements for the <dfn id=classes><code>class</code></dfn>, <dfn id=the-id-attribute><code>id</code></dfn>, and <dfn id=attr-slot><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-onabort><a href=#handler-onabort>onabort</a></code><li><code id=global-attributes:handler-onauxclick><a href=#handler-onauxclick>onauxclick</a></code><li><code id=global-attributes:handler-onblur><a href=#handler-onblur>onblur</a></code>*<li><code id=global-attributes:handler-oncancel><a href=#handler-oncancel>oncancel</a></code><li><code id=global-attributes:handler-oncanplay><a href=#handler-oncanplay>oncanplay</a></code><li><code id=global-attributes:handler-oncanplaythrough><a href=#handler-oncanplaythrough>oncanplaythrough</a></code><li><code id=global-attributes:handler-onchange><a href=#handler-onchange>onchange</a></code><li><code id=global-attributes:handler-onclick><a href=#handler-onclick>onclick</a></code><li><code id=global-attributes:handler-onclose><a href=#handler-onclose>onclose</a></code><li><code id=global-attributes:handler-oncontextmenu><a href=#handler-oncontextmenu>oncontextmenu</a></code><li><code id=global-attributes:handler-oncuechange><a href=#handler-oncuechange>oncuechange</a></code><li><code id=global-attributes:handler-ondblclick><a href=#handler-ondblclick>ondblclick</a></code><li><code id=global-attributes:handler-ondrag><a href=#handler-ondrag>ondrag</a></code><li><code id=global-attributes:handler-ondragend><a href=#handler-ondragend>ondragend</a></code><li><code id=global-attributes:handler-ondragenter><a href=#handler-ondragenter>ondragenter</a></code><li><code id=global-attributes:handler-ondragexit><a href=#handler-ondragexit>ondragexit</a></code><li><code id=global-attributes:handler-ondragleave><a href=#handler-ondragleave>ondragleave</a></code><li><code id=global-attributes:handler-ondragover><a href=#handler-ondragover>ondragover</a></code><li><code id=global-attributes:handler-ondragstart><a href=#handler-ondragstart>ondragstart</a></code><li><code id=global-attributes:handler-ondrop><a href=#handler-ondrop>ondrop</a></code><li><code id=global-attributes:handler-ondurationchange><a href=#handler-ondurationchange>ondurationchange</a></code><li><code id=global-attributes:handler-onemptied><a href=#handler-onemptied>onemptied</a></code><li><code id=global-attributes:handler-onended><a href=#handler-onended>onended</a></code><li><code id=global-attributes:handler-onerror><a href=#handler-onerror>onerror</a></code>*<li><code id=global-attributes:handler-onfocus><a href=#handler-onfocus>onfocus</a></code>*<li><code id=global-attributes:handler-oninput><a href=#handler-oninput>oninput</a></code><li><code id=global-attributes:handler-oninvalid><a href=#handler-oninvalid>oninvalid</a></code><li><code id=global-attributes:handler-onkeydown><a href=#handler-onkeydown>onkeydown</a></code><li><code id=global-attributes:handler-onkeypress><a href=#handler-onkeypress>onkeypress</a></code><li><code id=global-attributes:handler-onkeyup><a href=#handler-onkeyup>onkeyup</a></code><li><code id=global-attributes:handler-onload><a href=#handler-onload>onload</a></code>*<li><code id=global-attributes:handler-onloadeddata><a href=#handler-onloadeddata>onloadeddata</a></code><li><code id=global-attributes:handler-onloadedmetadata><a href=#handler-onloadedmetadata>onloadedmetadata</a></code><li><code id=global-attributes:handler-onloadend><a href=#handler-onloadend>onloadend</a></code><li><code id=global-attributes:handler-onloadstart><a href=#handler-onloadstart>onloadstart</a></code><li><code id=global-attributes:handler-onmousedown><a href=#handler-onmousedown>onmousedown</a></code><li><code id=global-attributes:handler-onmouseenter><a href=#handler-onmouseenter>onmouseenter</a></code><li><code id=global-attributes:handler-onmouseleave><a href=#handler-onmouseleave>onmouseleave</a></code><li><code id=global-attributes:handler-onmousemove><a href=#handler-onmousemove>onmousemove</a></code><li><code id=global-attributes:handler-onmouseout><a href=#handler-onmouseout>onmouseout</a></code><li><code id=global-attributes:handler-onmouseover><a href=#handler-onmouseover>onmouseover</a></code><li><code id=global-attributes:handler-onmouseup><a href=#handler-onmouseup>onmouseup</a></code><li><code id=global-attributes:handler-onwheel><a href=#handler-onwheel>onwheel</a></code><li><code id=global-attributes:handler-onpause><a href=#handler-onpause>onpause</a></code><li><code id=global-attributes:handler-onplay><a href=#handler-onplay>onplay</a></code><li><code id=global-attributes:handler-onplaying><a href=#handler-onplaying>onplaying</a></code><li><code id=global-attributes:handler-onprogress><a href=#handler-onprogress>onprogress</a></code><li><code id=global-attributes:handler-onratechange><a href=#handler-onratechange>onratechange</a></code><li><code id=global-attributes:handler-onreset><a href=#handler-onreset>onreset</a></code><li><code id=global-attributes:handler-onresize><a href=#handler-onresize>onresize</a></code>*<li><code id=global-attributes:handler-onscroll><a href=#handler-onscroll>onscroll</a></code>*<li><code id=global-attributes:handler-onsecuritypolicyviolation><a href=#handler-onsecuritypolicyviolation>onsecuritypolicyviolation</a></code><li><code id=global-attributes:handler-onseeked><a href=#handler-onseeked>onseeked</a></code><li><code id=global-attributes:handler-onseeking><a href=#handler-onseeking>onseeking</a></code><li><code id=global-attributes:handler-onselect><a href=#handler-onselect>onselect</a></code><li><code id=global-attributes:handler-onstalled><a href=#handler-onstalled>onstalled</a></code><li><code id=global-attributes:handler-onsubmit><a href=#handler-onsubmit>onsubmit</a></code><li><code id=global-attributes:handler-onsuspend><a href=#handler-onsuspend>onsuspend</a></code><li><code id=global-attributes:handler-ontimeupdate><a href=#handler-ontimeupdate>ontimeupdate</a></code><li><code id=global-attributes:handler-ontoggle><a href=#handler-ontoggle>ontoggle</a></code><li><code id=global-attributes:handler-onvolumechange><a href=#handler-onvolumechange>onvolumechange</a></code><li><code id=global-attributes:handler-onwaiting><a href=#handler-onwaiting>onwaiting</a></code></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, not the "<code>http://www.w3.org/2000/xmlns/</code>" namespace like namespace declaration attributes in
  XML do.</p>

  <p class=note>In XML, an <code>xmlns</code> attribute is part of the namespace
  declaration mechanism, and an element cannot actually have an <code>xmlns</code>
  attribute in no namespace specified.</p>

  <hr>

  <p>The XML specification also allows the use of the <code id=global-attributes:attr-xml-space><a href=#attr-xml-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 href=#attr-xml-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>

  <p>The <dfn id=attr-title><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>&quot;Hypertext</c->
<c- s>Transport Protocol&quot;</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> 

  

  <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 its
   value.<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>.<li><p>Return the empty string.</ol>

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

  <p>The <dfn id=dom-title><code>title</code></dfn> IDL attribute must <a href=#reflect id=the-title-attribute:reflect>reflect</a> the
  <code id=the-title-attribute:attr-title-9><a href=#attr-title>title</a></code> content attribute.</p>

  



  <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 href=#attr-xml-lang>xml:lang</a></code> attributes<a href=#the-lang-and-xml:lang-attributes class=self-link></a></h5>

  <p>The <dfn id=attr-lang><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><code>lang</code></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.</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=#attr-xml-lang id=the-lang-and-xml:lang-attributes:attr-xml-lang-2><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=#attr-xml-lang id=the-lang-and-xml:lang-attributes:attr-xml-lang-3><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=#attr-xml-lang id=the-lang-and-xml:lang-attributes:attr-xml-lang-4><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=#attr-xml-lang id=the-lang-and-xml:lang-attributes:attr-xml-lang-5><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>

  <p>To determine the <dfn id=language>language</dfn> of a node, user agents must look at the nearest ancestor
  element (including the element itself if the node is an element) that has a <a href=#attr-xml-lang id=the-lang-and-xml:lang-attributes:attr-xml-lang-6><code>lang</code> attribute in the <span>XML
  namespace</span></a> set or is an <a href=#html-elements id=the-lang-and-xml:lang-attributes:html-elements-5>HTML element</a> and 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. That attribute specifies the
  language of the node (regardless of its value).</p>

  <p>If both the <code id=the-lang-and-xml:lang-attributes:attr-lang-6><a href=#attr-lang>lang</a></code> attribute in no namespace and the <a href=#attr-xml-lang id=the-lang-and-xml:lang-attributes:attr-xml-lang-7><code>lang</code> attribute in the <span>XML
  namespace</span></a> are set on an element, user agents must use the <a href=#attr-xml-lang id=the-lang-and-xml:lang-attributes:attr-xml-lang-8><code>lang</code> attribute in the <span>XML
  namespace</span></a>, and the <code id=the-lang-and-xml:lang-attributes:attr-lang-7><a href=#attr-lang>lang</a></code> attribute in no namespace
  must be <a href=#ignore id=the-lang-and-xml:lang-attributes:ignore>ignored</a> for the purposes of determining the element's
  language.</p>

  <p>If node's <a href=https://dom.spec.whatwg.org/#concept-tree-inclusive-ancestor id=the-lang-and-xml:lang-attributes:inclusive-ancestor data-x-internal=inclusive-ancestor>inclusive ancestors</a> do not have either
  attribute set, but 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>

  <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 explicitly unknown.</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>

  

  <hr>

  <p>The <dfn id=dom-lang><code>lang</code></dfn> IDL attribute must <a href=#reflect id=the-lang-and-xml:lang-attributes:reflect>reflect</a> the
  <code id=the-lang-and-xml:lang-attributes:attr-lang-8><a href=#attr-lang>lang</a></code> content attribute in no namespace.</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>

  

  <p>The <dfn id=attr-translate><code>translate</code></dfn> attribute is an <a href=#enumerated-attribute id=the-translate-attribute:enumerated-attribute>enumerated
  attribute</a> that 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.</p>

  <p>The attribute's keywords are the empty string, <code>yes</code>, and <code>no</code>. The empty string and the <code>yes</code> keyword map to the
  <i>yes</i> state. The <code>no</code> keyword maps to the <i>no</i> state. In addition,
  there is a third state, the <i>inherit</i> state, which is the <i id=the-translate-attribute:missing-value-default><a href=#missing-value-default>missing value default</a></i> and the <i id=the-translate-attribute:invalid-value-default><a href=#invalid-value-default>invalid value default</a></i>.</p>

  <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>translate-enabled</a> state or the <a href=#no-translate id=the-translate-attribute:no-translate>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 <i>yes</i> state, then the element's <a href=#translation-mode id=the-translate-attribute:translation-mode>translation mode</a> is in the
  <a href=#translate-enabled id=the-translate-attribute:translate-enabled-2>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 <i>no</i> state, then the element's
  <a href=#translation-mode id=the-translate-attribute:translation-mode-2>translation mode</a> is in the <a href=#no-translate id=the-translate-attribute:no-translate-2>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 <i>inherit</i> 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-3>translation mode</a> is in the same state as its parent element's, if any, or in the
  <a href=#translate-enabled id=the-translate-attribute:translate-enabled-3>translate-enabled</a> state, if the element is a <a id=the-translate-attribute:document-element href=https://dom.spec.whatwg.org/#document-element data-x-internal=document-element>document element</a>.</p>

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

  <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><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><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><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><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><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><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><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><code id=the-translate-attribute:the-style-attribute><a href=#the-style-attribute>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/generate.html#content data-x-internal="'content'">'content'</a> properties)<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><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</ul>

  <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, ARIA 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/aria.html#aria-label>aria-label</a></code> attribute as translatable.</p>

  

  <hr>

  <p>The <dfn id=dom-translate><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-4>translation mode</a> is <a href=#translate-enabled id=the-translate-attribute:translate-enabled-4>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 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 <dfn><code>dir</code></dfn> attribute<a href=#the-dir-attribute class=self-link></a></h5>

  <p>The <code id=the-dir-attribute:the-dir-attribute><a href=#the-dir-attribute>dir</a></code> attribute specifies the element's text directionality.
  The attribute is an <a href=#enumerated-attribute id=the-dir-attribute:enumerated-attribute>enumerated attribute</a> with the following keywords and states:</p>

  <dl><dt>The <dfn id=attr-dir-ltr><code>ltr</code></dfn> keyword, which maps to the <dfn id=attr-dir-ltr-state>ltr</dfn> state<dd>

    <p>Indicates that the contents of the element are explicitly directionally isolated
    left-to-right text.</p>

   <dt>The <dfn id=attr-dir-rtl><code>rtl</code></dfn> keyword, which maps to the <dfn id=attr-dir-rtl-state>rtl</dfn> state<dd>

    <p>Indicates that the contents of the element are explicitly directionally isolated
    right-to-left text.</p>

   <dt>The <dfn id=attr-dir-auto><code>auto</code></dfn> keyword, which maps to the <dfn id=attr-dir-auto-state>auto</dfn> state<dd>

    <p>Indicates that the contents of the element are explicitly directionally isolated text, but
    that the direction is to be determined programmatically using the contents of the element (as
    described below).</p>

    <p class=note>The heuristic used by this 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 class=note>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>

   </dl>

  <p>The attribute has no <i id=the-dir-attribute:invalid-value-default><a href=#invalid-value-default>invalid value default</a></i> and no <i id=the-dir-attribute:missing-value-default><a href=#missing-value-default>missing value default</a></i>.</p>

  <hr>

  <p><dfn id=the-directionality>The 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>', and is determined as per the first appropriate set of steps from
  the following list:</p>

  <dl class=switch><dt>If the element's <code id=the-dir-attribute:the-dir-attribute-2><a href=#the-dir-attribute>dir</a></code> attribute is in the <a href=#attr-dir-ltr-state id=the-dir-attribute:attr-dir-ltr-state>ltr</a> state<dt>If the element is a <a id=the-dir-attribute:document-element href=https://dom.spec.whatwg.org/#document-element data-x-internal=document-element>document element</a> and the <code id=the-dir-attribute:the-dir-attribute-3><a href=#the-dir-attribute>dir</a></code>
   attribute is not in a defined state (i.e. it is not present or has an invalid value)<dt>If the element 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, and the <code id=the-dir-attribute:the-dir-attribute-4><a href=#the-dir-attribute>dir</a></code>
   attribute is not in a defined state (i.e. it is not present or has an invalid value)<dd><p><a href=#the-directionality id=the-dir-attribute:the-directionality>The directionality</a> of the element is '<a href=#concept-ltr id=the-dir-attribute:concept-ltr>ltr</a>'.<dt>If the element's <code id=the-dir-attribute:the-dir-attribute-5><a href=#the-dir-attribute>dir</a></code> attribute is in the <a href=#attr-dir-rtl-state id=the-dir-attribute:attr-dir-rtl-state>rtl</a> state<dd><p><a href=#the-directionality id=the-dir-attribute:the-directionality-2>The directionality</a> of the element is '<a href=#concept-rtl id=the-dir-attribute:concept-rtl>rtl</a>'.<dt>If the element is an <code id=the-dir-attribute:the-input-element-2><a href=#the-input-element>input</a></code> element whose <code id=the-dir-attribute: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-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>, or <a href="#e-mail-state-(type=email)" id="the-dir-attribute:e-mail-state-(type=email)">E-mail</a>
   state, and the <code id=the-dir-attribute:the-dir-attribute-6><a href=#the-dir-attribute>dir</a></code> attribute is in the <a href=#attr-dir-auto-state id=the-dir-attribute:attr-dir-auto-state>auto</a> state<dt>If the element is a <code id=the-dir-attribute:the-textarea-element-2><a href=#the-textarea-element>textarea</a></code> element and the <code id=the-dir-attribute:the-dir-attribute-7><a href=#the-dir-attribute>dir</a></code>
   attribute is in the <a href=#attr-dir-auto-state id=the-dir-attribute:attr-dir-auto-state-2>auto</a> state<dd>

    <p>If the element'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
    <a href=#the-directionality id=the-dir-attribute:the-directionality-3>the directionality</a> of the element is '<a href=#concept-rtl id=the-dir-attribute:concept-rtl-2>rtl</a>'. <a href=#refsBIDI>[BIDI]</a></p>

    <p>Otherwise, if the element's <a href=#concept-fe-value id=the-dir-attribute:concept-fe-value-3>value</a> is not the empty
    string, or if the element is a <a id=the-dir-attribute:document-element-2 href=https://dom.spec.whatwg.org/#document-element data-x-internal=document-element>document element</a>, <a href=#the-directionality id=the-dir-attribute:the-directionality-4>the directionality</a> of
    the element is '<a href=#concept-ltr id=the-dir-attribute:concept-ltr-2>ltr</a>'.</p>

    <p>Otherwise, <a href=#the-directionality id=the-dir-attribute:the-directionality-5>the directionality</a> of the element is the same as the element's parent
    element's <a href=#the-directionality id=the-dir-attribute:the-directionality-6>directionality</a>.</p>

   <dt>If the element's <code id=the-dir-attribute:the-dir-attribute-8><a href=#the-dir-attribute>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>If the element is a <code id=the-dir-attribute:the-bdi-element><a href=#the-bdi-element>bdi</a></code> element and the <code id=the-dir-attribute:the-dir-attribute-9><a href=#the-dir-attribute>dir</a></code>
   attribute is not in a defined state (i.e. it is not present or has an invalid value)<dd>

    <p>Find the first character 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> that matches the following criteria:</p>

    <ul><li><p>The character is from a <code id=the-dir-attribute:text><a data-x-internal=text href=https://dom.spec.whatwg.org/#interface-text>Text</a></code> node that is a descendant of the element whose
     <a href=#the-directionality id=the-dir-attribute:the-directionality-7>directionality</a> is being determined.<li><p>The character is of bidirectional character type L, AL, or R. <a href=#refsBIDI>[BIDI]</a><li>

      <p>The character is not in 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 that has an ancestor element that is a
      descendant of the element whose <a href=#the-directionality id=the-dir-attribute:the-directionality-8>directionality</a> is
      being determined and that is either:</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>A <code id=the-dir-attribute:the-script-element><a href=#the-script-element>script</a></code> element.
       <li>A <code id=the-dir-attribute:the-style-element><a href=#the-style-element>style</a></code> element.
       <li>A <code id=the-dir-attribute:the-textarea-element-3><a href=#the-textarea-element>textarea</a></code> element.
       <li>An element with a <code id=the-dir-attribute:the-dir-attribute-10><a href=#the-dir-attribute>dir</a></code> attribute in a defined state.
      </ul>

     </ul>

    <p>If such a character is found and it is of bidirectional character type AL or R, <a href=#the-directionality id=the-dir-attribute:the-directionality-9>the
    directionality</a> of the element is '<a href=#concept-rtl id=the-dir-attribute:concept-rtl-3>rtl</a>'.</p>

    <p>If such a character is found and it is of bidirectional character type L, <a href=#the-directionality id=the-dir-attribute:the-directionality-10>the
    directionality</a> of the element is '<a href=#concept-ltr id=the-dir-attribute:concept-ltr-3>ltr</a>'.</p>

    <p>Otherwise, if the element is a <a id=the-dir-attribute:document-element-3 href=https://dom.spec.whatwg.org/#document-element data-x-internal=document-element>document element</a>, <a href=#the-directionality id=the-dir-attribute:the-directionality-11>the directionality</a>
    of the element is '<a href=#concept-ltr id=the-dir-attribute:concept-ltr-4>ltr</a>'.</p>

    <p>Otherwise, <a href=#the-directionality id=the-dir-attribute:the-directionality-12>the directionality</a> of the element is the same as the element's parent
    element's <a href=#the-directionality id=the-dir-attribute:the-directionality-13>directionality</a>.</p>

   <dt>If the element has a parent element and the <code id=the-dir-attribute:the-dir-attribute-11><a href=#the-dir-attribute>dir</a></code> attribute is
   not in a defined state (i.e. it is not present or has an invalid value)<dd><p><a href=#the-directionality id=the-dir-attribute:the-directionality-14>The directionality</a> of the element is the same as the element's parent
   element's <a href=#the-directionality id=the-dir-attribute:the-directionality-15>directionality</a>.</dl>

  <p class=note>Since the <code id=the-dir-attribute:the-dir-attribute-12><a href=#the-dir-attribute>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 just inherit their <a href=#the-directionality id=the-dir-attribute:the-directionality-16>directionality</a> from their parent element, or, if they don't have one,
  default to '<a href=#concept-ltr id=the-dir-attribute:concept-ltr-5>ltr</a>'.</p>

  

  <p class=note>This attribute <a href=#bidireq>has rendering requirements involving the
  bidirectional algorithm</a>.</p>

  

  <hr>

  <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:the-dir-attribute-13><a href=#the-dir-attribute>dir</a></code> attribute is in the <a href=#attr-dir-auto-state id=the-dir-attribute:attr-dir-auto-state-4>auto</a>
   state<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-6>ltr</a>'.</p>

   <dt>Otherwise<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-17>the element's directionality</a>.</dl>

  <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><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><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><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><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><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></ul>

  <hr>

  <dl class=domintro><dt><var>document</var> . <code id=dom-dir-dev><a href=#dom-dir>dir</a></code> [ = <var>value</var> ]<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:the-dir-attribute-14><a href=#the-dir-attribute>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:the-dir-attribute-15><a href=#the-dir-attribute>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>
   </dl>

  

  <p>The <dfn id=dom-dir><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:the-dir-attribute-16><a href=#the-dir-attribute>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>

  <p>The <dfn id=dom-document-dir><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:the-dir-attribute-17><a href=#the-dir-attribute>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>

  

  <p class=note>Authors are strongly encouraged to use the <code id=the-dir-attribute:the-dir-attribute-18><a href=#the-dir-attribute>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>&quot;u1&quot;</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 &quot;What&apos;s your name?&quot; 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>&quot;u2&quot;</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>&quot;u1&quot;</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>&quot;u2&quot;</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&apos;s written &quot;شكرًا&quot;.<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>&quot;u2&quot;</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 &quot;Please&quot;?<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>&quot;u1&quot;</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-> &quot;من فضلك&quot;, 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 <dfn><code>style</code></dfn> attribute<a href=#the-style-attribute class=self-link></a></h5>

  <p>All <a href=#html-elements id=the-style-attribute:html-elements>HTML elements</a> may have the <code id=the-style-attribute:the-style-attribute><a href=#the-style-attribute>style</a></code> 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
  the <cite>CSS Style Attributes</cite> specification. <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:the-style-attribute-2><a href=#the-style-attribute>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:the-style-attribute-3><a href=#the-style-attribute>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:the-hidden-attribute><a href=#the-hidden-attribute>hidden</a></code>
  attribute.)</p>

  <hr>

  <dl class=domintro><dt><var>element</var> . <code id=dom-style-dev><a href=#dom-style>style</a></code><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:the-style-attribute-4><a href=#the-style-attribute>style</a></code> attribute.</p>
   </dl>

  

  <p>The <dfn id=dom-style><code>style</code></dfn> IDL attribute is defined in the CSS Object
  Model (CSSOM) specification. <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:the-style-attribute-5><a href=#the-style-attribute>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>&quot;color: green; background:</c->
<c- s>transparent&quot;</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>&quot;color: blue;</c->
<c- s>background: transparent&quot;</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=status><input onclick=toggleStatus(this) value=⋰ type=button><p class=support><strong>Support:</strong> dataset<span class="and_chr yes"><span>Chrome for Android</span> <span>67+</span></span><span class="chrome yes"><span>Chrome</span> <span>7+</span></span><span class="ios_saf yes"><span>iOS Safari</span> <span>5.0+</span></span><span class="and_uc yes"><span>UC Browser for Android</span> <span>11.8+</span></span><span class="firefox yes"><span>Firefox</span> <span>6+</span></span><span class="ie yes"><span>IE</span> <span>11+</span></span><span class="op_mini partial"><span>Opera Mini (limited)</span> <span>all+</span></span><span class="safari yes"><span>Safari</span> <span>5.1+</span></span><span class="edge yes"><span>Edge</span> <span>12+</span></span><span class="samsung yes"><span>Samsung Internet</span> <span>4+</span></span><span class="opera yes"><span>Opera</span> <span>11.1+</span></span><span class="android yes"><span>Android Browser</span> <span>3+</span></span><p class=caniuse>Source: <a href="https://caniuse.com/#feat=dataset">caniuse.com</a></div>

  <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 href=#xml-compatible id=embedding-custom-non-visible-data-with-the-data-*-attributes:xml-compatible>XML-compatible</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>

  <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>&quot;2m11s&quot;</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>&quot;Anspruch&quot;</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>&quot;no&quot;</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>&apos;PaymentRequest&apos;</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>&apos;&apos;</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><var>element</var> . <code id=dom-dataset-dev><a href=#dom-dataset>dataset</a></code><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>

   </dl>

  

  <p>The <dfn id=dom-dataset><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>

  

  <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->,
 <c- g>OverrideBuiltins</c->]
<c- b>interface</c-> <dfn id='domstringmap'><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>void</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>void</c-> (<c- b>DOMString</c-> <c- g>name</c->);
};</code></pre>

  

  <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.<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.<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>.<li><p>Return <var>list</var>.</ol>

  <p>The <a id=embedding-custom-non-visible-data-with-the-data-*-attributes:supported-property-names href=https://heycam.github.io/webidl/#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>

  <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://heycam.github.io/webidl/#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>

  <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://heycam.github.io/webidl/#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://heycam.github.io/webidl/#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://heycam.github.io/webidl/#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://heycam.github.io/webidl/#dfn-DOMException>DOMException</a></code>.<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>.<li><p>Insert the string <code>data-</code> at the front of <var>name</var>.<li><p>If <var>name</var> does not match the XML <code id=embedding-custom-non-visible-data-with-the-data-*-attributes:xml-name><a data-x-internal=xml-name href=https://www.w3.org/TR/xml/#NT-Name>Name</a></code> production,
   throw an <a id=embedding-custom-non-visible-data-with-the-data-*-attributes:invalidcharactererror href=https://heycam.github.io/webidl/#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://heycam.github.io/webidl/#dfn-DOMException>DOMException</a></code>.<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>.</ol>

  <p id=dom-domstringmap-removeitem>To <a id=embedding-custom-non-visible-data-with-the-data-*-attributes:delete-an-existing-named-property href=https://heycam.github.io/webidl/#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>.<li><p>Insert the string <code>data-</code> at the front of <var>name</var>.<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>.</ol>

  <p class=note>This algorithm will only get invoked by the Web IDL specification 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>&quot;spaceship&quot;</c-> <c- e>data-ship-id</c-><c- o>=</c-><c- s>&quot;92432&quot;</c->
     <c- e>data-weapons</c-><c- o>=</c-><c- s>&quot;laser 2&quot;</c-> <c- e>data-shields</c-><c- o>=</c-><c- s>&quot;50%&quot;</c->
     <c- e>data-</c-><c- e>x</c-><c- o>=</c-><c- s>&quot;30&quot;</c-> <c- e>data-y</c-><c- o>=</c-><c- s>&quot;10&quot;</c-> <c- e>data-z</c-><c- o>=</c-><c- s>&quot;90&quot;</c-><c- p>&gt;</c->
 <c- p>&lt;</c-><c- f>button</c-> <c- e>class</c-><c- o>=</c-><c- s>&quot;fire&quot;</c->
         <c- e>onclick</c-><c- o>=</c-><c- s>&quot;spaceships[this.parentNode.dataset.shipId].fire()&quot;</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>&quot;tower&quot;</c-> <c- e>id</c-><c- o>=</c-><c- s>&quot;tower5&quot;</c-> <c- e>data-</c-><c- e>x</c-><c- o>=</c-><c- s>&quot;12&quot;</c-> <c- e>data-y</c-><c- o>=</c-><c- s>&quot;5&quot;</c->
     <c- e>data-ai</c-><c- o>=</c-><c- s>&quot;robotarget&quot;</c-> <c- e>data-hp</c-><c- o>=</c-><c- s>&quot;46&quot;</c-> <c- e>data-ability</c-><c- o>=</c-><c- s>&quot;flames&quot;</c->
     <c- e>src</c-><c- o>=</c-><c- s>&quot;towers/rocket.png&quot;</c-> <c- e>alt</c-><c- o>=</c-><c- s>&quot;Rocket Tower&quot;</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>&apos;tower&apos;</c-><c- p>)</c-> <c- o>&amp;&amp;</c-> <c- c1>// checking the &apos;class&apos; attribute</c->
      node<c- p>.</c->dataset<c- p>.</c->x <c- o>==</c-> x <c- o>&amp;&amp;</c-> <c- c1>// reading the &apos;data-x&apos; 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 &apos;data-y&apos; 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 &apos;data-hp&apos; 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- mi>0</c-><c- p>)</c-> <c- p>{</c->
      hp <c- o>=</c-> <c- mi>0</c-><c- p>;</c->
      node<c- p>.</c->dataset<c- p>.</c->ai <c- o>=</c-> <c- t>&apos;dead&apos;</c-><c- p>;</c-> <c- c1>// setting the &apos;data-ai&apos; attribute</c->
      <c- k>delete</c-> node<c- p>.</c->dataset<c- p>.</c->ability<c- p>;</c-> <c- c1>// removing the &apos;data-ability&apos; 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 &apos;data-hp&apos; 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> IDL attribute<a href=#the-innertext-idl-attribute class=self-link></a></h4><div class=status><input onclick=toggleStatus(this) value=⋰ type=button><p class=support><strong>Support:</strong> innertext<span class="and_chr yes"><span>Chrome for Android</span> <span>67+</span></span><span class="chrome yes"><span>Chrome</span> <span>4+</span></span><span class="ios_saf yes"><span>iOS Safari</span> <span>4.0+</span></span><span class="and_uc yes"><span>UC Browser for Android</span> <span>11.8+</span></span><span class="firefox yes"><span>Firefox</span> <span>45+</span></span><span class="ie yes"><span>IE</span> <span>6+</span></span><span class="op_mini yes"><span>Opera Mini</span> <span>all+</span></span><span class="safari yes"><span>Safari</span> <span>3.2+</span></span><span class="edge yes"><span>Edge</span> <span>12+</span></span><span class="samsung yes"><span>Samsung Internet</span> <span>4+</span></span><span class="opera yes"><span>Opera</span> <span>9.5+</span></span><span class="android yes"><span>Android Browser</span> <span>2.3+</span></span><p class=caniuse>Source: <a href="https://caniuse.com/#feat=innertext">caniuse.com</a></div>

  <dl class=domintro><dt><var>element</var> . <code id=dom-innertext-dev><a href=#dom-innertext>innerText</a></code> [ = <var>value</var> ]<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>

  </dl>

  

  <p>On getting, the <dfn id=dom-innertext><code>innerText</code></dfn> attribute must follow
  these steps:</p>

  <ol><li>
    <p>If this element 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 the same value as the <code id=the-innertext-idl-attribute:textcontent><a data-x-internal=textcontent href=https://dom.spec.whatwg.org/#dom-node-textcontent>textContent</a></code> IDL attribute on this
    element.</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> attribute is accessed 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>
    <p>Let <var>results</var> be the <a id=the-innertext-idl-attribute:list href=https://infra.spec.whatwg.org/#list data-x-internal=list>list</a> resulting in running the <a href=#inner-text-collection-steps id=the-innertext-idl-attribute:inner-text-collection-steps>inner text
    collection steps</a> with this element. Each item in <var>results</var> will either be a
    <a id=the-innertext-idl-attribute:javascript-string href=https://infra.spec.whatwg.org/#javascript-string data-x-internal=javascript-string>JavaScript 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><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.<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>.<li><p><a href=https://infra.spec.whatwg.org/#list-remove 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 LINE FEED (LF) characters
   as the maximum of the values in the <i>required line break count</i> items.<li><p>Return the concatenation of the string items in <var>results</var>.</ol>

  <p>The <dfn id=inner-text-collection-steps>inner 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=#inner-text-collection-steps id=the-innertext-idl-attribute:inner-text-collection-steps-2>inner 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-2 href=https://infra.spec.whatwg.org/#list data-x-internal=list>list</a>.<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/visufx.html#propdef-visibility data-x-internal="'visibility'">'visibility'</a> is not
   'visible', then return <var>items</var>.<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/visuren.html#display-prop data-x-internal="'display'">'display'</a> property is not 'none':</p>

    <ul class=brief><li><code id=the-innertext-idl-attribute:the-select-element><a href=#the-select-element>select</a></code> elements have an associated non-replaced inline CSS box 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 child
     nodes;<li><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 CSS box 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 child nodes; and<li><code id=the-innertext-idl-attribute:the-option-element-3><a href=#the-option-element>option</a></code> element have an associated non-replaced block-level CSS box whose
     child boxes are as normal for non-replaced block-level CSS boxes.</ul>

    <p class=note><var>items</var> can be non-empty due to 'display:contents'.</p>
   <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-3 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-2><a href=#the-br-element>br</a></code> element. Soft hyphens should be preserved. <a href=#refsCSSTEXT>[CSSTEXT]</a><li><p>If <var>node</var> is a <code id=the-innertext-idl-attribute:the-br-element-3><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 LINE FEED (LF) character to
   <var>items</var>.<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/visuren.html#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 CSS box 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 CHARACTER TABULATION (tab)
   character to <var>items</var>.<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/visuren.html#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 CSS box 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 LINE FEED (LF) character to
   <var>items</var>.<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>.<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/visuren.html#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><p>Return <var>items</var>.</ol>

  <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 CSS boxes for the purposes of this algorithm.</p>

  <p class=big-issue>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>

  <p>On setting, the <code id=the-innertext-idl-attribute:dom-innertext-3><a href=#dom-innertext>innerText</a></code> attribute must follow these
  steps:</p>

  <ol><li><p>Let <var>document</var> be this element'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>.<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> object whose <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> is <var>document</var>.<li><p>Let <var>input</var> be the given value.<li><p>Let <var>position</var> be a pointer into <var>input</var>, initially pointing at the start
   of the string.<li><p>Let <var>text</var> be the empty string.<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 LINE FEED (LF) or
     U+000D CARRIAGE RETURN (CR) characters from <var>input</var> given <var>position</var>. Set
     <var>text</var> to the collected characters.<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 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 <var>text</var> 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
     <var>document</var> to <var>fragment</var>.<li>
      <p>While <var>position</var> is not past the end of <var>input</var>, and the character at
      <var>position</var> is either a U+000A LINE FEED (LF) or U+000D CARRIAGE RETURN (CR)
      character:</p>

      <ol><li><p>If the character at <var>position</var> is a U+000D CARRIAGE RETURN (CR) character and
       the next character is a U+000A LINE FEED (LF) character, then advance <var>position</var> to
       the next character in <var>input</var>.<li><p>Advance <var>position</var> to the next character in <var>input</var>.<li><p><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> 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 id=the-innertext-idl-attribute:the-br-element-4><a href=#the-br-element>br</a></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>.</ol>
     </ol>
   <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
   this element.</ol>

  

  <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:the-dir-attribute><a href=#the-dir-attribute>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/generate.html#content 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:the-dir-attribute><a href=#the-dir-attribute>dir</a></code> attribute<li><code id=user-agent-conformance-criteria:the-bdi-element><a href=#the-bdi-element>bdi</a></code> element<li><code id=user-agent-conformance-criteria:the-bdo-element><a href=#the-bdo-element>bdo</a></code> element<li><code id=user-agent-conformance-criteria:the-br-element><a href=#the-br-element>br</a></code> element<li><code id=user-agent-conformance-criteria:the-pre-element><a href=#the-pre-element>pre</a></code> element<li><code id=user-agent-conformance-criteria:the-textarea-element><a href=#the-textarea-element>textarea</a></code> element<li><code id=user-agent-conformance-criteria:the-wbr-element><a href=#the-wbr-element>wbr</a></code> element</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>

  <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>. <a href=#refsHTMLAAM>[HTMLAAM]</a></p>

  <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><code>html</code></dfn> element<a href=#the-html-element class=self-link></a></h4>

  <dl class=element><dt><a href=#concept-element-categories id=the-html-element:concept-element-categories>Categories</a>:<dd>None.<dt><a href=#concept-element-contexts id=the-html-element:concept-element-contexts>Contexts in which this element can be used</a>:<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>Wherever a subdocument fragment is allowed in a compound document.<dt><a href=#concept-element-content-model id=the-html-element:concept-element-content-model>Content model</a>:<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.<dt><a href=#concept-element-tag-omission id=the-html-element:concept-element-tag-omission>Tag omission in text/html</a>:<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>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>.<dt><a href=#concept-element-attributes id=the-html-element:concept-element-attributes>Content attributes</a>:<dd><a href=#global-attributes id=the-html-element:global-attributes>Global attributes</a><dd><code id=the-html-element:attr-html-manifest><a href=#attr-html-manifest>manifest</a></code> — <a href=#concept-appcache-manifest id=the-html-element:concept-appcache-manifest>Application cache manifest</a><dt><a href=#concept-element-dom id=the-html-element:concept-element-dom>DOM interface</a>:<dd>
    <pre><code class='idl'>[<c- g>Exposed</c->=<c- n>Window</c->,
 <a href='#htmlconstructor' id='the-html-element:htmlconstructor'><c- g>HTMLConstructor</c-></a>]
<c- b>interface</c-> <dfn id='htmlhtmlelement'><c- g>HTMLHtmlElement</c-></dfn> : <a href='#htmlelement' id='the-html-element:htmlelement'><c- n>HTMLElement</c-></a> {};</code></pre>
   </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>

  <p>The <dfn id=attr-html-manifest><code>manifest</code></dfn> attribute gives the address of
  the document's <a href=#application-cache id=the-html-element:application-cache>application cache</a> <a href=#concept-appcache-manifest id=the-html-element:concept-appcache-manifest-2>manifest</a>, if there is one. If the attribute is present,
  the attribute's value must be a <a href=#valid-non-empty-url-potentially-surrounded-by-spaces id=the-html-element:valid-non-empty-url-potentially-surrounded-by-spaces>valid non-empty URL potentially surrounded by
  spaces</a>.</p>

  <p class=critical>The <code id=the-html-element:attr-html-manifest-2><a href=#attr-html-manifest>manifest</a></code> attribute is part of the
  legacy "<a href=#offline>offline Web applications</a>" feature, which is in the process of being
  removed from the Web platform. (This is a long process that takes many years.) Using the <code id=the-html-element:attr-html-manifest-3><a href=#attr-html-manifest>manifest</a></code> attribute at this time is highly discouraged. Use
  service workers instead. <a href=#refsSW>[SW]</a></p>

  <p>The <code id=the-html-element:attr-html-manifest-4><a href=#attr-html-manifest>manifest</a></code> attribute only <a href=#concept-appcache-init id=the-html-element:concept-appcache-init>has an effect</a> during the early stages of document load.
  Changing the attribute dynamically thus has no effect (and thus, no DOM API is provided for this
  attribute).</p>

  <p class=note>For the purposes of <a href=#concept-appcache-init id=the-html-element:concept-appcache-init-2>application cache
  selection</a>, later <code id=the-html-element:the-base-element><a href=#the-base-element>base</a></code> elements cannot affect the <a href=#parse-a-url id=the-html-element:parse-a-url>parsing of URLs</a> in <code id=the-html-element:attr-html-manifest-5><a href=#attr-html-manifest>manifest</a></code> attributes, as
  the attributes are processed before those elements are seen.</p>

  <p class=note>The <code id=the-html-element:dom-applicationcache><a href=#dom-applicationcache>window.applicationCache</a></code> IDL
  attribute provides scripted access to the offline <a href=#application-cache id=the-html-element:application-cache-2>application cache</a> mechanism.</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>&quot;en&quot;</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 data-dfn-type=element data-lt=head><span class=secno>4.2.1</span> The <dfn><code>head</code></dfn> element<a href=#the-head-element class=self-link></a></h4>

  <dl class=element><dt><a href=#concept-element-categories id=the-head-element:concept-element-categories>Categories</a>:<dd>None.<dt><a href=#concept-element-contexts id=the-head-element:concept-element-contexts>Contexts in which this element can be used</a>:<dd>As the first element in an <code id=the-head-element:the-html-element><a href=#the-html-element>html</a></code> element.<dt><a href=#concept-element-content-model id=the-head-element:concept-element-content-model>Content model</a>:<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>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.<dt><a href=#concept-element-tag-omission id=the-head-element:concept-element-tag-omission>Tag omission in text/html</a>:<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>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>.<dt><a href=#concept-element-attributes id=the-head-element:concept-element-attributes>Content attributes</a>:<dd><a href=#global-attributes id=the-head-element:global-attributes>Global attributes</a><dt><a href=#concept-element-dom id=the-head-element:concept-element-dom>DOM interface</a>:<dd>
    <pre><code class='idl'>[<c- g>Exposed</c->=<c- n>Window</c->,
 <a href='#htmlconstructor' id='the-head-element:htmlconstructor'><c- g>HTMLConstructor</c-></a>]
<c- b>interface</c-> <dfn id='htmlheadelement'><c- g>HTMLHeadElement</c-></dfn> : <a href='#htmlelement' id='the-head-element:htmlelement'><c- n>HTMLElement</c-></a> {};</code></pre>
   </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>&quot;EN&quot;</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>&quot;UTF-8&quot;</c-><c- p>&gt;</c->
  <c- p>&lt;</c-><c- f>BASE</c-> <c- e>HREF</c-><c- o>=</c-><c- s>&quot;https://www.example.com/&quot;</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>&quot;STYLESHEET&quot;</c-> <c- e>HREF</c-><c- o>=</c-><c- s>&quot;default.css&quot;</c-><c- p>&gt;</c->
  <c- p>&lt;</c-><c- f>LINK</c-> <c- e>REL</c-><c- o>=</c-><c- s>&quot;STYLESHEET ALTERNATE&quot;</c-> <c- e>HREF</c-><c- o>=</c-><c- s>&quot;big.css&quot;</c-> <c- e>TITLE</c-><c- o>=</c-><c- s>&quot;Big Text&quot;</c-><c- p>&gt;</c->
  <c- p>&lt;</c-><c- f>SCRIPT</c-> <c- e>SRC</c-><c- o>=</c-><c- s>&quot;support.js&quot;</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>&quot;APPLICATION-NAME&quot;</c-> <c- e>CONTENT</c-><c- o>=</c-><c- s>&quot;Long headed application&quot;</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 e-mail when HTML
  is used as an e-mail 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><code>title</code></dfn> element<a href=#the-title-element class=self-link></a></h4>

  <dl class=element><dt><a href=#concept-element-categories id=the-title-element:concept-element-categories>Categories</a>:<dd><a href=#metadata-content-2 id=the-title-element:metadata-content-2>Metadata content</a>.<dt><a href=#concept-element-contexts id=the-title-element:concept-element-contexts>Contexts in which this element can be used</a>:<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.<dt><a href=#concept-element-content-model id=the-title-element:concept-element-content-model>Content model</a>:<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>.<dt><a href=#concept-element-tag-omission id=the-title-element:concept-element-tag-omission>Tag omission in text/html</a>:<dd>Neither tag is omissible.<dt><a href=#concept-element-attributes id=the-title-element:concept-element-attributes>Content attributes</a>:<dd><a href=#global-attributes id=the-title-element:global-attributes>Global attributes</a><dt><a href=#concept-element-dom id=the-title-element:concept-element-dom>DOM interface</a>:<dd>
    <pre><code class='idl'>[<c- g>Exposed</c->=<c- n>Window</c->,
 <a href='#htmlconstructor' id='the-title-element:htmlconstructor'><c- g>HTMLConstructor</c-></a>]
<c- b>interface</c-> <dfn id='htmltitleelement'><c- g>HTMLTitleElement</c-></dfn> : <a href='#htmlelement' id='the-title-element:htmlelement'><c- n>HTMLElement</c-></a> {
  [<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>
   </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><var>title</var> . <code id=dom-title-text-dev><a href=#dom-title-text>text</a></code> [ = <var>value</var> ]<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>

   </dl>

  

  <p>The IDL attribute <dfn id=dom-title-text><code>text</code></dfn> must return the
  <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> of the <code id=the-title-element:the-title-element-5><a href=#the-title-element>title</a></code> element. On setting, it must act the
  same way as the <code id=the-title-element:textcontent><a data-x-internal=textcontent href=https://dom.spec.whatwg.org/#dom-node-textcontent>textContent</a></code> IDL attribute.</p>

  

  <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-6><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-7><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 data-dfn-type=element data-lt=base><span class=secno>4.2.3</span> The <dfn><code>base</code></dfn> element<a href=#the-base-element class=self-link></a></h4>

  <dl class=element><dt><a href=#concept-element-categories id=the-base-element:concept-element-categories>Categories</a>:<dd><a href=#metadata-content-2 id=the-base-element:metadata-content-2>Metadata content</a>.<dt><a href=#concept-element-contexts id=the-base-element:concept-element-contexts>Contexts in which this element can be used</a>:<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.<dt><a href=#concept-element-content-model id=the-base-element:concept-element-content-model>Content model</a>:<dd><a href=#concept-content-nothing id=the-base-element:concept-content-nothing>Nothing</a>.<dt><a href=#concept-element-tag-omission id=the-base-element:concept-element-tag-omission>Tag omission in text/html</a>:<dd>No <a href=#syntax-end-tag id=the-base-element:syntax-end-tag>end tag</a>.<dt><a href=#concept-element-attributes id=the-base-element:concept-element-attributes>Content attributes</a>:<dd><a href=#global-attributes id=the-base-element:global-attributes>Global attributes</a><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><code id=the-base-element:attr-base-target><a href=#attr-base-target>target</a></code> — Default <a href=#browsing-context id=the-base-element:browsing-context>browsing context</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><dt><a href=#concept-element-dom id=the-base-element:concept-element-dom>DOM interface</a>:<dd>
    <pre><code class='idl'>[<c- g>Exposed</c->=<c- n>Window</c->,
 <a href='#htmlconstructor' id='the-base-element:htmlconstructor'><c- g>HTMLConstructor</c-></a>]
<c- b>interface</c-> <dfn id='htmlbaseelement'><c- g>HTMLBaseElement</c-></dfn> : <a href='#htmlelement' id='the-base-element:htmlelement'><c- n>HTMLElement</c-></a> {
  [<a href='#cereactions' id='the-base-element:cereactions'><c- g>CEReactions</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>] <c- b>attribute</c-> <c- b>DOMString</c-> <a href='#dom-base-target' id='the-base-element:dom-base-target'><c- g>target</c-></a>;
};</code></pre>
   </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 <a href=#parse-a-url id=the-base-element:parse-a-url>parsing URLs</a>, and the name of the default
  <a href=#browsing-context id=the-base-element:browsing-context-2>browsing context</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 id=attr-base-href><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 data-x-internal=url>URLs</a>, except the <code id=the-base-element:the-html-element><a href=#the-html-element>html</a></code> element (its <code id=the-base-element:attr-html-manifest><a href=#attr-html-manifest>manifest</a></code> attribute isn't affected by <code id=the-base-element:the-base-element-6><a href=#the-base-element>base</a></code>
  elements).</p>

  

  <p class=note>If there are multiple <code id=the-base-element:the-base-element-7><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 id=attr-base-target><code>target</code></dfn> attribute, if specified, must
  contain a <a href=#valid-browsing-context-name-or-keyword id=the-base-element:valid-browsing-context-name-or-keyword>valid browsing context name or keyword</a>, which specifies which
  <a href=#browsing-context id=the-base-element:browsing-context-3>browsing context</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-8><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-9><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>

  <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>, run these steps:

  <ol><li><p>If <var>element</var> has a <code>target</code> attribute, then return that
   attribute's value.<li><p>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-10><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, then return 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-11><a href=#the-base-element>base</a></code>
   element.<li><p>Return the empty string.</ol>

  <hr>

  <p>A <code id=the-base-element:the-base-element-12><a href=#the-base-element>base</a></code> element that is the first <code id=the-base-element:the-base-element-13><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 class=brief><li>The <code id=the-base-element:the-base-element-14><a href=#the-base-element>base</a></code> element becomes the first <code id=the-base-element:the-base-element-15><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>.<li>The <code id=the-base-element:the-base-element-16><a href=#the-base-element>base</a></code> element is the first <code id=the-base-element:the-base-element-17><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.</ul>

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

   <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-18><a href=#the-base-element>base</a></code>
   element isn't affected by itself.)<li><p>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>, if <var>urlRecord</var> is failure or 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 the <a href=#resulting-url-record id=the-base-element:resulting-url-record>resulting URL record</a> and <var>document</var>
   returns "<code>Blocked</code>", and to <var>urlRecord</var> otherwise.</ol>

  <p>The <dfn id=dom-base-href><code>href</code></dfn> IDL attribute, on getting, must return
  the result of running the following algorithm:
  

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

   <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.<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-19><a href=#the-base-element>base</a></code> element isn't affected by other <code id=the-base-element:the-base-element-20><a href=#the-base-element>base</a></code> elements or
   itself.)<li><p>If <var>urlRecord</var> is failure, return <var>url</var>.<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>.</ol>

  <p>The <code id=the-base-element:dom-base-href-2><a href=#dom-base-href>href</a></code> IDL attribute, on setting, must set the <code id=the-base-element:attr-base-href-11><a href=#attr-base-href>href</a></code> content attribute to the given new value.</p>

  <p>The <dfn id=dom-base-target><code>target</code></dfn> IDL attribute must
  <a href=#reflect id=the-base-element:reflect>reflect</a> the content attribute of the same name.</p>

  

  <div class=example>

   <p>In this example, a <code id=the-base-element:the-base-element-21><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>&quot;en&quot;</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- p>&lt;</c-><c- f>base</c-><c- p>&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>&quot;https://www.example.com/news/index.html&quot;</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>&quot;archives.html&quot;</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 data-dfn-type=element data-lt=link><span class=secno>4.2.4</span> The <dfn><code>link</code></dfn> element<a href=#the-link-element class=self-link></a></h4>

  <dl class=element><dt><a href=#concept-element-categories id=the-link-element:concept-element-categories>Categories</a>:<dd><a href=#metadata-content-2 id=the-link-element:metadata-content-2>Metadata content</a>.<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>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>.<dt><a href=#concept-element-contexts id=the-link-element:concept-element-contexts>Contexts in which this element can be used</a>:<dd>Where <a href=#metadata-content-2 id=the-link-element:metadata-content-2-2>metadata content</a> is expected.<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>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.<dt><a href=#concept-element-content-model id=the-link-element:concept-element-content-model>Content model</a>:<dd><a href=#concept-content-nothing id=the-link-element:concept-content-nothing>Nothing</a>.<dt><a href=#concept-element-tag-omission id=the-link-element:concept-element-tag-omission>Tag omission in text/html</a>:<dd>No <a href=#syntax-end-tag id=the-link-element:syntax-end-tag>end tag</a>.<dt><a href=#concept-element-attributes id=the-link-element:concept-element-attributes>Content attributes</a>:<dd><a href=#global-attributes id=the-link-element:global-attributes>Global attributes</a><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><code id=the-link-element:attr-link-crossorigin><a href=#attr-link-crossorigin>crossorigin</a></code> — How the element handles crossorigin requests<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><code id=the-link-element:attr-link-media><a href=#attr-link-media>media</a></code> — Applicable media<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><code id=the-link-element:attr-link-hreflang><a href=#attr-link-hreflang>hreflang</a></code> — Language of the linked resource<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><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><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><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-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>" and <code id=the-link-element:attr-link-rel-4><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><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-5><a href=#attr-link-rel>rel</a></code>="<code>mask-icon</code>")<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>.<dt><a href=#concept-element-dom id=the-link-element:concept-element-dom>DOM interface</a>:<dd>
    <pre><code class='idl'>[<c- g>Exposed</c->=<c- n>Window</c->,
 <a href='#htmlconstructor' id='the-link-element:htmlconstructor'><c- g>HTMLConstructor</c-></a>]
<c- b>interface</c-> <dfn id='htmllinkelement'><c- g>HTMLLinkElement</c-></dfn> : <a href='#htmlelement' id='the-link-element:htmlelement'><c- n>HTMLElement</c-></a> {
  [<a href='#cereactions' id='the-link-element:cereactions'><c- g>CEReactions</c-></a>] <c- b>attribute</c-> <c- b>USVString</c-> <a href='#dom-link-href' id='the-link-element:dom-link-href'><c- g>href</c-></a>;
  [<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>] <c- b>attribute</c-> <c- b>DOMString</c-> <a href='#dom-link-rel' id='the-link-element:dom-link-rel'><c- g>rel</c-></a>;
  [<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>; // (default &quot;&quot;)
  [<c- g>SameObject</c->, <c- g>PutForwards</c->=<a href='https://dom.spec.whatwg.org/#dom-domtokenlist-value' data-x-internal='dom-domtokenlist-value' id='the-link-element:dom-domtokenlist-value'><c- n>value</c-></a>] <c- b>readonly</c-> <c- b>attribute</c-> <a href='https://dom.spec.whatwg.org/#interface-domtokenlist' data-x-internal='domtokenlist' id='the-link-element:domtokenlist'><c- n>DOMTokenList</c-></a> <a href='#dom-link-rellist' id='the-link-element:dom-link-rellist'><c- g>relList</c-></a>;
  [<a href='#cereactions' id='the-link-element:cereactions-5'><c- g>CEReactions</c-></a>] <c- b>attribute</c-> <c- b>DOMString</c-> <a href='#dom-link-media' id='the-link-element:dom-link-media'><c- g>media</c-></a>;
  [<a href='#cereactions' id='the-link-element:cereactions-6'><c- g>CEReactions</c-></a>] <c- b>attribute</c-> <c- b>DOMString</c-> <a href='#dom-link-integrity' id='the-link-element:dom-link-integrity'><c- g>integrity</c-></a>;
  [<a href='#cereactions' id='the-link-element:cereactions-7'><c- g>CEReactions</c-></a>] <c- b>attribute</c-> <c- b>DOMString</c-> <a href='#dom-link-hreflang' id='the-link-element:dom-link-hreflang'><c- g>hreflang</c-></a>;
  [<a href='#cereactions' id='the-link-element:cereactions-8'><c- g>CEReactions</c-></a>] <c- b>attribute</c-> <c- b>DOMString</c-> <a href='#dom-link-type' id='the-link-element:dom-link-type'><c- g>type</c-></a>;
  [<c- g>SameObject</c->, <c- g>PutForwards</c->=<a href='https://dom.spec.whatwg.org/#dom-domtokenlist-value' data-x-internal='dom-domtokenlist-value' id='the-link-element:dom-domtokenlist-value-2'><c- n>value</c-></a>] <c- b>readonly</c-> <c- b>attribute</c-> <a href='https://dom.spec.whatwg.org/#interface-domtokenlist' data-x-internal='domtokenlist' id='the-link-element:domtokenlist-2'><c- n>DOMTokenList</c-></a> <a href='#dom-link-sizes' id='the-link-element:dom-link-sizes'><c- g>sizes</c-></a>;
  [<a href='#cereactions' id='the-link-element:cereactions-9'><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>;
};
<a href='#htmllinkelement' id='the-link-element:htmllinkelement'><c- n>HTMLLinkElement</c-></a> <c- b>includes</c-> <a href='https://drafts.csswg.org/cssom/#the-linkstyle-interface' data-x-internal='linkstyle' id='the-link-element:linkstyle'><c- n>LinkStyle</c-></a>;</code></pre>
   </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 destination of the link(s) is given by the <dfn id=attr-link-href><code>href</code></dfn> attribute, which must be present and must contain 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>. If the <code id=the-link-element:attr-link-href-2><a href=#attr-link-href>href</a></code> attribute is absent, then the element does not define a
  link.</p>

  <p>The <dfn id=attr-link-crossorigin><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>external resource links</a>.</p>

  <p>The types of link indicated (the relationships) are given by the value of the <dfn id=attr-link-rel><code>rel</code></dfn> attribute, which, if present, must have a value that is a
  <a href=#set-of-space-separated-tokens id=the-link-element:set-of-space-separated-tokens>set of 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-6><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-7><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:rel-icon-2><a href=#rel-icon>icon</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-2><a href=#link-type-preload>preload</a></code>,
  <code id=the-link-element:link-type-prerender><a href=#link-type-prerender>prerender</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-8><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-9><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-10><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>

  <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-11><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>

  <p class=note>If the <code id=the-link-element:attr-link-rel-12><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>

  <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-2>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-3>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-13><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-14><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-4>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>&quot;author license&quot;</c-> <c- e>href</c-><c- o>=</c-><c- s>&quot;/about&quot;</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 class=note><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-15><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>The exact behavior for <a href=#external-resource-link id=the-link-element:external-resource-link-5>links to external resources</a>
  depends on the exact relationship, as defined for the relevant <a href=#linkTypes>link
  type</a>.</p>

  <p>The <dfn id=attr-link-media><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>

  <p>The <dfn data-dfn-for=link id=attr-link-integrity data-dfn-type=element-attr data-export=""><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 not be specified on
  <code id=the-link-element:the-link-element-12><a href=#the-link-element>link</a></code> elements that do not have a <code id=the-link-element:attr-link-rel-16><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> keyword. <a href=#refsSRI>[SRI]</a></p>

  <p>The <dfn id=attr-link-hreflang><code>hreflang</code></dfn> attribute on the
  <code id=the-link-element:the-link-element-13><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 id=attr-link-type><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 id=attr-link-referrerpolicy><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=#concept-link-obtain id=the-link-element:concept-link-obtain>obtaining</a> the external resource. <a href=#refsREFERRERPOLICY>[REFERRERPOLICY]</a>.</p>

  <p>The <dfn id=attr-link-title><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-14><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 id=attr-link-sizes><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>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 not be specified on <code id=the-link-element:the-link-element-15><a href=#the-link-element>link</a></code> elements that do not have a <code id=the-link-element:attr-link-rel-17><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 id=attr-link-as><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-3><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-16><a href=#the-link-element>link</a></code> elements that have a <code id=the-link-element:attr-link-rel-18><a href=#attr-link-rel>rel</a></code> attribute that contains the <code id=the-link-element:link-type-preload-3><a href=#link-type-preload>preload</a></code> keyword. It may 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-19><a href=#attr-link-rel>rel</a></code> attribute that contains the <code id=the-link-element:link-type-modulepreload-3><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-18><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-2><a href=#attr-link-as>as</a></code> attribute is
  used is given in the steps to obtain the resource, for <a href=#concept-link-obtain id=the-link-element:concept-link-obtain-2>for
  <code>preload</code> links</a> and <a href=#modulepreload-obtain-steps>for <code>modulepreload</code>
  links</a>, respectively.</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-4><a href=#link-type-preload>preload</a></code> links, both conditions are an error; for
  <code id=the-link-element:link-type-modulepreload-4><a href=#link-type-modulepreload>modulepreload</a></code> links, a missing value will be treated as
  "<code>script</code>".</p>

  <hr>

  <p>The <dfn id=attr-link-color><code>color</code></dfn> attribute is used with the <code>mask-icon</code> link type. The attribute must not be specified on <code id=the-link-element:the-link-element-19><a href=#the-link-element>link</a></code>
  elements that do not have a <code id=the-link-element:attr-link-rel-20><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></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>The IDL attributes
  <dfn id=dom-link-href><code>href</code></dfn>,
  <dfn id=dom-link-hreflang><code>hreflang</code></dfn>,
  <dfn id=dom-link-integrity><code>integrity</code></dfn>,
  <dfn id=dom-link-media><code>media</code></dfn>,
  <dfn id=dom-link-rel><code>rel</code></dfn>,
  <dfn id=dom-link-sizes><code>sizes</code></dfn>, and
  <dfn id=dom-link-type><code>type</code></dfn>
  each must <a href=#reflect id=the-link-element:reflect>reflect</a> the respective content attributes of the same name.</p>

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

  <p>The <dfn id=dom-link-as><code>as</code></dfn> IDL attribute must <a href=#reflect id=the-link-element:reflect-2>reflect</a> the
  <code id=the-link-element:attr-link-as-3><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>

  <p>The <dfn id=dom-link-crossorigin><code>crossOrigin</code></dfn> IDL attribute must
  <a href=#reflect id=the-link-element:reflect-3>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>

  <p>The <dfn id=dom-link-referrerpolicy><code>referrerPolicy</code></dfn> IDL attribute must
  <a href=#reflect id=the-link-element:reflect-4>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>

  <p>The <dfn id=dom-link-rellist><code>relList</code></dfn> IDL attribute must <a href=#reflect id=the-link-element:reflect-5>reflect</a> the <code id=the-link-element:attr-link-rel-21><a href=#attr-link-rel>rel</a></code> content attribute.</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=#concept-link-obtain id=processing-the-type-attribute:concept-link-obtain>obtain</a>
  the resource; 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=#concept-link-obtain id=processing-the-type-attribute:concept-link-obtain-2>obtain</a> the resource 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=#concept-link-obtain id=processing-the-type-attribute:concept-link-obtain-3>obtain</a>
  the resource if the type was known and supported, then the user agent should <a href=#concept-link-obtain id=processing-the-type-attribute:concept-link-obtain-4>obtain</a> the resource 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>&quot;stylesheet&quot;</c-> <c- e>href</c-><c- o>=</c-><c- s>&quot;A&quot;</c-> <c- e>type</c-><c- o>=</c-><c- s>&quot;text/plain&quot;</c-><c- p>&gt;</c->
<c- p>&lt;</c-><c- f>link</c-> <c- e>rel</c-><c- o>=</c-><c- s>&quot;stylesheet&quot;</c-> <c- e>href</c-><c- o>=</c-><c- s>&quot;B&quot;</c-> <c- e>type</c-><c- o>=</c-><c- s>&quot;text/css&quot;</c-><c- p>&gt;</c->
<c- p>&lt;</c-><c- f>link</c-> <c- e>rel</c-><c- o>=</c-><c- s>&quot;stylesheet&quot;</c-> <c- e>href</c-><c- o>=</c-><c- s>&quot;C&quot;</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://tools.ietf.org/html/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://tools.ietf.org/html/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: "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=obtaining-a-resource-from-a-link-element><span class=secno>4.2.4.3</span> Obtaining a resource from a <code id=obtaining-a-resource-from-a-link-element:the-link-element><a href=#the-link-element>link</a></code> element<a href=#obtaining-a-resource-from-a-link-element class=self-link></a></h5>

  <p>For external resources that are represented in the DOM (for example, style sheets), the DOM
  representation must be made available (modulo cross-origin restrictions) even if the resource is
  not applied. To <dfn id=concept-link-obtain>obtain the resource</dfn>, the user agent must
  run the following steps:</p>

  <ol><li><p>If the <code id=obtaining-a-resource-from-a-link-element:attr-link-href><a href=#attr-link-href>href</a></code> attribute's value is the empty string,
   then return.<li><p><a href=#parse-a-url id=obtaining-a-resource-from-a-link-element:parse-a-url>Parse</a> the <a id=obtaining-a-resource-from-a-link-element:url href=https://url.spec.whatwg.org/#concept-url data-x-internal=url>URL</a> given by the <code id=obtaining-a-resource-from-a-link-element:attr-link-href-2><a href=#attr-link-href>href</a></code> attribute, relative to the element's <a id=obtaining-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>. If that fails, then return. Otherwise, let <var>url</var> be the
   <a href=#resulting-url-record id=obtaining-a-resource-from-a-link-element:resulting-url-record>resulting URL record</a>.<li><p>Let <var>corsAttributeState</var> be the current state of the element's <code id=obtaining-a-resource-from-a-link-element:attr-link-crossorigin><a href=#attr-link-crossorigin>crossorigin</a></code> content attribute.<li><p>Let <var>request</var> be the result of <a href=#create-a-potential-cors-request id=obtaining-a-resource-from-a-link-element:create-a-potential-cors-request>creating a potential-CORS request</a> given
   <var>url</var>, the empty string, and <var>corsAttributeState</var>.<li><p>Set <var>request</var>'s <a href=https://fetch.spec.whatwg.org/#concept-request-client id=obtaining-a-resource-from-a-link-element:concept-request-client data-x-internal=concept-request-client>client</a> to the
   <code id=obtaining-a-resource-from-a-link-element:the-link-element-2><a href=#the-link-element>link</a></code> element's <a id=obtaining-a-resource-from-a-link-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=obtaining-a-resource-from-a-link-element:relevant-settings-object>relevant settings
   object</a>.<li><p>Set <var>request</var>'s <a href=https://fetch.spec.whatwg.org/#concept-request-nonce-metadata id=obtaining-a-resource-from-a-link-element:concept-request-nonce-metadata data-x-internal=concept-request-nonce-metadata>cryptographic
   nonce metadata</a> to the current value of the <code id=obtaining-a-resource-from-a-link-element:the-link-element-3><a href=#the-link-element>link</a></code> element's
   <a href=#cryptographicnonce id=obtaining-a-resource-from-a-link-element:cryptographicnonce>[[CryptographicNonce]]</a> internal slot.<li><p>Set <var>request</var>'s <a href=https://fetch.spec.whatwg.org/#concept-request-integrity-metadata id=obtaining-a-resource-from-a-link-element:concept-request-integrity-metadata data-x-internal=concept-request-integrity-metadata>integrity
   metadata</a> to the current value of the <code id=obtaining-a-resource-from-a-link-element:the-link-element-4><a href=#the-link-element>link</a></code> element's <code id=obtaining-a-resource-from-a-link-element:attr-link-integrity><a href=#attr-link-integrity>integrity</a></code> content attribute.<li><p>Set <var>request</var>'s
   <a href=https://fetch.spec.whatwg.org/#concept-request-referrer-policy id=obtaining-a-resource-from-a-link-element:concept-request-referrer-policy data-x-internal=concept-request-referrer-policy>referrer policy</a> to the current state of the
   <code id=obtaining-a-resource-from-a-link-element:the-link-element-5><a href=#the-link-element>link</a></code> element's <code id=obtaining-a-resource-from-a-link-element:attr-link-referrerpolicy><a href=#attr-link-referrerpolicy>referrerpolicy</a></code>
   attribute.<li>
    <p>If the <code id=obtaining-a-resource-from-a-link-element:attr-link-rel><a href=#attr-link-rel>rel</a></code> attribute contains the <code id=obtaining-a-resource-from-a-link-element:link-type-preload><a href=#link-type-preload>preload</a></code> keyword, then:</p>

    <ol><li><p>Let <var>as</var> be the current state of the <code id=obtaining-a-resource-from-a-link-element:attr-link-as><a href=#attr-link-as>as</a></code>
     attribute.<li><p>If <var>as</var> is no state, then return.<li><p>Set <var>request</var>'s <a href=https://fetch.spec.whatwg.org/#concept-request-destination id=obtaining-a-resource-from-a-link-element:concept-request-destination data-x-internal=concept-request-destination>destination</a>
     to the result of <a href=https://fetch.spec.whatwg.org/#concept-potential-destination-translate id=obtaining-a-resource-from-a-link-element:concept-potential-destination-translate data-x-internal=concept-potential-destination-translate>translating</a>
     <var>as</var>.</ol>
   <li><p><a href=https://fetch.spec.whatwg.org/#concept-fetch id=obtaining-a-resource-from-a-link-element:concept-fetch data-x-internal=concept-fetch>Fetch</a> <var>request</var>.</ol>

  <p>User agents may opt to only try to obtain such resources when they are needed, instead of
  pro-actively fetching all the external resources that are not applied.</p>

  <p>The semantics of the protocol used (e.g. HTTP) must be followed when fetching external
  resources. (For example, redirects will be followed and 404 responses will cause the external
  resource to not be applied.)</p>

  
  <p>Once the attempts to obtain the resource and its <a href=#critical-subresources id=obtaining-a-resource-from-a-link-element:critical-subresources>critical subresources</a> are
  complete, the user agent must, if the loads were successful, <a href=#queue-a-task id=obtaining-a-resource-from-a-link-element:queue-a-task>queue a task</a> to
  <a href=https://dom.spec.whatwg.org/#concept-event-fire id=obtaining-a-resource-from-a-link-element:concept-event-fire data-x-internal=concept-event-fire>fire an event</a> named <code id=obtaining-a-resource-from-a-link-element:event-load><a href=#event-load>load</a></code>
  at the <code id=obtaining-a-resource-from-a-link-element:the-link-element-6><a href=#the-link-element>link</a></code> element, or, if the resource or one of its <a href=#critical-subresources id=obtaining-a-resource-from-a-link-element:critical-subresources-2>critical
  subresources</a> failed to completely load for any reason (e.g. DNS error, HTTP 404 response, a
  connection being prematurely closed, unsupported Content-Type), <a href=#queue-a-task id=obtaining-a-resource-from-a-link-element:queue-a-task-2>queue a task</a> to <a href=https://dom.spec.whatwg.org/#concept-event-fire id=obtaining-a-resource-from-a-link-element:concept-event-fire-2 data-x-internal=concept-event-fire>fire an event</a> named <code id=obtaining-a-resource-from-a-link-element:event-error><a href=#event-error>error</a></code> at
  the <code id=obtaining-a-resource-from-a-link-element:the-link-element-7><a href=#the-link-element>link</a></code> element. Non-network errors in processing the resource or its subresources
  (e.g. CSS parse errors, PNG decoding errors) are not failures for the purposes of this
  paragraph.</p>

  <p>The <a href=#task-source id=obtaining-a-resource-from-a-link-element:task-source>task source</a> for these <a href=#concept-task id=obtaining-a-resource-from-a-link-element:concept-task>tasks</a> is the
  <a href=#dom-manipulation-task-source id=obtaining-a-resource-from-a-link-element:dom-manipulation-task-source>DOM manipulation task source</a>.</p>

  <p>Unless otherwise specified for a given <code id=obtaining-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=obtaining-a-resource-from-a-link-element:delay-the-load-event>delay the load event</a> of the element's <a id=obtaining-a-resource-from-a-link-element:node-document-3 href=https://dom.spec.whatwg.org/#concept-node-document data-x-internal=node-document>node document</a> until
  all the attempts to obtain the resource and its <a href=#critical-subresources id=obtaining-a-resource-from-a-link-element:critical-subresources-3>critical subresources</a> are complete.
  (Resources that the user agent has not yet attempted to obtain, e.g. because it is waiting for the
  resource to be needed, do not <a href=#delay-the-load-event id=obtaining-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://tools.ietf.org/html/rfc5988#section-5>Link</a></code>` headers<a href=#processing-link-headers class=self-link></a></h5>

  <p>HTTP `<code id=processing-link-headers:http-link-2><a data-x-internal=http-link href=https://tools.ietf.org/html/rfc5988#section-5>Link</a></code>` headers, if supported, must be assumed to come
  before any links in the document, in the order that they were given in the HTTP message. These
  headers are to be processed according to the rules given in the relevant specifications. <a href=#refsHTTP>[HTTP]</a> <a href=#refsWEBLINK>[WEBLINK]</a></p> 

  <p class=note>Registration of relation types in HTTP `<code id=processing-link-headers:http-link-3><a data-x-internal=http-link href=https://tools.ietf.org/html/rfc5988#section-5>Link</a></code>`
  headers is distinct from <a href=#linkTypes>HTML link types</a>, and thus their semantics can be
  different from same-named HTML types.</p>

  

  <h5 id=providing-users-with-a-means-to-follow-hyperlinks-created-using-the-link-element><span class=secno>4.2.4.5</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. 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>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>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>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>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).</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>

  
  <p>The <a id=providing-users-with-a-means-to-follow-hyperlinks-created-using-the-link-element:activation-behaviour href=https://dom.spec.whatwg.org/#eventtarget-activation-behavior data-x-internal=activation-behaviour>activation behavior</a> of <code id=providing-users-with-a-means-to-follow-hyperlinks-created-using-the-link-element:the-link-element-4><a href=#the-link-element>link</a></code> elements that create <a href=#hyperlink id=providing-users-with-a-means-to-follow-hyperlinks-created-using-the-link-element:hyperlink-2>hyperlinks</a> is to <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> created by the <code id=providing-users-with-a-means-to-follow-hyperlinks-created-using-the-link-element:the-link-element-5><a href=#the-link-element>link</a></code> element.</p>




  <h4 id=the-meta-element data-dfn-type=element data-lt=meta><span class=secno>4.2.5</span> The <dfn id=meta><code>meta</code></dfn> element<a href=#the-meta-element class=self-link></a></h4>

  <dl class=element><dt><a href=#concept-element-categories id=the-meta-element:concept-element-categories>Categories</a>:<dd><a href=#metadata-content-2 id=the-meta-element:metadata-content-2>Metadata content</a>.<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>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>.<dt><a href=#concept-element-contexts id=the-meta-element:concept-element-contexts>Contexts in which this element can be used</a>:<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>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>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>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>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>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.<dt><a href=#concept-element-content-model id=the-meta-element:concept-element-content-model>Content model</a>:<dd><a href=#concept-content-nothing id=the-meta-element:concept-content-nothing>Nothing</a>.<dt><a href=#concept-element-tag-omission id=the-meta-element:concept-element-tag-omission>Tag omission in text/html</a>:<dd>No <a href=#syntax-end-tag id=the-meta-element:syntax-end-tag>end tag</a>.<dt><a href=#concept-element-attributes id=the-meta-element:concept-element-attributes>Content attributes</a>:<dd><a href=#global-attributes id=the-meta-element:global-attributes>Global attributes</a><dd><code id=the-meta-element:attr-meta-name-2><a href=#attr-meta-name>name</a></code> — Metadata name<dd><code id=the-meta-element:attr-meta-http-equiv-4><a href=#attr-meta-http-equiv>http-equiv</a></code> — Pragma directive<dd><code id=the-meta-element:attr-meta-content><a href=#attr-meta-content>content</a></code> — Value of the element<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><dt><a href=#concept-element-dom id=the-meta-element:concept-element-dom>DOM interface</a>:<dd>
    <pre><code class='idl'>[<c- g>Exposed</c->=<c- n>Window</c->,
 <a href='#htmlconstructor' id='the-meta-element:htmlconstructor'><c- g>HTMLConstructor</c-></a>]
<c- b>interface</c-> <dfn id='htmlmetaelement'><c- g>HTMLMetaElement</c-></dfn> : <a href='#htmlelement' id='the-meta-element:htmlelement'><c- n>HTMLElement</c-></a> {
  [<a href='#cereactions' id='the-meta-element:cereactions'><c- g>CEReactions</c-></a>] <c- b>attribute</c-> <c- b>DOMString</c-> <a href='#dom-meta-name' id='the-meta-element:dom-meta-name'><c- g>name</c-></a>;
  [<a href='#cereactions' id='the-meta-element:cereactions-2'><c- g>CEReactions</c-></a>] <c- b>attribute</c-> <c- b>DOMString</c-> <a href='#dom-meta-httpequiv' id='the-meta-element:dom-meta-httpequiv'><c- g>httpEquiv</c-></a>;
  [<a href='#cereactions' id='the-meta-element:cereactions-3'><c- g>CEReactions</c-></a>] <c- b>attribute</c-> <c- b>DOMString</c-> <a href='#dom-meta-content' id='the-meta-element:dom-meta-content'><c- g>content</c-></a>;
};</code></pre>
   </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-5><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-6><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-7><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 id=attr-meta-charset><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 data-export=""><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 id=attr-meta-name><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 id=dom-meta-name><code>name</code></dfn> and <dfn id=dom-meta-content><code>content</code></dfn> IDL attributes must <a href=#reflect id=the-meta-element:reflect>reflect</a> the
  respective content attributes of the same name. The IDL attribute <dfn id=dom-meta-httpequiv><code>httpEquiv</code></dfn> must <a href=#reflect id=the-meta-element:reflect-2>reflect</a> the content
  attribute <code id=the-meta-element:attr-meta-http-equiv-8><a href=#attr-meta-http-equiv>http-equiv</a></code>.</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>

  <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 id=meta-application-name><code>application-name</code></dfn><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>

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

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

     </ol>

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

    

   <dt><dfn id=meta-author><code>author</code></dfn><dd><p>The value must be a free-form string giving the name of one of the page's
   authors.<dt><dfn id=meta-description><code>description</code></dfn><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.<dt><dfn id=meta-generator><code>generator</code></dfn><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>&quot;Frontweaver 8.2&quot;</c-><c- p>&gt;</c-></code></pre>

    </div>

   <dt><dfn id=meta-keywords><code>keywords</code></dfn><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>&quot;en-GB&quot;</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>&quot;keywords&quot;</c-> <c- e>content</c-><c- o>=</c-><c- s>&quot;british,type face,font,fonts,highway,highways&quot;</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>

    

    <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.<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>.<li><p>Add the resulting tokens, if any, to <var>keywords</var>.</ol>

     <li><p>Remove any duplicates from <var>keywords</var>.<li><p>Return <var>keywords</var>. This is the list of keywords that the author has
     specified as applicable to the page.</ol>

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

    

   <dt><dfn id=meta-referrer><code>referrer</code></dfn><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>

    

    <p>If any <code id=standard-metadata-names:the-meta-element-9><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>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-10><a href=#the-meta-element>meta</a></code> elements have their <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>Let <var>candidate elements</var> be the list of all <code id=standard-metadata-names:the-meta-element-11><a href=#the-meta-element>meta</a></code> elements that
      meet the following criteria, in <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>:</p>

      <ul class=brief><li>The element is <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><li>The element has 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><li>The element has a <code id=standard-metadata-names:attr-meta-content-4><a href=#attr-meta-content>content</a></code> attribute, whose value
       is not the empty string<li>The element is a child of <a href=#the-head-element-2 id=standard-metadata-names:the-head-element-2>the <code>head</code> element</a> of the document</ul>
     <li>
      <p>For each <var>element</var> in <var>candidate elements</var>:</p>

      <ol><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>.<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>Referrer policy
         <tbody><tr><td><code>never</code>
           <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>
          <tr><td><code>default</code>
           <td><code id=standard-metadata-names:referrer-policy-no-referrer-when-downgrade><a data-x-internal=referrer-policy-no-referrer-when-downgrade href=https://w3c.github.io/webappsec-referrer-policy/#referrer-policy-no-referrer-when-downgrade>no-referrer-when-downgrade</a></code>
          <tr><td><code>always</code>
           <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>
          <tr><td><code>origin-when-crossorigin</code>
           <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>
        </table>
       <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-referrer-policy id=standard-metadata-names:concept-document-referrer-policy>referrer
       policy</a> to <var>policy</var>.</ol>

      <p class=note>The fact that these steps are applied for each element enables <a href=https://w3c.github.io/webappsec-referrer-policy/#unknown-policy-values>deployment of
      fallback values for older user agents</a>. <a href=#refsREFERRERPOLICY>[REFERRERPOLICY]</a></p>
     </ol>

    
   <dt><dfn id=meta-theme-color><code>theme-color</code></dfn><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></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>There must not be more than one <code id=standard-metadata-names:the-meta-element-12><a href=#the-meta-element>meta</a></code> element with its <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> per document.</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>&quot;theme-color&quot;</c-> <c- e>content</c-><c- o>=</c-><c- s>&quot;#3c790a&quot;</c-><c- p>&gt;</c->
...</code></pre>

    </div>

    

     <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-13><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 class=brief><li>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><li>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><li>The element has a <code id=standard-metadata-names:attr-meta-content-6><a href=#attr-meta-content>content</a></code> attribute</ul>
      <li>
       <p>For each <var>element</var> in <var>candidate elements</var>:</p>

       <ol><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.<li><p>Let <var>color</var> be the result of <a href=#parsed-as-a-css-color-value id=standard-metadata-names:parsed-as-a-css-color-value>parsing</a> <var>value</var>.<li><p>If <var>color</var> is not failure, then return <var>color</var>.</ol>
      <li><p>Return nothing (the page has no theme color).</ol>

     <p>If any <code id=standard-metadata-names:the-meta-element-14><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-2>removed from the document</a>, or existing <code id=standard-metadata-names:the-meta-element-15><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> or <code id=standard-metadata-names:attr-meta-content-8><a href=#attr-meta-content>content</a></code>
     attributes changed, 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>

   </dl><div class=status><input onclick=toggleStatus(this) value=⋰ type=button><p class=support><strong>Support:</strong> meta-theme-color<span class="and_chr yes"><span>Chrome for Android</span> <span>67+</span></span><span class="chrome no"><span>Chrome</span> <span>None</span></span><span class="ios_saf no"><span>iOS Safari</span> <span>None</span></span><span class="and_uc no"><span>UC Browser for Android</span> <span>None</span></span><span class="firefox no"><span>Firefox</span> <span>None</span></span><span class="ie no"><span>IE</span> <span>None</span></span><span class="op_mini no"><span>Opera Mini</span> <span>None</span></span><span class="safari no"><span>Safari</span> <span>None</span></span><span class="edge no"><span>Edge</span> <span>None</span></span><span class="samsung yes"><span>Samsung Internet</span> <span>6.2+</span></span><span class="opera no"><span>Opera</span> <span>None</span></span><span class="android no"><span>Android Browser</span> <span>None</span></span><p class=caniuse>Source: <a href="https://caniuse.com/#feat=meta-theme-color">caniuse.com</a></div>



  <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).<li><p>If the name is for something expected to have processing requirements in user agents; in
   that case it ought to be standardized.</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<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).<dt>Brief description<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.<dt>Specification<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.<dt>Synonyms<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.<dt>Status<dd>

    <p>One of the following:</p>

    <dl><dt>Proposed<dd>The name has not received wide peer review and approval. Someone has proposed it and is, or
     soon will be, using it.<dt>Ratified<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.<dt>Discontinued<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.</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>

   </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 data-export=""><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>

  <p>The <code id=pragma-directives:attr-meta-http-equiv><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>. The following table lists the keywords defined for this attribute. The states
  given in the first cell of the rows with keywords give the states to which those keywords map.
  Some of the keywords are non-conforming, as noted in the last
  column.</p>

  <table id=table-http-equiv><thead><tr><th>State
     <th>Keyword
     <th>Notes
   <tbody><tr><td><a href=#attr-meta-http-equiv-content-language id=pragma-directives:attr-meta-http-equiv-content-language>Content Language</a>
     <td><dfn id=attr-meta-http-equiv-keyword-content-language><code>content-language</code></dfn>
     <td>Non-conforming
    <tr><td><a href=#attr-meta-http-equiv-content-type id=pragma-directives:attr-meta-http-equiv-content-type>Encoding declaration</a>
     <td><dfn id=attr-meta-http-equiv-keyword-content-type><code>content-type</code></dfn>
     <td>
    <tr><td><a href=#attr-meta-http-equiv-default-style id=pragma-directives:attr-meta-http-equiv-default-style>Default style</a>
     <td><dfn id=attr-meta-http-equiv-keyword-default-style><code>default-style</code></dfn>
     <td>
    <tr><td><a href=#attr-meta-http-equiv-refresh id=pragma-directives:attr-meta-http-equiv-refresh>Refresh</a>
     <td><dfn id=attr-meta-http-equiv-keyword-refresh><code>refresh</code></dfn>
     <td>
    <tr><td><a href=#attr-meta-http-equiv-set-cookie id=pragma-directives:attr-meta-http-equiv-set-cookie>Set-Cookie</a>
     <td><dfn id=attr-meta-http-equiv-keyword-set-cookie><code>set-cookie</code></dfn>
     <td>Non-conforming
    <tr><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><dfn id=attr-meta-http-equiv-keyword-x-ua-compatible><code>x-ua-compatible</code></dfn>
     <td>
    <tr><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><dfn id=attr-meta-http-equiv-keyword-content-security-policy><code>content-security-policy</code></dfn>
     <td>
  </table>



  

  <p>When a <code id=pragma-directives:the-meta-element-2><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-2><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>)

   <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>pragma-set default language</a>.</p>

    

    <ol><li><p>If the <code id=pragma-directives:the-meta-element-3><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.<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.<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.<li><p>Let <var>position</var> point at the first character of <var>input</var>.<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>.<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>.<li><p>Let <var>candidate</var> be the string that resulted from the previous
     step.<li><p>If <var>candidate</var> is the empty string, return.<li>

      <p>Set the <a href=#pragma-set-default-language id=pragma-directives:pragma-set-default-language-2>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>

     </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://tools.ietf.org/html/rfc7231#section-3.1.3.2>Content-Language</a></code>` header of the same name. <a href=#refsHTTP>[HTTP]</a></p>

   <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>)

   <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><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-4><a href=#the-meta-element>meta</a></code> elements with an <code id=pragma-directives:attr-meta-http-equiv-3><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: the literal
    string "<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 the literal string "<code>charset=utf-8</code>".</p>

    <p>A document must not contain both a <code id=pragma-directives:the-meta-element-5><a href=#the-meta-element>meta</a></code> element with an <code id=pragma-directives:attr-meta-http-equiv-4><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-6><a href=#the-meta-element>meta</a></code> element with the <code id=pragma-directives:attr-meta-charset-2><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-5><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>

   <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>)

   <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 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>.</p>

    

    <ol><li><p>If the <code id=pragma-directives:the-meta-element-7><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.<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></ol>

    

   <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>)

   <dd>

    <p>This pragma acts as timed redirect.</p>

    <p>A <code id=pragma-directives:document><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-8><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.<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.<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-9><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-10><a href=#the-meta-element>meta</a></code>
     element.</ol>

    <p>The <dfn id=shared-declarative-refresh-steps>shared declarative refresh steps</dfn>, given a <code id=pragma-directives:document-2><a href=#document>Document</a></code> object
    <var>document</var>, string <var>input</var>, and optionally a <code id=pragma-directives:the-meta-element-11><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.<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>.<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>.<li><p>Let <var>time</var> be 0.<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 the result be
     <var>timeString</var>.<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.</ol>
     <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>.<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.<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>.<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.<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>.<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>.<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>.</ol>
     <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.<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>.<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>.<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>.<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>.<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>.<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>.<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.<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.<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><p><i>Parse</i>: <a href=#parse-a-url id=pragma-directives:parse-a-url>Parse</a> <var>urlString</var> relative to
       <var>document</var>. If that fails, return. Otherwise, set <var>urlRecord</var> to the
       <a href=#resulting-url-record id=pragma-directives:resulting-url-record>resulting URL record</a>.</ol>
     <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.<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=#concept-document-bc id=pragma-directives:concept-document-bc>browsing context</a> to
        <var>urlRecord</var>, with <a href=#replacement-enabled id=pragma-directives:replacement-enabled>replacement enabled</a>, and with <var>document</var>'s
        <a href=#concept-document-bc id=pragma-directives:concept-document-bc-2>browsing context</a> as the <a href=#source-browsing-context id=pragma-directives:source-browsing-context>source browsing
        context</a>.</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> has
         <a href=#completely-loaded id=pragma-directives:completely-loaded>completely loaded</a>, adjusted to take into account user or user agent
         preferences.<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.</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><a href=#refresh>Refresh</a></code>` header).</p>
       <li><p>Provide the user with an interface that, when selected, <a href=#navigate id=pragma-directives:navigate-2>navigates</a> a <a href=#browsing-context id=pragma-directives:browsing-context>browsing context</a>
       to <var>urlRecord</var>, with <var>document</var>'s <a href=#concept-document-bc id=pragma-directives:concept-document-bc-3>browsing context</a> as the <a href=#source-browsing-context id=pragma-directives:source-browsing-context-2>source browsing
       context</a>.<li><p>Do nothing.</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>
     </ol>

    

    <p>For <code id=pragma-directives:the-meta-element-12><a href=#the-meta-element>meta</a></code> elements 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-refresh id=pragma-directives:attr-meta-http-equiv-refresh-2>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>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.</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>&quot;Refresh&quot;</c-> <c- e>content</c-><c- o>=</c-><c- s>&quot;300&quot;</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>&quot;Refresh&quot;</c-> <c- e>content</c-><c- o>=</c-><c- s>&quot;20; URL=page4.html&quot;</c-><c- p>&gt;</c-></code></pre>

    </div>

   <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>)

   <dd>
    <p>This pragma is non-conforming and has no effect.</p>

    <p>User agents are required to ignore this pragma.</p>
   <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>)

   <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-13><a href=#the-meta-element>meta</a></code> elements with an <code id=pragma-directives:attr-meta-http-equiv-7><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>

   <dt><dfn id=attr-meta-http-equiv-content-security-policy data-dfn-type=dfn 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>)

   <dd>

    <p>This pragma <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-3><a href=#document>Document</a></code>. <a href=#refsCSP>[CSP]</a></p>

    

    <ol><li><p>If the <code id=pragma-directives:the-meta-element-14><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.<li><p>If the <code id=pragma-directives:the-meta-element-15><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.<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-16><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".<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>.<li><p><a id=pragma-directives:enforce-the-policy-2 href=https://w3c.github.io/webappsec-csp/#enforced data-x-internal=enforce-the-policy>Enforce the policy</a> <var>policy</var>.</ol>

    

    <p>For <code id=pragma-directives:the-meta-element-17><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-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-2 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-3 data-x-internal=enforce-the-policy>enforced</a> upon the current document. <a href=#refsCSP>[CSP]</a></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:

     <pre><code class='html'><c- p>&lt;</c-><c- f>meta</c-> <c- e>http-equiv</c-><c- o>=</c-><c- s>&quot;Content-Security-Policy&quot;</c-> <c- e>content</c-><c- o>=</c-><c- s>&quot;script-src &apos;self&apos;; object-src &apos;none&apos;&quot;</c-><c- p>&gt;</c-></code></pre>

    </div>
   </dl>

  <p>There must not be more than one <code id=pragma-directives:the-meta-element-18><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 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></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> 

  <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 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>&quot;utf-8&quot;</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=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;</c-></code></pre>

  </div>



  <h4 id=the-style-element data-dfn-type=element data-lt=style><span class=secno>4.2.6</span> The <dfn><code>style</code></dfn> element<a href=#the-style-element class=self-link></a></h4>

  <dl class=element><dt><a href=#concept-element-categories id=the-style-element:concept-element-categories>Categories</a>:<dd><a href=#metadata-content-2 id=the-style-element:metadata-content-2>Metadata content</a>.<dt><a href=#concept-element-contexts id=the-style-element:concept-element-contexts>Contexts in which this element can be used</a>:<dd>Where <a href=#metadata-content-2 id=the-style-element:metadata-content-2-2>metadata content</a> is expected.<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.<dt><a href=#concept-element-content-model id=the-style-element:concept-element-content-model>Content model</a>:<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>.<dt><a href=#concept-element-tag-omission id=the-style-element:concept-element-tag-omission>Tag omission in text/html</a>:<dd>Neither tag is omissible.<dt><a href=#concept-element-attributes id=the-style-element:concept-element-attributes>Content attributes</a>:<dd><a href=#global-attributes id=the-style-element:global-attributes>Global attributes</a><dd><code id=the-style-element:attr-style-media><a href=#attr-style-media>media</a></code> — Applicable media<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>.<dt><a href=#concept-element-dom id=the-style-element:concept-element-dom>DOM interface</a>:<dd>
    <pre><code class='idl'>[<c- g>Exposed</c->=<c- n>Window</c->,
 <a href='#htmlconstructor' id='the-style-element:htmlconstructor'><c- g>HTMLConstructor</c-></a>]
<c- b>interface</c-> <dfn id='htmlstyleelement'><c- g>HTMLStyleElement</c-></dfn> : <a href='#htmlelement' id='the-style-element:htmlelement'><c- n>HTMLElement</c-></a> {
  [<a href='#cereactions' id='the-style-element:cereactions'><c- g>CEReactions</c-></a>] <c- b>attribute</c-> <c- b>DOMString</c-> <a href='#dom-style-media' id='the-style-element:dom-style-media'><c- g>media</c-></a>;
};
<a href='#htmlstyleelement' id='the-style-element:htmlstyleelement'><c- n>HTMLStyleElement</c-></a> <c- b>includes</c-> <a href='https://drafts.csswg.org/cssom/#the-linkstyle-interface' data-x-internal='linkstyle' id='the-style-element:linkstyle'><c- n>LinkStyle</c-></a>;</code></pre>
   </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>

  <p>The <dfn id=attr-style-media><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 id=title-on-style>The <dfn id=attr-style-title><code>title</code></dfn> attribute on
  <code id=the-style-element:the-style-element-3><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-4><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-5><a href=#the-style-element>style</a></code> element. If the <code id=the-style-element:the-style-element-6><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-7><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-8><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-9><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>

  <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
  one 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>.<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>.<li><p>The element's <a id=the-style-element:child-text-content-change-steps href=https://dom.spec.whatwg.org/#concept-node-text-change-ext data-x-internal=child-text-content-change-steps>child text content change steps</a> run.</ul>

  <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-10><a href=#the-style-element>style</a></code> element.<li><p>If <var>element</var> has 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>, <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.<li><p>If <var>element</var>'s <a id=the-style-element:root href=https://dom.spec.whatwg.org/#concept-tree-root data-x-internal=root>root</a> is neither a <a id=the-style-element:shadow-root href=https://dom.spec.whatwg.org/#concept-shadow-root data-x-internal=shadow-root>shadow root</a> nor a
   <a href=#document id=the-style-element:document>document</a>, then return.<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><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-11><a href=#the-style-element>style</a></code> element, "<code>style</code>", and the <code id=the-style-element:the-style-element-12><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><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><dd><p><code id=the-style-element:text/css-2><a href=#text/css>text/css</a></code><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><dd><p><var>element</var><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><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. The CSSOM specification defines what happens
      when the attribute is dynamically set, changed, or removed.</p>

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

     <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><dd><p>Unset.<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><dd><p>Set.<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><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><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><dd><p>null<dt><a href=https://drafts.csswg.org/cssom/#concept-css-style-sheet-disabled-flag id=the-style-element:concept-css-style-sheet-disabeld-flag data-x-internal=concept-css-style-sheet-disabeld-flag>disabled flag</a><dd><p>Left at its default value.<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><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>
     </dl>

    

   </ol>

  
  <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, if the loads were successful or there were
  none, <a href=#queue-a-task id=the-style-element:queue-a-task>queue a task</a> to <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 the <code id=the-style-element:the-style-element-13><a href=#the-style-element>style</a></code> element, or, if one of the style
  sheet's <a href=#critical-subresources id=the-style-element:critical-subresources-3>critical subresources</a> failed to completely load for any reason (e.g. DNS
  error, HTTP 404 response, a connection being prematurely closed, unsupported Content-Type),
  <a href=#queue-a-task id=the-style-element:queue-a-task-2>queue a task</a> to <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 the <code id=the-style-element:the-style-element-14><a href=#the-style-element>style</a></code> element. Non-network errors in
  processing the style sheet or its subresources (e.g. CSS parse errors, PNG decoding errors) are
  not failures for the purposes of this paragraph.</p>

  <p>The <a href=#task-source id=the-style-element:task-source>task source</a> for these <a href=#concept-task id=the-style-element:concept-task>tasks</a> is the <a href=#dom-manipulation-task-source id=the-style-element:dom-manipulation-task-source>DOM
  manipulation task source</a>.</p>

  <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 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-4>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 <dfn id=dom-style-media><code>media</code></dfn> IDL attribute must
  <a href=#reflect id=the-style-element:reflect>reflect</a> the content attribute of the same name.</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>&quot;en-US&quot;</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&apos;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>&quot;la&quot;</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>Style sheets, whether added by a <code id=interactions-of-styling-and-scripting:the-link-element><a href=#the-link-element>link</a></code> element, a <code id=interactions-of-styling-and-scripting:the-style-element><a href=#the-style-element>style</a></code> element, an
  <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?></a></code> PI, an HTTP `<code id=interactions-of-styling-and-scripting:http-link><a data-x-internal=http-link href=https://tools.ietf.org/html/rfc5988#section-5>Link</a></code>` header, or
  some other mechanism, have a <dfn id=style-sheet-ready>style sheet ready</dfn> flag, which is initially unset.</p>

  <p>When a style sheet is ready to be applied, its <a href=#style-sheet-ready id=interactions-of-styling-and-scripting:style-sheet-ready>style sheet ready</a> flag must be set.
  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-2><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>

  <p>A style sheet in the context of the <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> is said to be <dfn id=a-style-sheet-that-is-blocking-scripts>a style sheet that is blocking scripts</dfn> if all of
  the following conditions occur:</p>

  <ul><li><p>The element was created by that <code id=interactions-of-styling-and-scripting:document-2><a href=#document>Document</a></code>'s parser.<li><p>The element is either a <code id=interactions-of-styling-and-scripting:the-style-element-3><a href=#the-style-element>style</a></code> element or a <code id=interactions-of-styling-and-scripting:the-link-element-2><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 element was created by the parser.<li><p>If the element is a <code id=interactions-of-styling-and-scripting:the-link-element-3><a href=#the-link-element>link</a></code> element, it's <code id=interactions-of-styling-and-scripting:attr-link-media><a href=#attr-link-media>media</a></code> attribute's value <a href=#matches-the-environment id=interactions-of-styling-and-scripting:matches-the-environment>matches the
   environment</a>.<li><p>The element's style sheet was enabled when the element was created by the parser.<li><p>The element's <a href=#style-sheet-ready id=interactions-of-styling-and-scripting:style-sheet-ready-2>style sheet ready</a> flag is not yet set.<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>, the
   element'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>.<li><p>The user agent hasn't given up on that particular style sheet yet. A user agent may give
   up on a style sheet at any time.</ul>

  <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). Implementors
  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>

  <p>A <code id=interactions-of-styling-and-scripting:document-4><a href=#document>Document</a></code> <dfn id=has-a-style-sheet-that-is-blocking-scripts>has a style sheet that is blocking scripts</dfn> if there is
  either <a href=#a-style-sheet-that-is-blocking-scripts id=interactions-of-styling-and-scripting:a-style-sheet-that-is-blocking-scripts>a style sheet that is blocking scripts</a> in the context of that
  <code id=interactions-of-styling-and-scripting:document-5><a href=#document>Document</a></code>, or if that <code id=interactions-of-styling-and-scripting:document-6><a href=#document>Document</a></code> has a <a href=#concept-document-bc id=interactions-of-styling-and-scripting:concept-document-bc>browsing context</a> that has a <a href=#parent-browsing-context id=interactions-of-styling-and-scripting:parent-browsing-context>parent browsing
  context</a>, and the <a href=#active-document id=interactions-of-styling-and-scripting:active-document>active document</a> of that <a href=#parent-browsing-context id=interactions-of-styling-and-scripting:parent-browsing-context-2>parent browsing context</a>
  itself <a href=#has-a-style-sheet-that-is-blocking-scripts id=interactions-of-styling-and-scripting:has-a-style-sheet-that-is-blocking-scripts>has a style sheet that is blocking scripts</a>.</p>

  <p>A <code id=interactions-of-styling-and-scripting:document-7><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-2>have a style sheet that is blocking
  scripts</a> as defined in the previous paragraph.</p>

  




  <h3 id=sections><span class=secno>4.3</span> Sections<a href=#sections class=self-link></a></h3><div class=status><input onclick=toggleStatus(this) value=⋰ type=button><p class=support><strong>Support:</strong> html5semantic<span class="and_chr yes"><span>Chrome for Android</span> <span>67+</span></span><span class="chrome yes"><span>Chrome</span> <span>26+</span></span><span class="ios_saf yes"><span>iOS Safari</span> <span>7.0+</span></span><span class="and_uc yes"><span>UC Browser for Android</span> <span>11.8+</span></span><span class="firefox yes"><span>Firefox</span> <span>21+</span></span><span class="ie partial"><span>IE (limited)</span> <span>9+</span></span><span class="op_mini partial"><span>Opera Mini (limited)</span> <span>all+</span></span><span class="safari yes"><span>Safari</span> <span>6.1+</span></span><span class="edge yes"><span>Edge</span> <span>12+</span></span><span class="samsung yes"><span>Samsung Internet</span> <span>4+</span></span><span class="opera yes"><span>Opera</span> <span>15+</span></span><span class="android yes"><span>Android Browser</span> <span>4.4+</span></span><p class=caniuse>Source: <a href="https://caniuse.com/#feat=html5semantic">caniuse.com</a></div>

  <h4 id=the-body-element><span class=secno>4.3.1</span> The <dfn><code>body</code></dfn> element<a href=#the-body-element class=self-link></a></h4>

  <dl class=element><dt><a href=#concept-element-categories id=the-body-element:concept-element-categories>Categories</a>:<dd><a href=#sectioning-root id=the-body-element:sectioning-root>Sectioning root</a>.<dt><a href=#concept-element-contexts id=the-body-element:concept-element-contexts>Contexts in which this element can be used</a>:<dd>As the second element in an <code id=the-body-element:the-html-element><a href=#the-html-element>html</a></code> element.<dt><a href=#concept-element-content-model id=the-body-element:concept-element-content-model>Content model</a>:<dd><a href=#flow-content-2 id=the-body-element:flow-content-2>Flow content</a>.<dt><a href=#concept-element-tag-omission id=the-body-element:concept-element-tag-omission>Tag omission in text/html</a>:<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-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>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>.<dt><a href=#concept-element-attributes id=the-body-element:concept-element-attributes>Content attributes</a>:<dd><a href=#global-attributes id=the-body-element:global-attributes>Global attributes</a><dd><code id=the-body-element:handler-window-onafterprint><a href=#handler-window-onafterprint>onafterprint</a></code><dd><code id=the-body-element:handler-window-onbeforeprint><a href=#handler-window-onbeforeprint>onbeforeprint</a></code><dd><code id=the-body-element:handler-window-onbeforeunload><a href=#handler-window-onbeforeunload>onbeforeunload</a></code><dd><code id=the-body-element:handler-window-onhashchange><a href=#handler-window-onhashchange>onhashchange</a></code><dd><code id=the-body-element:handler-window-onlanguagechange><a href=#handler-window-onlanguagechange>onlanguagechange</a></code><dd><code id=the-body-element:handler-window-onmessage><a href=#handler-window-onmessage>onmessage</a></code><dd><code id=the-body-element:handler-window-onmessageerror><a href=#handler-window-onmessageerror>onmessageerror</a></code><dd><code id=the-body-element:handler-window-onoffline><a href=#handler-window-onoffline>onoffline</a></code><dd><code id=the-body-element:handler-window-ononline><a href=#handler-window-ononline>ononline</a></code><dd><code id=the-body-element:handler-window-onpagehide><a href=#handler-window-onpagehide>onpagehide</a></code><dd><code id=the-body-element:handler-window-onpageshow><a href=#handler-window-onpageshow>onpageshow</a></code><dd><code id=the-body-element:handler-window-onpopstate><a href=#handler-window-onpopstate>onpopstate</a></code><dd><code id=the-body-element:handler-window-onrejectionhandled><a href=#handler-window-onrejectionhandled>onrejectionhandled</a></code><dd><code id=the-body-element:handler-window-onstorage><a href=#handler-window-onstorage>onstorage</a></code><dd><code id=the-body-element:handler-window-onunhandledrejection><a href=#handler-window-onunhandledrejection>onunhandledrejection</a></code><dd><code id=the-body-element:handler-window-onunload><a href=#handler-window-onunload>onunload</a></code><dt><a href=#concept-element-dom id=the-body-element:concept-element-dom>DOM interface</a>:<dd>
    <pre><code class='idl'>[<c- g>Exposed</c->=<c- n>Window</c->,
 <a href='#htmlconstructor' id='the-body-element:htmlconstructor'><c- g>HTMLConstructor</c-></a>]
<c- b>interface</c-> <dfn id='htmlbodyelement'><c- g>HTMLBodyElement</c-></dfn> : <a href='#htmlelement' id='the-body-element:htmlelement'><c- n>HTMLElement</c-></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>
</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>&quot;en&quot;</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>&apos;status&apos;</c-><c- p>).</c->textContent <c- o>=</c->
       online <c- o>?</c-> <c- t>&apos;Online&apos;</c-> <c- o>:</c-> <c- t>&apos;Offline&apos;</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>&quot;update(true)&quot;</c->
       <c- e>onoffline</c-><c- o>=</c-><c- s>&quot;update(false)&quot;</c->
       <c- e>onload</c-><c- o>=</c-><c- s>&quot;update(navigator.onLine)&quot;</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>&quot;status&quot;</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><code>article</code></dfn> element<a href=#the-article-element class=self-link></a></h4>

  <dl class=element><dt><a href=#concept-element-categories id=the-article-element:concept-element-categories>Categories</a>:<dd><a href=#flow-content-2 id=the-article-element:flow-content-2>Flow content</a>.<dd><a href=#sectioning-content-2 id=the-article-element:sectioning-content-2>Sectioning content</a>.<dd><a href=#palpable-content-2 id=the-article-element:palpable-content-2>Palpable content</a>.<dt><a href=#concept-element-contexts id=the-article-element:concept-element-contexts>Contexts in which this element can be used</a>:<dd>Where <a href=#flow-content-2 id=the-article-element:flow-content-2-2>flow content</a> is expected.<dt><a href=#concept-element-content-model id=the-article-element:concept-element-content-model>Content model</a>:<dd><a href=#flow-content-2 id=the-article-element:flow-content-2-3>Flow content</a>.<dt><a href=#concept-element-tag-omission id=the-article-element:concept-element-tag-omission>Tag omission in text/html</a>:<dd>Neither tag is omissible.<dt><a href=#concept-element-attributes id=the-article-element:concept-element-attributes>Content attributes</a>:<dd><a href=#global-attributes id=the-article-element:global-attributes>Global attributes</a><dt><a href=#concept-element-dom id=the-article-element:concept-element-dom>DOM interface</a>:<dd>Uses <code id=the-article-element:htmlelement><a href=#htmlelement>HTMLElement</a></code>.</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 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>

   <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>&quot;http://schema.org/BlogPosting&quot;</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>&quot;headline&quot;</c-><c- p>&gt;</c->The Very First Rule of Life<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>&quot;datePublished&quot;</c-> <c- e>datetime</c-><c- o>=</c-><c- s>&quot;2009-10-09&quot;</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>&quot;url&quot;</c-> <c- e>href</c-><c- o>=</c-><c- s>&quot;?comments=0&quot;</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&apos;s a microphone anywhere near you, assume it&apos;s hot and
 sending whatever you&apos;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>&quot;discussionUrl&quot;</c-> <c- e>href</c-><c- o>=</c-><c- s>&quot;?comments=1&quot;</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>&quot;http://schema.org/BlogPosting&quot;</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>&quot;headline&quot;</c-><c- p>&gt;</c->The Very First Rule of Life<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>&quot;datePublished&quot;</c-> <c- e>datetime</c-><c- o>=</c-><c- s>&quot;2009-10-09&quot;</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>&quot;url&quot;</c-> <c- e>href</c-><c- o>=</c-><c- s>&quot;?comments=0&quot;</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&apos;s a microphone anywhere near you, assume it&apos;s hot and
 sending whatever you&apos;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>&quot;comment&quot;</c-> <c- e>itemscope</c-> <c- e>itemtype</c-><c- o>=</c-><c- s>&quot;http://schema.org/UserComments&quot;</c-> <c- e>id</c-><c- o>=</c-><c- s>&quot;c1&quot;</c-><c- p>&gt;</c->
   <c- p>&lt;</c-><c- f>link</c-> <c- e>itemprop</c-><c- o>=</c-><c- s>&quot;url&quot;</c-> <c- e>href</c-><c- o>=</c-><c- s>&quot;#c1&quot;</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>&quot;creator&quot;</c-> <c- e>itemscope</c-> <c- e>itemtype</c-><c- o>=</c-><c- s>&quot;http://schema.org/Person&quot;</c-><c- p>&gt;</c->
     <c- p>&lt;</c-><c- f>span</c-> <c- e>itemprop</c-><c- o>=</c-><c- s>&quot;name&quot;</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>&quot;commentTime&quot;</c-> <c- e>datetime</c-><c- o>=</c-><c- s>&quot;2009-10-10&quot;</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>&quot;comment&quot;</c-> <c- e>itemscope</c-> <c- e>itemtype</c-><c- o>=</c-><c- s>&quot;http://schema.org/UserComments&quot;</c-> <c- e>id</c-><c- o>=</c-><c- s>&quot;c2&quot;</c-><c- p>&gt;</c->
   <c- p>&lt;</c-><c- f>link</c-> <c- e>itemprop</c-><c- o>=</c-><c- s>&quot;url&quot;</c-> <c- e>href</c-><c- o>=</c-><c- s>&quot;#c2&quot;</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>&quot;creator&quot;</c-> <c- e>itemscope</c-> <c- e>itemtype</c-><c- o>=</c-><c- s>&quot;http://schema.org/Person&quot;</c-><c- p>&gt;</c->
     <c- p>&lt;</c-><c- f>span</c-> <c- e>itemprop</c-><c- o>=</c-><c- s>&quot;name&quot;</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>&quot;commentTime&quot;</c-> <c- e>datetime</c-><c- o>=</c-><c- s>&quot;2009-10-10&quot;</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>&quot;/scripts/widgets.js&quot;</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>&quot;/styles/main.css&quot;</c-><c- p>&gt;</c->
<c- p>&lt;</c-><c- f>article</c-> <c- e>is</c-><c- o>=</c-><c- s>&quot;stock-widget&quot;</c-><c- p>&gt;</c->
 <c- p>&lt;</c-><c- f>h1</c-><c- p>&gt;</c->Stocks<c- p>&lt;/</c-><c- f>h1</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>&quot;Refresh&quot;</c-> <c- e>onclick</c-><c- o>=</c-><c- s>&quot;this.parentElement.refresh()&quot;</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>&quot;news-widget&quot;</c-><c- p>&gt;</c->
 <c- p>&lt;</c-><c- f>h1</c-><c- p>&gt;</c->News<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>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>&quot;Refresh&quot;</c-> <c- e>onclick</c-><c- o>=</c-><c- s>&quot;this.parentElement.refresh()&quot;</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><code>section</code></dfn> element<a href=#the-section-element class=self-link></a></h4>

  <dl class=element><dt><a href=#concept-element-categories id=the-section-element:concept-element-categories>Categories</a>:<dd><a href=#flow-content-2 id=the-section-element:flow-content-2>Flow content</a>.<dd><a href=#sectioning-content-2 id=the-section-element:sectioning-content-2>Sectioning content</a>.<dd><a href=#palpable-content-2 id=the-section-element:palpable-content-2>Palpable content</a>.<dt><a href=#concept-element-contexts id=the-section-element:concept-element-contexts>Contexts in which this element can be used</a>:<dd>Where <a href=#flow-content-2 id=the-section-element:flow-content-2-2>flow content</a> is expected.<dt><a href=#concept-element-content-model id=the-section-element:concept-element-content-model>Content model</a>:<dd><a href=#flow-content-2 id=the-section-element:flow-content-2-3>Flow content</a>.<dt><a href=#concept-element-tag-omission id=the-section-element:concept-element-tag-omission>Tag omission in text/html</a>:<dd>Neither tag is omissible.<dt><a href=#concept-element-attributes id=the-section-element:concept-element-attributes>Content attributes</a>:<dd><a href=#global-attributes id=the-section-element:global-attributes>Global attributes</a><dt><a href=#concept-element-dom id=the-section-element:concept-element-dom>DOM interface</a>:<dd>Uses <code id=the-section-element:htmlelement><a href=#htmlelement>HTMLElement</a></code>.</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>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>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>h2</c-><c- p>&gt;</c->Tasty, delicious fruit!<c- p>&lt;/</c-><c- f>h2</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>h1</c-><c- p>&gt;</c->Red Delicious<c- p>&lt;/</c-><c- f>h1</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>h1</c-><c- p>&gt;</c->Granny Smith<c- p>&lt;/</c-><c- f>h1</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>

   <p>Notice how the use of <code id=the-section-element:the-section-element-5><a href=#the-section-element>section</a></code> means that the author can use <code id=the-section-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 throughout, without having to worry about whether a particular section is at the top
   level, the second level, the third level, and so on.</p>

  </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>H1</c->
       <c- p>&gt;</c->Ceremony<c- p>&lt;/</c-><c- f>H1</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 Validactorian<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>H1</c->
       <c- p>&gt;</c->Graduates<c- p>&lt;/</c-><c- f>H1</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>h1</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>h1</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>h2</c-><c- p>&gt;</c->A sample with not much content<c- p>&lt;/</c-><c- f>h2</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>&quot;chapter&quot;</c-><c- p>&gt;</c->
 <c- p>&lt;</c-><c- f>h1</c-><c- p>&gt;</c->My First Chapter<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 the first of my chapters. It doesn&apos;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>&quot;chapter&quot;</c-><c- p>&gt;</c->
 <c- p>&lt;</c-><c- f>h1</c-><c- p>&gt;</c->It Continues: The Second Chapter<c- p>&lt;/</c-><c- f>h1</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>&quot;chapter&quot;</c-><c- p>&gt;</c->
 <c- p>&lt;</c-><c- f>h1</c-><c- p>&gt;</c->Chapter Three: A Further Example<c- p>&lt;/</c-><c- f>h1</c-><c- p>&gt;</c->
 <c- p>&lt;</c-><c- f>p</c-><c- p>&gt;</c->It&apos;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>&quot;appendix&quot;</c-><c- p>&gt;</c->
 <c- p>&lt;</c-><c- f>h1</c-><c- p>&gt;</c->Appendix A: Overview of Examples<c- p>&lt;/</c-><c- f>h1</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>&quot;appendix&quot;</c-><c- p>&gt;</c->
 <c- p>&lt;</c-><c- f>h1</c-><c- p>&gt;</c->Appendix B: Some Closing Remarks<c- p>&lt;/</c-><c- f>h1</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><code>nav</code></dfn> element<a href=#the-nav-element class=self-link></a></h4>

  <dl class=element><dt><a href=#concept-element-categories id=the-nav-element:concept-element-categories>Categories</a>:<dd><a href=#flow-content-2 id=the-nav-element:flow-content-2>Flow content</a>.<dd><a href=#sectioning-content-2 id=the-nav-element:sectioning-content-2>Sectioning content</a>.<dd><a href=#palpable-content-2 id=the-nav-element:palpable-content-2>Palpable content</a>.<dt><a href=#concept-element-contexts id=the-nav-element:concept-element-contexts>Contexts in which this element can be used</a>:<dd>Where <a href=#flow-content-2 id=the-nav-element:flow-content-2-2>flow content</a> is expected.<dt><a href=#concept-element-content-model id=the-nav-element:concept-element-content-model>Content model</a>:<dd><a href=#flow-content-2 id=the-nav-element:flow-content-2-3>Flow content</a>.<dt><a href=#concept-element-tag-omission id=the-nav-element:concept-element-tag-omission>Tag omission in text/html</a>:<dd>Neither tag is omissible.<dt><a href=#concept-element-attributes id=the-nav-element:concept-element-attributes>Content attributes</a>:<dd><a href=#global-attributes id=the-nav-element:global-attributes>Global attributes</a><dt><a href=#concept-element-dom id=the-nav-element:concept-element-dom>DOM interface</a>:<dd>Uses <code id=the-nav-element:htmlelement><a href=#htmlelement>HTMLElement</a></code>.</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>&quot;/&quot;</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>&quot;/events&quot;</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>h1</c-><c- p>&gt;</c->Demos in Exampland<c- p>&lt;/</c-><c- f>h1</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>&quot;#public&quot;</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>&quot;#destroy&quot;</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>&quot;public&quot;</c-><c- p>&gt;</c->
    <c- p>&lt;</c-><c- f>h1</c-><c- p>&gt;</c->Public demonstrations<c- p>&lt;/</c-><c- f>h1</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>&quot;destroy&quot;</c-><c- p>&gt;</c->
    <c- p>&lt;</c-><c- f>h1</c-><c- p>&gt;</c->Demolitions<c- p>&lt;/</c-><c- f>h1</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>&quot;?edit&quot;</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>&quot;?delete&quot;</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>&quot;?Rename&quot;</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>&quot;http://schema.org/Blog&quot;</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>&quot;news.html&quot;</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>&quot;blog.html&quot;</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>&quot;forums.html&quot;</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>&quot;dateModified&quot;</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>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>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>&quot;articles.html&quot;</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>&quot;today.html&quot;</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>&quot;successes.html&quot;</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>&quot;blogPosts&quot;</c-> <c- e>itemscope</c-> <c- e>itemtype</c-><c- o>=</c-><c- s>&quot;http://schema.org/BlogPosting&quot;</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>&quot;headline&quot;</c-><c- p>&gt;</c->My Day at the Beach<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>div</c-> <c- e>itemprop</c-><c- o>=</c-><c- s>&quot;articleBody&quot;</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>&quot;datePublished&quot;</c-> <c- e>datetime</c-><c- o>=</c-><c- s>&quot;2009-10-10&quot;</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>&quot;copyrightYear&quot;</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>&quot;copyrightHolder&quot;</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>&quot;about.html&quot;</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>&quot;policy.html&quot;</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>&quot;contact.html&quot;</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>&quot;/blog&quot;</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>&quot;/school&quot;</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>&quot;/school/thesis&quot;</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>&quot;https://games.example.com/&quot;</c-><c- p>&gt;</c->&quot;games&quot;<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>&quot;https://isp.example.net/&quot;</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>&quot;/about&quot;</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 e-mail 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>&quot;Compose&quot;</c-> <c- e>onclick</c-><c- o>=</c-><c- s>&quot;compose()&quot;</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>&quot;/inbox&quot;</c-> <c- e>onclick</c-><c- o>=</c-><c- s>&quot;return openFolder(this.href)&quot;</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>&quot;/sent&quot;</c-> <c- e>onclick</c-><c- o>=</c-><c- s>&quot;return openFolder(this.href)&quot;</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>&quot;/drafts&quot;</c-> <c- e>onclick</c-><c- o>=</c-><c- s>&quot;return openFolder(this.href)&quot;</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>&quot;/trash&quot;</c-> <c- e>onclick</c-><c- o>=</c-><c- s>&quot;return openFolder(this.href)&quot;</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>&quot;/customers&quot;</c-> <c- e>onclick</c-><c- o>=</c-><c- s>&quot;return openFolder(this.href)&quot;</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><code>aside</code></dfn> element<a href=#the-aside-element class=self-link></a></h4>

  <dl class=element><dt><a href=#concept-element-categories id=the-aside-element:concept-element-categories>Categories</a>:<dd><a href=#flow-content-2 id=the-aside-element:flow-content-2>Flow content</a>.<dd><a href=#sectioning-content-2 id=the-aside-element:sectioning-content-2>Sectioning content</a>.<dd><a href=#palpable-content-2 id=the-aside-element:palpable-content-2>Palpable content</a>.<dt><a href=#concept-element-contexts id=the-aside-element:concept-element-contexts>Contexts in which this element can be used</a>:<dd>Where <a href=#flow-content-2 id=the-aside-element:flow-content-2-2>flow content</a> is expected.<dt><a href=#concept-element-content-model id=the-aside-element:concept-element-content-model>Content model</a>:<dd><a href=#flow-content-2 id=the-aside-element:flow-content-2-3>Flow content</a>.<dt><a href=#concept-element-tag-omission id=the-aside-element:concept-element-tag-omission>Tag omission in text/html</a>:<dd>Neither tag is omissible.<dt><a href=#concept-element-attributes id=the-aside-element:concept-element-attributes>Content attributes</a>:<dd><a href=#global-attributes id=the-aside-element:global-attributes>Global attributes</a><dt><a href=#concept-element-dom id=the-aside-element:concept-element-dom>DOM interface</a>:<dd>Uses <code id=the-aside-element:htmlelement><a href=#htmlelement>HTMLElement</a></code>.</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>h1</c-><c- p>&gt;</c->Switzerland<c- p>&lt;/</c-><c- f>h1</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&apos;m not at
work. But I&apos;m paid to do my hobby, so I never know what to
answer. Some people wonder what they would do if they didn&apos;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&apos;m not at work. But I&apos;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&apos;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>h1</c-><c- p>&gt;</c->My blogroll<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>&quot;https://blog.example.com/&quot;</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>h1</c-><c- p>&gt;</c->Archives<c- p>&lt;/</c-><c- f>h1</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>&quot;/last-post&quot;</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>&quot;/first-post&quot;</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>&quot;https://twitter.example.net/t31351234&quot;</c-><c- p>&gt;</c->
   I&apos;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>&quot;https://twitter.example.net/t31219752&quot;</c-><c- p>&gt;</c->
   I&apos;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>h1</c-><c- p>&gt;</c->My last post<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 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>&quot;/last-post&quot;</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>h1</c-><c- p>&gt;</c->My first post<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 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&apos;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&apos;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>h1</c-><c- p>&gt;</c->Posting<c- p>&lt;/</c-><c- f>h1</c-><c- p>&gt;</c->
   <c- p>&lt;</c-><c- f>p</c-><c- p>&gt;</c->While I&apos;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>&quot;/first-post&quot;</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>nav</c-><c- p>&gt;</c->
   <c- p>&lt;</c-><c- f>a</c-> <c- e>href</c-><c- o>=</c-><c- s>&quot;/archives&quot;</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>&quot;/about&quot;</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>&quot;/copyright&quot;</c-><c- p>&gt;</c->Copyright<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>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><code>h1</code></dfn>, <dfn id=the-h2-element><code>h2</code></dfn>, <dfn id=the-h3-element><code>h3</code></dfn>, <dfn id=the-h4-element><code>h4</code></dfn>, <dfn id=the-h5-element><code>h5</code></dfn>, and
  <dfn id=the-h6-element><code>h6</code></dfn> elements<a href=#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements class=self-link></a></h4>

  <dl class=element><dt><a href=#concept-element-categories id=the-h1,-h2,-h3,-h4,-h5,-and-h6-elements:concept-element-categories>Categories</a>:<dd><a href=#flow-content-2 id=the-h1,-h2,-h3,-h4,-h5,-and-h6-elements:flow-content-2>Flow content</a>.<dd><a href=#heading-content-2 id=the-h1,-h2,-h3,-h4,-h5,-and-h6-elements:heading-content-2>Heading content</a>.<dd><a href=#palpable-content-2 id=the-h1,-h2,-h3,-h4,-h5,-and-h6-elements:palpable-content-2>Palpable content</a>.<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>:<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>Where <a href=#flow-content-2 id=the-h1,-h2,-h3,-h4,-h5,-and-h6-elements:flow-content-2-2>flow content</a> is expected.<dt><a href=#concept-element-content-model id=the-h1,-h2,-h3,-h4,-h5,-and-h6-elements:concept-element-content-model>Content model</a>:<dd><a href=#phrasing-content-2 id=the-h1,-h2,-h3,-h4,-h5,-and-h6-elements:phrasing-content-2>Phrasing content</a>.<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>:<dd>Neither tag is omissible.<dt><a href=#concept-element-attributes id=the-h1,-h2,-h3,-h4,-h5,-and-h6-elements:concept-element-attributes>Content attributes</a>:<dd><a href=#global-attributes id=the-h1,-h2,-h3,-h4,-h5,-and-h6-elements:global-attributes>Global attributes</a><dt><a href=#concept-element-dom id=the-h1,-h2,-h3,-h4,-h5,-and-h6-elements:concept-element-dom>DOM interface</a>:<dd>
    <pre><code class='idl'>[<c- g>Exposed</c->=<c- n>Window</c->,
 <a href='#htmlconstructor' id='the-h1,-h2,-h3,-h4,-h5,-and-h6-elements:htmlconstructor'><c- g>HTMLConstructor</c-></a>]
<c- b>interface</c-> <dfn id='htmlheadingelement'><c- g>HTMLHeadingElement</c-></dfn> : <a href='#htmlelement' id='the-h1,-h2,-h3,-h4,-h5,-and-h6-elements:htmlelement'><c- n>HTMLElement</c-></a> {};</code></pre>
   </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-sections id=the-h1,-h2,-h3,-h4,-h5,-and-h6-elements:headings-and-sections>headings and
  sections</a>.</p>

  <p>These elements have a <dfn id=rank>rank</dfn> given by the number in their name. 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 said to have the highest rank, the <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>h6</a></code> element has the lowest rank, and two
  elements with the same name have equal rank.</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&apos;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&apos;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>h1</c-><c- p>&gt;</c->Diving in<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>section</c-><c- p>&gt;</c->
  <c- p>&lt;</c-><c- f>h1</c-><c- p>&gt;</c->Simple shapes<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>section</c-><c- p>&gt;</c->
  <c- p>&lt;</c-><c- f>h1</c-><c- p>&gt;</c->Canvas coordinates<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>h1</c-><c- p>&gt;</c->Canvas coordinates diagram<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>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->Paths<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>body</c-><c- p>&gt;</c-></code></pre>

   <p>Authors might prefer the former style for its terseness, or the latter style for its
   convenience in the face of heavy editing; which is best is purely an issue of preferred authoring
   style.</p>

   <p>The two styles can be combined, for compatibility with legacy tools while still
   future-proofing for when that compatibility is no longer needed. This third snippet again has the
   same outline as the previous two:</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&apos;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>

  </div>




  <h4 id=the-hgroup-element><span class=secno>4.3.7</span> The <dfn><code>hgroup</code></dfn> element<a href=#the-hgroup-element class=self-link></a></h4>

  <dl class=element><dt><a href=#concept-element-categories id=the-hgroup-element:concept-element-categories>Categories</a>:<dd><a href=#flow-content-2 id=the-hgroup-element:flow-content-2>Flow content</a>.<dd><a href=#heading-content-2 id=the-hgroup-element:heading-content-2>Heading content</a>.<dd><a href=#palpable-content-2 id=the-hgroup-element:palpable-content-2>Palpable content</a>.<dt><a href=#concept-element-contexts id=the-hgroup-element:concept-element-contexts>Contexts in which this element can be used</a>:<dd>Where <a href=#flow-content-2 id=the-hgroup-element:flow-content-2-2>flow content</a> is expected.<dt><a href=#concept-element-content-model id=the-hgroup-element:concept-element-content-model>Content model</a>:<dd>One or more <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>, <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> elements, optionally intermixed with <a href=#script-supporting-elements-2 id=the-hgroup-element:script-supporting-elements-2>script-supporting
   elements</a>.<dt><a href=#concept-element-tag-omission id=the-hgroup-element:concept-element-tag-omission>Tag omission in text/html</a>:<dd>Neither tag is omissible.<dt><a href=#concept-element-attributes id=the-hgroup-element:concept-element-attributes>Content attributes</a>:<dd><a href=#global-attributes id=the-hgroup-element:global-attributes>Global attributes</a><dt><a href=#concept-element-dom id=the-hgroup-element:concept-element-dom>DOM interface</a>:<dd>Uses <code id=the-hgroup-element:htmlelement><a href=#htmlelement>HTMLElement</a></code>.</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> the heading of a section, which
  consists of all the <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 children of the
  <code id=the-hgroup-element:the-hgroup-element-2><a href=#the-hgroup-element>hgroup</a></code> element. The element is used to group a set of
  <code id=the-hgroup-element:the-h1,-h2,-h3,-h4,-h5,-and-h6-elements-9><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-10><a href=#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements>h6</a></code> elements when the heading has multiple levels, such as
  subheadings, alternative titles, or taglines.</p>

  <p>The <a href=#rank id=the-hgroup-element:rank>rank</a> of an <code id=the-hgroup-element:the-hgroup-element-3><a href=#the-hgroup-element>hgroup</a></code> element is the rank of the highest-ranked
  <code id=the-hgroup-element:the-h1,-h2,-h3,-h4,-h5,-and-h6-elements-11><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-12><a href=#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements>h6</a></code> element descendant of the <code id=the-hgroup-element:the-hgroup-element-4><a href=#the-hgroup-element>hgroup</a></code> element, if
  there are any such elements, or otherwise the same as for an <code id=the-hgroup-element:the-h1,-h2,-h3,-h4,-h5,-and-h6-elements-13><a href=#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements>h1</a></code> element (the highest
  rank). Other <code id=the-hgroup-element:the-h1,-h2,-h3,-h4,-h5,-and-h6-elements-14><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-15><a href=#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements>h6</a></code> elements of <a href=#heading-content-2 id=the-hgroup-element:heading-content-2-2>heading content</a> in the
  <code id=the-hgroup-element:the-hgroup-element-5><a href=#the-hgroup-element>hgroup</a></code> element indicate subheadings or subtitles or (secondary) alternative
  titles.</p>

  <p>The section on <a href=#headings-and-sections id=the-hgroup-element:headings-and-sections>headings and sections</a> defines how <code id=the-hgroup-element:the-hgroup-element-6><a href=#the-hgroup-element>hgroup</a></code> elements are
  assigned to individual sections.</p>

  <div class=example>

   <p>Here are some examples of valid headings.</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>h2</c-><c- p>&gt;</c->Space is not the only void<c- p>&lt;/</c-><c- f>h2</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>h2</c-><c- p>&gt;</c->Or: How I Learned to Stop Worrying and Love the Bomb<c- p>&lt;/</c-><c- f>h2</c-><c- p>&gt;</c->
<c- p>&lt;/</c-><c- f>hgroup</c-><c- p>&gt;</c-></code></pre>

   <p>The point of using <code id=the-hgroup-element:the-hgroup-element-7><a href=#the-hgroup-element>hgroup</a></code> in these examples is to prevent the <code id=the-hgroup-element:the-h1,-h2,-h3,-h4,-h5,-and-h6-elements-16><a href=#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements>h2</a></code>
   element (which acts as a secondary title) from creating a separate section of its own in any
   <a href=#outline id=the-hgroup-element:outline>outline</a> and to instead cause the contents of the <code id=the-hgroup-element:the-h1,-h2,-h3,-h4,-h5,-and-h6-elements-17><a href=#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements>h2</a></code> to be shown in
   rendered output from the <a href=#outline id=the-hgroup-element:outline-2>outline</a> algorithm in some way to indicate that it is not
   the title of a separate section but instead just a secondary title in a group of titles.</p>
   

   <p>How a user agent exposes such multi-level headings in user interfaces (e.g. in tables of
   contents or search results) is left open to implementers, as it is a user interface issue. The
   first example above could be rendered as:</p>

   <pre>The reality dysfunction: Space is not the only void</pre>

   <p>Alternatively, it could look like this:

   <pre>The reality dysfunction (Space is not the only void)</pre>

   <p>In interfaces where a title can be rendered on multiple lines, it could be rendered as
   follows, maybe with the first line in a bigger font size:</p>

   <pre>The reality dysfunction
Space is not the only void</pre>

  </div>

  <div class=example>
   <p>The following two examples show ways in which two <code id=the-hgroup-element:the-h1,-h2,-h3,-h4,-h5,-and-h6-elements-18><a href=#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements>h1</a></code> headings could be used
   within an <code id=the-hgroup-element:the-hgroup-element-8><a href=#the-hgroup-element>hgroup</a></code> element to group the US and UK names for the same movie.</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 Avengers<c- p>&lt;/</c-><c- f>h1</c-><c- p>&gt;</c->
 <c- p>&lt;</c-><c- f>h1</c-><c- p>&gt;</c->Avengers Assemble<c- p>&lt;/</c-><c- f>h1</c-><c- p>&gt;</c->
<c- p>&lt;/</c-><c- f>hgroup</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->Avengers Assemble<c- p>&lt;/</c-><c- f>h1</c-><c- p>&gt;</c->
 <c- p>&lt;</c-><c- f>h1</c-><c- p>&gt;</c->The Avengers<c- p>&lt;/</c-><c- f>h1</c-><c- p>&gt;</c->
<c- p>&lt;/</c-><c- f>hgroup</c-><c- p>&gt;</c-></code></pre>

   <p>The first example above shows how the movie names might be grouped in a publication in the US,
   with the US name <i>The Avengers</i> as the (primary) title, and the UK name <i>Avengers
   Assemble</i> as the (secondary) alternative title. The second example above shows how the movie
   names might be grouped in a publication in the UK, with the UK name as the (primary) title, and
   the US name as the (secondary) alternative title.</p>

   <p>In both cases it is important to note the use of the <code id=the-hgroup-element:the-hgroup-element-9><a href=#the-hgroup-element>hgroup</a></code> element to group the
   two titles indicates that the titles are not equivalent; instead the first <code id=the-hgroup-element:the-h1,-h2,-h3,-h4,-h5,-and-h6-elements-19><a href=#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements>h1</a></code> gives
   the (primary) title while the second gives the (secondary) alternative title. Even though both
   the title and alternative title are marked up with <code id=the-hgroup-element:the-h1,-h2,-h3,-h4,-h5,-and-h6-elements-20><a href=#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements>h1</a></code> elements, in a rendered view
   of output from the <a href=#outline id=the-hgroup-element:outline-3>outline</a> algorithm, the second <code id=the-hgroup-element:the-h1,-h2,-h3,-h4,-h5,-and-h6-elements-21><a href=#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements>h1</a></code> in the
   <code id=the-hgroup-element:the-hgroup-element-10><a href=#the-hgroup-element>hgroup</a></code> will be shown in some way that clearly indicates it is secondary; for
   example:

   <p>In a US publication:</p>
   <pre>The Avengers (Avengers Assemble)</pre>

   <p>In a UK publication:</p>
   <pre>Avengers Assemble (The Avengers)</pre>

  </div>

  <div class=example>

   <p>In the following example, an <code id=the-hgroup-element:the-hgroup-element-11><a href=#the-hgroup-element>hgroup</a></code> element is used to mark up a two-level
   heading in a wizard-style dialog box:</p>

   <pre><code class='html'><c- p>&lt;</c-><c- f>dialog</c-> <c- e>onclose</c-><c- o>=</c-><c- s>&quot;walletSetup.continue(this.returnValue)&quot;</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->Wallet Setup<c- p>&lt;/</c-><c- f>h1</c-><c- p>&gt;</c->
  <c- p>&lt;</c-><c- f>h2</c-><c- p>&gt;</c->Configure your Wallet funding source<c- p>&lt;/</c-><c- f>h2</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->Your Wallet can be used to buy wands at the merchant in town, to buy potions from travelling
 salesmen you may find in the dungeons, and to pay for mercenaries.<c- p>&lt;/</c-><c- f>p</c-><c- p>&gt;</c->
 <c- p>&lt;</c-><c- f>p</c-><c- p>&gt;</c->We support two payment sources:<c- p>&lt;/</c-><c- f>p</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>fieldset</c-> <c- e>oninput</c-><c- o>=</c-><c- s>&quot;this.getElementsByTagName(&apos;input&apos;)[0].checked = true&quot;</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>payment-type</c-> <c- e>value</c-><c- o>=</c-><c- s>cc</c-><c- p>&gt;</c-> Credit 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>cc1</c-> <c- e>autocomplete</c-><c- o>=</c-><c- s>&quot;section-cc cc-name&quot;</c-> <c- e>placeholder</c-><c- o>=</c-><c- s>&quot;Y. Name&quot;</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->Card number: <c- p>&lt;</c-><c- f>input</c-> <c- e>name</c-><c- o>=</c-><c- s>cc2</c-> <c- e>inputmode</c-><c- o>=</c-><c- s>numeric</c-> <c- e>autocomplete</c-><c- o>=</c-><c- s>&quot;section-cc cc-number&quot;</c-> <c- e>placeholder</c-><c- o>=</c-><c- s>&quot;6331 1019 9999 0016&quot;</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>name</c-><c- o>=</c-><c- s>cc3</c-> <c- e>type</c-><c- o>=</c-><c- s>month</c-> <c- e>autocomplete</c-><c- o>=</c-><c- s>&quot;section-cc cc-exp&quot;</c-> <c- e>placeholder</c-><c- o>=</c-><c- s>&quot;2020-02&quot;</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->Security Code: <c- p>&lt;</c-><c- f>input</c-> <c- e>name</c-><c- o>=</c-><c- s>cc4</c-> <c- e>inputmode</c-><c- o>=</c-><c- s>numeric</c-> <c- e>autocomplete</c-><c- o>=</c-><c- s>&quot;section-cc cc-csc&quot;</c-> <c- e>placeholder</c-><c- o>=</c-><c- s>&quot;246&quot;</c-><c- p>&gt;&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- e>oninput</c-><c- o>=</c-><c- s>&quot;this.getElementsByTagName(&apos;input&apos;)[0].checked = true&quot;</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>payment-type</c-> <c- e>value</c-><c- o>=</c-><c- s>bank</c-><c- p>&gt;</c-> Checking Account <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 account: <c- p>&lt;</c-><c- f>input</c-> <c- e>name</c-><c- o>=</c-><c- s>bank1</c-> <c- e>autocomplete</c-><c- o>=</c-><c- s>&quot;section-bank cc-name&quot;</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->Routing number: <c- p>&lt;</c-><c- f>input</c-> <c- e>name</c-><c- o>=</c-><c- s>bank2</c-> <c- e>inputmode</c-><c- o>=</c-><c- s>numeric</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->Account number: <c- p>&lt;</c-><c- f>input</c-> <c- e>name</c-><c- o>=</c-><c- s>bank3</c-> <c- e>inputmode</c-><c- o>=</c-><c- s>numeric</c-><c- p>&gt;&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>button</c-> <c- e>type</c-><c- o>=</c-><c- s>submit</c-> <c- e>value</c-><c- o>=</c-><c- s>&quot;back&quot;</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>type</c-><c- o>=</c-><c- s>submit</c-> <c- e>value</c-><c- o>=</c-><c- s>&quot;next&quot;</c-><c- p>&gt;</c-> Next → <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>



  <h4 id=the-header-element><span class=secno>4.3.8</span> The <dfn><code>header</code></dfn> element<a href=#the-header-element class=self-link></a></h4>

  <dl class=element><dt><a href=#concept-element-categories id=the-header-element:concept-element-categories>Categories</a>:<dd><a href=#flow-content-2 id=the-header-element:flow-content-2>Flow content</a>.<dd><a href=#palpable-content-2 id=the-header-element:palpable-content-2>Palpable content</a>.<dt><a href=#concept-element-contexts id=the-header-element:concept-element-contexts>Contexts in which this element can be used</a>:<dd>Where <a href=#flow-content-2 id=the-header-element:flow-content-2-2>flow content</a> is expected.<dt><a href=#concept-element-content-model id=the-header-element:concept-element-content-model>Content model</a>:<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.<dt><a href=#concept-element-tag-omission id=the-header-element:concept-element-tag-omission>Tag omission in text/html</a>:<dd>Neither tag is omissible.<dt><a href=#concept-element-attributes id=the-header-element:concept-element-attributes>Content attributes</a>:<dd><a href=#global-attributes id=the-header-element:global-attributes>Global attributes</a><dt><a href=#concept-element-dom id=the-header-element:concept-element-dom>DOM interface</a>:<dd>Uses <code id=the-header-element:htmlelement><a href=#htmlelement>HTMLElement</a></code>.</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 the section's 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>h2</c-><c- p>&gt;</c->Living Standard — Last Updated 19 October 2015<c- p>&lt;/</c-><c- f>h2</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>&quot;https://github.com/whatwg/fullscreen&quot;</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>&quot;https://github.com/whatwg/fullscreen/commits&quot;</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>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>&quot;/games&quot;</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>&quot;/forum&quot;</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>&quot;/download&quot;</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 &quot;Important News&quot; --&gt;</c->
  <c- p>&lt;</c-><c- f>p</c-><c- p>&gt;</c->To play today&apos;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 &quot;Games&quot; --&gt;</c->
 ...</code></pre>

  </div>




  <h4 id=the-footer-element><span class=secno>4.3.9</span> The <dfn><code>footer</code></dfn> element<a href=#the-footer-element class=self-link></a></h4>

  <dl class=element><dt><a href=#concept-element-categories id=the-footer-element:concept-element-categories>Categories</a>:<dd><a href=#flow-content-2 id=the-footer-element:flow-content-2>Flow content</a>.<dd><a href=#palpable-content-2 id=the-footer-element:palpable-content-2>Palpable content</a>.<dt><a href=#concept-element-contexts id=the-footer-element:concept-element-contexts>Contexts in which this element can be used</a>:<dd>Where <a href=#flow-content-2 id=the-footer-element:flow-content-2-2>flow content</a> is expected.<dt><a href=#concept-element-content-model id=the-footer-element:concept-element-content-model>Content model</a>:<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.<dt><a href=#concept-element-tag-omission id=the-footer-element:concept-element-tag-omission>Tag omission in text/html</a>:<dd>Neither tag is omissible.<dt><a href=#concept-element-attributes id=the-footer-element:concept-element-attributes>Content attributes</a>:<dd><a href=#global-attributes id=the-footer-element:global-attributes>Global attributes</a><dt><a href=#concept-element-dom id=the-footer-element:concept-element-dom>DOM interface</a>:<dd>Uses <code id=the-footer-element:htmlelement><a href=#htmlelement>HTMLElement</a></code>.</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>sectioning content</a> or <a href=#sectioning-root id=the-footer-element:sectioning-root>sectioning root</a> element. 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, indexes, 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 the nearest ancestor <a href=#sectioning-content-2 id=the-footer-element:sectioning-content-2-2>sectioning content</a> or <a href=#sectioning-root id=the-footer-element:sectioning-root-2>sectioning root</a>
  element is <a href=#the-body-element-2 id=the-footer-element:the-body-element-2>the body element</a>, 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 <a href=#sectioning-content-2 id=the-footer-element:sectioning-content-2-3>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>&quot;../&quot;</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>h2</c-><c- p>&gt;</c->The ipsum of all lorems<c- p>&lt;/</c-><c- f>h2</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>&quot;../&quot;</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>&quot;en&quot;</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>&quot;/fm/015.ogv&quot;</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>&quot;/fm/015.ogv&quot;</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>&quot;2009-10-21T18:26-07:00&quot;</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>&quot;2009-09-15T14:54-07:00&quot;</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>&quot;/credits.html&quot;</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>&quot;/tos.html&quot;</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>&quot;/index.html&quot;</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>&quot;images/somersaults.jpeg&quot;</c-> <c- e>alt</c-><c- o>=</c-><c- s>&quot;&quot;</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>&quot;articles/somersaults/1&quot;</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>&quot;articles/somersaults/2&quot;</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>&quot;images/kindplus.jpeg&quot;</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>&quot;articles/kindplus/1&quot;</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>&quot;images/crisps.jpeg&quot;</c-><c- p>&gt;</c-> The chips are down, now all
    that&apos;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>&quot;articles/crisps/1&quot;</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>&quot;/about&quot;</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>&quot;/feedback&quot;</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>&quot;/sitemap&quot;</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>&quot;/tos&quot;</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><code>address</code></dfn> element<a href=#the-address-element class=self-link></a></h4>

  <dl class=element><dt><a href=#concept-element-categories id=the-address-element:concept-element-categories>Categories</a>:<dd><a href=#flow-content-2 id=the-address-element:flow-content-2>Flow content</a>.<dd><a href=#palpable-content-2 id=the-address-element:palpable-content-2>Palpable content</a>.<dt><a href=#concept-element-contexts id=the-address-element:concept-element-contexts>Contexts in which this element can be used</a>:<dd>Where <a href=#flow-content-2 id=the-address-element:flow-content-2-2>flow content</a> is expected.<dt><a href=#concept-element-content-model id=the-address-element:concept-element-content-model>Content model</a>:<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.<dt><a href=#concept-element-tag-omission id=the-address-element:concept-element-tag-omission>Tag omission in text/html</a>:<dd>Neither tag is omissible.<dt><a href=#concept-element-attributes id=the-address-element:concept-element-attributes>Content attributes</a>:<dd><a href=#global-attributes id=the-address-element:global-attributes>Global attributes</a><dt><a href=#concept-element-dom id=the-address-element:concept-element-dom>DOM interface</a>:<dd>Uses <code id=the-address-element:htmlelement><a href=#htmlelement>HTMLElement</a></code>.</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>&quot;../People/Raggett/&quot;</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>&quot;../People/Arnaud/&quot;</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>&quot;Activity&quot;</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>

  

  <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>If <var>node</var> is a <code id=the-address-element:the-body-element-3><a href=#the-body-element>body</a></code> element<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>

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

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

   <dt>Otherwise<dd>

    <p>There is no contact information for <var>node</var>.</p>

   </dl>

  <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>&quot;mailto:js@example.com&quot;</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-sections><span class=secno>4.3.11</span> <dfn>Headings and sections</dfn><a href=#headings-and-sections class=self-link></a></h4>

  <p>The <code id=headings-and-sections: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-sections: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 and the <code id=headings-and-sections:the-hgroup-element><a href=#the-hgroup-element>hgroup</a></code> element are
  headings.</p>

  <p>The first element of <a href=#heading-content-2 id=headings-and-sections:heading-content-2>heading content</a> in an element of <a href=#sectioning-content-2 id=headings-and-sections:sectioning-content-2>sectioning
  content</a> <a href=#represents id=headings-and-sections:represents>represents</a> the heading for that section. Subsequent headings of equal
  or higher <a href=#rank id=headings-and-sections:rank>rank</a> start new (implied) sections, headings of lower <a href=#rank id=headings-and-sections:rank-2>rank</a>
  start implied subsections that are part of the previous one. In both cases, the element
  <a href=#represents id=headings-and-sections:represents-2>represents</a> the heading of the implied section.</p>

  <p>Certain elements are said to be <dfn id=sectioning-root>sectioning roots</dfn>, including
  <code id=headings-and-sections:the-blockquote-element><a href=#the-blockquote-element>blockquote</a></code> and <code id=headings-and-sections:the-td-element><a href=#the-td-element>td</a></code> elements. These elements can have their own outlines,
  but the sections and headings inside these elements do not contribute to the outlines of their
  ancestors.</p>

  
  <ul class="brief category-list"><li><code id=headings-and-sections:the-blockquote-element-2><a href=#the-blockquote-element>blockquote</a></code><li><code id=headings-and-sections:the-body-element><a href=#the-body-element>body</a></code><li><code id=headings-and-sections:the-details-element><a href=#the-details-element>details</a></code><li><code id=headings-and-sections:the-dialog-element><a href=#the-dialog-element>dialog</a></code><li><code id=headings-and-sections:the-fieldset-element><a href=#the-fieldset-element>fieldset</a></code><li><code id=headings-and-sections:the-figure-element><a href=#the-figure-element>figure</a></code><li><code id=headings-and-sections:the-td-element-2><a href=#the-td-element>td</a></code></ul>

  

  <p><a href=#sectioning-content-2 id=headings-and-sections:sectioning-content-2-2>Sectioning content</a> elements are always considered subsections of their nearest
  ancestor <a href=#sectioning-root id=headings-and-sections:sectioning-root>sectioning root</a> or their nearest ancestor element of <a href=#sectioning-content-2 id=headings-and-sections:sectioning-content-2-3>sectioning
  content</a>, whichever is nearest, regardless of what implied sections other headings may have
  created.</p>

  <div class=example>
   <p>For the following fragment:</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->Foo<c- p>&lt;/</c-><c- f>h1</c-><c- p>&gt;</c->
 <c- p>&lt;</c-><c- f>h2</c-><c- p>&gt;</c->Bar<c- p>&lt;/</c-><c- f>h2</c-><c- p>&gt;</c->
 <c- p>&lt;</c-><c- f>blockquote</c-><c- p>&gt;</c->
  <c- p>&lt;</c-><c- f>h3</c-><c- p>&gt;</c->Bla<c- p>&lt;/</c-><c- f>h3</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->Baz<c- p>&lt;/</c-><c- f>p</c-><c- p>&gt;</c->
 <c- p>&lt;</c-><c- f>h2</c-><c- p>&gt;</c->Quux<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->Thud<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>p</c-><c- p>&gt;</c->Grunt<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>...the structure would be:</p>
   <ol><li>
     Foo (heading of explicit <code id=headings-and-sections:the-body-element-2><a href=#the-body-element>body</a></code> section, containing the "Grunt" paragraph)
     <ol><li>
       Bar (heading starting implied section, containing a block quote and the "Baz" paragraph)
      <li>
       Quux (heading starting implied section with no content other than the heading itself)
      <li>
       Thud (heading of explicit <code id=headings-and-sections:the-section-element><a href=#the-section-element>section</a></code> section)
      </ol>
    </ol>
   <p>Notice how the <code id=headings-and-sections:the-section-element-2><a href=#the-section-element>section</a></code> ends the earlier implicit section so that a later
   paragraph ("Grunt") is back at the top level.</p>
  </div>

  <p>Sections may contain headings of any <a href=#rank id=headings-and-sections:rank-3>rank</a>, but authors are strongly encouraged to
  either use only <code id=headings-and-sections:the-h1,-h2,-h3,-h4,-h5,-and-h6-elements-3><a href=#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements>h1</a></code> elements, or to use elements of the appropriate <a href=#rank id=headings-and-sections:rank-4>rank</a>
  for the section's nesting level.</p>

  <p>Authors are also encouraged to explicitly wrap sections in elements of <a href=#sectioning-content-2 id=headings-and-sections:sectioning-content-2-4>sectioning
  content</a>, instead of relying on the implicit sections generated by having multiple headings
  in one element of <a href=#sectioning-content-2 id=headings-and-sections:sectioning-content-2-5>sectioning content</a>.</p>

  <div class=example>
   <p>For example, the following is correct:</p>

   <pre><code class='html'><c- p>&lt;</c-><c- f>body</c-><c- p>&gt;</c->
 <c- p>&lt;</c-><c- f>h4</c-><c- p>&gt;</c->Apples<c- p>&lt;/</c-><c- f>h4</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>h6</c-><c- p>&gt;</c->Sweet<c- p>&lt;/</c-><c- f>h6</c-><c- p>&gt;</c->
  <c- p>&lt;</c-><c- f>p</c-><c- p>&gt;</c->Red apples are sweeter than green ones.<c- p>&lt;/</c-><c- f>p</c-><c- p>&gt;</c->
  <c- p>&lt;</c-><c- f>h1</c-><c- p>&gt;</c->Color<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 come in various colors.<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>However, the same document would be more clearly expressed as:</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>h3</c-><c- p>&gt;</c->Sweet<c- p>&lt;/</c-><c- f>h3</c-><c- p>&gt;</c->
   <c- p>&lt;</c-><c- f>p</c-><c- p>&gt;</c->Red apples are sweeter than green ones.<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>section</c-><c- p>&gt;</c->
  <c- p>&lt;</c-><c- f>h2</c-><c- p>&gt;</c->Color<c- p>&lt;/</c-><c- f>h2</c-><c- p>&gt;</c->
  <c- p>&lt;</c-><c- f>p</c-><c- p>&gt;</c->Apples come in various colors.<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>Both of the documents above are semantically identical and would produce the same outline in
   compliant user agents.</p>

   <p>This third example is also semantically identical, and might be easier to maintain (e.g. if
   sections are often moved around in editing):</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>h1</c-><c- p>&gt;</c->Taste<c- p>&lt;/</c-><c- f>h1</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>h1</c-><c- p>&gt;</c->Sweet<c- p>&lt;/</c-><c- f>h1</c-><c- p>&gt;</c->
   <c- p>&lt;</c-><c- f>p</c-><c- p>&gt;</c->Red apples are sweeter than green ones.<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>section</c-><c- p>&gt;</c->
  <c- p>&lt;</c-><c- f>h1</c-><c- p>&gt;</c->Color<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 come in various colors.<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>This final example would need explicit style rules to be rendered well in legacy browsers.
   Legacy browsers without CSS support would render all the headings as top-level headings.</p>

  </div>


  <h5 id=outlines><span class=secno>4.3.11.1</span> Creating an outline<a href=#outlines class=self-link></a></h5>

  

  

  <p>This section defines an algorithm for creating an outline for a <a href=#sectioning-content-2 id=outlines:sectioning-content-2>sectioning content</a>
  element or a <a href=#sectioning-root id=outlines:sectioning-root>sectioning root</a> element. It is defined in terms of a walk over the nodes
  of a DOM tree, in <a id=outlines:tree-order href=https://dom.spec.whatwg.org/#concept-tree-order data-x-internal=tree-order>tree order</a>, with each node being visited when it is <i>entered</i> and when it
  is <i>exited</i> during the walk.</p>

  

  <p>The <dfn id=outline>outline</dfn> for a <a href=#sectioning-content-2 id=outlines:sectioning-content-2-2>sectioning content</a> element or a <a href=#sectioning-root id=outlines:sectioning-root-2>sectioning
  root</a> element consists of a list of one or more potentially nested <a href=#concept-section id=outlines:concept-section>sections</a>. The element for which an <a href=#outline id=outlines:outline>outline</a> is created
  is said to be <dfn id="the-outline's-owner">the outline's owner</dfn>.</p>

  <p>A <dfn id=concept-section>section</dfn> is a container that corresponds to some nodes in
  the original DOM tree. Each section can have one heading associated with it, and can contain any
  number of further nested sections. The algorithm for the outline also
  associates each node in the DOM tree with a particular section and potentially a heading.
  (The sections in the outline aren't <code id=outlines:the-section-element><a href=#the-section-element>section</a></code> elements, though some may correspond to
  such elements — they are merely conceptual sections.)</p>

  <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>&quot;document-title&quot;</c-><c- p>&gt;</c->
    <c- p>&lt;</c-><c- f>h1</c-><c- p>&gt;</c->HTML<c- p>&lt;/</c-><c- f>h1</c-><c- p>&gt;</c->
    <c- p>&lt;</c-><c- f>h2</c-><c- p>&gt;</c->Living Standard — Last Updated 12 August 2016<c- p>&lt;/</c-><c- f>h2</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 the following outline being created for the <code id=outlines:the-body-element><a href=#the-body-element>body</a></code> node (and thus the
   entire document):</p>

   <ol class=brief><li>
     <p><strong>Section created for <code id=outlines:the-body-element-2><a href=#the-body-element>body</a></code> node</strong>.</p>
     <p>Associated with heading <code>&lt;hgroup
     id="document-title">...&lt;/hgroup></code> consisting of primary heading <code>&lt;h1>HTML&lt;/h1></code> and secondary heading <code>&lt;h2>Living
     Standard — Last Updated 12 August 2016&lt;/h2></code>.</p>
     <p>Also associated with the paragraph <code>&lt;p>Some intro to the
     document.&lt;/p></code> (though it likely would not be shown in a rendered view of the
     outline).</p>
     <p>Nested sections:</p>
     <ol class=brief><li>
       <p><strong>Section implied for first <code id=outlines:the-h1,-h2,-h3,-h4,-h5,-and-h6-elements><a href=#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements>h2</a></code> element.</strong></p>
       <p>Associated with heading <code>&lt;h2>Table of contents&lt;/h2></code>.</p>
       <p>Also associated with the ordered list <code>&lt;ol id=toc>...&lt;/ol></code>
       (though it likely would not be shown in a rendered view of the outline).</p>
       <p>No nested sections.</p>
      <li>
       <p><strong>Section implied for second <code id=outlines:the-h1,-h2,-h3,-h4,-h5,-and-h6-elements-2><a href=#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements>h2</a></code> element.</strong></p>
       <p>Associated with heading <code>&lt;h2>First section&lt;/h2></code>.</p>
       <p>Also associated with the paragraph <code>&lt;p>Some intro to the first
       section.&lt;/p></code> (though it likely would not be shown in a rendered view of the
       outline).</p>
       <p>No nested sections.</p>
      </ol>
    </ol>

   <p>The following image shows what a rendered view of the outline might look like.</p>

   <p><img src=/images/outline.svg width=465 alt="Top-level section with the
   multi-level heading &quot;HTML: Living Standard — Last Updated 12 August 2016&quot; and two
   subsections; &quot;Table of contents&quot; and &quot;First section&quot;." height=120></p>
  </div>

  

  <p>The algorithm that must be followed during a walk of a DOM subtree rooted at a <a href=#sectioning-content-2 id=outlines:sectioning-content-2-3>sectioning
  content</a> element or a <a href=#sectioning-root id=outlines:sectioning-root-3>sectioning root</a> element to determine that element's
  <a href=#outline id=outlines:outline-2>outline</a> is as follows:</p>

  <ol><li><p>Let <var>current outline target</var> be null. (It holds the element whose
   <a href=#outline id=outlines:outline-3>outline</a> is being created.)<li><p>Let <var>current section</var> be null. (It holds a pointer to a <a href=#concept-section id=outlines:concept-section-2>section</a>, so that elements in the DOM can all be associated with a
   section.)<li><p>Create a stack to hold elements, which is used to handle nesting. Initialize this stack to
   empty.<li>

    <p>Walk over the DOM in <a id=outlines:tree-order-2 href=https://dom.spec.whatwg.org/#concept-tree-order data-x-internal=tree-order>tree order</a>, starting with the <a href=#sectioning-content-2 id=outlines:sectioning-content-2-4>sectioning
    content</a> element or <a href=#sectioning-root id=outlines:sectioning-root-4>sectioning root</a> element at the root of the subtree for
    which an outline is to be created, and trigger the first relevant step below for each element as
    the walk enters and exits it.</p>

    <dl class=switch><dt>When exiting an element, if that element is the element at the top of the stack<dd>

      <p class=note>The element being exited is a <a href=#heading-content-2 id=outlines:heading-content-2>heading content</a> element or an
      element with a <code id=outlines:the-hidden-attribute><a href=#the-hidden-attribute>hidden</a></code> attribute.</p>

      <p>Pop that element from the stack.</p>

     <dt>If the top of the stack is a <a href=#heading-content-2 id=outlines:heading-content-2-2>heading content</a> element or an element with a
     <code id=outlines:the-hidden-attribute-2><a href=#the-hidden-attribute>hidden</a></code> attribute<dd><p>Do nothing.<dt>When entering an element with a <code id=outlines:the-hidden-attribute-3><a href=#the-hidden-attribute>hidden</a></code> attribute<dd>

      <p>Push the element being entered onto the stack. (This causes the algorithm to skip that
      element and any descendants of the element.)</p>

     <dt>When entering a <a href=#sectioning-content-2 id=outlines:sectioning-content-2-5>sectioning content</a> element<dd>

      <p>Run these steps:</p>

      <ol><li>

        <p>If <var>current outline target</var> is not null, then:</p>

        <ol><li><p>If the <var>current section</var> has no heading, create an implied
         heading and let that be the heading for the <var>current section</var>.<li><p>Push <var>current outline target</var> onto the stack.</ol>

       <li><p>Let <var>current outline target</var> be the element that is being
       entered.<li><p>Let <var>current section</var> be a newly created <a href=#concept-section id=outlines:concept-section-3>section</a> for the <var>current outline target</var>
       element.<li><p>Associate <var>current outline target</var> with <var>current
       section</var>.<li><p>Let there be a new <a href=#outline id=outlines:outline-4>outline</a> for the new <var>current outline
       target</var>, initialized with just the new <var>current section</var> as the only
       <a href=#concept-section id=outlines:concept-section-4>section</a> in the outline.</ol>

     <dt>When exiting a <a href=#sectioning-content-2 id=outlines:sectioning-content-2-6>sectioning content</a> element, if the stack is not empty<dd>

      <p>Run these steps:</p>

      <ol><li><p>If the <var>current section</var> has no heading, create an implied heading
       and let that be the heading for the <var>current section</var>.<li><p>Pop the top element from the stack, and let the <var>current outline
       target</var> be that element.<li><p>Let <var>current section</var> be the last section in the
       <a href=#outline id=outlines:outline-5>outline</a> of the <var>current outline target</var> element.<li><p>Append the <a href=#outline id=outlines:outline-6>outline</a> of the <a href=#sectioning-content-2 id=outlines:sectioning-content-2-7>sectioning content</a> element being
       exited to the <var>current section</var>. (This does not change which section is
       the last section in the <a href=#outline id=outlines:outline-7>outline</a>.)</ol>

     <dt>When entering a <a href=#sectioning-root id=outlines:sectioning-root-5>sectioning root</a> element<dd>

      <p>Run these steps:</p>

      <ol><li><p>If <var>current outline target</var> is not null, push <var>current outline target</var> onto the stack.<li><p>Let <var>current outline target</var> be the element that is being
       entered.<li><p>Let <var>current outline target</var>'s <i>parent section</i> be <var>current section</var>.<li><p>Let <var>current section</var> be a newly created <a href=#concept-section id=outlines:concept-section-5>section</a> for the <var>current outline target</var>
       element.<li><p>Let there be a new <a href=#outline id=outlines:outline-8>outline</a> for the new <var>current outline
       target</var>, initialized with just the new <var>current section</var> as the only
       <a href=#concept-section id=outlines:concept-section-6>section</a> in the outline.</ol>

     <dt>When exiting a <a href=#sectioning-root id=outlines:sectioning-root-6>sectioning root</a> element, if the stack is not empty<dd>

      <p>Run these steps:</p>

      <ol><li><p>If the <var>current section</var> has no heading, create an implied heading
       and let that be the heading for the <var>current section</var>.<li><p>Let <var>current section</var> be <var>current outline
       target</var>'s <i>parent section</i>.<li><p>Pop the top element from the stack, and let the <var>current outline
       target</var> be that element.</ol>

     <dt>When exiting a <a href=#sectioning-content-2 id=outlines:sectioning-content-2-8>sectioning content</a> element or a <a href=#sectioning-root id=outlines:sectioning-root-7>sectioning root</a>
     element (when the stack is empty)<dd>

      <p class=note>The <var>current outline target</var> is the element being exited,
      and it is the <a href=#sectioning-content-2 id=outlines:sectioning-content-2-9>sectioning content</a> element or a <a href=#sectioning-root id=outlines:sectioning-root-8>sectioning root</a>
      element at the root of the subtree for which an outline is being generated.</p>

      <p>If the <var>current section</var> has no heading, create an implied heading and
      let that be the heading for the <var>current section</var>.</p>

      <p>Skip to the next step in the overall set of steps. (The walk is over.)</p>

     <dt>When entering a <a href=#heading-content-2 id=outlines:heading-content-2-3>heading content</a> element<dd>

      <p>If the <var>current section</var> has no heading, let the element being entered be
      the heading for the <var>current section</var>.</p>

      <p class=note>If the element being entered is an <code id=outlines:the-hgroup-element><a href=#the-hgroup-element>hgroup</a></code> element, that
      <code id=outlines:the-hgroup-element-2><a href=#the-hgroup-element>hgroup</a></code> as a whole is a <em>multi-level</em> heading for the <var>current
      section</var>, with the highest-<a href=#rank id=outlines:rank>ranked</a>
      <code id=outlines: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=outlines:the-h1,-h2,-h3,-h4,-h5,-and-h6-elements-4><a href=#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements>h6</a></code> descendant of the <code id=outlines:the-hgroup-element-3><a href=#the-hgroup-element>hgroup</a></code> providing the
      primary heading for the <var>current section</var>, and with other
      <code id=outlines:the-h1,-h2,-h3,-h4,-h5,-and-h6-elements-5><a href=#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements>h1</a></code>–<code id=outlines:the-h1,-h2,-h3,-h4,-h5,-and-h6-elements-6><a href=#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements>h6</a></code> descendants of the <code id=outlines:the-hgroup-element-4><a href=#the-hgroup-element>hgroup</a></code> providing
      secondary headings for the <var>current section</var>.</p>

      <p>Otherwise, if the element being entered has a <a href=#rank id=outlines:rank-2>rank</a> equal to or higher than the
      heading of the last section of the <a href=#outline id=outlines:outline-9>outline</a> of the <var>current outline
      target</var>, or if the heading of the last section of the <a href=#outline id=outlines:outline-10>outline</a> of the <var>current outline target</var> is an implied heading, then create a new <a href=#concept-section id=outlines:concept-section-7>section</a> and append it to the <a href=#outline id=outlines:outline-11>outline</a> of the <var>current outline target</var> element, so that this new section is the new last
      section of that outline. Let <var>current section</var> be that new section. Let the
      element being entered be the new heading for the <var>current section</var>.</p>

      <p>Otherwise, run these substeps:</p>

      <ol><li><p>Let <var>candidate section</var> be <var>current
       section</var>.<li><p><i>Heading loop</i>: If the element being entered has a <a href=#rank id=outlines:rank-3>rank</a> lower than
       the <a href=#rank id=outlines:rank-4>rank</a> of the heading of the <var>candidate section</var>, then create a new
       <a href=#concept-section id=outlines:concept-section-8>section</a>, and append it to <var>candidate
       section</var>. (This does not change which section is the last section in the outline.) Let
       <var>current section</var> be this new section. Let the element being entered be the
       new heading for the <var>current section</var>. Abort these substeps.</p>

       <li><p>Let <var>new candidate section</var> be the <a href=#concept-section id=outlines:concept-section-9>section</a> that contains <var>candidate section</var> in
       the <a href=#outline id=outlines:outline-12>outline</a> of <var>current outline target</var>.<li><p>Let <var>candidate section</var> be <var>new candidate
       section</var>.<li><p>Return to the step labeled <i>heading loop</i>.</ol>

      <p>Push the element being entered onto the stack. (This causes the algorithm to skip any
      descendants of the element.)</p>

      <p class=note>Recall that <code id=outlines:the-h1,-h2,-h3,-h4,-h5,-and-h6-elements-7><a href=#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements>h1</a></code> has the <em>highest</em> rank, and <code id=outlines:the-h1,-h2,-h3,-h4,-h5,-and-h6-elements-8><a href=#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements>h6</a></code>
      has the lowest rank.</p>

     <dt>Otherwise<dd><p>Do nothing.</dl>

    <p id=associatedSection>In addition, whenever the walk exits a node, after doing the steps
    above, if the node is not associated with a <a href=#concept-section id=outlines:concept-section-10>section</a> yet,
    associate the node with the <a href=#concept-section id=outlines:concept-section-11>section</a> <var>current
    section</var>.</p>

   <li><p>Associate all non-element nodes that are in the subtree for which an outline is being
   created with the <a href=#concept-section id=outlines:concept-section-12>section</a> with which their parent element is
   associated.<li><p>Associate all nodes in the subtree with the heading of the <a href=#concept-section id=outlines:concept-section-13>section</a> with which they are associated, if any.</ol>

  <p>The tree of sections created by the algorithm above, or a proper subset thereof, must be used
  when generating document outlines, for example when generating tables of contents.</p>

  <p>The outline created for <a href=#the-body-element-2 id=outlines:the-body-element-2-2>the body element</a> of a <code id=outlines:document><a href=#document>Document</a></code> is the
  <a href=#outline id=outlines:outline-13>outline</a> of the entire document.</p>

  <p>When creating an interactive table of contents, entries should jump the user to the relevant
  <a href=#sectioning-content-2 id=outlines:sectioning-content-2-10>sectioning content</a> element, if the <a href=#concept-section id=outlines:concept-section-14>section</a> was
  created for a real element in the original document, or to the relevant <a href=#heading-content-2 id=outlines:heading-content-2-4>heading
  content</a> element, if the <a href=#concept-section id=outlines:concept-section-15>section</a> in the tree was
  generated for a heading in the above process.</p>

  <p class=note>Selecting the first <a href=#concept-section id=outlines:concept-section-16>section</a> of the document
  therefore always takes the user to the top of the document, regardless of where the first heading
  in the <code id=outlines:the-body-element-3><a href=#the-body-element>body</a></code> is to be found.</p>

  <p>The <dfn id=outline-depth>outline depth</dfn> of a <a href=#heading-content-2 id=outlines:heading-content-2-5>heading content</a> element associated with a <a href=#concept-section id=outlines:concept-section-17>section</a> <var>section</var> is the number of <a href=#concept-section id=outlines:concept-section-18>sections</a> that are ancestors of <var>section</var> in the
  outermost <a href=#outline id=outlines:outline-14>outline</a> that <var>section</var> finds itself in when the <a href=#outline id=outlines:outline-15>outlines</a> of its <code id=outlines:document-2><a href=#document>Document</a></code>'s elements are created, plus 1. The
  <a href=#outline-depth id=outlines:outline-depth>outline depth</a> of a <a href=#heading-content-2 id=outlines:heading-content-2-6>heading content</a> element not associated with a <a href=#concept-section id=outlines:concept-section-19>section</a> is 1.</p>

  <p>User agents should provide default headings for sections that do not have explicit section
  headings.</p>

  <div class=example>

   <p>Consider the following snippet:</p>

   <pre><code class='html'><c- p>&lt;</c-><c- f>body</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>a</c-> <c- e>href</c-><c- o>=</c-><c- s>&quot;/&quot;</c-><c- p>&gt;</c->Home<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->Hello world.<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>p</c-><c- p>&gt;</c->My cat is cute.<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>body</c-><c- p>&gt;</c-></code></pre>

   <p>Although it contains no headings, this snippet has three sections: a document (the
   <code id=outlines:the-body-element-4><a href=#the-body-element>body</a></code>) with two subsections (a <code id=outlines:the-nav-element><a href=#the-nav-element>nav</a></code> and an <code id=outlines:the-aside-element><a href=#the-aside-element>aside</a></code>). A user
   agent could present the outline as follows:</p>

   <ol class=brief><li>Untitled document
     <ol><li>Navigation<li>Sidebar</ol>
    </ol>

   <p>These default headings ("Untitled document", "Navigation", "Sidebar") are not specified by
   this specification, and might vary with the user's language, the page's language, the user's
   preferences, the user agent implementer's preferences, etc.</p>

  </div>

  <div class=note>

   <p>The following JavaScript function shows how the tree walk could be implemented. The <var>root</var> argument is the root of the tree to walk (either a <a href=#sectioning-content-2 id=outlines:sectioning-content-2-11>sectioning
   content</a> element or a <a href=#sectioning-root id=outlines:sectioning-root-9>sectioning root</a> element), and the <var>enter</var> and <var>exit</var> arguments are callbacks that are called with
   the nodes as they are entered and exited. <a href=#refsJAVASCRIPT>[JAVASCRIPT]</a></p>

   <pre><code class='js'><c- a>function</c-> <c- p>(</c->root<c- p>,</c-> enter<c- p>,</c-> exit<c- p>)</c-> <c- p>{</c->
  <c- a>var</c-> node <c- o>=</c-> root<c- p>;</c->
  start<c- o>:</c-> <c- k>while</c-> <c- p>(</c->node<c- p>)</c-> <c- p>{</c->
    enter<c- p>(</c->node<c- p>);</c->
    <c- k>if</c-> <c- p>(</c->node<c- p>.</c->firstChild<c- p>)</c-> <c- p>{</c->
      node <c- o>=</c-> node<c- p>.</c->firstChild<c- p>;</c->
      <c- k>continue</c-> start<c- p>;</c->
    <c- p>}</c->
    <c- k>while</c-> <c- p>(</c->node<c- p>)</c-> <c- p>{</c->
      exit<c- p>(</c->node<c- p>);</c->
      <c- k>if</c-> <c- p>(</c->node <c- o>==</c-> root<c- p>)</c-> <c- p>{</c->
        node <c- o>=</c-> <c- kc>null</c-><c- p>;</c->
      <c- p>}</c-> <c- k>else</c-> <c- k>if</c-> <c- p>(</c->node<c- p>.</c->nextSibling<c- p>)</c-> <c- p>{</c->
        node <c- o>=</c-> node<c- p>.</c->nextSibling<c- p>;</c->
        <c- k>continue</c-> start<c- p>;</c->
      <c- p>}</c-> <c- k>else</c-> <c- p>{</c->
        node <c- o>=</c-> node<c- p>.</c->parentNode<c- p>;</c->
      <c- p>}</c->
    <c- p>}</c->
  <c- p>}</c->
<c- p>}</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>

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

  <div class=example>

   <p>The following document shows a straight-forward application of the <a href=#outline id=sample-outlines:outline>outline</a>
   algorithm. First, here is the 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&apos;s because you made a mistake.<c- p>&lt;/</c-><c- f>p</c-><c- p>&gt;</c-></code></pre>

   <p>This book would form the following outline:</p>

   <ol class=brief><li> The Tax Book
     <ol class=brief><li> Earning money
       <ol class=brief><li> Getting a job
       </ol>
      <li> Spending money
       <ol class=brief><li> Cheap things
        <li> Expensive things
       </ol>
      <li> Investing money
      <li> Losing money
       <ol class=brief><li> Poor judgement
       </ol>
     </ol>
   </ol>

   <p>Notice that the <code id=sample-outlines:the-title-element><a href=#the-title-element>title</a></code> element does not participate in the outline.</p>

  </div>

  <div class=example>

   <p>Here is a similar document, but this time using <code id=sample-outlines:the-section-element><a href=#the-section-element>section</a></code> elements to get the same
   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->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>section</c-><c- p>&gt;</c->
 <c- p>&lt;</c-><c- f>h1</c-><c- p>&gt;</c->Earning money<c- p>&lt;/</c-><c- f>h1</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>section</c-><c- p>&gt;</c->
  <c- p>&lt;</c-><c- f>h1</c-><c- p>&gt;</c->Getting a job<c- p>&lt;/</c-><c- f>h1</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>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>h1</c-><c- p>&gt;</c->Spending money<c- p>&lt;/</c-><c- f>h1</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>section</c-><c- p>&gt;</c->
  <c- p>&lt;</c-><c- f>h1</c-><c- p>&gt;</c->Cheap things<c- p>&lt;/</c-><c- f>h1</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>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->Expensive things<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 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>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>h1</c-><c- p>&gt;</c->Investing money<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 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>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->Losing money<c- p>&lt;/</c-><c- f>h1</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>section</c-><c- p>&gt;</c->
  <c- p>&lt;</c-><c- f>h1</c-><c- p>&gt;</c->Poor judgement<c- p>&lt;/</c-><c- f>h1</c-><c- p>&gt;</c->
  <c- p>&lt;</c-><c- f>p</c-><c- p>&gt;</c->Usually if you lose money it&apos;s because you made a mistake.<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-></code></pre>

   <p>This book would form the same outline:</p>

   <ol class=brief><li> The Tax Book
     <ol class=brief><li> Earning money
       <ol class=brief><li> Getting a job
       </ol>
      <li> Spending money
       <ol class=brief><li> Cheap things
        <li> Expensive things
       </ol>
      <li> Investing money
      <li> Losing money
       <ol class=brief><li> Poor judgement
       </ol>
     </ol>
   </ol>

  </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>This would form the following simple outline consisting of three top-level sections:</p>

   <ol class=brief><li> Apples
    <li> Bananas
    <li> Carambola
   </ol>

   <p>Effectively, the <code id=sample-outlines:the-body-element><a href=#the-body-element>body</a></code> element is split into three.</p>

  </div>

  <div class=example>

   <p>Mixing both the <code id=sample-outlines: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=sample-outlines:the-h1,-h2,-h3,-h4,-h5,-and-h6-elements-2><a href=#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements>h6</a></code> model and the
   <code id=sample-outlines:the-section-element-2><a href=#the-section-element>section</a></code>/<code id=sample-outlines:the-h1,-h2,-h3,-h4,-h5,-and-h6-elements-3><a href=#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements>h1</a></code> model can lead to some unintuitive results.</p>

   <p>Consider for example the following, which is just the previous example but with the contents
   of the (implied) <code id=sample-outlines:the-body-element-2><a href=#the-body-element>body</a></code> wrapped in a <code id=sample-outlines:the-section-element-3><a href=#the-section-element>section</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->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>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->
<c- p>&lt;/</c-><c- f>section</c-><c- p>&gt;</c-></code></pre>

   <p>The resulting outline would be:</p>

   <ol class=brief><li> <i>(untitled page)</i>
     <ol class=brief><li> Apples
      <li> Bananas
      <li> Carambola
     </ol>
   </ol>

   <p>This result is described as <i>unintuitive</i> because it results in three subsections even
   though there's only one <code id=sample-outlines:the-section-element-4><a href=#the-section-element>section</a></code> element. Effectively, the <code id=sample-outlines:the-section-element-5><a href=#the-section-element>section</a></code> is
   split into three, just like the implied <code id=sample-outlines:the-body-element-3><a href=#the-body-element>body</a></code> element in the previous example.</p>

   <p>(In this example, "<i>(untitled page)</i>" is the implied heading for the <code id=sample-outlines:the-body-element-4><a href=#the-body-element>body</a></code>
   element, since it has no explicit heading.)</p>

  </div>

  <div class=example>

   <p>Headings never rise above other sections. Thus, in the following example, the first
   <code id=sample-outlines:the-h1,-h2,-h3,-h4,-h5,-and-h6-elements-4><a href=#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements>h1</a></code> does not actually describe the page header; it describes the header for the
   second half of 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</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>section</c-><c- p>&gt;</c->
 <c- p>&lt;</c-><c- f>h1</c-><c- p>&gt;</c->A plea from our caretakers<c- p>&lt;/</c-><c- f>h1</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&apos;re stuck in the server room!<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->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 resulting outline would be:</p>

   <ol class=brief><li> <i>(untitled page)</i>
     <ol class=brief><li> A plea from our caretakers
     </ol>
    <li> Feathers
   </ol>

  </div>

  <div class=example>

   <p>Thus, when an <code id=sample-outlines:the-article-element><a href=#the-article-element>article</a></code> element starts with a <code id=sample-outlines:the-nav-element><a href=#the-nav-element>nav</a></code> block and only later
   has its heading, the result is that the <code id=sample-outlines:the-nav-element-2><a href=#the-nav-element>nav</a></code> block is not part of the same section as
   the rest of the <code id=sample-outlines:the-article-element-2><a href=#the-article-element>article</a></code> in the outline. For instance, take this 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>&quot;en&quot;</c-><c- p>&gt;</c->
<c- p>&lt;</c-><c- f>title</c-><c- p>&gt;</c->We&apos;re adopting a child! — Ray&apos;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&apos;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>&quot;?t=-1d&quot;</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>&quot;?t=-7d&quot;</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>&quot;?t=-1m&quot;</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>h1</c-><c- p>&gt;</c->We&apos;re adopting a child!<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>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&apos;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 resulting outline would be:</p>

   <ol class=brief><li> Ray's blog
     <ol class=brief><li> <i>Untitled article</i>
       <ol class=brief><li> <i>Untitled navigation section</i>
       </ol>
      <li> We're adopting a child!
     </ol>
   </ol>

   <p>Also worthy of note in this example is that the <code id=sample-outlines:the-header-element><a href=#the-header-element>header</a></code> element has no effect
   whatsoever on the document outline.</p>

  </div>

  <div class=example>

   <p>The <code id=sample-outlines:the-hgroup-element><a href=#the-hgroup-element>hgroup</a></code> element can be used for subheadings. For 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>&quot;en&quot;</c-><c- p>&gt;</c->
<c- p>&lt;</c-><c- f>title</c-><c- p>&gt;</c->Chronotype: CS Student<c- p>&lt;/</c-><c- f>title</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-> The morning <c- p>&lt;/</c-><c- f>h1</c-><c- p>&gt;</c->
 <c- p>&lt;</c-><c- f>h2</c-><c- p>&gt;</c-> 06:00 to 12:00 <c- p>&lt;/</c-><c- f>h2</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->We sleep.<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>h1</c-><c- p>&gt;</c-> The afternoon <c- p>&lt;/</c-><c- f>h1</c-><c- p>&gt;</c->
 <c- p>&lt;</c-><c- f>h2</c-><c- p>&gt;</c-> 12:00 to 18:00 <c- p>&lt;/</c-><c- f>h2</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->We study.<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>h2</c-><c- p>&gt;</c->Additional Commentary<c- p>&lt;/</c-><c- f>h2</c-><c- p>&gt;</c->
 <c- p>&lt;</c-><c- f>h3</c-><c- p>&gt;</c->Because not all this is necessarily true<c- p>&lt;/</c-><c- f>h3</c-><c- p>&gt;</c->
 <c- p>&lt;</c-><c- f>h6</c-><c- p>&gt;</c->Ok it&apos;s almost certainly not true<c- p>&lt;/</c-><c- f>h6</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->Yeah we probably play, rather than study.<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>h1</c-><c- p>&gt;</c-> The evening <c- p>&lt;/</c-><c- f>h1</c-><c- p>&gt;</c->
 <c- p>&lt;</c-><c- f>h2</c-><c- p>&gt;</c-> 18:00 to 00:00 <c- p>&lt;/</c-><c- f>h2</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->We play.<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>h1</c-><c- p>&gt;</c-> The night <c- p>&lt;/</c-><c- f>h1</c-><c- p>&gt;</c->
 <c- p>&lt;</c-><c- f>h2</c-><c- p>&gt;</c-> 00:00 to 06:00 <c- p>&lt;/</c-><c- f>h2</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->We play some more.<c- p>&lt;/</c-><c- f>p</c-><c- p>&gt;</c->
<c- p>&lt;/</c-><c- f>html</c-><c- p>&gt;</c-></code></pre>

   <p>The resulting outline would be:</p>

   <ol class=brief><li> The morning <small>06:00 to 12:00</small>
    <li> The afternoon <small>12:00 to 18:00</small>
     <ol class=brief><li> Additional Commentary <small>Because not all this is necessarily true <small>Ok it's almost certainly not true</small></small>
     </ol>
    <li> The evening <small>18:00 to 00:00</small>
    <li> The night <small>00:00 to 06:00</small>
   </ol>

   <p>Exactly how this is represented by user agents, as most interface issues, is left as a matter
   of implementation preference, but the key part is that the <code id=sample-outlines:the-hgroup-element-2><a href=#the-hgroup-element>hgroup</a></code>'s descendant
   <code id=sample-outlines:the-h1,-h2,-h3,-h4,-h5,-and-h6-elements-5><a href=#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements>h1</a></code>–<code id=sample-outlines: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 are what form the element's heading. Thus, the
   following would be equally valid:</p>

   <ol class=brief><li> The morning — 06:00 to 12:00
    <li> The afternoon — 12:00 to 18:00
     <ol class=brief><li> Additional Commentary — Because not all this is necessarily true — Ok it's almost certainly not true
     </ol>
    <li> The evening — 18:00 to 00:00
    <li> The night — 00:00 to 06:00
   </ol>

   <p>But so would the following:</p>

   <ol class=brief><li> The morning
    <li> The afternoon
     <ol class=brief><li> Additional Commentary
     </ol>
    <li> The evening
    <li> The night
   </ol>

   <p>The following would also be valid, though maybe less practical in most contexts:</p>

   <ol class=brief><li> <p>The morning
         <p> 06:00 to 12:00
    <li> <p>The afternoon
         <p> 12:00 to 18:00
     <ol class=brief><li> <p> Additional Commentary
           <p> Because not all this is necessarily true
           <p> Ok it's almost certainly not true
     </ol>
    <li> <p>The evening
         <p> 18:00 to 00:00
    <li> <p>The night
         <p> 00:00 to 06:00
   </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 outlines to users to aid in navigation. This is
  especially true for non-visual media, e.g. screen readers.</p>

  <p>However, to mitigate the difficulties that arise from authors misusing <a href=#sectioning-content-2 id=exposing-outlines-to-users:sectioning-content-2>sectioning
  content</a>, user agents are also encouraged to offer a mode that navigates the page using
  <a href=#heading-content-2 id=exposing-outlines-to-users:heading-content-2>heading content</a> alone.</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>
    <dd>Go to previous section, including subsections of previous sections

    <dt><kbd><kbd>Shift</kbd>+<kbd>→ Right</kbd></kbd>
    <dd>Go to next section, including subsections of the current section

    <dt><kbd><kbd>Shift</kbd>+<kbd>↑ Up</kbd></kbd>
    <dd>Go to parent section of the current section

    <dt><kbd><kbd>Shift</kbd>+<kbd>↓ Down</kbd></kbd>
    <dd>Go to next section, skipping subsections of the current section

   </dl>

   <p>Plus in addition, the user agent could map the <kbd><kbd>j</kbd></kbd> and
   <kbd><kbd>k</kbd></kbd> keys to navigating to the previous or next element of <a href=#heading-content-2 id=exposing-outlines-to-users:heading-content-2-2>heading
   content</a>, regardless of the section's outline depth and ignoring sections with no
   headings.</p>

  </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>Purpose
    <tr><th>Example
   <tbody><tr><td rowspan=2><code id=usage-summary-2:the-body-element><a href=#the-body-element>body</a></code>
     <td>The contents of the document.
    <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>&quot;en&quot;</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&apos;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>

    <tr><td rowspan=2><code id=usage-summary-2:the-article-element><a href=#the-article-element>article</a></code>
     <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.
    <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>&quot;/tumblr_masqy2s5yn1rzfqbpo1_500.jpg&quot;</c-> <c- e>alt</c-><c- o>=</c-><c- s>&quot;Yellow smiley face with the caption &apos;masif&apos;&quot;</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>&quot;/tumblr_m9tf6wSr6W1rzfqbpo1_500.jpg&quot;</c-> <c- e>alt</c-><c- o>=</c-><c- s>&quot;&quot;</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>

    <tr><td rowspan=2><code id=usage-summary-2:the-section-element><a href=#the-section-element>section</a></code>
     <td>A generic section of a document or application. A section, in this context, is a thematic grouping of content, typically with a heading.
    <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>

    <tr><td rowspan=2><code id=usage-summary-2:the-nav-element><a href=#the-nav-element>nav</a></code>
     <td>A section of a page that links to other pages or to parts within the page: a section with navigation links.
    <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>&quot;/&quot;</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>&quot;/biog.html&quot;</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>&quot;/discog.html&quot;</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>

    <tr><td rowspan=2><code id=usage-summary-2:the-aside-element><a href=#the-aside-element>aside</a></code>
     <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.
    <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>&quot;buy.html&quot;</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>

    <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>A section heading
    <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>

    <tr><td rowspan=2><code id=usage-summary-2:the-hgroup-element><a href=#the-hgroup-element>hgroup</a></code>
     <td>The heading of a section, which consists of all the <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 children of the <code id=usage-summary-2:the-hgroup-element-2><a href=#the-hgroup-element>hgroup</a></code> element. The element is used to group a set of <code id=usage-summary-2:the-h1,-h2,-h3,-h4,-h5,-and-h6-elements-5><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-6><a href=#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements>h6</a></code> elements when the heading has multiple levels, such as subheadings, alternative titles, or taglines.
    <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>h2</c-><c- p>&gt;</c->The Guide To Music On The Playa<c- p>&lt;/</c-><c- f>h2</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>h2</c-><c- p>&gt;</c->The Fiction Of A Music Festival<c- p>&lt;/</c-><c- f>h2</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>h2</c-><c- p>&gt;</c->Questions About Amplified Music<c- p>&lt;/</c-><c- f>h2</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>

    <tr><td rowspan=2><code id=usage-summary-2:the-header-element><a href=#the-header-element>header</a></code>
     <td>A group of introductory or navigational aids.
    <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>

    <tr><td rowspan=2><code id=usage-summary-2:the-footer-element><a href=#the-footer-element>footer</a></code>
     <td>A footer for its nearest ancestor <a href=#sectioning-content-2 id=usage-summary-2:sectioning-content-2>sectioning content</a> or <a href=#sectioning-root id=usage-summary-2:sectioning-root>sectioning root</a> element. A footer typically contains information about its section such as who wrote it, links to related documents, copyright data, and the like.
    <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>

  </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><code>p</code></dfn> element<a href=#the-p-element class=self-link></a></h4>

  <dl class=element><dt><a href=#concept-element-categories id=the-p-element:concept-element-categories>Categories</a>:<dd><a href=#flow-content-2 id=the-p-element:flow-content-2>Flow content</a>.<dd><a href=#palpable-content-2 id=the-p-element:palpable-content-2>Palpable content</a>.<dt><a href=#concept-element-contexts id=the-p-element:concept-element-contexts>Contexts in which this element can be used</a>:<dd>Where <a href=#flow-content-2 id=the-p-element:flow-content-2-2>flow content</a> is expected.<dt><a href=#concept-element-content-model id=the-p-element:concept-element-content-model>Content model</a>:<dd><a href=#phrasing-content-2 id=the-p-element:phrasing-content-2>Phrasing content</a>.<dt><a href=#concept-element-tag-omission id=the-p-element:concept-element-tag-omission>Tag omission in text/html</a>:<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-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><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-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>.<dt><a href=#concept-element-attributes id=the-p-element:concept-element-attributes>Content attributes</a>:<dd><a href=#global-attributes id=the-p-element:global-attributes>Global attributes</a><dt><a href=#concept-element-dom id=the-p-element:concept-element-dom>DOM interface</a>:<dd>
    <pre><code class='idl'>[<c- g>Exposed</c->=<c- n>Window</c->,
 <a href='#htmlconstructor' id='the-p-element:htmlconstructor'><c- g>HTMLConstructor</c-></a>]
<c- b>interface</c-> <dfn id='htmlparagraphelement'><c- g>HTMLParagraphElement</c-></dfn> : <a href='#htmlelement' id='the-p-element:htmlelement'><c- n>HTMLElement</c-></a> {};</code></pre>
   </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>&quot;n&quot;</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>&quot;anon&quot;</c-> <c- e>type</c-><c- o>=</c-><c- s>&quot;checkbox&quot;</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>&quot;a&quot;</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>faster-than-light travel, and
     <li>telepathy,
    </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><code>hr</code></dfn> element<a href=#the-hr-element class=self-link></a></h4>

  <dl class=element><dt><a href=#concept-element-categories id=the-hr-element:concept-element-categories>Categories</a>:<dd><a href=#flow-content-2 id=the-hr-element:flow-content-2>Flow content</a>.<dt><a href=#concept-element-contexts id=the-hr-element:concept-element-contexts>Contexts in which this element can be used</a>:<dd>Where <a href=#flow-content-2 id=the-hr-element:flow-content-2-2>flow content</a> is expected.<dt><a href=#concept-element-content-model id=the-hr-element:concept-element-content-model>Content model</a>:<dd><a href=#concept-content-nothing id=the-hr-element:concept-content-nothing>Nothing</a>.<dt><a href=#concept-element-tag-omission id=the-hr-element:concept-element-tag-omission>Tag omission in text/html</a>:<dd>No <a href=#syntax-end-tag id=the-hr-element:syntax-end-tag>end tag</a>.<dt><a href=#concept-element-attributes id=the-hr-element:concept-element-attributes>Content attributes</a>:<dd><a href=#global-attributes id=the-hr-element:global-attributes>Global attributes</a><dt><a href=#concept-element-dom id=the-hr-element:concept-element-dom>DOM interface</a>:<dd>
    <pre><code class='idl'>[<c- g>Exposed</c->=<c- n>Window</c->,
 <a href='#htmlconstructor' id='the-hr-element:htmlconstructor'><c- g>HTMLConstructor</c-></a>]
<c- b>interface</c-> <dfn id='htmlhrelement'><c- g>HTMLHRElement</c-></dfn> : <a href='#htmlelement' id='the-hr-element:htmlelement'><c- n>HTMLElement</c-></a> {};</code></pre>
   </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.</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&apos;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&apos;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&apos;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&apos;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><code>pre</code></dfn> element<a href=#the-pre-element class=self-link></a></h4>

  <dl class=element><dt><a href=#concept-element-categories id=the-pre-element:concept-element-categories>Categories</a>:<dd><a href=#flow-content-2 id=the-pre-element:flow-content-2>Flow content</a>.<dd><a href=#palpable-content-2 id=the-pre-element:palpable-content-2>Palpable content</a>.<dt><a href=#concept-element-contexts id=the-pre-element:concept-element-contexts>Contexts in which this element can be used</a>:<dd>Where <a href=#flow-content-2 id=the-pre-element:flow-content-2-2>flow content</a> is expected.<dt><a href=#concept-element-content-model id=the-pre-element:concept-element-content-model>Content model</a>:<dd><a href=#phrasing-content-2 id=the-pre-element:phrasing-content-2>Phrasing content</a>.<dt><a href=#concept-element-tag-omission id=the-pre-element:concept-element-tag-omission>Tag omission in text/html</a>:<dd>Neither tag is omissible.<dt><a href=#concept-element-attributes id=the-pre-element:concept-element-attributes>Content attributes</a>:<dd><a href=#global-attributes id=the-pre-element:global-attributes>Global attributes</a><dt><a href=#concept-element-dom id=the-pre-element:concept-element-dom>DOM interface</a>:<dd>
    <pre><code class='idl'>[<c- g>Exposed</c->=<c- n>Window</c->,
 <a href='#htmlconstructor' id='the-pre-element:htmlconstructor'><c- g>HTMLConstructor</c-></a>]
<c- b>interface</c-> <dfn id='htmlpreelement'><c- g>HTMLPreElement</c-></dfn> : <a href='#htmlelement' id='the-pre-element:htmlelement'><c- n>HTMLElement</c-></a> {};</code></pre>
   </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 e-mail, with paragraphs indicated by blank lines, lists indicated by lines
   prefixed with a bullet, and so on.<li>Including fragments of computer code, with structure indicated according to the conventions
   of that language.<li>Displaying ASCII art.</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><code>blockquote</code></dfn> element<a href=#the-blockquote-element class=self-link></a></h4>

  <dl class=element><dt><a href=#concept-element-categories id=the-blockquote-element:concept-element-categories>Categories</a>:<dd><a href=#flow-content-2 id=the-blockquote-element:flow-content-2>Flow content</a>.<dd><a href=#sectioning-root id=the-blockquote-element:sectioning-root>Sectioning root</a>.<dd><a href=#palpable-content-2 id=the-blockquote-element:palpable-content-2>Palpable content</a>.<dt><a href=#concept-element-contexts id=the-blockquote-element:concept-element-contexts>Contexts in which this element can be used</a>:<dd>Where <a href=#flow-content-2 id=the-blockquote-element:flow-content-2-2>flow content</a> is expected.<dt><a href=#concept-element-content-model id=the-blockquote-element:concept-element-content-model>Content model</a>:<dd><a href=#flow-content-2 id=the-blockquote-element:flow-content-2-3>Flow content</a>.<dt><a href=#concept-element-tag-omission id=the-blockquote-element:concept-element-tag-omission>Tag omission in text/html</a>:<dd>Neither tag is omissible.<dt><a href=#concept-element-attributes id=the-blockquote-element:concept-element-attributes>Content attributes</a>:<dd><a href=#global-attributes id=the-blockquote-element:global-attributes>Global attributes</a><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<dt><a href=#concept-element-dom id=the-blockquote-element:concept-element-dom>DOM interface</a>:<dd>
<pre><code class='idl'>[<c- g>Exposed</c->=<c- n>Window</c->,
 <a href='#htmlconstructor' id='the-blockquote-element:htmlconstructor'><c- g>HTMLConstructor</c-></a>]
<c- b>interface</c-> <dfn id='htmlquoteelement'><c- g>HTMLQuoteElement</c-></dfn> : <a href='#htmlelement' id='the-blockquote-element:htmlelement'><c- n>HTMLElement</c-></a> {
  [<a href='#cereactions' id='the-blockquote-element:cereactions'><c- g>CEReactions</c-></a>] <c- b>attribute</c-> <c- b>USVString</c-> <a href='#dom-quote-cite' id='the-blockquote-element:dom-quote-cite'><c- g>cite</c-></a>;
};</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>
   </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 id=attr-blockquote-cite><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=#parse-a-url id=the-blockquote-element:parse-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>

  

  <p>The <dfn id=dom-quote-cite><code>cite</code></dfn> IDL attribute must <a href=#reflect id=the-blockquote-element:reflect>reflect</a>
  the element's <code>cite</code> content attribute.</p>

  

  <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&apos;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 &quot;<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->&quot;, 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>&quot;https://quotes.example.org/s/sonnet130.html&quot;</c-><c- p>&gt;</c->
  <c- p>&lt;</c-><c- f>p</c-><c- p>&gt;</c->My mistress&apos; 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>&quot;https://bacon.example.com/?blog=109431&quot;</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>&quot;?pid=29578&quot;</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&apos;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>&quot;?pid=29579&quot;</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&apos;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&apos;ll be saying they don&apos;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>&quot;?pid=29580&quot;</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>&quot;?pid=29581&quot;</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&apos;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>&quot;?pid=29582&quot;</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 &quot;lessons&quot; 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><code>ol</code></dfn> element<a href=#the-ol-element class=self-link></a></h4>

  <dl class=element><dt><a href=#concept-element-categories id=the-ol-element:concept-element-categories>Categories</a>:<dd><a href=#flow-content-2 id=the-ol-element:flow-content-2>Flow content</a>.<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>.<dt><a href=#concept-element-contexts id=the-ol-element:concept-element-contexts>Contexts in which this element can be used</a>:<dd>Where <a href=#flow-content-2 id=the-ol-element:flow-content-2-2>flow content</a> is expected.<dt><a href=#concept-element-content-model id=the-ol-element:concept-element-content-model>Content model</a>:<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.<dt><a href=#concept-element-tag-omission id=the-ol-element:concept-element-tag-omission>Tag omission in text/html</a>:<dd>Neither tag is omissible.<dt><a href=#concept-element-attributes id=the-ol-element:concept-element-attributes>Content attributes</a>:<dd><a href=#global-attributes id=the-ol-element:global-attributes>Global attributes</a><dd><code id=the-ol-element:attr-ol-reversed><a href=#attr-ol-reversed>reversed</a></code> — Number the list backwards<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><code id=the-ol-element:attr-ol-type><a href=#attr-ol-type>type</a></code> — Kind of list marker<dt><a href=#concept-element-dom id=the-ol-element:concept-element-dom>DOM interface</a>:<dd>
<pre><code class='idl'>[<c- g>Exposed</c->=<c- n>Window</c->,
 <a href='#htmlconstructor' id='the-ol-element:htmlconstructor'><c- g>HTMLConstructor</c-></a>]
<c- b>interface</c-> <dfn id='htmlolistelement'><c- g>HTMLOListElement</c-></dfn> : <a href='#htmlelement' id='the-ol-element:htmlelement'><c- n>HTMLElement</c-></a> {
  [<a href='#cereactions' id='the-ol-element:cereactions'><c- g>CEReactions</c-></a>] <c- b>attribute</c-> <c- b>boolean</c-> <a href='#dom-ol-reversed' id='the-ol-element:dom-ol-reversed'><c- g>reversed</c-></a>;
  [<a href='#cereactions' id='the-ol-element:cereactions-2'><c- g>CEReactions</c-></a>] <c- b>attribute</c-> <c- b>long</c-> <a href='#dom-ol-start' id='the-ol-element:dom-ol-start'><c- g>start</c-></a>;
  [<a href='#cereactions' id='the-ol-element:cereactions-3'><c- g>CEReactions</c-></a>] <c- b>attribute</c-> <c- b>DOMString</c-> <a href='#dom-ol-type' id='the-ol-element:dom-ol-type'><c- g>type</c-></a>;
};</code></pre>
   </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>

  <p>The <dfn id=attr-ol-reversed><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, ...).<div class=status><input onclick=toggleStatus(this) value=⋰ type=button><p class=support><strong>Support:</strong> ol-reversed<span class="and_chr yes"><span>Chrome for Android</span> <span>67+</span></span><span class="chrome yes"><span>Chrome</span> <span>20+</span></span><span class="ios_saf yes"><span>iOS Safari</span> <span>6.0+</span></span><span class="and_uc yes"><span>UC Browser for Android</span> <span>11.8+</span></span><span class="firefox yes"><span>Firefox</span> <span>18+</span></span><span class="ie no"><span>IE</span> <span>None</span></span><span class="op_mini yes"><span>Opera Mini</span> <span>all+</span></span><span class="safari yes"><span>Safari</span> <span>6.1+</span></span><span class="edge no"><span>Edge</span> <span>None</span></span><span class="samsung yes"><span>Samsung Internet</span> <span>4+</span></span><span class="opera yes"><span>Opera</span> <span>12.1+</span></span><span class="android yes"><span>Android Browser</span> <span>4.4+</span></span><p class=caniuse>Source: <a href="https://caniuse.com/#feat=ol-reversed">caniuse.com</a></div>

  <p>The <dfn id=attr-ol-start><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>

  

  

  <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>.<li><p>If <var>parsed</var> is not an error, then return <var>parsed</var>.</ol>
   <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>.<li><p>Return 1.</ol>

  

  <p>The <dfn id=attr-ol-type><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 <a href=#case-sensitive id=the-ol-element:case-sensitive>case-sensitive</a> match for 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>State
     <th>Description
     <th colspan=8>Examples for values 1-3 and 3999-4001
   <tbody><tr><td><dfn id=attr-ol-type-keyword-decimal><code>1</code></dfn> (U+0031)
     <td><dfn id=attr-ol-type-state-decimal>decimal</dfn>
     <td>Decimal numbers
     <td class=eg><samp>1.</samp> <td class=eg><samp>2.</samp> <td class=eg><samp>3.</samp> <td class=eg>... <td class=eg><samp>3999.</samp> <td class=eg><samp>4000.</samp> <td class=eg><samp>4001.</samp> <td class=eg>...
    <tr><td><dfn id=attr-ol-type-keyword-lower-alpha><code>a</code></dfn> (U+0061)
     <td><dfn id=attr-ol-type-state-lower-alpha>lower-alpha</dfn>
     <td>Lowercase latin alphabet
     <td class=eg><samp>a.</samp> <td class=eg><samp>b.</samp> <td class=eg><samp>c.</samp> <td class=eg>... <td class=eg><samp>ewu.</samp> <td class=eg><samp>ewv.</samp> <td class=eg><samp>eww.</samp> <td class=eg>...
    <tr><td><dfn id=attr-ol-type-keyword-upper-alpha><code>A</code></dfn> (U+0041)
     <td><dfn id=attr-ol-type-state-upper-alpha>upper-alpha</dfn>
     <td>Uppercase latin alphabet
     <td class=eg><samp>A.</samp> <td class=eg><samp>B.</samp> <td class=eg><samp>C.</samp> <td class=eg>... <td class=eg><samp>EWU.</samp> <td class=eg><samp>EWV.</samp> <td class=eg><samp>EWW.</samp> <td class=eg>...
    <tr><td><dfn id=attr-ol-type-keyword-lower-roman><code>i</code></dfn> (U+0069)
     <td><dfn id=attr-ol-type-state-lower-roman>lower-roman</dfn>
     <td>Lowercase roman numerals
     <td class=eg><samp>i.</samp> <td class=eg><samp>ii.</samp> <td class=eg><samp>iii.</samp> <td class=eg>... <td class=eg><samp>mmmcmxcix.</samp> <td class=eg><samp>i̅v̅.</samp> <td class=eg><samp>i̅v̅i.</samp> <td class=eg>...
    <tr><td><dfn id=attr-ol-type-keyword-upper-roman><code>I</code></dfn> (U+0049)
     <td><dfn id=attr-ol-type-state-upper-roman>upper-roman</dfn>
     <td>Uppercase roman numerals
     <td class=eg><samp>I.</samp> <td class=eg><samp>II.</samp> <td class=eg><samp>III.</samp> <td class=eg>... <td class=eg><samp>MMMCMXCIX.</samp> <td class=eg><samp>I̅V̅.</samp> <td class=eg><samp>I̅V̅I.</samp> <td class=eg>...
  </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>The <dfn id=dom-ol-reversed><code>reversed</code></dfn> and
  <dfn id=dom-ol-type><code>type</code></dfn> IDL attributes must <a href=#reflect id=the-ol-element:reflect>reflect</a> the
  respective content attributes of the same name.</p>

  <p>The <dfn id=dom-ol-start><code>start</code></dfn> IDL attribute must <a href=#reflect id=the-ol-element:reflect-2>reflect</a>
  the content attribute of the same name, with a default value of 1.</p>

  <p class=note>This means that the <code id=the-ol-element:dom-ol-start-2><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><code>ul</code></dfn> element<a href=#the-ul-element class=self-link></a></h4>

  <dl class=element><dt><a href=#concept-element-categories id=the-ul-element:concept-element-categories>Categories</a>:<dd><a href=#flow-content-2 id=the-ul-element:flow-content-2>Flow content</a>.<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>.<dt><a href=#concept-element-contexts id=the-ul-element:concept-element-contexts>Contexts in which this element can be used</a>:<dd>Where <a href=#flow-content-2 id=the-ul-element:flow-content-2-2>flow content</a> is expected.<dt><a href=#concept-element-content-model id=the-ul-element:concept-element-content-model>Content model</a>:<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.<dt><a href=#concept-element-tag-omission id=the-ul-element:concept-element-tag-omission>Tag omission in text/html</a>:<dd>Neither tag is omissible.<dt><a href=#concept-element-attributes id=the-ul-element:concept-element-attributes>Content attributes</a>:<dd><a href=#global-attributes id=the-ul-element:global-attributes>Global attributes</a><dt><a href=#concept-element-dom id=the-ul-element:concept-element-dom>DOM interface</a>:<dd>
    <pre><code class='idl'>[<c- g>Exposed</c->=<c- n>Window</c->,
 <a href='#htmlconstructor' id='the-ul-element:htmlconstructor'><c- g>HTMLConstructor</c-></a>]
<c- b>interface</c-> <dfn id='htmlulistelement'><c- g>HTMLUListElement</c-></dfn> : <a href='#htmlelement' id='the-ul-element:htmlelement'><c- n>HTMLElement</c-></a> {};</code></pre>
   </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><code>menu</code></dfn> element<a href=#the-menu-element class=self-link></a></h4>

  <dl class=element><dt><a href=#concept-element-categories id=the-menu-element:concept-element-categories>Categories</a>:<dd><a href=#flow-content-2 id=the-menu-element:flow-content-2>Flow content</a>.<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>.<dt><a href=#concept-element-contexts id=the-menu-element:concept-element-contexts>Contexts in which this element can be used</a>:<dd>Where <a href=#flow-content-2 id=the-menu-element:flow-content-2-2>flow content</a> is expected.<dt><a href=#concept-element-content-model id=the-menu-element:concept-element-content-model>Content model</a>:<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.<dt><a href=#concept-element-tag-omission id=the-menu-element:concept-element-tag-omission>Tag omission in text/html</a>:<dd>Neither tag is omissible.<dt><a href=#concept-element-attributes id=the-menu-element:concept-element-attributes>Content attributes</a>:<dd><a href=#global-attributes id=the-menu-element:global-attributes>Global attributes</a><dt><a href=#concept-element-dom id=the-menu-element:concept-element-dom>DOM interface</a>:<dd>
<pre><code class='idl'>[<c- g>Exposed</c->=<c- n>Window</c->,
 <a href='#htmlconstructor' id='the-menu-element:htmlconstructor'><c- g>HTMLConstructor</c-></a>]
<c- b>interface</c-> <dfn id='htmlmenuelement'><c- g>HTMLMenuElement</c-></dfn> : <a href='#htmlelement' id='the-menu-element:htmlelement'><c- n>HTMLElement</c-></a> {
};</code></pre>
   </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>&quot;copy()&quot;</c-><c- p>&gt;&lt;</c-><c- f>img</c-> <c- e>src</c-><c- o>=</c-><c- s>&quot;copy.svg&quot;</c-> <c- e>alt</c-><c- o>=</c-><c- s>&quot;Copy&quot;</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>&quot;cut()&quot;</c-><c- p>&gt;&lt;</c-><c- f>img</c-> <c- e>src</c-><c- o>=</c-><c- s>&quot;cut.svg&quot;</c-> <c- e>alt</c-><c- o>=</c-><c- s>&quot;Cut&quot;</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>&quot;paste()&quot;</c-><c- p>&gt;&lt;</c-><c- f>img</c-> <c- e>src</c-><c- o>=</c-><c- s>&quot;paste.svg&quot;</c-> <c- e>alt</c-><c- o>=</c-><c- s>&quot;Paste&quot;</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><code>li</code></dfn> element<a href=#the-li-element class=self-link></a></h4>

  <dl class=element><dt><a href=#concept-element-categories id=the-li-element:concept-element-categories>Categories</a>:<dd>None.<dt><a href=#concept-element-contexts id=the-li-element:concept-element-contexts>Contexts in which this element can be used</a>:<dd>Inside <code id=the-li-element:the-ol-element><a href=#the-ol-element>ol</a></code> elements.<dd>Inside <code id=the-li-element:the-ul-element><a href=#the-ul-element>ul</a></code> elements.<dd>Inside <code id=the-li-element:the-menu-element><a href=#the-menu-element>menu</a></code> elements.<dt><a href=#concept-element-content-model id=the-li-element:concept-element-content-model>Content model</a>:<dd><a href=#flow-content-2 id=the-li-element:flow-content-2>Flow content</a>.<dt><a href=#concept-element-tag-omission id=the-li-element:concept-element-tag-omission>Tag omission in text/html</a>:<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.<dt><a href=#concept-element-attributes id=the-li-element:concept-element-attributes>Content attributes</a>:<dd><a href=#global-attributes id=the-li-element:global-attributes>Global attributes</a><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<dt><a href=#concept-element-dom id=the-li-element:concept-element-dom>DOM interface</a>:<dd>
<pre><code class='idl'>[<c- g>Exposed</c->=<c- n>Window</c->,
 <a href='#htmlconstructor' id='the-li-element:htmlconstructor'><c- g>HTMLConstructor</c-></a>]
<c- b>interface</c-> <dfn id='htmllielement'><c- g>HTMLLIElement</c-></dfn> : <a href='#htmlelement' id='the-li-element:htmlelement'><c- n>HTMLElement</c-></a> {
  [<a href='#cereactions' id='the-li-element:cereactions'><c- g>CEReactions</c-></a>] <c- b>attribute</c-> <c- b>long</c-> <a href='#dom-li-value' id='the-li-element:dom-li-value'><c- g>value</c-></a>;
};</code></pre>
   </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 id=attr-li-value><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>

  <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/visuren.html#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><p>Let <var>ancestor</var> be the element's parent.<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.<li>
    <p>Return the closest inclusive ancestor of <var>ancestor</var> that produces a CSS box.</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 CSS box.</p>
   </ol>

  <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.<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.<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>.<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>
    <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>.<li><p>If <var>parsed</var> is not an error, then set <var>numbering</var> to
     <var>parsed</var>.</ol>
   <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>.<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.<li><p>Increment <var>i</var> by 1.<li><p>Go to the step labeled <i>loop</i>.</p>
  </ol>

  <hr>

  <p>The <dfn id=dom-li-value><code>value</code></dfn> IDL attribute must <a href=#reflect id=the-li-element:reflect>reflect</a>
  the value of the <code id=the-li-element:attr-li-value-3><a href=#attr-li-value>value</a></code> content attribute.</p>

  <div class=example>
   <p>The element's <code id=the-li-element:dom-li-value-2><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-2>reflects</a>
   the content attribute. For example, given this list:

   <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>&quot;3&quot;</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-3><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>&quot;10&quot;</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>&quot;9&quot;</c-><c- p>&gt;&lt;</c-><c- f>cite</c-> <c- e>lang</c-><c- o>=</c-><c- s>&quot;sh&quot;</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>&quot;8&quot;</c-><c- p>&gt;&lt;</c-><c- f>cite</c-><c- p>&gt;</c->A Bug&apos;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>&quot;7&quot;</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>&quot;6&quot;</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>&quot;5&quot;</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>&quot;4&quot;</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>&quot;3&quot;</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>&quot;2&quot;</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>&quot;1&quot;</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>&quot;sh&quot;</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&apos;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><code>dl</code></dfn> element<a href=#the-dl-element class=self-link></a></h4>

  <dl class=element><dt><a href=#concept-element-categories id=the-dl-element:concept-element-categories>Categories</a>:<dd><a href=#flow-content-2 id=the-dl-element:flow-content-2>Flow content</a>.<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>.<dt><a href=#concept-element-contexts id=the-dl-element:concept-element-contexts>Contexts in which this element can be used</a>:<dd>Where <a href=#flow-content-2 id=the-dl-element:flow-content-2-2>flow content</a> is expected.<dt><a href=#concept-element-content-model id=the-dl-element:concept-element-content-model>Content model</a>:<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>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>.<dt><a href=#concept-element-tag-omission id=the-dl-element:concept-element-tag-omission>Tag omission in text/html</a>:<dd>Neither tag is omissible.<dt><a href=#concept-element-attributes id=the-dl-element:concept-element-attributes>Content attributes</a>:<dd><a href=#global-attributes id=the-dl-element:global-attributes>Global attributes</a><dt><a href=#concept-element-dom id=the-dl-element:concept-element-dom>DOM interface</a>:<dd>
    <pre><code class='idl'>[<c- g>Exposed</c->=<c- n>Window</c->,
 <a href='#htmlconstructor' id='the-dl-element:htmlconstructor'><c- g>HTMLConstructor</c-></a>]
<c- b>interface</c-> <dfn id='htmldlistelement'><c- g>HTMLDListElement</c-></dfn> : <a href='#htmlelement' id='the-dl-element:htmlelement'><c- n>HTMLElement</c-></a> {};</code></pre>
   </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>

  

  <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.<li><p>Let <var>current</var> be a new name-value group.<li><p>Let <var>seenDd</var> be false.<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>.<li><p>Let <var>grandchild</var> be null.<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>.<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>.<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>.</ol>
       </ol>
     <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>.<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>.</ol>
   <li><p>If <var>current</var> is not empty, then append <var>current</var> to
   <var>groups</var>.<li><p>Return <var>groups</var>.</ol>

  <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.<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.<li><p>Append <var>node</var> to <var>current</var>'s name.</ol>
   <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.</ol>

  <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>&quot;en-US&quot;</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>&quot;en-GB&quot;</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&apos;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>&quot;http://schema.org/Product&quot;</c-><c- p>&gt;</c->
  <c- p>&lt;</c-><c- f>dt</c-> <c- e>itemprop</c-><c- o>=</c-><c- s>&quot;name&quot;</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>&quot;offers&quot;</c-> <c- e>itemscope</c-> <c- e>itemtype</c-><c- o>=</c-><c- s>&quot;http://schema.org/Offer&quot;</c-><c- p>&gt;</c->
   <c- p>&lt;</c-><c- f>span</c-> <c- e>itemprop</c-><c- o>=</c-><c- s>&quot;price&quot;</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>&quot;priceCurrency&quot;</c-> <c- e>value</c-><c- o>=</c-><c- s>&quot;EUR&quot;</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>&quot;description&quot;</c-><c- p>&gt;</c->
   2 boules Café ou Chocolat, 1 boule Vanille, sause 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>&quot;http://schema.org/Product&quot;</c-><c- p>&gt;</c->
  <c- p>&lt;</c-><c- f>dt</c-> <c- e>itemprop</c-><c- o>=</c-><c- s>&quot;name&quot;</c-><c- p>&gt;</c->Américaine
  <c- p>&lt;</c-><c- f>dd</c-> <c- e>itemprop</c-><c- o>=</c-><c- s>&quot;offers&quot;</c-> <c- e>itemscope</c-> <c- e>itemtype</c-><c- o>=</c-><c- s>&quot;http://schema.org/Offer&quot;</c-><c- p>&gt;</c->
   <c- p>&lt;</c-><c- f>span</c-> <c- e>itemprop</c-><c- o>=</c-><c- s>&quot;price&quot;</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>&quot;priceCurrency&quot;</c-> <c- e>value</c-><c- o>=</c-><c- s>&quot;EUR&quot;</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>&quot;description&quot;</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>&quot;http://schema.org/Product&quot;</c-> <c- e>itemref</c-><c- o>=</c-><c- s>&quot;1-offer 1-description&quot;</c-><c- p>&gt;</c->
  <c- p>&lt;</c-><c- f>span</c-> <c- e>itemprop</c-><c- o>=</c-><c- s>&quot;name&quot;</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>&quot;1-offer&quot;</c-> <c- e>itemprop</c-><c- o>=</c-><c- s>&quot;offers&quot;</c-> <c- e>itemscope</c-> <c- e>itemtype</c-><c- o>=</c-><c- s>&quot;http://schema.org/Offer&quot;</c-><c- p>&gt;</c->
  <c- p>&lt;</c-><c- f>span</c-> <c- e>itemprop</c-><c- o>=</c-><c- s>&quot;price&quot;</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>&quot;priceCurrency&quot;</c-> <c- e>value</c-><c- o>=</c-><c- s>&quot;EUR&quot;</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>&quot;1-description&quot;</c-> <c- e>itemprop</c-><c- o>=</c-><c- s>&quot;description&quot;</c-><c- p>&gt;</c->
  2 boules Café ou Chocolat, 1 boule Vanille, sause 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>&quot;http://schema.org/Product&quot;</c-> <c- e>itemref</c-><c- o>=</c-><c- s>&quot;2-offer 2-description&quot;</c-><c- p>&gt;</c->
  <c- p>&lt;</c-><c- f>span</c-> <c- e>itemprop</c-><c- o>=</c-><c- s>&quot;name&quot;</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>&quot;2-offer&quot;</c-> <c- e>itemprop</c-><c- o>=</c-><c- s>&quot;offers&quot;</c-> <c- e>itemscope</c-> <c- e>itemtype</c-><c- o>=</c-><c- s>&quot;http://schema.org/Offer&quot;</c-><c- p>&gt;</c->
  <c- p>&lt;</c-><c- f>span</c-> <c- e>itemprop</c-><c- o>=</c-><c- s>&quot;price&quot;</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>&quot;priceCurrency&quot;</c-> <c- e>value</c-><c- o>=</c-><c- s>&quot;EUR&quot;</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>&quot;2-description&quot;</c-> <c- e>itemprop</c-><c- o>=</c-><c- s>&quot;description&quot;</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><code>dt</code></dfn> element<a href=#the-dt-element class=self-link></a></h4>

  <dl class=element><dt><a href=#concept-element-categories id=the-dt-element:concept-element-categories>Categories</a>:<dd>None.<dt><a href=#concept-element-contexts id=the-dt-element:concept-element-contexts>Contexts in which this element can be used</a>:<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>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.<dt><a href=#concept-element-content-model id=the-dt-element:concept-element-content-model>Content model</a>:<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.<dt><a href=#concept-element-tag-omission id=the-dt-element:concept-element-tag-omission>Tag omission in text/html</a>:<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.<dt><a href=#concept-element-attributes id=the-dt-element:concept-element-attributes>Content attributes</a>:<dd><a href=#global-attributes id=the-dt-element:global-attributes>Global attributes</a><dt><a href=#concept-element-dom id=the-dt-element:concept-element-dom>DOM interface</a>:<dd>Uses <code id=the-dt-element:htmlelement><a href=#htmlelement>HTMLElement</a></code>.</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><code>dd</code></dfn> element<a href=#the-dd-element class=self-link></a></h4>

  <dl class=element><dt><a href=#concept-element-categories id=the-dd-element:concept-element-categories>Categories</a>:<dd>None.<dt><a href=#concept-element-contexts id=the-dd-element:concept-element-contexts>Contexts in which this element can be used</a>:<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>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.<dt><a href=#concept-element-content-model id=the-dd-element:concept-element-content-model>Content model</a>:<dd><a href=#flow-content-2 id=the-dd-element:flow-content-2>Flow content</a>.<dt><a href=#concept-element-tag-omission id=the-dd-element:concept-element-tag-omission>Tag omission in text/html</a>:<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.<dt><a href=#concept-element-attributes id=the-dd-element:concept-element-attributes>Content attributes</a>:<dd><a href=#global-attributes id=the-dd-element:global-attributes>Global attributes</a><dt><a href=#concept-element-dom id=the-dd-element:concept-element-dom>DOM interface</a>:<dd>Uses <code id=the-dd-element:htmlelement><a href=#htmlelement>HTMLElement</a></code>.</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>&quot;pronunciation&quot;</c-><c- p>&gt;</c->/&apos;hæ p. nes/<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>&quot;part-of-speech&quot;</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>&quot;pronunciation&quot;</c-><c- p>&gt;</c->/ri jois&apos;/<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>&quot;part-of-speech&quot;</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>&quot;part-of-speech&quot;</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><code>figure</code></dfn> element<a href=#the-figure-element class=self-link></a></h4>

  <dl class=element><dt><a href=#concept-element-categories id=the-figure-element:concept-element-categories>Categories</a>:<dd><a href=#flow-content-2 id=the-figure-element:flow-content-2>Flow content</a>.<dd><a href=#sectioning-root id=the-figure-element:sectioning-root>Sectioning root</a>.<dd><a href=#palpable-content-2 id=the-figure-element:palpable-content-2>Palpable content</a>.<dt><a href=#concept-element-contexts id=the-figure-element:concept-element-contexts>Contexts in which this element can be used</a>:<dd>Where <a href=#flow-content-2 id=the-figure-element:flow-content-2-2>flow content</a> is expected.<dt><a href=#concept-element-content-model id=the-figure-element:concept-element-content-model>Content model</a>:<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>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>Or: <a href=#flow-content-2 id=the-figure-element:flow-content-2-5>flow content</a>.<dt><a href=#concept-element-tag-omission id=the-figure-element:concept-element-tag-omission>Tag omission in text/html</a>:<dd>Neither tag is omissible.<dt><a href=#concept-element-attributes id=the-figure-element:concept-element-attributes>Content attributes</a>:<dd><a href=#global-attributes id=the-figure-element:global-attributes>Global attributes</a><dt><a href=#concept-element-dom id=the-figure-element:concept-element-dom>DOM interface</a>:<dd>Uses <code id=the-figure-element:htmlelement><a href=#htmlelement>HTMLElement</a></code>.</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>
   <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>&quot;#l4&quot;</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>&quot;l4&quot;</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();
 void sendData(in sequence<c- p>&lt;</c-><c- f>byte</c-><c- p>&gt;</c-> data);
 void 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>&quot;en&quot;</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>&quot;bubbles-work.jpeg&quot;</c->
      <c- e>alt</c-><c- o>=</c-><c- s>&quot;Bubbles, sitting in his office chair, works on his</c->
<c- s>           latest project intently.&quot;</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>&quot;19414.html&quot;</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>&quot;19416.html&quot;</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&apos;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 &quot;intellectual property&quot;
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>&quot;promblem-packed-action.png&quot;</c-> <c- e>alt</c-><c- o>=</c-><c- s>&quot;ROUGH COPY! Promblem-Packed Action!&quot;</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>&quot;ex-a.png&quot;</c-> <c- e>alt</c-><c- o>=</c-><c- s>&quot;Two squiggles on a dirty piece of paper.&quot;</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>&quot;ex-b.mov&quot;</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->&apos;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>&quot;castle1423.jpeg&quot;</c-> <c- e>alt</c-><c- o>=</c-><c- s>&quot;The castle has one tower, and a tall wall around it.&quot;</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>&quot;castle1858.jpeg&quot;</c-> <c- e>alt</c-><c- o>=</c-><c- s>&quot;The castle now has two towers and two walls.&quot;</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>&quot;castle1999.jpeg&quot;</c-> <c- e>alt</c-><c- o>=</c-><c- s>&quot;The castle lies in ruins, the original tower all that remains in one piece.&quot;</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>&quot;castle1423.jpeg&quot;</c-> <c- e>title</c-><c- o>=</c-><c- s>&quot;Etching. Anonymous, ca. 1423.&quot;</c->
      <c- e>alt</c-><c- o>=</c-><c- s>&quot;The castle has one tower, and a tall wall around it.&quot;</c-><c- p>&gt;</c->
 <c- p>&lt;</c-><c- f>img</c-> <c- e>src</c-><c- o>=</c-><c- s>&quot;castle1858.jpeg&quot;</c-> <c- e>title</c-><c- o>=</c-><c- s>&quot;Oil-based paint on canvas. Maria Towle, 1858.&quot;</c->
      <c- e>alt</c-><c- o>=</c-><c- s>&quot;The castle now has two towers and two walls.&quot;</c-><c- p>&gt;</c->
 <c- p>&lt;</c-><c- f>img</c-> <c- e>src</c-><c- o>=</c-><c- s>&quot;castle1999.jpeg&quot;</c-> <c- e>title</c-><c- o>=</c-><c- s>&quot;Film photograph. Peter Jankle, 1999.&quot;</c->
      <c- e>alt</c-><c- o>=</c-><c- s>&quot;The castle lies in ruins, the original tower all that remains in one piece.&quot;</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>&quot;obama-reid.jpeg&quot;</c-> <c- e>alt</c-><c- o>=</c-><c- s>&quot;Obama and Reid sit together smiling in the Oval Office.&quot;</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&apos;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><code>figcaption</code></dfn> element<a href=#the-figcaption-element class=self-link></a></h4>

  <dl class=element><dt><a href=#concept-element-categories id=the-figcaption-element:concept-element-categories>Categories</a>:<dd>None.<dt><a href=#concept-element-contexts id=the-figcaption-element:concept-element-contexts>Contexts in which this element can be used</a>:<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.<dt><a href=#concept-element-content-model id=the-figcaption-element:concept-element-content-model>Content model</a>:<dd><a href=#flow-content-2 id=the-figcaption-element:flow-content-2>Flow content</a>.<dt><a href=#concept-element-tag-omission id=the-figcaption-element:concept-element-tag-omission>Tag omission in text/html</a>:<dd>Neither tag is omissible.<dt><a href=#concept-element-attributes id=the-figcaption-element:concept-element-attributes>Content attributes</a>:<dd><a href=#global-attributes id=the-figcaption-element:global-attributes>Global attributes</a><dt><a href=#concept-element-dom id=the-figcaption-element:concept-element-dom>DOM interface</a>:<dd>Uses <code id=the-figcaption-element:htmlelement><a href=#htmlelement>HTMLElement</a></code>.</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><code>main</code></dfn> element<a href=#the-main-element class=self-link></a></h4>

  <dl class=element><dt><a href=#concept-element-categories id=the-main-element:concept-element-categories>Categories</a>:<dd><a href=#flow-content-2 id=the-main-element:flow-content-2>Flow content</a>.<dd><a href=#palpable-content-2 id=the-main-element:palpable-content-2>Palpable content</a>.<dt><a href=#concept-element-contexts id=the-main-element:concept-element-contexts>Contexts in which this element can be used</a>:<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>.<dt><a href=#concept-element-content-model id=the-main-element:concept-element-content-model>Content model</a>:<dd><a href=#flow-content-2 id=the-main-element:flow-content-2-3>Flow content</a>.<dt><a href=#concept-element-tag-omission id=the-main-element:concept-element-tag-omission>Tag omission in text/html</a>:<dd>Neither tag is omissible.<dt><a href=#concept-element-attributes id=the-main-element:concept-element-attributes>Content attributes</a>:<dd><a href=#global-attributes id=the-main-element:global-attributes>Global attributes</a><dt><a href=#concept-element-dom id=the-main-element:concept-element-dom>DOM interface</a>:<dd>Uses <code id=the-main-element:htmlelement><a href=#htmlelement>HTMLElement</a></code>.</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:the-hidden-attribute><a href=#the-hidden-attribute>hidden</a></code> attribute specified.</p>

  <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/aria/aria.html#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 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>&quot;en&quot;</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>&quot;../16/&quot;</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>&quot;../18/&quot;</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&apos;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:the-hidden-attribute-2><a href=#the-hidden-attribute>hidden</a></code> attribute on those that are not current:

   <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-div-element><span class=secno>4.4.15</span> The <dfn><code>div</code></dfn> element<a href=#the-div-element class=self-link></a></h4>

  <dl class=element><dt><a href=#concept-element-categories id=the-div-element:concept-element-categories>Categories</a>:<dd><a href=#flow-content-2 id=the-div-element:flow-content-2>Flow content</a>.<dd><a href=#palpable-content-2 id=the-div-element:palpable-content-2>Palpable content</a>.<dt><a href=#concept-element-contexts id=the-div-element:concept-element-contexts>Contexts in which this element can be used</a>:<dd>Where <a href=#flow-content-2 id=the-div-element:flow-content-2-2>flow content</a> is expected.<dd>As a child of a <code id=the-div-element:the-dl-element><a href=#the-dl-element>dl</a></code> element.<dt><a href=#concept-element-content-model id=the-div-element:concept-element-content-model>Content model</a>:<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>If the element is not a child of a <code id=the-div-element:the-dl-element-3><a href=#the-dl-element>dl</a></code> element: <a href=#flow-content-2 id=the-div-element:flow-content-2-3>flow content</a>.<dt><a href=#concept-element-tag-omission id=the-div-element:concept-element-tag-omission>Tag omission in text/html</a>:<dd>Neither tag is omissible.<dt><a href=#concept-element-attributes id=the-div-element:concept-element-attributes>Content attributes</a>:<dd><a href=#global-attributes id=the-div-element:global-attributes>Global attributes</a><dt><a href=#concept-element-dom id=the-div-element:concept-element-dom>DOM interface</a>:<dd>
    <pre><code class='idl'>[<c- g>Exposed</c->=<c- n>Window</c->,
 <a href='#htmlconstructor' id='the-div-element:htmlconstructor'><c- g>HTMLConstructor</c-></a>]
<c- b>interface</c-> <dfn id='htmldivelement'><c- g>HTMLDivElement</c-></dfn> : <a href='#htmlelement' id='the-div-element:htmlelement'><c- n>HTMLElement</c-></a> {};</code></pre>
   </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-4><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>&quot;en-US&quot;</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&apos;s behavior hasn&apos;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>&quot;en-GB&quot;</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&apos;m supposed to write in American English. So I
  shouldn&apos;t say &quot;pavement&quot; or &quot;flat&quot; or &quot;colour&quot;...<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 &quot;sidewalk&quot; and &quot;apartment&quot; and &quot;color&quot;!<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 data-dfn-type=element data-lt=a><span class=secno>4.5.1</span> The <dfn><code>a</code></dfn> element<a href=#the-a-element class=self-link></a></h4>

  <dl class=element><dt><a href=#concept-element-categories id=the-a-element:concept-element-categories>Categories</a>:<dd><a href=#flow-content-2 id=the-a-element:flow-content-2>Flow content</a>.<dd><a href=#phrasing-content-2 id=the-a-element:phrasing-content-2>Phrasing content</a>.<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><a href=#palpable-content-2 id=the-a-element:palpable-content-2>Palpable content</a>.<dt><a href=#concept-element-contexts id=the-a-element:concept-element-contexts>Contexts in which this element can be used</a>:<dd>Where <a href=#phrasing-content-2 id=the-a-element:phrasing-content-2-2>phrasing content</a> is expected.<dt><a href=#concept-element-content-model id=the-a-element:concept-element-content-model>Content model</a>:<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> or <code id=the-a-element:the-a-element><a href=#the-a-element>a</a></code> element descendants.<dt><a href=#concept-element-tag-omission id=the-a-element:concept-element-tag-omission>Tag omission in text/html</a>:<dd>Neither tag is omissible.<dt><a href=#concept-element-attributes id=the-a-element:concept-element-attributes>Content attributes</a>:<dd><a href=#global-attributes id=the-a-element:global-attributes>Global attributes</a><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><code id=the-a-element:attr-hyperlink-target><a href=#attr-hyperlink-target>target</a></code> — <a href=#browsing-context id=the-a-element:browsing-context>Browsing context</a> for <a href=#hyperlink id=the-a-element:hyperlink-2>hyperlink</a> <a href=#navigate id=the-a-element:navigate>navigation</a><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 file name if so<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><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><code id=the-a-element:attr-hyperlink-hreflang><a href=#attr-hyperlink-hreflang>hreflang</a></code> — Language of the linked resource<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><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<dt><a href=#concept-element-dom id=the-a-element:concept-element-dom>DOM interface</a>:<dd>
    <pre><code class='idl'>[<c- g>Exposed</c->=<c- n>Window</c->,
 <a href='#htmlconstructor' id='the-a-element:htmlconstructor'><c- g>HTMLConstructor</c-></a>]
<c- b>interface</c-> <dfn id='htmlanchorelement'><c- g>HTMLAnchorElement</c-></dfn> : <a href='#htmlelement' id='the-a-element:htmlelement'><c- n>HTMLElement</c-></a> {
  [<a href='#cereactions' id='the-a-element:cereactions'><c- g>CEReactions</c-></a>] <c- b>attribute</c-> <c- b>DOMString</c-> <a href='#dom-a-target' id='the-a-element:dom-a-target'><c- g>target</c-></a>;
  [<a href='#cereactions' id='the-a-element:cereactions-2'><c- g>CEReactions</c-></a>] <c- b>attribute</c-> <c- b>DOMString</c-> <a href='#dom-a-download' id='the-a-element:dom-a-download'><c- g>download</c-></a>;
  [<a href='#cereactions' id='the-a-element:cereactions-3'><c- g>CEReactions</c-></a>] <c- b>attribute</c-> <c- b>USVString</c-> <a href='#dom-a-ping' id='the-a-element:dom-a-ping'><c- g>ping</c-></a>;
  [<a href='#cereactions' id='the-a-element:cereactions-4'><c- g>CEReactions</c-></a>] <c- b>attribute</c-> <c- b>DOMString</c-> <a href='#dom-a-rel' id='the-a-element:dom-a-rel'><c- g>rel</c-></a>;
  [<c- g>SameObject</c->, <c- g>PutForwards</c->=<a href='https://dom.spec.whatwg.org/#dom-domtokenlist-value' data-x-internal='dom-domtokenlist-value' id='the-a-element:dom-domtokenlist-value'><c- n>value</c-></a>] <c- b>readonly</c-> <c- b>attribute</c-> <a href='https://dom.spec.whatwg.org/#interface-domtokenlist' data-x-internal='domtokenlist' id='the-a-element:domtokenlist'><c- n>DOMTokenList</c-></a> <a href='#dom-a-rellist' id='the-a-element:dom-a-rellist'><c- g>relList</c-></a>;
  [<a href='#cereactions' id='the-a-element:cereactions-5'><c- g>CEReactions</c-></a>] <c- b>attribute</c-> <c- b>DOMString</c-> <a href='#dom-a-hreflang' id='the-a-element:dom-a-hreflang'><c- g>hreflang</c-></a>;
  [<a href='#cereactions' id='the-a-element:cereactions-6'><c- g>CEReactions</c-></a>] <c- b>attribute</c-> <c- b>DOMString</c-> <a href='#dom-a-type' id='the-a-element:dom-a-type'><c- g>type</c-></a>;

  [<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' 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>
   </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-3><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-4><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-2><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-5><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-6><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>&quot;/&quot;</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>&quot;/news&quot;</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>&quot;/legal&quot;</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-7><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-3><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>

  <p>The <a id=the-a-element:activation-behaviour href=https://dom.spec.whatwg.org/#eventtarget-activation-behavior data-x-internal=activation-behaviour>activation behavior</a> of <code id=the-a-element:the-a-element-7><a href=#the-a-element>a</a></code> elements that create <a href=#hyperlink id=the-a-element:hyperlink-5>hyperlinks</a> is to run the following steps:</p>

  <ol><li><p>If the target of the <code id=the-a-element:event-click><a data-x-internal=event-click href=https://w3c.github.io/uievents/#event-type-click>click</a></code> event is an <code id=the-a-element:the-img-element><a href=#the-img-element>img</a></code>
   element with an <code id=the-a-element:attr-img-ismap><a href=#attr-img-ismap>ismap</a></code> attribute specified, then server-side
   image map processing must be performed, as follows:</p>

    <ol><li>Let <var>x</var> and <var>y</var> be zero.<li>If the <code id=the-a-element:event-click-2><a data-x-internal=event-click href=https://w3c.github.io/uievents/#event-type-click>click</a></code> event was a real pointing-device-triggered
     <code id=the-a-element:event-click-3><a data-x-internal=event-click href=https://w3c.github.io/uievents/#event-type-click>click</a></code> event on the <code id=the-a-element:the-img-element-2><a href=#the-img-element>img</a></code> element, then set
     <var>x</var> to the distance in <a href=https://drafts.csswg.org/css-values/#px id="the-a-element:'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="the-a-element:'px'-2" data-x-internal="'px'">CSS pixels</a> from the top edge of the image to the location of the
     click.<li>If <var>x</var> is negative, set <var>x</var> to zero.<li>If <var>y</var> is negative, set <var>y</var> to zero.<li>Let <var>hyperlink suffix</var> be a U+003F QUESTION MARK character, the value of
     <var>x</var> expressed as a base-ten integer using <a id=the-a-element:ascii-digits href=https://infra.spec.whatwg.org/#ascii-digit data-x-internal=ascii-digits>ASCII digits</a>, a U+002C COMMA
     character (,), and the value of <var>y</var> expressed as a base-ten integer using <a id=the-a-element:ascii-digits-2 href=https://infra.spec.whatwg.org/#ascii-digit data-x-internal=ascii-digits>ASCII
     digits</a>.</ol>

   <li><p><a href=#following-hyperlinks-2 id=the-a-element:following-hyperlinks-2-2>Follow the hyperlink</a> or <a href=#downloading-hyperlinks id=the-a-element:downloading-hyperlinks-2>download the hyperlink</a> created by the <code id=the-a-element:the-a-element-8><a href=#the-a-element>a</a></code>
   element, as determined by the <code id=the-a-element:attr-hyperlink-download-4><a href=#attr-hyperlink-download>download</a></code> attribute
   and any expressed user preference, passing <var>hyperlink suffix</var>, if the steps above
   defined it.</ol>

  

  <dl class=domintro><dt><var>a</var> . <code id=dom-a-text-dev><a href=#dom-a-text>text</a></code><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>

   </dl>

  

  <p>The IDL attributes <dfn id=dom-a-download><code>download</code></dfn>, <dfn data-dfn-for=a id=dom-a-ping data-dfn-type=element-attr data-export=""><code>ping</code></dfn>, <dfn id=dom-a-target><code>target</code></dfn>,
  <dfn id=dom-a-rel><code>rel</code></dfn>, <dfn id=dom-a-hreflang><code>hreflang</code></dfn>, and <dfn id=dom-a-type><code>type</code></dfn>, must <a href=#reflect id=the-a-element:reflect>reflect</a> the respective content attributes
  of the same name.</p>

  <p>The IDL attribute <dfn id=dom-a-rellist><code>relList</code></dfn> must
  <a href=#reflect id=the-a-element:reflect-2>reflect</a> the <code id=the-a-element:attr-hyperlink-rel-4><a href=#attr-hyperlink-rel>rel</a></code> content attribute.<div class=status><input onclick=toggleStatus(this) value=⋰ type=button><p class=support><strong>Support:</strong> rellist<span class="and_chr yes"><span>Chrome for Android</span> <span>67+</span></span><span class="chrome yes"><span>Chrome</span> <span>65+</span></span><span class="ios_saf yes"><span>iOS Safari</span> <span>9.0+</span></span><span class="and_uc partial"><span>UC Browser for Android (limited)</span> <span>11.8+</span></span><span class="firefox yes"><span>Firefox</span> <span>30+</span></span><span class="ie no"><span>IE</span> <span>None</span></span><span class="op_mini no"><span>Opera Mini</span> <span>None</span></span><span class="safari yes"><span>Safari</span> <span>9+</span></span><span class="edge yes"><span>Edge</span> <span>18+</span></span><span class="samsung partial"><span>Samsung Internet (limited)</span> <span>5+</span></span><span class="opera yes"><span>Opera</span> <span>52+</span></span><span class="android yes"><span>Android Browser</span> <span>67+</span></span><p class=caniuse>Source: <a href="https://caniuse.com/#feat=rellist">caniuse.com</a></div>

  <p>The IDL attribute <dfn id=dom-a-referrerpolicy><code>referrerPolicy</code></dfn> must
  <a href=#reflect id=the-a-element:reflect-3>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>

  <p>The <dfn id=dom-a-text><code>text</code></dfn> IDL attribute, on getting, must return the
  same value as the <code id=the-a-element:textcontent-2><a data-x-internal=textcontent href=https://dom.spec.whatwg.org/#dom-node-textcontent>textContent</a></code> IDL attribute on the element, and on setting, must act
  as if the <code id=the-a-element:textcontent-3><a data-x-internal=textcontent href=https://dom.spec.whatwg.org/#dom-node-textcontent>textContent</a></code> IDL attribute on the element had been set to the new value.</p>

  

  <div class=example>

   <p>The <code id=the-a-element:the-a-element-9><a href=#the-a-element>a</a></code> element may 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>&quot;advertising&quot;</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>&quot;https://ad.example.com/?adid=1929&amp;amp;pubid=1422&quot;</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>&quot;https://ad.example.com/?adid=375&amp;amp;pubid=1422&quot;</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>


  <h4 id=the-em-element><span class=secno>4.5.2</span> The <dfn><code>em</code></dfn> element<a href=#the-em-element class=self-link></a></h4>

  <dl class=element><dt><a href=#concept-element-categories id=the-em-element:concept-element-categories>Categories</a>:<dd><a href=#flow-content-2 id=the-em-element:flow-content-2>Flow content</a>.<dd><a href=#phrasing-content-2 id=the-em-element:phrasing-content-2>Phrasing content</a>.<dd><a href=#palpable-content-2 id=the-em-element:palpable-content-2>Palpable content</a>.<dt><a href=#concept-element-contexts id=the-em-element:concept-element-contexts>Contexts in which this element can be used</a>:<dd>Where <a href=#phrasing-content-2 id=the-em-element:phrasing-content-2-2>phrasing content</a> is expected.<dt><a href=#concept-element-content-model id=the-em-element:concept-element-content-model>Content model</a>:<dd><a href=#phrasing-content-2 id=the-em-element:phrasing-content-2-3>Phrasing content</a>.<dt><a href=#concept-element-tag-omission id=the-em-element:concept-element-tag-omission>Tag omission in text/html</a>:<dd>Neither tag is omissible.<dt><a href=#concept-element-attributes id=the-em-element:concept-element-attributes>Content attributes</a>:<dd><a href=#global-attributes id=the-em-element:global-attributes>Global attributes</a><dt><a href=#concept-element-dom id=the-em-element:concept-element-dom>DOM interface</a>:<dd>Uses <code id=the-em-element:htmlelement><a href=#htmlelement>HTMLElement</a></code>.</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><code>strong</code></dfn> element<a href=#the-strong-element class=self-link></a></h4>

  <dl class=element><dt><a href=#concept-element-categories id=the-strong-element:concept-element-categories>Categories</a>:<dd><a href=#flow-content-2 id=the-strong-element:flow-content-2>Flow content</a>.<dd><a href=#phrasing-content-2 id=the-strong-element:phrasing-content-2>Phrasing content</a>.<dd><a href=#palpable-content-2 id=the-strong-element:palpable-content-2>Palpable content</a>.<dt><a href=#concept-element-contexts id=the-strong-element:concept-element-contexts>Contexts in which this element can be used</a>:<dd>Where <a href=#phrasing-content-2 id=the-strong-element:phrasing-content-2-2>phrasing content</a> is expected.<dt><a href=#concept-element-content-model id=the-strong-element:concept-element-content-model>Content model</a>:<dd><a href=#phrasing-content-2 id=the-strong-element:phrasing-content-2-3>Phrasing content</a>.<dt><a href=#concept-element-tag-omission id=the-strong-element:concept-element-tag-omission>Tag omission in text/html</a>:<dd>Neither tag is omissible.<dt><a href=#concept-element-attributes id=the-strong-element:concept-element-attributes>Content attributes</a>:<dd><a href=#global-attributes id=the-strong-element:global-attributes>Global attributes</a><dt><a href=#concept-element-dom id=the-strong-element:concept-element-dom>DOM interface</a>:<dd>Uses <code id=the-strong-element:htmlelement><a href=#htmlelement>HTMLElement</a></code>.</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&apos;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><code>small</code></dfn> element<a href=#the-small-element class=self-link></a></h4>

  <dl class=element><dt><a href=#concept-element-categories id=the-small-element:concept-element-categories>Categories</a>:<dd><a href=#flow-content-2 id=the-small-element:flow-content-2>Flow content</a>.<dd><a href=#phrasing-content-2 id=the-small-element:phrasing-content-2>Phrasing content</a>.<dd><a href=#palpable-content-2 id=the-small-element:palpable-content-2>Palpable content</a>.<dt><a href=#concept-element-contexts id=the-small-element:concept-element-contexts>Contexts in which this element can be used</a>:<dd>Where <a href=#phrasing-content-2 id=the-small-element:phrasing-content-2-2>phrasing content</a> is expected.<dt><a href=#concept-element-content-model id=the-small-element:concept-element-content-model>Content model</a>:<dd><a href=#phrasing-content-2 id=the-small-element:phrasing-content-2-3>Phrasing content</a>.<dt><a href=#concept-element-tag-omission id=the-small-element:concept-element-tag-omission>Tag omission in text/html</a>:<dd>Neither tag is omissible.<dt><a href=#concept-element-attributes id=the-small-element:concept-element-attributes>Content attributes</a>:<dd><a href=#global-attributes id=the-small-element:global-attributes>Global attributes</a><dt><a href=#concept-element-dom id=the-small-element:concept-element-dom>DOM interface</a>:<dd>Uses <code id=the-small-element:htmlelement><a href=#htmlelement>HTMLElement</a></code>.</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 &quot;To provide entertainment
 and news on a sample basis&quot;.<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>&quot;https://example.com/about.html&quot;</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><code>s</code></dfn> element<a href=#the-s-element class=self-link></a></h4>

  <dl class=element><dt><a href=#concept-element-categories id=the-s-element:concept-element-categories>Categories</a>:<dd><a href=#flow-content-2 id=the-s-element:flow-content-2>Flow content</a>.<dd><a href=#phrasing-content-2 id=the-s-element:phrasing-content-2>Phrasing content</a>.<dd><a href=#palpable-content-2 id=the-s-element:palpable-content-2>Palpable content</a>.<dt><a href=#concept-element-contexts id=the-s-element:concept-element-contexts>Contexts in which this element can be used</a>:<dd>Where <a href=#phrasing-content-2 id=the-s-element:phrasing-content-2-2>phrasing content</a> is expected.<dt><a href=#concept-element-content-model id=the-s-element:concept-element-content-model>Content model</a>:<dd><a href=#phrasing-content-2 id=the-s-element:phrasing-content-2-3>Phrasing content</a>.<dt><a href=#concept-element-tag-omission id=the-s-element:concept-element-tag-omission>Tag omission in text/html</a>:<dd>Neither tag is omissible.<dt><a href=#concept-element-attributes id=the-s-element:concept-element-attributes>Content attributes</a>:<dd><a href=#global-attributes id=the-s-element:global-attributes>Global attributes</a><dt><a href=#concept-element-dom id=the-s-element:concept-element-dom>DOM interface</a>:<dd>Uses <code id=the-s-element:htmlelement><a href=#htmlelement>HTMLElement</a></code>.</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><code>cite</code></dfn> element<a href=#the-cite-element class=self-link></a></h4>

  <dl class=element><dt><a href=#concept-element-categories id=the-cite-element:concept-element-categories>Categories</a>:<dd><a href=#flow-content-2 id=the-cite-element:flow-content-2>Flow content</a>.<dd><a href=#phrasing-content-2 id=the-cite-element:phrasing-content-2>Phrasing content</a>.<dd><a href=#palpable-content-2 id=the-cite-element:palpable-content-2>Palpable content</a>.<dt><a href=#concept-element-contexts id=the-cite-element:concept-element-contexts>Contexts in which this element can be used</a>:<dd>Where <a href=#phrasing-content-2 id=the-cite-element:phrasing-content-2-2>phrasing content</a> is expected.<dt><a href=#concept-element-content-model id=the-cite-element:concept-element-content-model>Content model</a>:<dd><a href=#phrasing-content-2 id=the-cite-element:phrasing-content-2-3>Phrasing content</a>.<dt><a href=#concept-element-tag-omission id=the-cite-element:concept-element-tag-omission>Tag omission in text/html</a>:<dd>Neither tag is omissible.<dt><a href=#concept-element-attributes id=the-cite-element:concept-element-attributes>Content attributes</a>:<dd><a href=#global-attributes id=the-cite-element:global-attributes>Global attributes</a><dt><a href=#concept-element-dom id=the-cite-element:concept-element-dom>DOM interface</a>:<dd>Uses <code id=the-cite-element:htmlelement><a href=#htmlelement>HTMLElement</a></code>.</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 obviously 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><code>q</code></dfn> element<a href=#the-q-element class=self-link></a></h4>

  <dl class=element><dt><a href=#concept-element-categories id=the-q-element:concept-element-categories>Categories</a>:<dd><a href=#flow-content-2 id=the-q-element:flow-content-2>Flow content</a>.<dd><a href=#phrasing-content-2 id=the-q-element:phrasing-content-2>Phrasing content</a>.<dd><a href=#palpable-content-2 id=the-q-element:palpable-content-2>Palpable content</a>.<dt><a href=#concept-element-contexts id=the-q-element:concept-element-contexts>Contexts in which this element can be used</a>:<dd>Where <a href=#phrasing-content-2 id=the-q-element:phrasing-content-2-2>phrasing content</a> is expected.<dt><a href=#concept-element-content-model id=the-q-element:concept-element-content-model>Content model</a>:<dd><a href=#phrasing-content-2 id=the-q-element:phrasing-content-2-3>Phrasing content</a>.<dt><a href=#concept-element-tag-omission id=the-q-element:concept-element-tag-omission>Tag omission in text/html</a>:<dd>Neither tag is omissible.<dt><a href=#concept-element-attributes id=the-q-element:concept-element-attributes>Content attributes</a>:<dd><a href=#global-attributes id=the-q-element:global-attributes>Global attributes</a><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<dt><a href=#concept-element-dom id=the-q-element:concept-element-dom>DOM interface</a>:<dd>Uses <code id=the-q-element:htmlquoteelement><a href=#htmlquoteelement>HTMLQuoteElement</a></code>.</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 id=attr-q-cite><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=#parse-a-url id=the-q-element:parse-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&apos;s
mission is <c- p>&lt;</c-><c- f>q</c-> <c- e>cite</c-><c- o>=</c-><c- s>&quot;https://www.w3.org/Consortium/&quot;</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 &quot;ineffable&quot; could have been used to describe the disaster
resulting from the campaign&apos;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><code>dfn</code></dfn> element<a href=#the-dfn-element class=self-link></a></h4>

  <dl class=element><dt><a href=#concept-element-categories id=the-dfn-element:concept-element-categories>Categories</a>:<dd><a href=#flow-content-2 id=the-dfn-element:flow-content-2>Flow content</a>.<dd><a href=#phrasing-content-2 id=the-dfn-element:phrasing-content-2>Phrasing content</a>.<dd><a href=#palpable-content-2 id=the-dfn-element:palpable-content-2>Palpable content</a>.<dt><a href=#concept-element-contexts id=the-dfn-element:concept-element-contexts>Contexts in which this element can be used</a>:<dd>Where <a href=#phrasing-content-2 id=the-dfn-element:phrasing-content-2-2>phrasing content</a> is expected.<dt><a href=#concept-element-content-model id=the-dfn-element:concept-element-content-model>Content model</a>:<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.<dt><a href=#concept-element-tag-omission id=the-dfn-element:concept-element-tag-omission>Tag omission in text/html</a>:<dd>Neither tag is omissible.<dt><a href=#concept-element-attributes id=the-dfn-element:concept-element-attributes>Content attributes</a>:<dd><a href=#global-attributes id=the-dfn-element:global-attributes>Global attributes</a><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.<dt><a href=#concept-element-dom id=the-dfn-element:concept-element-dom>DOM interface</a>:<dd>Uses <code id=the-dfn-element:htmlelement><a href=#htmlelement>HTMLElement</a></code>.</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>

  <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 id=attr-dfn-title><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 exact <code id=the-dfn-element:textcontent><a data-x-internal=textcontent href=https://dom.spec.whatwg.org/#dom-node-textcontent>textContent</a></code> 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>

  

  <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>&quot;Garage Door Opener&quot;</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&apos;c activated his <strong><c- p>&lt;</c-><c- f>abbr</c-> <c- e>title</c-><c- o>=</c-><c- s>&quot;Garage Door Opener&quot;</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>&quot;Garage Door Opener&quot;</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&apos;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>&quot;Garage Door Opener&quot;</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><code>abbr</code></dfn> element<a href=#the-abbr-element class=self-link></a></h4>

  <dl class=element><dt><a href=#concept-element-categories id=the-abbr-element:concept-element-categories>Categories</a>:<dd><a href=#flow-content-2 id=the-abbr-element:flow-content-2>Flow content</a>.<dd><a href=#phrasing-content-2 id=the-abbr-element:phrasing-content-2>Phrasing content</a>.<dd><a href=#palpable-content-2 id=the-abbr-element:palpable-content-2>Palpable content</a>.<dt><a href=#concept-element-contexts id=the-abbr-element:concept-element-contexts>Contexts in which this element can be used</a>:<dd>Where <a href=#phrasing-content-2 id=the-abbr-element:phrasing-content-2-2>phrasing content</a> is expected.<dt><a href=#concept-element-content-model id=the-abbr-element:concept-element-content-model>Content model</a>:<dd><a href=#phrasing-content-2 id=the-abbr-element:phrasing-content-2-3>Phrasing content</a>.<dt><a href=#concept-element-tag-omission id=the-abbr-element:concept-element-tag-omission>Tag omission in text/html</a>:<dd>Neither tag is omissible.<dt><a href=#concept-element-attributes id=the-abbr-element:concept-element-attributes>Content attributes</a>:<dd><a href=#global-attributes id=the-abbr-element:global-attributes>Global attributes</a><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.<dt><a href=#concept-element-dom id=the-abbr-element:concept-element-dom>DOM interface</a>:<dd>Uses <code id=the-abbr-element:htmlelement><a href=#htmlelement>HTMLElement</a></code>.</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 id=attr-abbr-title><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>&quot;Web Hypertext Application Technology Working Group&quot;</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>&quot;Web Hypertext Application Technology Working Group&quot;</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>&quot;Web Hypertext Application Technology Working Group&quot;</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>&quot;#whatwg&quot;</c-><c- p>&gt;&lt;</c-><c- f>abbr</c->
<c- e>title</c-><c- o>=</c-><c- s>&quot;Web Hypertext Application Technology Working Group&quot;</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>&quot;Working Group&quot;</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>&quot;Working Groups&quot;</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>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>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.</ul>

  <p>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><code>ruby</code></dfn> element<a href=#the-ruby-element class=self-link></a></h4><div class=status><input onclick=toggleStatus(this) value=⋰ type=button><p class=support><strong>Support:</strong> ruby<span class="and_chr partial"><span>Chrome for Android (limited)</span> <span>67+</span></span><span class="chrome partial"><span>Chrome (limited)</span> <span>5+</span></span><span class="ios_saf partial"><span>iOS Safari (limited)</span> <span>5.0+</span></span><span class="and_uc partial"><span>UC Browser for Android (limited)</span> <span>11.8+</span></span><span class="firefox yes"><span>Firefox</span> <span>38+</span></span><span class="ie partial"><span>IE (limited)</span> <span>5.5+</span></span><span class="safari partial"><span>Safari (limited)</span> <span>5+</span></span><span class="edge partial"><span>Edge (limited)</span> <span>12+</span></span><span class="samsung partial"><span>Samsung Internet (limited)</span> <span>4+</span></span><span class="opera partial"><span>Opera (limited)</span> <span>15+</span></span><span class="android partial"><span>Android Browser (limited)</span> <span>3+</span></span><p class=caniuse>Source: <a href="https://caniuse.com/#feat=ruby">caniuse.com</a></div>

  <dl class=element><dt><a href=#concept-element-categories id=the-ruby-element:concept-element-categories>Categories</a>:<dd><a href=#flow-content-2 id=the-ruby-element:flow-content-2>Flow content</a>.<dd><a href=#phrasing-content-2 id=the-ruby-element:phrasing-content-2>Phrasing content</a>.<dd><a href=#palpable-content-2 id=the-ruby-element:palpable-content-2>Palpable content</a>.<dt><a href=#concept-element-contexts id=the-ruby-element:concept-element-contexts>Contexts in which this element can be used</a>:<dd>Where <a href=#phrasing-content-2 id=the-ruby-element:phrasing-content-2-2>phrasing content</a> is expected.<dt><a href=#concept-element-content-model id=the-ruby-element:concept-element-content-model>Content model</a>:<dd>See prose.<dt><a href=#concept-element-tag-omission id=the-ruby-element:concept-element-tag-omission>Tag omission in text/html</a>:<dd>Neither tag is omissible.<dt><a href=#concept-element-attributes id=the-ruby-element:concept-element-attributes>Content attributes</a>:<dd><a href=#global-attributes id=the-ruby-element:global-attributes>Global attributes</a><dt><a href=#concept-element-dom id=the-ruby-element:concept-element-dom>DOM interface</a>:<dd>Uses <code id=the-ruby-element:htmlelement><a href=#htmlelement>HTMLElement</a></code>.</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 class=brief><li>One or the other of the following:
    <ul class=brief><li><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
     <li>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
    </ul>
   <li>One or the other of the following:
    <ul class=brief><li>One or more <code id=the-ruby-element:the-rt-element><a href=#the-rt-element>rt</a></code> elements
     <li>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
    </ul>
  </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

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

    <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.
     <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>くん</ruby><ruby>子<rt>し</ruby>は<ruby>和<rt>わ</ruby>して<ruby>同<rt>どう</ruby>ぜず。
     <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):
     <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>

   <dt>Mono-ruby for compound words (jukugo)

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

    <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>もん</ruby>の<ruby>方<rt>ほう</rt>角<rt>がく</ruby>を<ruby>凝<rt>ぎょう</rt>視<rt>し</ruby>する

    </div>

   <dt>Jukugo-ruby

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

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

   <dt>Group ruby for describing meanings

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

    <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.
     <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>インターフェース</ruby>
    </div>

    <div class=example>
     <p>Here a compound ideographic word has its translation in English provided as an annotation.
     <pre><code class='html'><c- p>&lt;</c-><c- f>ruby</c-> <c- e>lang</c-><c- o>=</c-><c- s>&quot;ja&quot;</c-><c- p>&gt;</c->編集者<c- p>&lt;</c-><c- f>rt</c-> <c- e>lang</c-><c- o>=</c-><c- s>&quot;en&quot;</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</ruby>
    </div>

   <dt>Group ruby for Jukuji readings

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

    <div class=example>
     <p>In this example, the name of a species of flowers has a phonetic reading provided using group ruby:
     <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>あじさい</ruby>
    </div>

   <dt>Text with both phonetic and semantic annotations (double-sided ruby)

   <dd>

    <p>Sometimes, ruby styles described above are combined.

    <p>If this results in two annotations covering the same single base segment, then the
    annotations can just be placed back to back.

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

     <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 complication situations such as 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.

    <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.
     <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>なん</ruby><rt>たつみ</ruby>の方角
    </div>

    <div class=example>
     <p>This is the same example, but the meaning is given in English instead of Japanese:
     <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>なん</ruby><rt lang=en>Southeast</ruby>の方角
    </div>

   </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>

  

  <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.<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.<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.<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>.<li><p>Let <var>current parent</var> be <var>root</var>.<li><p>Let <var>index</var> be 0.<li><p>Let <var>start index</var> be null.<li><p>Let <var>parent start index</var> be null.<li><p>Let <var>current base text</var> be null.<li><p><i>Start mode</i>: If <var>index</var> is equal to or greater than the number of
   child nodes in <var>current parent</var>, then jump to the step labeled <i>end
   mode</i>.</p>

   <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>.<li><p>Set <var>start index</var> to the value of <var>index</var>.<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>.<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>.<li><p>Increment <var>index</var> by one.<li><p><i>Base mode post-increment</i>: If <var>index</var> is equal to or greater than
   the number of child nodes in <var>current parent</var>, then jump to the step labeled
   <i>end mode</i>.<li><p>Jump back to the step labeled <i>base mode</i>.<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>.<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>.<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>.<li><p><i>Annotation mode increment</i>: Let <var>lookahead index</var> be <var>index</var> plus one.<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>.<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>.<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).<li><p>Increment <var>lookahead index</var> by one.<li><p>Jump to the step labeled <i>annotation mode white-space skipper</i>.<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>.<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>.</ol>


  <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>).<li><p>Let <var>new text segment</var> be a base text segment described by the range
   <var>annotation range</var>.</p>

   <li><p>Add <var>new text segment</var> to <var>base text
   segments</var>.<li><p>Let <var>current base text</var> be <var>new text
   segment</var>.<li><p>Let <var>start index</var> be null.</ol>


  <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>.<li><p>Let <var>index</var> be 0.<li><p>Set <var>saved start index</var> to the value of <var>start
   index</var>.<li><p>Let <var>start index</var> be null.</ol>


  <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>.<li><p>Let <var>current parent</var> be <var>root</var>.<li><p>Increment <var>index</var> by one.<li><p>Set <var>start index</var> to the value of <var>saved start
   index</var>.<li><p>Let <var>saved start index</var> be null.</ol>


  <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>.<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>).<li><p>Let <var>new annotation segment</var> be an annotation segment described by the
   range <var>annotation range</var>.<li><p>If <var>current base text</var> is not null, associate <var>new
   annotation segment</var> with <var>current base text</var>.<li><p>Add <var>new annotation segment</var> to <var>annotation
   segments</var>.</ol>

  

  <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><code>rt</code></dfn> element<a href=#the-rt-element class=self-link></a></h4>

  <dl class=element><dt><a href=#concept-element-categories id=the-rt-element:concept-element-categories>Categories</a>:<dd>None.<dt><a href=#concept-element-contexts id=the-rt-element:concept-element-contexts>Contexts in which this element can be used</a>:<dd>As a child of a <code id=the-rt-element:the-ruby-element><a href=#the-ruby-element>ruby</a></code> element.<dt><a href=#concept-element-content-model id=the-rt-element:concept-element-content-model>Content model</a>:<dd><a href=#phrasing-content-2 id=the-rt-element:phrasing-content-2>Phrasing content</a>.<dt><a href=#concept-element-tag-omission id=the-rt-element:concept-element-tag-omission>Tag omission in text/html</a>:<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.<dt><a href=#concept-element-attributes id=the-rt-element:concept-element-attributes>Content attributes</a>:<dd><a href=#global-attributes id=the-rt-element:global-attributes>Global attributes</a><dt><a href=#concept-element-dom id=the-rt-element:concept-element-dom>DOM interface</a>:<dd>Uses <code id=the-rt-element:htmlelement><a href=#htmlelement>HTMLElement</a></code>.</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><code>rp</code></dfn> element<a href=#the-rp-element class=self-link></a></h4>

  <dl class=element><dt><a href=#concept-element-categories id=the-rp-element:concept-element-categories>Categories</a>:<dd>None.<dt><a href=#concept-element-contexts id=the-rp-element:concept-element-contexts>Contexts in which this element can be used</a>:<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.<dt><a href=#concept-element-content-model id=the-rp-element:concept-element-content-model>Content model</a>:<dd><a href=#text-content id=the-rp-element:text-content>Text</a>.<dt><a href=#concept-element-tag-omission id=the-rp-element:concept-element-tag-omission>Tag omission in text/html</a>:<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.<dt><a href=#concept-element-attributes id=the-rp-element:concept-element-attributes>Content attributes</a>:<dd><a href=#global-attributes id=the-rp-element:global-attributes>Global attributes</a><dt><a href=#concept-element-dom id=the-rp-element:concept-element-dom>DOM interface</a>:<dd>Uses <code id=the-rp-element:htmlelement><a href=#htmlelement>HTMLElement</a></code>.</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:

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

   <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><code>data</code></dfn> element<a href=#the-data-element class=self-link></a></h4>

  <dl class=element><dt><a href=#concept-element-categories id=the-data-element:concept-element-categories>Categories</a>:<dd><a href=#flow-content-2 id=the-data-element:flow-content-2>Flow content</a>.<dd><a href=#phrasing-content-2 id=the-data-element:phrasing-content-2>Phrasing content</a>.<dd><a href=#palpable-content-2 id=the-data-element:palpable-content-2>Palpable content</a>.<dt><a href=#concept-element-contexts id=the-data-element:concept-element-contexts>Contexts in which this element can be used</a>:<dd>Where <a href=#phrasing-content-2 id=the-data-element:phrasing-content-2-2>phrasing content</a> is expected.<dt><a href=#concept-element-content-model id=the-data-element:concept-element-content-model>Content model</a>:<dd><a href=#phrasing-content-2 id=the-data-element:phrasing-content-2-3>Phrasing content</a>.<dt><a href=#concept-element-tag-omission id=the-data-element:concept-element-tag-omission>Tag omission in text/html</a>:<dd>Neither tag is omissible.<dt><a href=#concept-element-attributes id=the-data-element:concept-element-attributes>Content attributes</a>:<dd><a href=#global-attributes id=the-data-element:global-attributes>Global attributes</a><dd><code id=the-data-element:attr-data-value><a href=#attr-data-value>value</a></code> — Machine-readable value<dt><a href=#concept-element-dom id=the-data-element:concept-element-dom>DOM interface</a>:<dd>
    <pre><code class='idl'>[<c- g>Exposed</c->=<c- n>Window</c->,
 <a href='#htmlconstructor' id='the-data-element:htmlconstructor'><c- g>HTMLConstructor</c-></a>]
<c- b>interface</c-> <dfn id='htmldataelement'><c- g>HTMLDataElement</c-></dfn> : <a href='#htmlelement' id='the-data-element:htmlelement'><c- n>HTMLElement</c-></a> {
  [<a href='#cereactions' id='the-data-element:cereactions'><c- g>CEReactions</c-></a>] <c- b>attribute</c-> <c- b>DOMString</c-> <a href='#dom-data-value' id='the-data-element:dom-data-value'><c- g>value</c-></a>;
};</code></pre>
   </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 id=attr-data-value><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>

  

  <p>The <dfn id=dom-data-value><code>value</code></dfn> IDL attribute must
  <a href=#reflect id=the-data-element:reflect>reflect</a> the content attribute of the same name.</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>&quot;sortable.js&quot;</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>&quot;sortable&quot;</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>&quot;8&quot;</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>&quot;93&quot;</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>&quot;11&quot;</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>&quot;99&quot;</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>&quot;10&quot;</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>&quot;149&quot;</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><code>time</code></dfn> element<a href=#the-time-element class=self-link></a></h4>

  <dl class=element><dt><a href=#concept-element-categories id=the-time-element:concept-element-categories>Categories</a>:<dd><a href=#flow-content-2 id=the-time-element:flow-content-2>Flow content</a>.<dd><a href=#phrasing-content-2 id=the-time-element:phrasing-content-2>Phrasing content</a>.<dd><a href=#palpable-content-2 id=the-time-element:palpable-content-2>Palpable content</a>.<dt><a href=#concept-element-contexts id=the-time-element:concept-element-contexts>Contexts in which this element can be used</a>:<dd>Where <a href=#phrasing-content-2 id=the-time-element:phrasing-content-2-2>phrasing content</a> is expected.<dt><a href=#concept-element-content-model id=the-time-element:concept-element-content-model>Content model</a>:<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>Otherwise: <a href=#text-content id=the-time-element:text-content>Text</a>, but must match requirements described in prose below.<dt><a href=#concept-element-tag-omission id=the-time-element:concept-element-tag-omission>Tag omission in text/html</a>:<dd>Neither tag is omissible.<dt><a href=#concept-element-attributes id=the-time-element:concept-element-attributes>Content attributes</a>:<dd><a href=#global-attributes id=the-time-element:global-attributes>Global attributes</a><dd><code id=the-time-element:attr-time-datetime-2><a href=#attr-time-datetime>datetime</a></code> — Machine-readable value<dt><a href=#concept-element-dom id=the-time-element:concept-element-dom>DOM interface</a>:<dd>
<pre><code class='idl'>[<c- g>Exposed</c->=<c- n>Window</c->,
 <a href='#htmlconstructor' id='the-time-element:htmlconstructor'><c- g>HTMLConstructor</c-></a>]
<c- b>interface</c-> <dfn id='htmltimeelement'><c- g>HTMLTimeElement</c-></dfn> : <a href='#htmlelement' id='the-time-element:htmlelement'><c- n>HTMLElement</c-></a> {
  [<a href='#cereactions' id='the-time-element:cereactions'><c- g>CEReactions</c-></a>] <c- b>attribute</c-> <c- b>DOMString</c-> <a href='#dom-time-datetime' id='the-time-element:dom-time-datetime'><c- g>dateTime</c-></a>;
};</code></pre>
   </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 id=attr-time-datetime><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>

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

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

   <dt>A <a href=#valid-date-string id=the-time-element:valid-date-string>valid date string</a><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>

   <dt>A <a href=#valid-yearless-date-string id=the-time-element:valid-yearless-date-string>valid yearless date string</a><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>

   <dt>A <a href=#valid-time-string id=the-time-element:valid-time-string>valid time string</a><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>

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

   <dt>A <a href=#valid-time-zone-offset-string id=the-time-element:valid-time-zone-offset-string>valid time-zone offset string</a><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>

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

   <dt>A <a href=#valid-week-string id=the-time-element:valid-week-string>valid week string</a><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>

   <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)<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>

   <dt>A <a href=#valid-duration-string id=the-time-element:valid-duration-string>valid duration string</a><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>

   </dl>

  

  <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.<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.<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.<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.<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.<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.<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.<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.<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.<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.<li><p>There is no machine-readable equivalent.</ol>

  <p 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>

  <p>The <dfn id=dom-time-datetime><code>dateTime</code></dfn> IDL attribute must
  <a href=#reflect id=the-time-element:reflect>reflect</a> the element's <code id=the-time-element:attr-time-datetime-6><a href=#attr-time-datetime>datetime</a></code> content
  attribute.</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>&quot;vevent&quot;</c-><c- p>&gt;</c->
 <c- p>&lt;</c-><c- f>a</c-> <c- e>class</c-><c- o>=</c-><c- s>&quot;url&quot;</c-> <c- e>href</c-><c- o>=</c-><c- s>&quot;http://www.web2con.com/&quot;</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>&quot;summary&quot;</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>&quot;dtstart&quot;</c-> <c- e>datetime</c-><c- o>=</c-><c- s>&quot;2005-10-05&quot;</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>&quot;dtend&quot;</c-> <c- e>datetime</c-><c- o>=</c-><c- s>&quot;2005-10-07&quot;</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>&quot;location&quot;</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>&quot;https://n.example.org/rfc4287&quot;</c-><c- p>&gt;</c->
 <c- p>&lt;</c-><c- f>h1</c-> <c- e>itemprop</c-><c- o>=</c-><c- s>&quot;title&quot;</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>&quot;published&quot;</c-> <c- e>datetime</c-><c- o>=</c-><c- s>&quot;2009-08-29&quot;</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>&quot;content&quot;</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>&quot;http://schema.org/BlogPosting&quot;</c-><c- p>&gt;</c->
 <c- p>&lt;</c-><c- f>h1</c-> <c- e>itemprop</c-><c- o>=</c-><c- s>&quot;headline&quot;</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>&quot;datePublished&quot;</c-> <c- e>datetime</c-><c- o>=</c-><c- s>&quot;2009-08-30&quot;</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>&quot;articleBody&quot;</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>&quot;2006-09-23&quot;</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>&quot;2006-09-24T05:00-07:00&quot;</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>&quot;2011-11-18&quot;</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>&quot;2011-11-18T15:00-08:00&quot;</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><code>code</code></dfn> element<a href=#the-code-element class=self-link></a></h4>

  <dl class=element><dt><a href=#concept-element-categories id=the-code-element:concept-element-categories>Categories</a>:<dd><a href=#flow-content-2 id=the-code-element:flow-content-2>Flow content</a>.<dd><a href=#phrasing-content-2 id=the-code-element:phrasing-content-2>Phrasing content</a>.<dd><a href=#palpable-content-2 id=the-code-element:palpable-content-2>Palpable content</a>.<dt><a href=#concept-element-contexts id=the-code-element:concept-element-contexts>Contexts in which this element can be used</a>:<dd>Where <a href=#phrasing-content-2 id=the-code-element:phrasing-content-2-2>phrasing content</a> is expected.<dt><a href=#concept-element-content-model id=the-code-element:concept-element-content-model>Content model</a>:<dd><a href=#phrasing-content-2 id=the-code-element:phrasing-content-2-3>Phrasing content</a>.<dt><a href=#concept-element-tag-omission id=the-code-element:concept-element-tag-omission>Tag omission in text/html</a>:<dd>Neither tag is omissible.<dt><a href=#concept-element-attributes id=the-code-element:concept-element-attributes>Content attributes</a>:<dd><a href=#global-attributes id=the-code-element:global-attributes>Global attributes</a><dt><a href=#concept-element-dom id=the-code-element:concept-element-dom>DOM interface</a>:<dd>Uses <code id=the-code-element:htmlelement><a href=#htmlelement>HTMLElement</a></code>.</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 file name, 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>&quot;language-pascal&quot;</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><code>var</code></dfn> element<a href=#the-var-element class=self-link></a></h4>

  <dl class=element><dt><a href=#concept-element-categories id=the-var-element:concept-element-categories>Categories</a>:<dd><a href=#flow-content-2 id=the-var-element:flow-content-2>Flow content</a>.<dd><a href=#phrasing-content-2 id=the-var-element:phrasing-content-2>Phrasing content</a>.<dd><a href=#palpable-content-2 id=the-var-element:palpable-content-2>Palpable content</a>.<dt><a href=#concept-element-contexts id=the-var-element:concept-element-contexts>Contexts in which this element can be used</a>:<dd>Where <a href=#phrasing-content-2 id=the-var-element:phrasing-content-2-2>phrasing content</a> is expected.<dt><a href=#concept-element-content-model id=the-var-element:concept-element-content-model>Content model</a>:<dd><a href=#phrasing-content-2 id=the-var-element:phrasing-content-2-3>Phrasing content</a>.<dt><a href=#concept-element-tag-omission id=the-var-element:concept-element-tag-omission>Tag omission in text/html</a>:<dd>Neither tag is omissible.<dt><a href=#concept-element-attributes id=the-var-element:concept-element-attributes>Content attributes</a>:<dd><a href=#global-attributes id=the-var-element:global-attributes>Global attributes</a><dt><a href=#concept-element-dom id=the-var-element:concept-element-dom>DOM interface</a>:<dd>Uses <code id=the-var-element:htmlelement><a href=#htmlelement>HTMLElement</a></code>.</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&apos; 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&apos;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><code>samp</code></dfn> element<a href=#the-samp-element class=self-link></a></h4>

  <dl class=element><dt><a href=#concept-element-categories id=the-samp-element:concept-element-categories>Categories</a>:<dd><a href=#flow-content-2 id=the-samp-element:flow-content-2>Flow content</a>.<dd><a href=#phrasing-content-2 id=the-samp-element:phrasing-content-2>Phrasing content</a>.<dd><a href=#palpable-content-2 id=the-samp-element:palpable-content-2>Palpable content</a>.<dt><a href=#concept-element-contexts id=the-samp-element:concept-element-contexts>Contexts in which this element can be used</a>:<dd>Where <a href=#phrasing-content-2 id=the-samp-element:phrasing-content-2-2>phrasing content</a> is expected.<dt><a href=#concept-element-content-model id=the-samp-element:concept-element-content-model>Content model</a>:<dd><a href=#phrasing-content-2 id=the-samp-element:phrasing-content-2-3>Phrasing content</a>.<dt><a href=#concept-element-tag-omission id=the-samp-element:concept-element-tag-omission>Tag omission in text/html</a>:<dd>Neither tag is omissible.<dt><a href=#concept-element-attributes id=the-samp-element:concept-element-attributes>Content attributes</a>:<dd><a href=#global-attributes id=the-samp-element:global-attributes>Global attributes</a><dt><a href=#concept-element-dom id=the-samp-element:concept-element-dom>DOM interface</a>:<dd>Uses <code id=the-samp-element:htmlelement><a href=#htmlelement>HTMLElement</a></code>.</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&apos;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>&quot;prompt&quot;</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>&quot;prompt&quot;</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>&quot;cursor&quot;</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>&quot;language-javascript&quot;</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><code>kbd</code></dfn> element<a href=#the-kbd-element class=self-link></a></h4>

  <dl class=element><dt><a href=#concept-element-categories id=the-kbd-element:concept-element-categories>Categories</a>:<dd><a href=#flow-content-2 id=the-kbd-element:flow-content-2>Flow content</a>.<dd><a href=#phrasing-content-2 id=the-kbd-element:phrasing-content-2>Phrasing content</a>.<dd><a href=#palpable-content-2 id=the-kbd-element:palpable-content-2>Palpable content</a>.<dt><a href=#concept-element-contexts id=the-kbd-element:concept-element-contexts>Contexts in which this element can be used</a>:<dd>Where <a href=#phrasing-content-2 id=the-kbd-element:phrasing-content-2-2>phrasing content</a> is expected.<dt><a href=#concept-element-content-model id=the-kbd-element:concept-element-content-model>Content model</a>:<dd><a href=#phrasing-content-2 id=the-kbd-element:phrasing-content-2-3>Phrasing content</a>.<dt><a href=#concept-element-tag-omission id=the-kbd-element:concept-element-tag-omission>Tag omission in text/html</a>:<dd>Neither tag is omissible.<dt><a href=#concept-element-attributes id=the-kbd-element:concept-element-attributes>Content attributes</a>:<dd><a href=#global-attributes id=the-kbd-element:global-attributes>Global attributes</a><dt><a href=#concept-element-dom id=the-kbd-element:concept-element-dom>DOM interface</a>:<dd>Uses <code id=the-kbd-element:htmlelement><a href=#htmlelement>HTMLElement</a></code>.</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><code>sub</code></dfn> and <dfn id=the-sup-element><code>sup</code></dfn> elements<a href=#the-sub-and-sup-elements class=self-link></a></h4>

  <dl class=element><dt><a href=#concept-element-categories id=the-sub-and-sup-elements:concept-element-categories>Categories</a>:<dd><a href=#flow-content-2 id=the-sub-and-sup-elements:flow-content-2>Flow content</a>.<dd><a href=#phrasing-content-2 id=the-sub-and-sup-elements:phrasing-content-2>Phrasing content</a>.<dd><a href=#palpable-content-2 id=the-sub-and-sup-elements:palpable-content-2>Palpable content</a>.<dt><a href=#concept-element-contexts id=the-sub-and-sup-elements:concept-element-contexts>Contexts in which this element can be used</a>:<dd>Where <a href=#phrasing-content-2 id=the-sub-and-sup-elements:phrasing-content-2-2>phrasing content</a> is expected.<dt><a href=#concept-element-content-model id=the-sub-and-sup-elements:concept-element-content-model>Content model</a>:<dd><a href=#phrasing-content-2 id=the-sub-and-sup-elements:phrasing-content-2-3>Phrasing content</a>.<dt><a href=#concept-element-tag-omission id=the-sub-and-sup-elements:concept-element-tag-omission>Tag omission in text/html</a>:<dd>Neither tag is omissible.<dt><a href=#concept-element-attributes id=the-sub-and-sup-elements:concept-element-attributes>Content attributes</a>:<dd><a href=#global-attributes id=the-sub-and-sup-elements:global-attributes>Global attributes</a><dt><a href=#concept-element-dom id=the-sub-and-sup-elements:concept-element-dom>DOM interface</a>:<dd>Use <code id=the-sub-and-sup-elements:htmlelement><a href=#htmlelement>HTMLElement</a></code>.</dl>

  <p>The <code id=the-sub-and-sup-elements:the-sub-and-sup-elements><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-2><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-3><a href=#the-sub-and-sup-elements>sub</a></code> and <code id=the-sub-and-sup-elements:the-sub-and-sup-elements-4><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>&quot;fr&quot;</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>&quot;fr&quot;</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-5><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-6><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-7><a href=#the-sub-and-sup-elements>sub</a></code> and
  <code id=the-sub-and-sup-elements:the-sub-and-sup-elements-8><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><code>i</code></dfn> element<a href=#the-i-element class=self-link></a></h4>

  <dl class=element><dt><a href=#concept-element-categories id=the-i-element:concept-element-categories>Categories</a>:<dd><a href=#flow-content-2 id=the-i-element:flow-content-2>Flow content</a>.<dd><a href=#phrasing-content-2 id=the-i-element:phrasing-content-2>Phrasing content</a>.<dd><a href=#palpable-content-2 id=the-i-element:palpable-content-2>Palpable content</a>.<dt><a href=#concept-element-contexts id=the-i-element:concept-element-contexts>Contexts in which this element can be used</a>:<dd>Where <a href=#phrasing-content-2 id=the-i-element:phrasing-content-2-2>phrasing content</a> is expected.<dt><a href=#concept-element-content-model id=the-i-element:concept-element-content-model>Content model</a>:<dd><a href=#phrasing-content-2 id=the-i-element:phrasing-content-2-3>Phrasing content</a>.<dt><a href=#concept-element-tag-omission id=the-i-element:concept-element-tag-omission>Tag omission in text/html</a>:<dd>Neither tag is omissible.<dt><a href=#concept-element-attributes id=the-i-element:concept-element-attributes>Content attributes</a>:<dd><a href=#global-attributes id=the-i-element:global-attributes>Global attributes</a><dt><a href=#concept-element-dom id=the-i-element:concept-element-dom>DOM interface</a>:<dd>Uses <code id=the-i-element:htmlelement><a href=#htmlelement>HTMLElement</a></code>.</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=#attr-xml-lang id=the-i-element: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>&quot;taxonomy&quot;</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>&quot;fr&quot;</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><code>b</code></dfn> element<a href=#the-b-element class=self-link></a></h4>

  <dl class=element><dt><a href=#concept-element-categories id=the-b-element:concept-element-categories>Categories</a>:<dd><a href=#flow-content-2 id=the-b-element:flow-content-2>Flow content</a>.<dd><a href=#phrasing-content-2 id=the-b-element:phrasing-content-2>Phrasing content</a>.<dd><a href=#palpable-content-2 id=the-b-element:palpable-content-2>Palpable content</a>.<dt><a href=#concept-element-contexts id=the-b-element:concept-element-contexts>Contexts in which this element can be used</a>:<dd>Where <a href=#phrasing-content-2 id=the-b-element:phrasing-content-2-2>phrasing content</a> is expected.<dt><a href=#concept-element-content-model id=the-b-element:concept-element-content-model>Content model</a>:<dd><a href=#phrasing-content-2 id=the-b-element:phrasing-content-2-3>Phrasing content</a>.<dt><a href=#concept-element-tag-omission id=the-b-element:concept-element-tag-omission>Tag omission in text/html</a>:<dd>Neither tag is omissible.<dt><a href=#concept-element-attributes id=the-b-element:concept-element-attributes>Content attributes</a>:<dd><a href=#global-attributes id=the-b-element:global-attributes>Global attributes</a><dt><a href=#concept-element-dom id=the-b-element:concept-element-dom>DOM interface</a>:<dd>Uses <code id=the-b-element:htmlelement><a href=#htmlelement>HTMLElement</a></code>.</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 &apos;adopted&apos; 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>&quot;lede&quot;</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><code>u</code></dfn> element<a href=#the-u-element class=self-link></a></h4>

  <dl class=element><dt><a href=#concept-element-categories id=the-u-element:concept-element-categories>Categories</a>:<dd><a href=#flow-content-2 id=the-u-element:flow-content-2>Flow content</a>.<dd><a href=#phrasing-content-2 id=the-u-element:phrasing-content-2>Phrasing content</a>.<dd><a href=#palpable-content-2 id=the-u-element:palpable-content-2>Palpable content</a>.<dt><a href=#concept-element-contexts id=the-u-element:concept-element-contexts>Contexts in which this element can be used</a>:<dd>Where <a href=#phrasing-content-2 id=the-u-element:phrasing-content-2-2>phrasing content</a> is expected.<dt><a href=#concept-element-content-model id=the-u-element:concept-element-content-model>Content model</a>:<dd><a href=#phrasing-content-2 id=the-u-element:phrasing-content-2-3>Phrasing content</a>.<dt><a href=#concept-element-tag-omission id=the-u-element:concept-element-tag-omission>Tag omission in text/html</a>:<dd>Neither tag is omissible.<dt><a href=#concept-element-attributes id=the-u-element:concept-element-attributes>Content attributes</a>:<dd><a href=#global-attributes id=the-u-element:global-attributes>Global attributes</a><dt><a href=#concept-element-dom id=the-u-element:concept-element-dom>DOM interface</a>:<dd>Uses <code id=the-u-element:htmlelement><a href=#htmlelement>HTMLElement</a></code>.</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><code>mark</code></dfn> element<a href=#the-mark-element class=self-link></a></h4>

  <dl class=element><dt><a href=#concept-element-categories id=the-mark-element:concept-element-categories>Categories</a>:<dd><a href=#flow-content-2 id=the-mark-element:flow-content-2>Flow content</a>.<dd><a href=#phrasing-content-2 id=the-mark-element:phrasing-content-2>Phrasing content</a>.<dd><a href=#palpable-content-2 id=the-mark-element:palpable-content-2>Palpable content</a>.<dt><a href=#concept-element-contexts id=the-mark-element:concept-element-contexts>Contexts in which this element can be used</a>:<dd>Where <a href=#phrasing-content-2 id=the-mark-element:phrasing-content-2-2>phrasing content</a> is expected.<dt><a href=#concept-element-content-model id=the-mark-element:concept-element-content-model>Content model</a>:<dd><a href=#phrasing-content-2 id=the-mark-element:phrasing-content-2-3>Phrasing content</a>.<dt><a href=#concept-element-tag-omission id=the-mark-element:concept-element-tag-omission>Tag omission in text/html</a>:<dd>Neither tag is omissible.<dt><a href=#concept-element-attributes id=the-mark-element:concept-element-attributes>Content attributes</a>:<dd><a href=#global-attributes id=the-mark-element:global-attributes>Global attributes</a><dt><a href=#concept-element-dom id=the-mark-element:concept-element-dom>DOM interface</a>:<dd>Uses <code id=the-mark-element:htmlelement><a href=#htmlelement>HTMLElement</a></code>.</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>&quot;en-US&quot;</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>&quot;en-GB&quot;</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&apos;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>&quot;en-US&quot;</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&apos;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>&quot;bubble&quot;</c-><c- p>&gt;</c->I didn&apos;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&apos;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&apos;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><code>bdi</code></dfn> element<a href=#the-bdi-element class=self-link></a></h4>

  <dl class=element><dt><a href=#concept-element-categories id=the-bdi-element:concept-element-categories>Categories</a>:<dd><a href=#flow-content-2 id=the-bdi-element:flow-content-2>Flow content</a>.<dd><a href=#phrasing-content-2 id=the-bdi-element:phrasing-content-2>Phrasing content</a>.<dd><a href=#palpable-content-2 id=the-bdi-element:palpable-content-2>Palpable content</a>.<dt><a href=#concept-element-contexts id=the-bdi-element:concept-element-contexts>Contexts in which this element can be used</a>:<dd>Where <a href=#phrasing-content-2 id=the-bdi-element:phrasing-content-2-2>phrasing content</a> is expected.<dt><a href=#concept-element-content-model id=the-bdi-element:concept-element-content-model>Content model</a>:<dd><a href=#phrasing-content-2 id=the-bdi-element:phrasing-content-2-3>Phrasing content</a>.<dt><a href=#concept-element-tag-omission id=the-bdi-element:concept-element-tag-omission>Tag omission in text/html</a>:<dd>Neither tag is omissible.<dt><a href=#concept-element-attributes id=the-bdi-element:concept-element-attributes>Content attributes</a>:<dd><a href=#global-attributes id=the-bdi-element:global-attributes>Global attributes</a><dd>Also, the <code id=the-bdi-element:the-dir-attribute><a href=#the-dir-attribute>dir</a></code> global attribute has special semantics on this element.<dt><a href=#concept-element-dom id=the-bdi-element:concept-element-dom>DOM interface</a>:<dd>Uses <code id=the-bdi-element:htmlelement><a href=#htmlelement>HTMLElement</a></code>.</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:the-dir-attribute-2><a href=#the-dir-attribute>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><code>bdo</code></dfn> element<a href=#the-bdo-element class=self-link></a></h4>

  <dl class=element><dt><a href=#concept-element-categories id=the-bdo-element:concept-element-categories>Categories</a>:<dd><a href=#flow-content-2 id=the-bdo-element:flow-content-2>Flow content</a>.<dd><a href=#phrasing-content-2 id=the-bdo-element:phrasing-content-2>Phrasing content</a>.<dd><a href=#palpable-content-2 id=the-bdo-element:palpable-content-2>Palpable content</a>.<dt><a href=#concept-element-contexts id=the-bdo-element:concept-element-contexts>Contexts in which this element can be used</a>:<dd>Where <a href=#phrasing-content-2 id=the-bdo-element:phrasing-content-2-2>phrasing content</a> is expected.<dt><a href=#concept-element-content-model id=the-bdo-element:concept-element-content-model>Content model</a>:<dd><a href=#phrasing-content-2 id=the-bdo-element:phrasing-content-2-3>Phrasing content</a>.<dt><a href=#concept-element-tag-omission id=the-bdo-element:concept-element-tag-omission>Tag omission in text/html</a>:<dd>Neither tag is omissible.<dt><a href=#concept-element-attributes id=the-bdo-element:concept-element-attributes>Content attributes</a>:<dd><a href=#global-attributes id=the-bdo-element:global-attributes>Global attributes</a><dd>Also, the <code id=the-bdo-element:the-dir-attribute><a href=#the-dir-attribute>dir</a></code> global attribute has special semantics on this element.<dt><a href=#concept-element-dom id=the-bdo-element:concept-element-dom>DOM interface</a>:<dd>Uses <code id=the-bdo-element:htmlelement><a href=#htmlelement>HTMLElement</a></code>.</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:the-dir-attribute-2><a href=#the-dir-attribute>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><code>span</code></dfn> element<a href=#the-span-element class=self-link></a></h4>

  <dl class=element><dt><a href=#concept-element-categories id=the-span-element:concept-element-categories>Categories</a>:<dd><a href=#flow-content-2 id=the-span-element:flow-content-2>Flow content</a>.<dd><a href=#phrasing-content-2 id=the-span-element:phrasing-content-2>Phrasing content</a>.<dd><a href=#palpable-content-2 id=the-span-element:palpable-content-2>Palpable content</a>.<dt><a href=#concept-element-contexts id=the-span-element:concept-element-contexts>Contexts in which this element can be used</a>:<dd>Where <a href=#phrasing-content-2 id=the-span-element:phrasing-content-2-2>phrasing content</a> is expected.<dt><a href=#concept-element-content-model id=the-span-element:concept-element-content-model>Content model</a>:<dd><a href=#phrasing-content-2 id=the-span-element:phrasing-content-2-3>Phrasing content</a>.<dt><a href=#concept-element-tag-omission id=the-span-element:concept-element-tag-omission>Tag omission in text/html</a>:<dd>Neither tag is omissible.<dt><a href=#concept-element-attributes id=the-span-element:concept-element-attributes>Content attributes</a>:<dd><a href=#global-attributes id=the-span-element:global-attributes>Global attributes</a><dt><a href=#concept-element-dom id=the-span-element:concept-element-dom>DOM interface</a>:<dd>
    <pre><code class='idl'>[<c- g>Exposed</c->=<c- n>Window</c->,
 <a href='#htmlconstructor' id='the-span-element:htmlconstructor'><c- g>HTMLConstructor</c-></a>]
<c- b>interface</c-> <dfn id='htmlspanelement'><c- g>HTMLSpanElement</c-></dfn> : <a href='#htmlelement' id='the-span-element:htmlelement'><c- n>HTMLElement</c-></a> {};</code></pre>
   </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:the-dir-attribute><a href=#the-dir-attribute>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>&quot;lang-c&quot;</c-><c- p>&gt;&lt;</c-><c- f>span</c-> <c- e>class</c-><c- o>=</c-><c- s>&quot;keyword&quot;</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>&quot;ident&quot;</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>&quot;ident&quot;</c-><c- p>&gt;</c->j<c- p>&lt;/</c-><c- f>span</c-><c- p>&gt;</c-> <c- p>&lt;</c-> <c- f>256</c->; &lt;<c- e>span</c-> <c- e>class</c-><c- o>=</c-><c- s>&quot;ident&quot;</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>&quot;ident&quot;</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>&quot;ident&quot;</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>&quot;ident&quot;</c-><c- p>&gt;</c->j<c- p>&lt;/</c-><c- f>span</c-><c- p>&gt;</c-> &lt;<c- p>&lt;</c-> <c- f>17</c->);
  &lt;<c- e>span</c-> <c- e>class</c-><c- o>=</c-><c- s>&quot;ident&quot;</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>&quot;ident&quot;</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>&quot;ident&quot;</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>&quot;ident&quot;</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>&quot;ident&quot;</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>&quot;keyword&quot;</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>&quot;ident&quot;</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>&quot;ident&quot;</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>&quot;keyword&quot;</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><code>br</code></dfn> element<a href=#the-br-element class=self-link></a></h4>

  <dl class=element><dt><a href=#concept-element-categories id=the-br-element:concept-element-categories>Categories</a>:<dd><a href=#flow-content-2 id=the-br-element:flow-content-2>Flow content</a>.<dd><a href=#phrasing-content-2 id=the-br-element:phrasing-content-2>Phrasing content</a>.<dt><a href=#concept-element-contexts id=the-br-element:concept-element-contexts>Contexts in which this element can be used</a>:<dd>Where <a href=#phrasing-content-2 id=the-br-element:phrasing-content-2-2>phrasing content</a> is expected.<dt><a href=#concept-element-content-model id=the-br-element:concept-element-content-model>Content model</a>:<dd><a href=#concept-content-nothing id=the-br-element:concept-content-nothing>Nothing</a>.<dt><a href=#concept-element-tag-omission id=the-br-element:concept-element-tag-omission>Tag omission in text/html</a>:<dd>No <a href=#syntax-end-tag id=the-br-element:syntax-end-tag>end tag</a>.<dt><a href=#concept-element-attributes id=the-br-element:concept-element-attributes>Content attributes</a>:<dd><a href=#global-attributes id=the-br-element:global-attributes>Global attributes</a><dt><a href=#concept-element-dom id=the-br-element:concept-element-dom>DOM interface</a>:<dd>
    <pre><code class='idl'>[<c- g>Exposed</c->=<c- n>Window</c->,
 <a href='#htmlconstructor' id='the-br-element:htmlconstructor'><c- g>HTMLConstructor</c-></a>]
<c- b>interface</c-> <dfn id='htmlbrelement'><c- g>HTMLBRElement</c-></dfn> : <a href='#htmlelement' id='the-br-element:htmlelement'><c- n>HTMLElement</c-></a> {};</code></pre>
   </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>&quot;name&quot;</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>&quot;address&quot;</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>&quot;name&quot;</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>&quot;address&quot;</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><code>wbr</code></dfn> element<a href=#the-wbr-element class=self-link></a></h4><div class=status><input onclick=toggleStatus(this) value=⋰ type=button><p class=support><strong>Support:</strong> wbr-element<span class="and_chr yes"><span>Chrome for Android</span> <span>67+</span></span><span class="chrome yes"><span>Chrome</span> <span>4+</span></span><span class="ios_saf yes"><span>iOS Safari</span> <span>5.0+</span></span><span class="and_uc yes"><span>UC Browser for Android</span> <span>11.8+</span></span><span class="firefox yes"><span>Firefox</span> <span>2+</span></span><span class="ie no"><span>IE</span> <span>None</span></span><span class="op_mini yes"><span>Opera Mini</span> <span>all+</span></span><span class="safari yes"><span>Safari</span> <span>3.2+</span></span><span class="edge yes"><span>Edge</span> <span>12+</span></span><span class="samsung yes"><span>Samsung Internet</span> <span>4+</span></span><span class="opera yes"><span>Opera</span> <span>9.5+</span></span><span class="android yes"><span>Android Browser</span> <span>2.3+</span></span><p class=caniuse>Source: <a href="https://caniuse.com/#feat=wbr-element">caniuse.com</a></div>

  <dl class=element><dt><a href=#concept-element-categories id=the-wbr-element:concept-element-categories>Categories</a>:<dd><a href=#flow-content-2 id=the-wbr-element:flow-content-2>Flow content</a>.<dd><a href=#phrasing-content-2 id=the-wbr-element:phrasing-content-2>Phrasing content</a>.<dt><a href=#concept-element-contexts id=the-wbr-element:concept-element-contexts>Contexts in which this element can be used</a>:<dd>Where <a href=#phrasing-content-2 id=the-wbr-element:phrasing-content-2-2>phrasing content</a> is expected.<dt><a href=#concept-element-content-model id=the-wbr-element:concept-element-content-model>Content model</a>:<dd><a href=#concept-content-nothing id=the-wbr-element:concept-content-nothing>Nothing</a>.<dt><a href=#concept-element-tag-omission id=the-wbr-element:concept-element-tag-omission>Tag omission in text/html</a>:<dd>No <a href=#syntax-end-tag id=the-wbr-element:syntax-end-tag>end tag</a>.<dt><a href=#concept-element-attributes id=the-wbr-element:concept-element-attributes>Content attributes</a>:<dd><a href=#global-attributes id=the-wbr-element:global-attributes>Global attributes</a><dt><a href=#concept-element-dom id=the-wbr-element:concept-element-dom>DOM interface</a>:<dd>Uses <code id=the-wbr-element:htmlelement><a href=#htmlelement>HTMLElement</a></code>.</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
&quot;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&quot;!<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>&quot;wbr&quot;</c-><c- p>);</c->
wbr<c- p>.</c->textContent <c- o>=</c-> <c- u>&quot;This is wrong&quot;</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>Purpose
     <th>Example
   <tbody><tr><td><code id=usage-summary:the-a-element><a href=#the-a-element>a</a></code>
     <td>Hyperlinks
     <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>&quot;drinks.html&quot;</c-><c- p>&gt;</c->drinks<c- p>&lt;/</c-><c- f>a</c-><c- p>&gt;</c-></strong> page.</code></pre>

    <tr><td><code id=usage-summary:the-em-element><a href=#the-em-element>em</a></code>
     <td>Stress emphasis
     <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>

    <tr><td><code id=usage-summary:the-strong-element><a href=#the-strong-element>strong</a></code>
     <td>Importance
     <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>

    <tr><td><code id=usage-summary:the-small-element><a href=#the-small-element>small</a></code>
     <td>Side comments
     <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>

    <tr><td><code id=usage-summary:the-s-element><a href=#the-s-element>s</a></code>
     <td>Inaccurate text
     <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>

    <tr><td><code id=usage-summary:the-cite-element><a href=#the-cite-element>cite</a></code>
     <td>Titles of works
     <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>

    <tr><td><code id=usage-summary:the-q-element><a href=#the-q-element>q</a></code>
     <td>Quotations
     <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>

    <tr><td><code id=usage-summary:the-dfn-element><a href=#the-dfn-element>dfn</a></code>
     <td>Defining instance
     <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>

    <tr><td><code id=usage-summary:the-abbr-element><a href=#the-abbr-element>abbr</a></code>
     <td>Abbreviations
     <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>&quot;Irish Organic Farmers and Growers Association&quot;</c-><c- p>&gt;</c->IOFGA<c- p>&lt;/</c-><c- f>abbr</c-><c- p>&gt;</c-></strong>.</code></pre>

    <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>Ruby annotations
     <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>

    <tr><td><code id=usage-summary:the-data-element><a href=#the-data-element>data</a></code>
     <td>Machine-readable equivalent
     <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>&quot;UPC:022014640201&quot;</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>

    <tr><td><code id=usage-summary:the-time-element><a href=#the-time-element>time</a></code>
     <td>Machine-readable equivalent of date- or time-related data
     <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>&quot;2011-11-18&quot;</c-><c- p>&gt;</c->November 18th<c- p>&lt;/</c-><c- f>time</c-><c- p>&gt;</c-></strong>!</code></pre>

    <tr><td><code id=usage-summary:the-code-element><a href=#the-code-element>code</a></code>
     <td>Computer code
     <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>

    <tr><td><code id=usage-summary:the-var-element><a href=#the-var-element>var</a></code>
     <td>Variables
     <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>

    <tr><td><code id=usage-summary:the-samp-element><a href=#the-samp-element>samp</a></code>
     <td>Computer output
     <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>

    <tr><td><code id=usage-summary:the-kbd-element><a href=#the-kbd-element>kbd</a></code>
     <td>User input
     <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>

    <tr><td><code id=usage-summary:the-sub-and-sup-elements><a href=#the-sub-and-sup-elements>sub</a></code>
     <td>Subscripts
     <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>

    <tr><td><code id=usage-summary:the-sub-and-sup-elements-2><a href=#the-sub-and-sup-elements>sup</a></code>
     <td>Superscripts
     <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>

    <tr><td><code id=usage-summary:the-i-element><a href=#the-i-element>i</a></code>
     <td>Alternative voice
     <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>

    <tr><td><code id=usage-summary:the-b-element><a href=#the-b-element>b</a></code>
     <td>Keywords
     <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>

    <tr><td><code id=usage-summary:the-u-element><a href=#the-u-element>u</a></code>
     <td>Annotations
     <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>&quot;spelling&quot;</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>

    <tr><td><code id=usage-summary:the-mark-element><a href=#the-mark-element>mark</a></code>
     <td>Highlight
     <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>

    <tr><td><code id=usage-summary:the-bdi-element><a href=#the-bdi-element>bdi</a></code>
     <td>Text directionality isolation
     <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>&quot;&quot;</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>

    <tr><td><code id=usage-summary:the-bdo-element><a href=#the-bdo-element>bdo</a></code>
     <td>Text directionality formatting
     <td><pre class=example><code class='html'>The proposal is to write English, but in reverse order. &quot;Juice&quot; would become &quot;<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>&quot;&gt;</code></pre>

    <tr><td><code id=usage-summary:the-span-element><a href=#the-span-element>span</a></code>
     <td>Other
     <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>&quot;fr&quot;</c-><c- p>&gt;</c->sirop de sureau<c- p>&lt;/</c-><c- f>span</c-><c- p>&gt;</c-></strong>.</code></pre>

    <tr><td><code id=usage-summary:the-br-element><a href=#the-br-element>br</a></code>
     <td>Line break
     <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>

    <tr><td><code id=usage-summary:the-wbr-element><a href=#the-wbr-element>wbr</a></code>
     <td>Line breaking opportunity
     <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>

  </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>, 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 two 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><dd><p>These are links to resources that are to be used to augment the current document,
   generally automatically processed by the user agent.<dt><dfn id=hyperlink data-lt=hyperlink data-export="">Hyperlinks</dfn><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.</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>A <a href=#hyperlink id=introduction-2:hyperlink-3>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 id=attr-hyperlink-href><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 id=attr-hyperlink-target><code>target</code></dfn> attribute, if present, must be
  a <a href=#valid-browsing-context-name-or-keyword id=links-created-by-a-and-area-elements:valid-browsing-context-name-or-keyword>valid browsing context name or keyword</a>. It gives the name of the <a href=#browsing-context id=links-created-by-a-and-area-elements:browsing-context>browsing
  context</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>When an <code id=links-created-by-a-and-area-elements:the-a-element-4><a href=#the-a-element>a</a></code> or <code id=links-created-by-a-and-area-elements:the-area-element-4><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>

  <p>Whether determined by the user's preferences or via the presence or absence of the attribute,
  if the decision is to use the hyperlink for <a href=#navigate id=links-created-by-a-and-area-elements:navigate-2>navigation</a> then the user
  agent must <a href=#following-hyperlinks-2 id=links-created-by-a-and-area-elements:following-hyperlinks-2-2>follow the hyperlink</a>, and if the decision is
  to use the hyperlink to download a resource, the user agent must <a href=#downloading-hyperlinks id=links-created-by-a-and-area-elements:downloading-hyperlinks>download the hyperlink</a>. These terms are defined in subsequent sections
  below.</p>

  <p>The <dfn id=attr-hyperlink-download><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-2>downloading a resource</a>. The attribute may have a value; the value, if any,
  specifies the default file name 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 file names,
  and user agents are likely to adjust file names accordingly.</p>


  <p>The <dfn id=ping><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>.<div class=status><input onclick=toggleStatus(this) value=⋰ type=button><p class=support><strong>Support:</strong> ping<span class="and_chr yes"><span>Chrome for Android</span> <span>67+</span></span><span class="chrome yes"><span>Chrome</span> <span>15+</span></span><span class="ios_saf yes"><span>iOS Safari</span> <span>5.0+</span></span><span class="and_uc yes"><span>UC Browser for Android</span> <span>11.8+</span></span><span class="firefox no"><span>Firefox</span> <span>None</span></span><span class="ie no"><span>IE</span> <span>None</span></span><span class="op_mini no"><span>Opera Mini</span> <span>None</span></span><span class="safari yes"><span>Safari</span> <span>6+</span></span><span class="edge yes"><span>Edge</span> <span>17+</span></span><span class="samsung yes"><span>Samsung Internet</span> <span>4+</span></span><span class="opera yes"><span>Opera</span> <span>15+</span></span><span class="android yes"><span>Android Browser</span> <span>4.4+</span></span><p class=caniuse>Source: <a href="https://caniuse.com/#feat=ping">caniuse.com</a></div>

  <p>The <dfn id=attr-hyperlink-rel><code>rel</code></dfn> attribute 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 controls what kinds of links the elements create. The attribute's value must be a
  <a href=#set-of-space-separated-tokens id=links-created-by-a-and-area-elements:set-of-space-separated-tokens-2>set of 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-6><a href=#the-a-element>a</a></code> and
  <code id=links-created-by-a-and-area-elements:the-area-element-6><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> and
  <code id=links-created-by-a-and-area-elements:link-type-noopener><a href=#link-type-noopener>noopener</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>Other specifications may add <a href=#linkTypes>HTML link types</a> as defined in <a href=#other-link-types>Other link types</a>, with the following additional requirements:</p>

  <ul><li>Such specifications may require that their link types be included in <code id=links-created-by-a-and-area-elements:attr-link-rel><a href=#attr-link-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-4 data-x-internal=concept-supported-tokens>supported
   tokens</a>.<li>Such specifications may specify that their link types are <a href=#body-ok id=links-created-by-a-and-area-elements:body-ok>body-ok</a>.</ul>

  <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 id=attr-hyperlink-hreflang><code>hreflang</code></dfn> attribute on
  <code id=links-created-by-a-and-area-elements:the-a-element-7><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 id=attr-hyperlink-type><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 id=attr-hyperlink-referrerpolicy><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-3>following hyperlinks</a>. <a href=#refsREFERRERPOLICY>[REFERRERPOLICY]</a></p>


  <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'><c- g>HTMLHyperlinkElementUtils</c-></dfn> {
  [<a href='#cereactions' id='api-for-a-and-area-elements:cereactions'><c- g>CEReactions</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><var>hyperlink</var> . <code>toString()</code><dt><var>hyperlink</var> . <code id=dom-hyperlink-href-dev><a href=#dom-hyperlink-href>href</a></code><dd>
    <p>Returns the hyperlink's URL.</p>
    <p>Can be set, to change the URL.</p>
   <dt><var>hyperlink</var> . <code id=dom-hyperlink-origin-dev><a href=#dom-hyperlink-origin>origin</a></code><dd>
    <p>Returns the hyperlink's URL's origin.</p>
   <dt><var>hyperlink</var> . <code id=dom-hyperlink-protocol-dev><a href=#dom-hyperlink-protocol>protocol</a></code><dd>
    <p>Returns the hyperlink's URL's scheme.</p>
    <p>Can be set, to change the URL's scheme.</p>
   <dt><var>hyperlink</var> . <code id=dom-hyperlink-username-dev><a href=#dom-hyperlink-username>username</a></code><dd>
    <p>Returns the hyperlink's URL's username.</p>
    <p>Can be set, to change the URL's username.</p>
   <dt><var>hyperlink</var> . <code id=dom-hyperlink-password-dev><a href=#dom-hyperlink-password>password</a></code><dd>
    <p>Returns the hyperlink's URL's password.</p>
    <p>Can be set, to change the URL's password.</p>
   <dt><var>hyperlink</var> . <code id=dom-hyperlink-host-dev><a href=#dom-hyperlink-host>host</a></code><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>
   <dt><var>hyperlink</var> . <code id=dom-hyperlink-hostname-dev><a href=#dom-hyperlink-hostname>hostname</a></code><dd>
    <p>Returns the hyperlink's URL's host.</p>
    <p>Can be set, to change the URL's host.</p>
   <dt><var>hyperlink</var> . <code id=dom-hyperlink-port-dev><a href=#dom-hyperlink-port>port</a></code><dd>
    <p>Returns the hyperlink's URL's port.</p>
    <p>Can be set, to change the URL's port.</p>
   <dt><var>hyperlink</var> . <code id=dom-hyperlink-pathname-dev><a href=#dom-hyperlink-pathname>pathname</a></code><dd>
    <p>Returns the hyperlink's URL's path.</p>
    <p>Can be set, to change the URL's path.</p>
   <dt><var>hyperlink</var> . <code id=dom-hyperlink-search-dev><a href=#dom-hyperlink-search>search</a></code><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>
   <dt><var>hyperlink</var> . <code id=dom-hyperlink-hash-dev><a href=#dom-hyperlink-hash>hash</a></code><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>
   </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>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>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, set this element's <a href=#concept-hyperlink-url id=api-for-a-and-area-elements:concept-hyperlink-url>url</a> to null.<li><p>Otherwise, parse 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 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>. If <a href=#parse-a-url id=api-for-a-and-area-elements:parse-a-url>parsing</a> is successful, set this element's <a href=#concept-hyperlink-url id=api-for-a-and-area-elements:concept-hyperlink-url-2>url</a> to the result; otherwise, set this element's
    <a href=#concept-hyperlink-url id=api-for-a-and-area-elements:concept-hyperlink-url-3>url</a> to null.</ol>

  <p>When elements implementing the <code id=api-for-a-and-area-elements:htmlhyperlinkelementutils-3><a href=#htmlhyperlinkelementutils>HTMLHyperlinkElementUtils</a></code> mixin are created, and
  whenever those elements have their <code id=api-for-a-and-area-elements:attr-hyperlink-href-3><a href=#attr-hyperlink-href>href</a></code> content
  attribute set, changed, or removed, 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>

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

  <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 element's <a href=#concept-hyperlink-url id=api-for-a-and-area-elements:concept-hyperlink-url-4>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 its
   <a id=api-for-a-and-area-elements:cannot-be-a-base-url-flag href=https://url.spec.whatwg.org/#url-cannot-be-a-base-url-flag data-x-internal=cannot-be-a-base-url-flag>cannot-be-a-base-URL flag</a> is set, terminate these steps.<li><p><a href=#concept-hyperlink-url-set id=api-for-a-and-area-elements:concept-hyperlink-url-set-2>Set the url</a>.</ol>

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

  <hr>

  <p>The <dfn id=dom-hyperlink-href><code>href</code></dfn> attribute's getter must run these
  steps:</p>

  <ol><li><p><a href=#reinitialise-url id=api-for-a-and-area-elements:reinitialise-url>Reinitialize url</a>.<li><p>Let <var>url</var> be this element's <a href=#concept-hyperlink-url id=api-for-a-and-area-elements:concept-hyperlink-url-6>url</a>.<li><p>If <var>url</var> is null and this element has no <code id=api-for-a-and-area-elements:attr-hyperlink-href-5><a href=#attr-hyperlink-href>href</a></code> content attribute, return the empty string.

   <li><p>Otherwise, if <var>url</var> is null, return this element's <code id=api-for-a-and-area-elements:attr-hyperlink-href-6><a href=#attr-hyperlink-href>href</a></code> content attribute's value.<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>.</ol>

  <p>The <code id=api-for-a-and-area-elements:dom-hyperlink-href-2><a href=#dom-hyperlink-href>href</a></code> attribute's setter must set this element'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 to the given value.

  <p>The <dfn id=dom-hyperlink-origin><code>origin</code></dfn> attribute's getter must run
  these steps:</p>

  <ol><li><p><a href=#reinitialise-url id=api-for-a-and-area-elements:reinitialise-url-2>Reinitialize url</a>.<li><p>If this element's <a href=#concept-hyperlink-url id=api-for-a-and-area-elements:concept-hyperlink-url-7>url</a> is null, return the
   empty string.<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 this
   element's <a href=#concept-hyperlink-url id=api-for-a-and-area-elements:concept-hyperlink-url-8>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>.</ol>

  <p>The <dfn id=dom-hyperlink-protocol><code>protocol</code></dfn> attribute's getter must
  run these steps:</p>

  <ol><li><p><a href=#reinitialise-url id=api-for-a-and-area-elements:reinitialise-url-3>Reinitialize url</a>.<li><p>If this element's <a href=#concept-hyperlink-url id=api-for-a-and-area-elements:concept-hyperlink-url-9>url</a> is null, return "<code>:</code>".<li><p>Return this element's <a href=#concept-hyperlink-url id=api-for-a-and-area-elements:concept-hyperlink-url-10>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>".</ol>

  <p>The <code id=api-for-a-and-area-elements:dom-hyperlink-protocol-2><a href=#dom-hyperlink-protocol>protocol</a></code> attribute's setter must run these
  steps:</p>

  <ol><li><p><a href=#reinitialise-url id=api-for-a-and-area-elements:reinitialise-url-4>Reinitialize url</a>.<li><p>If this element's <a href=#concept-hyperlink-url id=api-for-a-and-area-elements:concept-hyperlink-url-11>url</a> is null, terminate these
   steps.<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 this element's <a href=#concept-hyperlink-url id=api-for-a-and-area-elements:concept-hyperlink-url-12>url</a>
    as <var>url</var> 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 <var>state override</var>.</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><p><a href=#update-href id=api-for-a-and-area-elements:update-href>Update <code>href</code></a>.</ol>

  <p>The <dfn id=dom-hyperlink-username><code>username</code></dfn> attribute's getter must
  run these steps:</p>

  <ol><li><p><a href=#reinitialise-url id=api-for-a-and-area-elements:reinitialise-url-5>Reinitialize url</a>.<li><p>If this element's <a href=#concept-hyperlink-url id=api-for-a-and-area-elements:concept-hyperlink-url-13>url</a> is null, return the
   empty string.<li><p>Return this element's <a href=#concept-hyperlink-url id=api-for-a-and-area-elements:concept-hyperlink-url-14>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>.</ol>

  <p>The <code id=api-for-a-and-area-elements:dom-hyperlink-username-2><a href=#dom-hyperlink-username>username</a></code> attribute's setter must run these
  steps:</p>

  <ol><li><p><a href=#reinitialise-url id=api-for-a-and-area-elements:reinitialise-url-6>Reinitialize url</a>.<li><p>Let <var>url</var> be this element's <a href=#concept-hyperlink-url id=api-for-a-and-area-elements:concept-hyperlink-url-15>url</a>.<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.<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.<li><p><a href=#update-href id=api-for-a-and-area-elements:update-href-2>Update <code>href</code></a>.</ol>

  <p>The <dfn id=dom-hyperlink-password><code>password</code></dfn> attribute's getter must
  run these steps:</p>

  <ol><li><p><a href=#reinitialise-url id=api-for-a-and-area-elements:reinitialise-url-7>Reinitialize url</a>.<li><p>Let <var>url</var> be this element's <a href=#concept-hyperlink-url id=api-for-a-and-area-elements:concept-hyperlink-url-16>url</a>.<li><p>If <var>url</var> is null, then return the empty string.<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>.</ol>

  <p>The <code id=api-for-a-and-area-elements:dom-hyperlink-password-2><a href=#dom-hyperlink-password>password</a></code> attribute's setter must run these
  steps:</p>

  <ol><li><p><a href=#reinitialise-url id=api-for-a-and-area-elements:reinitialise-url-8>Reinitialize url</a>.<li><p>Let <var>url</var> be this element's <a href=#concept-hyperlink-url id=api-for-a-and-area-elements:concept-hyperlink-url-17>url</a>.<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.<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.<li><p><a href=#update-href id=api-for-a-and-area-elements:update-href-3>Update <code>href</code></a>.</ol>

  <p>The <dfn id=dom-hyperlink-host><code>host</code></dfn> attribute's getter must run these
  steps:</p>

  <ol><li><p><a href=#reinitialise-url id=api-for-a-and-area-elements:reinitialise-url-9>Reinitialize url</a>.<li><p>Let <var>url</var> be this element's <a href=#concept-hyperlink-url id=api-for-a-and-area-elements:concept-hyperlink-url-18>url</a>.<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.<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>.<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>.</ol>

  <p>The <code id=api-for-a-and-area-elements:dom-hyperlink-host-2><a href=#dom-hyperlink-host>host</a></code> attribute's setter must run these steps:</p>

  <ol><li><p><a href=#reinitialise-url id=api-for-a-and-area-elements:reinitialise-url-10>Reinitialize url</a>.<li><p>Let <var>url</var> be this element's <a href=#concept-hyperlink-url id=api-for-a-and-area-elements:concept-hyperlink-url-19>url</a>.<li><p>If <var>url</var> is null or <var>url</var>'s <a id=api-for-a-and-area-elements:cannot-be-a-base-url-flag-2 href=https://url.spec.whatwg.org/#url-cannot-be-a-base-url-flag data-x-internal=cannot-be-a-base-url-flag>cannot-be-a-base-URL flag</a> is
   set, terminate these steps.<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 <var>url</var> 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 <var>state
   override</var>.<li><p><a href=#update-href id=api-for-a-and-area-elements:update-href-4>Update <code>href</code></a>.</ol>

  <p>The <dfn id=dom-hyperlink-hostname><code>hostname</code></dfn> attribute's getter must
  run these steps:</p>

  <ol><li><p><a href=#reinitialise-url id=api-for-a-and-area-elements:reinitialise-url-11>Reinitialize url</a>.<li><p>Let <var>url</var> be this element's <a href=#concept-hyperlink-url id=api-for-a-and-area-elements:concept-hyperlink-url-20>url</a>.<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.<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>.</ol>

  <p>The <code id=api-for-a-and-area-elements:dom-hyperlink-hostname-2><a href=#dom-hyperlink-hostname>hostname</a></code> attribute's setter must run these
  steps:</p>

  <ol><li><p><a href=#reinitialise-url id=api-for-a-and-area-elements:reinitialise-url-12>Reinitialize url</a>.<li><p>Let <var>url</var> be this element's <a href=#concept-hyperlink-url id=api-for-a-and-area-elements:concept-hyperlink-url-21>url</a>.<li><p>If <var>url</var> is null or <var>url</var>'s <a id=api-for-a-and-area-elements:cannot-be-a-base-url-flag-3 href=https://url.spec.whatwg.org/#url-cannot-be-a-base-url-flag data-x-internal=cannot-be-a-base-url-flag>cannot-be-a-base-URL flag</a> is
   set, terminate these steps.<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 <var>url</var> 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 <var>state
   override</var>.<li><p><a href=#update-href id=api-for-a-and-area-elements:update-href-5>Update <code>href</code></a>.</ol>

  <p>The <dfn id=dom-hyperlink-port><code>port</code></dfn> attribute's getter must run these
  steps:</p>

  <ol><li><p><a href=#reinitialise-url id=api-for-a-and-area-elements:reinitialise-url-13>Reinitialize url</a>.<li><p>Let <var>url</var> be this element's <a href=#concept-hyperlink-url id=api-for-a-and-area-elements:concept-hyperlink-url-22>url</a>.<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.<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>.</ol>

  <p>The <code id=api-for-a-and-area-elements:dom-hyperlink-port-2><a href=#dom-hyperlink-port>port</a></code> attribute's setter must run these steps:</p>

  <ol><li><p><a href=#reinitialise-url id=api-for-a-and-area-elements:reinitialise-url-14>Reinitialize url</a>.<li><p>Let <var>url</var> be this element's <a href=#concept-hyperlink-url id=api-for-a-and-area-elements:concept-hyperlink-url-23>url</a>.<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.<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.<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 <var>url</var> 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 <var>state
   override</var>.<li><p><a href=#update-href id=api-for-a-and-area-elements:update-href-6>Update <code>href</code></a>.</ol>

  <p>The <dfn id=dom-hyperlink-pathname><code>pathname</code></dfn> attribute's getter must
  run these steps:</p>

  <ol><li><p><a href=#reinitialise-url id=api-for-a-and-area-elements:reinitialise-url-15>Reinitialize url</a>.<li><p>Let <var>url</var> be this element's <a href=#concept-hyperlink-url id=api-for-a-and-area-elements:concept-hyperlink-url-24>url</a>.<li><p>If <var>url</var> is null, return the empty string.<li><p>If <var>url</var>'s <a id=api-for-a-and-area-elements:cannot-be-a-base-url-flag-4 href=https://url.spec.whatwg.org/#url-cannot-be-a-base-url-flag data-x-internal=cannot-be-a-base-url-flag>cannot-be-a-base-URL flag</a> is set, return the first string
   in <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>.<li><p>If <var>url</var>'s <a href=https://url.spec.whatwg.org/#concept-url-path id=api-for-a-and-area-elements:concept-url-path-2 data-x-internal=concept-url-path>path</a> is empty, then return the
   empty string.<li><p>Return "<code>/</code>", followed by the strings in <var>url</var>'s <a href=https://url.spec.whatwg.org/#concept-url-path id=api-for-a-and-area-elements:concept-url-path-3 data-x-internal=concept-url-path>path</a> (including empty strings), separated from each other by
   "<code>/</code>".</ol>

  <p>The <code id=api-for-a-and-area-elements:dom-hyperlink-pathname-2><a href=#dom-hyperlink-pathname>pathname</a></code> attribute's setter must run these
  steps:</p>

  <ol><li><p><a href=#reinitialise-url id=api-for-a-and-area-elements:reinitialise-url-16>Reinitialize url</a>.<li><p>Let <var>url</var> be this element's <a href=#concept-hyperlink-url id=api-for-a-and-area-elements:concept-hyperlink-url-25>url</a>.<li><p>If <var>url</var> is null or <var>url</var>'s <a id=api-for-a-and-area-elements:cannot-be-a-base-url-flag-5 href=https://url.spec.whatwg.org/#url-cannot-be-a-base-url-flag data-x-internal=cannot-be-a-base-url-flag>cannot-be-a-base-URL flag</a> is
   set, terminate these steps.<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-4 data-x-internal=concept-url-path>path</a> to the empty
   list.<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 <var>url</var> 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 <var>state
   override</var>.<li><p><a href=#update-href id=api-for-a-and-area-elements:update-href-7>Update <code>href</code></a>.</ol>

  <p>The <dfn id=dom-hyperlink-search><code>search</code></dfn> attribute's getter must run
  these steps:</p>

  <ol><li><p><a href=#reinitialise-url id=api-for-a-and-area-elements:reinitialise-url-17>Reinitialize url</a>.<li><p>Let <var>url</var> be this element's <a href=#concept-hyperlink-url id=api-for-a-and-area-elements:concept-hyperlink-url-26>url</a>.<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.<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>.</ol>

  <p>The <code id=api-for-a-and-area-elements:dom-hyperlink-search-2><a href=#dom-hyperlink-search>search</a></code> attribute's setter must run these
  steps:</p>

  <ol><li><p><a href=#reinitialise-url id=api-for-a-and-area-elements:reinitialise-url-18>Reinitialize url</a>.<li><p>Let <var>url</var> be this element's <a href=#concept-hyperlink-url id=api-for-a-and-area-elements:concept-hyperlink-url-27>url</a>.<li><p>If <var>url</var> is null, terminate these steps.<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.

   <li>
    <p>Otherwise:</p>

    <ol><li><p>Let <var>input</var> be the given value with a single leading "<code>?</code>"
     removed, if any.<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.<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 <var>url</var> 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 <var>state override</var>, and
     this element'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>'s <a id="api-for-a-and-area-elements: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> as
     <var>encoding override</var>.</ol>
   <li><p><a href=#update-href id=api-for-a-and-area-elements:update-href-8>Update <code>href</code></a>.</ol>

  <p>The <dfn id=dom-hyperlink-hash><code>hash</code></dfn> attribute's getter must run these
  steps:</p>

  <ol><li><p><a href=#reinitialise-url id=api-for-a-and-area-elements:reinitialise-url-19>Reinitialize url</a>.<li><p>Let <var>url</var> be this element's <a href=#concept-hyperlink-url id=api-for-a-and-area-elements:concept-hyperlink-url-28>url</a>.<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.<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>.</ol>

  <p>The <code id=api-for-a-and-area-elements:dom-hyperlink-hash-2><a href=#dom-hyperlink-hash>hash</a></code> attribute's setter must run these steps:</p>

  <ol><li><p><a href=#reinitialise-url id=api-for-a-and-area-elements:reinitialise-url-20>Reinitialize url</a>.<li><p>Let <var>url</var> be this element's <a href=#concept-hyperlink-url id=api-for-a-and-area-elements:concept-hyperlink-url-29>url</a>.<li><p>If <var>url</var> is null, then return.<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.

   <li>
    <p>Otherwise:</p>

    <ol><li><p>Let <var>input</var> be the given value with a single leading "<code>#</code>"
     removed, if any.<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.<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 <var>url</var> 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 <var>state
     override</var>.</ol>
   <li><p><a href=#update-href id=api-for-a-and-area-elements:update-href-9>Update <code>href</code></a>.</ol>


  <h4 id=following-hyperlinks><span class=secno>4.6.4</span> Following hyperlinks<a href=#following-hyperlinks class=self-link></a></h4>

  <p>An element <var>element</var> <dfn id=cannot-navigate>cannot navigate</dfn> if one of the following is true:</p>

  <ul class=brief><li><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><li><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>.</ul>

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

  <p>When a user <dfn id=following-hyperlinks-2>follows a hyperlink</dfn> created by an element
  <var>subject</var>, optionally with a <var>hyperlink suffix</var>, the user agent must run the
  following steps:</p>

  <ol><li><p>If <var>subject</var> <a href=#cannot-navigate id=following-hyperlinks:cannot-navigate>cannot navigate</a>, then return.<li><p>Let <var>replace</var> be false.<li><p>Let <var>source</var> be <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>'s <a href=#concept-document-bc id=following-hyperlinks:concept-document-bc>browsing context</a>.<li><p>Let <var>targetAttributeValue</var> be the empty string.<li><p>If <var>subject</var> is an <code id=following-hyperlinks:the-a-element-3><a href=#the-a-element>a</a></code> or <code id=following-hyperlinks:the-area-element><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>.<li><p>Let <var>noopener</var> be true if <var>subject</var>'s <a href=#linkTypes>link
   types</a> include the <code id=following-hyperlinks:link-type-noreferrer><a href=#link-type-noreferrer>noreferrer</a></code>
   or <code id=following-hyperlinks:link-type-noopener><a href=#link-type-noopener>noopener</a></code> keyword<li><p>Let <var>target</var> and <var>replace</var> be the result of applying <a href=#the-rules-for-choosing-a-browsing-context-given-a-browsing-context-name id=following-hyperlinks:the-rules-for-choosing-a-browsing-context-given-a-browsing-context-name>the rules for
   choosing a browsing context</a> given <var>targetAttributeValue</var>, <var>source</var>, and
   <var>noopener</var>.<li><p>If <var>target</var> is null, then return.<li><p>If <var>noopener</var> and <var>replace</var> are true, then <a href=#disowned-its-opener id=following-hyperlinks:disowned-its-opener>disown</a> <var>target</var>.<li><p><a href=#parse-a-url id=following-hyperlinks:parse-a-url>Parse</a> the <a id=following-hyperlinks:url href=https://url.spec.whatwg.org/#concept-url data-x-internal=url>URL</a> given by <var>subject</var>'s
   <code id=following-hyperlinks:attr-hyperlink-href><a href=#attr-hyperlink-href>href</a></code> attribute, relative to <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>.<li>

    <p>If that is successful, let <var>URL</var> be the <a href=#resulting-url-string id=following-hyperlinks:resulting-url-string>resulting URL string</a>.</p>

    <p>Otherwise, if <a href=#parse-a-url id=following-hyperlinks:parse-a-url-2>parsing</a> the <a id=following-hyperlinks:url-2 href=https://url.spec.whatwg.org/#concept-url data-x-internal=url>URL</a> failed, the
    user agent may report the error to the user in a user-agent-specific manner, may <a href=#queue-a-task id=following-hyperlinks:queue-a-task>queue a
    task</a> to <a href=#navigate id=following-hyperlinks:navigate>navigate</a> the <var>target</var>
    <a href=#browsing-context id=following-hyperlinks:browsing-context>browsing context</a> to an error page to report the error, or may ignore the error and
    do nothing. In any case, the user agent must then return.</p>

   <li><p>If there is a <var>hyperlink suffix</var>, append it to <var>URL</var>.<li><p>Let <var>resource</var> be a new <a href=https://fetch.spec.whatwg.org/#concept-request id=following-hyperlinks:concept-request data-x-internal=concept-request>request</a> whose <a href=https://fetch.spec.whatwg.org/#concept-request-url id=following-hyperlinks: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-referrer-policy id=following-hyperlinks:concept-request-referrer-policy data-x-internal=concept-request-referrer-policy>referrer policy</a> is the current state of
   <var>subject</var>'s <code>referrerpolicy</code> content attribute.<li><p><a href=#queue-a-task id=following-hyperlinks:queue-a-task-2>Queue a task</a> to <a href=#navigate id=following-hyperlinks:navigate-2>navigate</a> the
   <var>target</var> <a href=#browsing-context id=following-hyperlinks:browsing-context-2>browsing context</a> to <var>resource</var>. If <var>replace</var> is
   true, the navigation must be performed with <a href=#replacement-enabled id=following-hyperlinks:replacement-enabled>replacement enabled</a>. The
   <a href=#source-browsing-context id=following-hyperlinks:source-browsing-context>source browsing context</a> must be <var>source</var>.</ol>

  <p>The <a href=#task-source id=following-hyperlinks:task-source>task source</a> for the tasks mentioned above is the <a href=#dom-manipulation-task-source id=following-hyperlinks:dom-manipulation-task-source>DOM manipulation task
  source</a>.</p>

  




  <h4 id=downloading-resources><span class=secno>4.6.5</span> Downloading resources<a href=#downloading-resources class=self-link></a></h4><div class=status><input onclick=toggleStatus(this) value=⋰ type=button><p class=support><strong>Support:</strong> download<span class="and_chr yes"><span>Chrome for Android</span> <span>67+</span></span><span class="chrome yes"><span>Chrome</span> <span>14+</span></span><span class="ios_saf no"><span>iOS Safari</span> <span>None</span></span><span class="and_uc yes"><span>UC Browser for Android</span> <span>11.8+</span></span><span class="firefox yes"><span>Firefox</span> <span>20+</span></span><span class="ie no"><span>IE</span> <span>None</span></span><span class="op_mini no"><span>Opera Mini</span> <span>None</span></span><span class="safari yes"><span>Safari</span> <span>10.1+</span></span><span class="edge yes"><span>Edge</span> <span>13+</span></span><span class="samsung yes"><span>Samsung Internet</span> <span>4+</span></span><span class="opera yes"><span>Opera</span> <span>15+</span></span><span class="android yes"><span>Android Browser</span> <span>4.4+</span></span><p class=caniuse>Source: <a href="https://caniuse.com/#feat=download">caniuse.com</a></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 file name 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://tools.ietf.org/html/rfc6266>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://tools.ietf.org/html/rfc6266>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>

  <p>When a user <dfn id=downloading-hyperlinks data-export="">downloads a hyperlink</dfn>
  created by an element <var>subject</var>, optionally with a <var>hyperlink suffix</var>, the user
  agent must run the following steps:</p>

  <ol><li><p>If <var>subject</var> <a href=#cannot-navigate id=downloading-resources:cannot-navigate>cannot navigate</a>, then return.<li><p><a href=#parse-a-url id=downloading-resources:parse-a-url>Parse</a> the <a id=downloading-resources:url href=https://url.spec.whatwg.org/#concept-url data-x-internal=url>URL</a> given by
   <var>subject</var>'s <code id=downloading-resources:attr-hyperlink-href><a href=#attr-hyperlink-href>href</a></code> attribute, relative to
   <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>.<li><p>If <a href=#parse-a-url id=downloading-resources:parse-a-url-2>parsing</a> the <a id=downloading-resources:url-2 href=https://url.spec.whatwg.org/#concept-url data-x-internal=url>URL</a> fails, the user agent
   may report the error to the user in a user-agent-specific manner, may
   <a href=#navigate id=downloading-resources:navigate>navigate</a> to an error page to report the error, or may
   ignore the error and do nothing. In either case, the user agent must return.</p>

   <li><p>Otherwise, let <var>URL</var> be the <a href=#resulting-url-string id=downloading-resources:resulting-url-string>resulting URL string</a>.<li><p>If there is a <var>hyperlink suffix</var>, append it to <var>URL</var>.<li>
    <p>Run these steps <a href=#in-parallel id=downloading-resources: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=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>URL</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.<li><p>Handle 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> <a href=#as-a-download id=downloading-resources:as-a-download>as a download</a>.</ol>
   </ol>

  <p>When a user agent is to handle a resource obtained from a fetch <dfn id=as-a-download>as a download</dfn>, it
  should provide the user with a way to save the resource for later use, if a resource is
  successfully obtained; or otherwise should report any problems downloading the file to the
  user.</p>

  <p>If the user agent needs a file name for a resource being handled <a href=#as-a-download id=downloading-resources:as-a-download-2>as a download</a>, it
  should select one using the following algorithm.</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 void value.<li><p>If the resource has a `<code id=downloading-resources:http-content-disposition-3><a data-x-internal=http-content-disposition href=https://tools.ietf.org/html/rfc6266>Content-Disposition</a></code>`
   header, that header specifies the <code>attachment</code> disposition type, and the
   header includes file name 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><li><p>Let <var>interface origin</var> be the <a href=#concept-origin id=downloading-resources:concept-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-2>navigate</a> action resulting in the download was initiated, if any.<li><p>Let <var>resource origin</var> be the <a href=#concept-origin id=downloading-resources:concept-origin-2>origin</a> of the URL of the
   resource being downloaded, 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>resource origin</var> be
   the same as the <var>interface origin</var>, if any.<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>resource origin</var> is the <a href=#same-origin id=downloading-resources:same-origin>same origin</a> as <var>interface
   origin</var>, and false otherwise.<li><p>If <var>trusted operation</var> is true and the resource has a `<code id=downloading-resources:http-content-disposition-4><a data-x-internal=http-content-disposition href=https://tools.ietf.org/html/rfc6266>Content-Disposition</a></code>` header and that header includes file
   name 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><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-3><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
   file name</i>.<li><p>Let <var>proposed filename</var> have the value of the <code id=downloading-resources:attr-hyperlink-download-4><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.<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.<li><p>If the resource has a `<code id=downloading-resources:http-content-disposition-5><a data-x-internal=http-content-disposition href=https://tools.ietf.org/html/rfc6266>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><li><p><i>No proposed file name</i>: If <var>trusted operation</var> is true, or if the
   user indicated a preference for having the resource in question downloaded, let <var>filename</var> have a value derived from the <a id=downloading-resources:url-3 href=https://url.spec.whatwg.org/#concept-url data-x-internal=url>URL</a> of the resource in a
   user-agent-defined manner, and jump to the step labeled <i>sanitize</i> below.<li>

    <p>Act in a user-agent-defined manner to safeguard the user from a potentially hostile
    cross-origin download. If the download is not to be aborted, then let <var>filename</var> be set to the user's preferred file name or to a file name 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
     the resource being downloaded, 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-5><a href=#attr-hyperlink-download>download</a></code> attribute was used to trigger the download, or
     because the resource in question 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 the resource in
     question comes from quite a different source, and to prevent confusion, any suggested file name
     from the potentially hostile <var>interface origin</var> should be ignored.</p>

    </div>

   <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 file name, potentially providing the value of
   <var>filename</var> as determined above as a default value.<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
    file names, or trimming leading and trailing whitespace.</p>

   <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 file name.<li><p>Let <var>claimed type</var> be the type given by the resource'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>.<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 file name.<li><p>If <var>claimed type</var> and <var>named type</var> are the same type
   (i.e. the type given by the resource'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 file
   name.<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><p>Return <var>filename</var> as the file name.</ol>

  <p>For the purposes of this algorithm, a file <dfn id=concept-extension>extension</dfn>
  consists of any part of the file name that platform conventions dictate will be used for
  identifying the type of the file. For example, many operating systems use the part of the file
  name following the last dot ("<code>.</code>") in the file name 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 resource itself,
  its <a id=downloading-resources:url-4 href=https://url.spec.whatwg.org/#concept-url data-x-internal=url>URL</a>, and any <code id=downloading-resources:attr-hyperlink-download-6><a href=#attr-hyperlink-download>download</a></code> attribute, in
  deciding where to store the resulting file in the user's file system.</p>

  




  

  <h5 id=hyperlink-auditing><span class=secno>4.6.5.1</span> <dfn>Hyperlink auditing</dfn><a href=#hyperlink-auditing class=self-link></a></h5>

  <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=#parse-a-url id=hyperlink-auditing:parse-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=#parse-a-url id=hyperlink-auditing:parse-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 <a href=#resulting-url-record id=hyperlink-auditing:resulting-url-record>resulting URL
  record</a> <var>ping URL</var>, ignoring tokens that fail to parse:</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.<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.)<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-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 the <a href=#environment-settings-object id=hyperlink-auditing:environment-settings-object>environment settings object</a> of
   the <code id=hyperlink-auditing:document><a href=#document>Document</a></code> containing the <a href=#hyperlink id=hyperlink-auditing:hyperlink-2>hyperlink</a>, <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.<li>
    <p>Let <var>target URL</var> be the <a href=#resulting-url-string id=hyperlink-auditing:resulting-url-string>resulting URL string</a> obtained from <a href=#parse-a-url id=hyperlink-auditing:parse-a-url-3>parsing</a> the value of the element's <code id=hyperlink-auditing:attr-hyperlink-href-2><a href=#attr-hyperlink-href>href</a></code> attribute 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-2><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>If the origins are different, but the <a href=#concept-document-https-state id=hyperlink-auditing:concept-document-https-state>HTTPS
     state</a> of the <code id=hyperlink-auditing:document-3><a href=#document>Document</a></code> containing the hyperlink being audited is "<code>none</code>"<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-2" 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>.<dt>Otherwise<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></dl>
   <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>.</ol>

  <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://tools.ietf.org/html/rfc7231#section-5.5.2>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>When the <code id=hyperlink-auditing:ping-4><a href=#ping>ping</a></code> attribute is present, user agents
  should clearly 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>It allows the UA to inform the user about the out-of-band notifications.<li>It allows the user to disable the notifications without losing the underlying link
    functionality.<li>It allows the UA to optimize the use of available network bandwidth so that the target page
    loads faster.</ul>

   <p>Thus, while it is possible to track users without this feature, authors are encouraged to use
   the <code id=hyperlink-auditing:ping-7><a href=#ping>ping</a></code> attribute so that the user agent can make the
   user experience more transparent.</p>

  </div>

  



  <h4 id=linkTypes><span class=secno>4.6.6</span> Link types<a href=#linkTypes class=self-link></a></h4>

  <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>, or
  <code id=linkTypes:the-area-element><a href=#the-area-element>area</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 defined by this specification
  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>,
  <code id=linkTypes:link-type-prerender><a href=#link-type-prerender>prerender</a></code>, and
  <code id=linkTypes:link-type-stylesheet><a href=#link-type-stylesheet>stylesheet</a></code>.
  Other specifications can also define <a href=#body-ok id=linkTypes:body-ok-2>body-ok</a> keywords.</p>

  <table class=yesno><thead><tr><th rowspan=2>Link type<th colspan=2>Effect on...<th rowspan=2><a href=#body-ok id=linkTypes:body-ok-3>body-ok</a><th rowspan=2>Brief description<tr><th><code id=linkTypes:the-link-element-3><a href=#the-link-element>link</a></code><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><tbody><tr><td><code id=linkTypes:rel-alternate><a href=#rel-alternate>alternate</a></code><td><a href=#hyperlink id=linkTypes:hyperlink>Hyperlink</a><td><a href=#hyperlink id=linkTypes:hyperlink-2>Hyperlink</a><td class=no> · <td>Gives alternate representations of the current document.<tr><td><code id=linkTypes:link-type-canonical><a href=#link-type-canonical>canonical</a></code><td><a href=#hyperlink id=linkTypes:hyperlink-3>Hyperlink</a><td><em>not allowed</em><td class=no> · <td>Gives the preferred URL for the current document.<tr><td><code id=linkTypes:link-type-author><a href=#link-type-author>author</a></code><td><a href=#hyperlink id=linkTypes:hyperlink-4>Hyperlink</a><td><a href=#hyperlink id=linkTypes:hyperlink-5>Hyperlink</a><td class=no> · <td>Gives a link to the author of the current document or article.<tr><td><code id=linkTypes:link-type-bookmark><a href=#link-type-bookmark>bookmark</a></code><td><em>not allowed</em><td><a href=#hyperlink id=linkTypes:hyperlink-6>Hyperlink</a><td class=no> · <td>Gives the permalink for the nearest ancestor section.<tr><td><code id=linkTypes:link-type-dns-prefetch-2><a href=#link-type-dns-prefetch>dns-prefetch</a></code><td><a href=#external-resource-link id=linkTypes:external-resource-link>External Resource</a><td><em>not allowed</em><td class=yes> Yes <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>.<tr><td><code id=linkTypes:link-type-external><a href=#link-type-external>external</a></code><td><em>not allowed</em><td><a href=#hyperlink-annotation id=linkTypes:hyperlink-annotation>Annotation</a><td class=no> · <td>Indicates that the referenced document is not part of the same site as the current document.<tr><td><code id=linkTypes:link-type-help><a href=#link-type-help>help</a></code><td><a href=#hyperlink id=linkTypes:hyperlink-7>Hyperlink</a><td><a href=#hyperlink id=linkTypes:hyperlink-8>Hyperlink</a><td class=no> · <td>Provides a link to context-sensitive help.<tr><td><code id=linkTypes:rel-icon><a href=#rel-icon>icon</a></code><td><a href=#external-resource-link id=linkTypes:external-resource-link-2>External Resource</a><td><em>not allowed</em><td class=no> · <td>Imports an icon to represent the current document.<tr><td><code id=linkTypes:link-type-modulepreload-2><a href=#link-type-modulepreload>modulepreload</a></code><td><a href=#external-resource-link id=linkTypes:external-resource-link-3>External Resource</a><td><em>not allowed</em><td class=yes> Yes <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.<tr><td><code id=linkTypes:link-type-license><a href=#link-type-license>license</a></code><td><a href=#hyperlink id=linkTypes:hyperlink-9>Hyperlink</a><td><a href=#hyperlink id=linkTypes:hyperlink-10>Hyperlink</a><td class=no> · <td>Indicates that the main content of the current document is covered by the copyright license described by the referenced document.<tr><td><code id=linkTypes:link-type-next><a href=#link-type-next>next</a></code><td><a href=#hyperlink id=linkTypes:hyperlink-11>Hyperlink</a><td><a href=#hyperlink id=linkTypes:hyperlink-12>Hyperlink</a><td class=no> · <td>Indicates that the current document is a part of a series, and that the next document in the series is the referenced document.<tr><td><code id=linkTypes:link-type-nofollow><a href=#link-type-nofollow>nofollow</a></code><td><em>not allowed</em><td><a href=#hyperlink-annotation id=linkTypes:hyperlink-annotation-2>Annotation</a><td class=no> · <td>Indicates that the current document's original author or publisher does not endorse the referenced document.<tr><td><code id=linkTypes:link-type-noopener><a href=#link-type-noopener>noopener</a></code><td><em>not allowed</em><td><a href=#hyperlink-annotation id=linkTypes:hyperlink-annotation-3>Annotation</a><td class=no> · <td>Indicates that any <a href=#browsing-context id=linkTypes:browsing-context>browsing context</a> created by following the hyperlink is
     <a href=#disowned-its-opener id=linkTypes:disowned-its-opener>disowned</a>.<tr><td><code id=linkTypes:link-type-noreferrer><a href=#link-type-noreferrer>noreferrer</a></code><td><em>not allowed</em><td><a href=#hyperlink-annotation id=linkTypes:hyperlink-annotation-4>Annotation</a><td class=no> · <td>Indicates that any <a href=#browsing-context id=linkTypes:browsing-context-2>browsing context</a> created by following the hyperlink is
     <a href=#disowned-its-opener id=linkTypes:disowned-its-opener-2>disowned</a> and will not get a `<code id=linkTypes:http-referer><a data-x-internal=http-referer href=https://tools.ietf.org/html/rfc7231#section-5.5.2>Referer</a></code>` (sic)
     header.<tr><td><code id=linkTypes:link-type-pingback-2><a href=#link-type-pingback>pingback</a></code><td><a href=#external-resource-link id=linkTypes:external-resource-link-4>External Resource</a><td><em>not allowed</em><td class=yes> Yes <td>Gives the address of the pingback server that handles pingbacks to the current document.<tr><td><code id=linkTypes:link-type-preconnect-2><a href=#link-type-preconnect>preconnect</a></code><td><a href=#external-resource-link id=linkTypes:external-resource-link-5>External Resource</a><td><em>not allowed</em><td class=yes> Yes <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>.<tr><td><code id=linkTypes:link-type-prefetch-2><a href=#link-type-prefetch>prefetch</a></code><td><a href=#external-resource-link id=linkTypes:external-resource-link-6>External Resource</a><td><em>not allowed</em><td class=yes> Yes <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>.<tr><td><code id=linkTypes:link-type-preload-2><a href=#link-type-preload>preload</a></code><td><a href=#external-resource-link id=linkTypes:external-resource-link-7>External Resource</a><td><em>not allowed</em><td class=yes> Yes <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/#concept-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>).<tr><td><code id=linkTypes:link-type-prerender-2><a href=#link-type-prerender>prerender</a></code><td><a href=#external-resource-link id=linkTypes:external-resource-link-8>External Resource</a><td><em>not allowed</em><td class=yes> Yes <td>Specifies that the user agent should preemptively <a href=https://fetch.spec.whatwg.org/#concept-fetch id=linkTypes:concept-fetch-3 data-x-internal=concept-fetch>fetch</a> the target resource and process it in a way that helps deliver a faster response in the future.<tr><td><code id=linkTypes:link-type-prev><a href=#link-type-prev>prev</a></code><td><a href=#hyperlink id=linkTypes:hyperlink-13>Hyperlink</a><td><a href=#hyperlink id=linkTypes:hyperlink-14>Hyperlink</a><td class=no> · <td>Indicates that the current document is a part of a series, and that the previous document in the series is the referenced document.<tr><td><code id=linkTypes:link-type-search><a href=#link-type-search>search</a></code><td><a href=#hyperlink id=linkTypes:hyperlink-15>Hyperlink</a><td><a href=#hyperlink id=linkTypes:hyperlink-16>Hyperlink</a><td class=no> · <td>Gives a link to a resource that can be used to search through the current document and its related pages.<tr><td><code id=linkTypes:link-type-stylesheet-2><a href=#link-type-stylesheet>stylesheet</a></code><td><a href=#external-resource-link id=linkTypes:external-resource-link-9>External Resource</a><td><em>not allowed</em><td class=yes> Yes <td>Imports a style sheet.<tr><td><code id=linkTypes:link-type-tag><a href=#link-type-tag>tag</a></code><td><em>not allowed</em><td><a href=#hyperlink id=linkTypes:hyperlink-17>Hyperlink</a><td class=no> · <td>Gives a tag (identified by the given address) that applies to the current document.</table>

  


  <h5 id=rel-alternate><span class=secno>4.6.6.1</span> Link type "<dfn><code>alternate</code></dfn>"<a href=#rel-alternate class=self-link></a></h5>

  <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><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>&quot;stylesheet&quot;</c-> <c- e>href</c-><c- o>=</c-><c- s>&quot;default.css&quot;</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>&quot;stylesheet&quot;</c-> <c- e>href</c-><c- o>=</c-><c- s>&quot;green.css&quot;</c-> <c- e>title</c-><c- o>=</c-><c- s>&quot;Green styles&quot;</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>&quot;alternate stylesheet&quot;</c-> <c- e>href</c-><c- o>=</c-><c- s>&quot;contrast.css&quot;</c-> <c- e>title</c-><c- o>=</c-><c- s>&quot;High contrast&quot;</c-><c- p>&gt;</c->
<c- p>&lt;</c-><c- f>link</c-> <c- e>rel</c-><c- o>=</c-><c- s>&quot;alternate stylesheet&quot;</c-> <c- e>href</c-><c- o>=</c-><c- s>&quot;big.css&quot;</c-> <c- e>title</c-><c- o>=</c-><c- s>&quot;Big fonts&quot;</c-><c- p>&gt;</c->
<c- p>&lt;</c-><c- f>link</c-> <c- e>rel</c-><c- o>=</c-><c- s>&quot;alternate stylesheet&quot;</c-> <c- e>href</c-><c- o>=</c-><c- s>&quot;wide.css&quot;</c-> <c- e>title</c-><c- o>=</c-><c- s>&quot;Wide screen&quot;</c-><c- p>&gt;</c-></code></pre>

    </div>

   <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><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>&quot;alternate&quot;</c-> <c- e>type</c-><c- o>=</c-><c- s>&quot;application/atom+xml&quot;</c-> <c- e>href</c-><c- o>=</c-><c- s>&quot;posts.xml&quot;</c-> <c- e>title</c-><c- o>=</c-><c- s>&quot;Cool Stuff Blog&quot;</c-><c- p>&gt;</c->
<c- p>&lt;</c-><c- f>link</c-> <c- e>rel</c-><c- o>=</c-><c- s>&quot;alternate&quot;</c-> <c- e>type</c-><c- o>=</c-><c- s>&quot;application/atom+xml&quot;</c-> <c- e>href</c-><c- o>=</c-><c- s>&quot;posts.xml?category=robots&quot;</c-> <c- e>title</c-><c- o>=</c-><c- s>&quot;Cool Stuff Blog: robots category&quot;</c-><c- p>&gt;</c->
<c- p>&lt;</c-><c- f>link</c-> <c- e>rel</c-><c- o>=</c-><c- s>&quot;alternate&quot;</c-> <c- e>type</c-><c- o>=</c-><c- s>&quot;application/atom+xml&quot;</c-> <c- e>href</c-><c- o>=</c-><c- s>&quot;comments.xml&quot;</c-> <c- e>title</c-><c- o>=</c-><c- s>&quot;Cool Stuff Blog: Comments&quot;</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>&quot;recently-visited-planets.xml&quot;</c-> <c- e>rel</c-><c- o>=</c-><c- s>&quot;alternate&quot;</c-> <c- e>type</c-><c- o>=</c-><c- s>&quot;application/atom+xml&quot;</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>&quot;known-bad-planets.xml&quot;</c-> <c- e>rel</c-><c- o>=</c-><c- s>&quot;alternate&quot;</c-> <c- e>type</c-><c- o>=</c-><c- s>&quot;application/atom+xml&quot;</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>&quot;unexplored-planets.xml&quot;</c-> <c- e>rel</c-><c- o>=</c-><c- s>&quot;alternate&quot;</c-> <c- e>type</c-><c- o>=</c-><c- s>&quot;application/atom+xml&quot;</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>

   <dt>Otherwise<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>&quot;/en/html&quot;</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>&quot;English HTML&quot;</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>&quot;/fr/html&quot;</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>&quot;French HTML&quot;</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>&quot;/en/html/print&quot;</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>&quot;English HTML (for printing)&quot;</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>&quot;/fr/html/print&quot;</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>&quot;French HTML (for printing)&quot;</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>&quot;/en/pdf&quot;</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>&quot;English PDF&quot;</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>&quot;/fr/pdf&quot;</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>&quot;French PDF&quot;</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>

   </dl>



  <h5 id=link-type-author><span class=secno>4.6.6.2</span> Link type "<dfn><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://tools.ietf.org/html/rfc6068#section-2>mailto:</a></code> URL giving the e-mail 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.6.3</span> Link type "<dfn><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 <a href=#associatedSection>the section the linking element is most closely associated with</a>, 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>&quot;a&quot;</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>&quot;a.html&quot;</c-> <c- e>rel</c-><c- o>=</c-><c- s>&quot;bookmark&quot;</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&apos;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>&quot;b&quot;</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>&quot;b.html&quot;</c-> <c- e>rel</c-><c- o>=</c-><c- s>&quot;bookmark&quot;</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>&quot;c&quot;</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>&quot;c.html&quot;</c-> <c- e>rel</c-><c- o>=</c-><c- s>&quot;bookmark&quot;</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.6.4</span> Link type "<dfn><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> specification. <a href=#refsRFC6596>[RFC6596]</a></p>


  <h5 id=link-type-dns-prefetch><span class=secno>4.6.6.5</span> Link type "<dfn><code>dns-prefetch</code></dfn>"<a href=#link-type-dns-prefetch class=self-link></a></h5>

  <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. User agents must implement the processing model of
  the <code id=link-type-dns-prefetch:link-type-dns-prefetch-3><a href=#link-type-dns-prefetch>dns-prefetch</a></code> keyword described in the <cite>Resource
  Hints</cite> specification. <a href=#refsRESOURCEHINTS>[RESOURCEHINTS]</a></p>

  <p>There is no default type for resources given by the <code id=link-type-dns-prefetch:link-type-dns-prefetch-4><a href=#link-type-dns-prefetch>dns-prefetch</a></code> keyword.</p>


  <h5 id=link-type-external><span class=secno>4.6.6.6</span> Link type "<dfn><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> and
  <code id=link-type-external:the-area-element><a href=#the-area-element>area</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.6.7</span> Link type "<dfn><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>, and <code id=link-type-help:the-area-element><a href=#the-area-element>area</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> and <code id=link-type-help:the-area-element-2><a href=#the-area-element>area</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>&quot;help/topic.html&quot;</c-> <c- e>rel</c-><c- o>=</c-><c- s>&quot;help&quot;</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.6.8</span> Link type "<dfn><code>icon</code></dfn>"<a href=#rel-icon class=self-link></a></h5><div class=status><input onclick=toggleStatus(this) value=⋰ type=button><p class=support><strong>Support:</strong> link-icon-png<span class="and_chr yes"><span>Chrome for Android</span> <span>67+</span></span><span class="chrome yes"><span>Chrome</span> <span>4+</span></span><span class="ios_saf no"><span>iOS Safari</span> <span>None</span></span><span class="and_uc yes"><span>UC Browser for Android</span> <span>11.8+</span></span><span class="firefox yes"><span>Firefox</span> <span>2+</span></span><span class="ie yes"><span>IE</span> <span>11+</span></span><span class="op_mini no"><span>Opera Mini</span> <span>None</span></span><span class="safari yes"><span>Safari</span> <span>3.1+</span></span><span class="edge yes"><span>Edge</span> <span>12+</span></span><span class="samsung yes"><span>Samsung Internet</span> <span>4+</span></span><span class="opera yes"><span>Opera</span> <span>9+</span></span><span class="android yes"><span>Android Browser</span> <span>2.1+</span></span><p class=caniuse>Source: <a href="https://caniuse.com/#feat=link-icon-png">caniuse.com</a></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>

  

  <p>Other keywords must be further parsed as follows to determine what they represent:</p>

  <ul><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.<li><p>Let <var>width string</var> be the string before the "<code>x</code>" or
   "<code>X</code>".<li><p>Let <var>height string</var> be the string after the "<code>x</code>" or
   "<code>X</code>".<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.<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>.<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>.<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.</ul>

  

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

  

  <p>In the absence of a <code id=rel-icon:the-link-element-2><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 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 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.<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>.<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.</ol>

  

  <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>&quot;en&quot;</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>&quot;16x16&quot;</c-> <c- e>type</c-><c- o>=</c-><c- s>&quot;image/png&quot;</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>&quot;32x32 48x48&quot;</c-> <c- e>type</c-><c- o>=</c-><c- s>&quot;image/vnd.microsoft.icon&quot;</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>&quot;128x128 512x512 8192x8192 32768x32768&quot;</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>&quot;57x57&quot;</c-> <c- e>type</c-><c- o>=</c-><c- s>&quot;image/png&quot;</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>&quot;any&quot;</c-> <c- e>type</c-><c- o>=</c-><c- s>&quot;image/svg+xml&quot;</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>&quot;lsForums&quot;</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 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.6.9</span> Link type "<dfn><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>, and <code id=link-type-license:the-area-element><a href=#the-area-element>area</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>&quot;en&quot;</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>&quot;stylesheet&quot;</c-> <c- e>href</c-><c- o>=</c-><c- s>&quot;/style/default&quot;</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>&quot;../&quot;</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>&quot;/pix/39627052_fd8dcd98b5.jpg&quot;</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>&quot;license&quot;</c-> <c- e>href</c-><c- o>=</c-><c- s>&quot;http://www.opensource.org/licenses/mit-license.php&quot;</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>&quot;/&quot;</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>&quot;../&quot;</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-modulepreload><span class=secno>4.6.6.10</span> Link type "<dfn><code>modulepreload</code></dfn>"<a href=#link-type-modulepreload class=self-link></a></h5>

  <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>The appropriate times to fetch the resource 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>.<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>.<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.</ul>

  

  <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>
  attribute 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>

  

  <p id=modulepreload-obtain-steps>To obtain the resource for such a link:</p>

  <ol><li><p>If the <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.<li><p>Let <var>destination</var> be the current state of the <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.<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-a-task id=link-type-modulepreload:queue-a-task>queue a task</a> on
   the <a href=#networking-task-source id=link-type-modulepreload:networking-task-source>networking task source</a> 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 the <code id=link-type-modulepreload:the-link-element-6><a href=#the-link-element>link</a></code> element, and
   return.<li><p><a href=#parse-a-url id=link-type-modulepreload:parse-a-url>Parse</a> the <a id=link-type-modulepreload:url href=https://url.spec.whatwg.org/#concept-url data-x-internal=url>URL</a> given by the <code id=link-type-modulepreload:attr-link-href-3><a href=#attr-link-href>href</a></code> attribute, relative to the element'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>. If that fails, then return. Otherwise, let <var>url</var> be the <a href=#resulting-url-record id=link-type-modulepreload:resulting-url-record>resulting
   URL record</a>.<li><p>Let <var>settings object</var> be the <code id=link-type-modulepreload:the-link-element-7><a href=#the-link-element>link</a></code> element'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>.<li><p>Let <var>credentials mode</var> be the <a href=#module-script-credentials-mode id=link-type-modulepreload:module-script-credentials-mode>module script credentials mode</a> for the
   <code id=link-type-modulepreload:attr-link-crossorigin-3><a href=#attr-link-crossorigin>crossorigin</a></code> attribute.<li><p>Let <var>cryptographic nonce</var> be the current value of the element's
   <a href=#cryptographicnonce id=link-type-modulepreload:cryptographicnonce>[[CryptographicNonce]]</a> internal slot.<li><p>Let <var>integrity metadata</var> be the value of the <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.<li><p>Let <var>referrer policy</var> be the current state of the element's <code id=link-type-modulepreload:attr-link-referrerpolicy-2><a href=#attr-link-referrerpolicy>referrerpolicy</a></code> attribute.<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>, and <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>.<li><p><a href=#fetch-a-single-module-script id=link-type-modulepreload:fetch-a-single-module-script>Fetch a single module script</a> given <var>url</var>, <var>settings
   object</var>, <var>destination</var>, <var>options</var>, <var>settings object</var>, "<code>client</code>", and with the <var>top-level module fetch</var> flag set. Wait until
   algorithm asynchronously completes with <var>result</var>.<li><p>If <var>result</var> is null, <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 the <code id=link-type-modulepreload:the-link-element-8><a href=#the-link-element>link</a></code> element, and
   return.<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 the <code id=link-type-modulepreload:the-link-element-9><a href=#the-link-element>link</a></code> element.<li>
    <p>Optionally, perform the following steps:</p>

    <ol><li><p>Let <var>visited set</var> be « <var>url</var> ».<li><p><a href=#fetch-the-descendants-of-and-instantiate-a-module-script id=link-type-modulepreload:fetch-the-descendants-of-and-instantiate-a-module-script>Fetch the
     descendants of and instantiate</a> <var>result</var> given <var>settings object</var>,
     <var>destination</var>, and <var>visited set</var>.</ol>

    <p class=note>Generally, performing these steps will be beneficial for performance, as it
    allows pre-loading the modules that will invariably be requested later, when <a href=#fetch-a-module-script-tree id=link-type-modulepreload:fetch-a-module-script-tree>fetch a
    module script graph</a> is called. However, user agents might wish to skip them in
    bandwidth-constrained situations, or situations where the relevant fetches are already in
    flight.</p>
   </ol>

  

  <div id=example-modulepreload-manifest class=example>
   <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>&quot;en&quot;</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>&quot;modulepreload&quot;</c-> <c- e>href</c-><c- o>=</c-><c- s>&quot;app.mjs&quot;</c-><c- p>&gt;</c->
<c- p>&lt;</c-><c- f>link</c-> <c- e>rel</c-><c- o>=</c-><c- s>&quot;modulepreload&quot;</c-> <c- e>href</c-><c- o>=</c-><c- s>&quot;helpers.mjs&quot;</c-><c- p>&gt;</c->
<c- p>&lt;</c-><c- f>link</c-> <c- e>rel</c-><c- o>=</c-><c- s>&quot;modulepreload&quot;</c-> <c- e>href</c-><c- o>=</c-><c- s>&quot;irc.mjs&quot;</c-><c- p>&gt;</c->
<c- p>&lt;</c-><c- f>link</c-> <c- e>rel</c-><c- o>=</c-><c- s>&quot;modulepreload&quot;</c-> <c- e>href</c-><c- o>=</c-><c- s>&quot;fog-machine.mjs&quot;</c-><c- p>&gt;</c->

<c- p>&lt;</c-><c- f>script</c-> <c- e>type</c-><c- o>=</c-><c- s>&quot;module&quot;</c-> <c- e>src</c-><c- o>=</c-><c- s>&quot;app.mjs&quot;</c-><c- p>&gt;</c->
...</code></pre>

   <p>Assume that the module graph for the application is as follows:</p>

   <img 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-3><a href=#link-type-modulepreload>modulepreload</a></code> 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-4><a href=#link-type-modulepreload>modulepreload</a></code> <code id=link-type-modulepreload:the-link-element-10><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>
   <p>The following code shows how <code id=link-type-modulepreload:link-type-modulepreload-5><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.github.io/proposal-dynamic-import/#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.github.io/proposal-dynamic-import/#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>&quot;modulepreload&quot;</c-> <c- e>href</c-><c- o>=</c-><c- s>&quot;awesome-viewer.mjs&quot;</c-><c- p>&gt;</c->

<c- p>&lt;</c-><c- f>button</c-> <c- e>onclick</c-><c- o>=</c-><c- s>&quot;import(&apos;./awesome-viewer.mjs&apos;).then(m =&gt; m.view())&quot;</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.6.11</span> Link type "<dfn><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> and
  <code id=link-type-nofollow:the-area-element><a href=#the-area-element>area</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.6.12</span> Link type "<dfn><code>noopener</code></dfn>"<a href=#link-type-noopener class=self-link></a></h5><div class=status><input onclick=toggleStatus(this) value=⋰ type=button><p class=support><strong>Support:</strong> rel-noopener<span class="and_chr yes"><span>Chrome for Android</span> <span>67+</span></span><span class="chrome yes"><span>Chrome</span> <span>49+</span></span><span class="ios_saf yes"><span>iOS Safari</span> <span>10.3+</span></span><span class="and_uc yes"><span>UC Browser for Android</span> <span>11.8+</span></span><span class="firefox yes"><span>Firefox</span> <span>52+</span></span><span class="ie no"><span>IE</span> <span>None</span></span><span class="op_mini no"><span>Opera Mini</span> <span>None</span></span><span class="safari yes"><span>Safari</span> <span>10.1+</span></span><span class="edge no"><span>Edge</span> <span>None</span></span><span class="samsung yes"><span>Samsung Internet</span> <span>5+</span></span><span class="opera yes"><span>Opera</span> <span>36+</span></span><span class="android yes"><span>Android Browser</span> <span>67+</span></span><p class=caniuse>Source: <a href="https://caniuse.com/#feat=rel-noopener">caniuse.com</a></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> and
  <code id=link-type-noopener:the-area-element><a href=#the-area-element>area</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=#browsing-context id=link-type-noopener:browsing-context>browsing context</a> which results from
  following the <a href=#hyperlink id=link-type-noopener:hyperlink-2>hyperlink</a> will be <a href=#disowned-its-opener id=link-type-noopener:disowned-its-opener>disowned</a>, which means that its <code id=link-type-noopener:dom-opener><a href=#dom-opener>window.opener</a></code> attribute will be null.</p>


  <h5 id=link-type-noreferrer><span class=secno>4.6.6.13</span> Link type "<dfn><code>noreferrer</code></dfn>"<a href=#link-type-noreferrer class=self-link></a></h5><div class=status><input onclick=toggleStatus(this) value=⋰ type=button><p class=support><strong>Support:</strong> rel-noreferrer<span class="and_chr yes"><span>Chrome for Android</span> <span>67+</span></span><span class="chrome yes"><span>Chrome</span> <span>16+</span></span><span class="ios_saf yes"><span>iOS Safari</span> <span>4.0+</span></span><span class="and_uc yes"><span>UC Browser for Android</span> <span>11.8+</span></span><span class="firefox yes"><span>Firefox</span> <span>33+</span></span><span class="ie partial"><span>IE (limited)</span> <span>11+</span></span><span class="op_mini no"><span>Opera Mini</span> <span>None</span></span><span class="safari yes"><span>Safari</span> <span>5+</span></span><span class="edge yes"><span>Edge</span> <span>13+</span></span><span class="samsung yes"><span>Samsung Internet</span> <span>4+</span></span><span class="opera yes"><span>Opera</span> <span>15+</span></span><span class="android yes"><span>Android Browser</span> <span>2.3+</span></span><p class=caniuse>Source: <a href="https://caniuse.com/#feat=rel-noreferrer">caniuse.com</a></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> and
  <code id=link-type-noreferrer:the-area-element><a href=#the-area-element>area</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.</p>

  

  <p>If a user agent follows a link defined by an <code id=link-type-noreferrer:the-a-element-2><a href=#the-a-element>a</a></code> or <code id=link-type-noreferrer:the-area-element-2><a href=#the-area-element>area</a></code> element that
  has the <code id=link-type-noreferrer:link-type-noreferrer-2><a href=#link-type-noreferrer>noreferrer</a></code> keyword, the user agent must set their
  <a href=https://fetch.spec.whatwg.org/#concept-request id=link-type-noreferrer:concept-request data-x-internal=concept-request>request</a>'s <a href=https://fetch.spec.whatwg.org/#concept-request-referrer id=link-type-noreferrer:concept-request-referrer data-x-internal=concept-request-referrer>referrer</a> to "<code>no-referrer</code>".</p>

  <p class=note>For historical reasons, the <code id=link-type-noreferrer:link-type-noreferrer-3><a href=#link-type-noreferrer>noreferrer</a></code>
  keyword implies the behavior associated with the <code id=link-type-noreferrer:link-type-noopener><a href=#link-type-noopener>noopener</a></code>
  keyword when present on a hyperlink that <a href=#creating-a-new-browsing-context id=link-type-noreferrer:creating-a-new-browsing-context>creates</a> a new <a href=#browsing-context id=link-type-noreferrer:browsing-context>browsing context</a>. That is, <code>&lt;a
  href="..." rel="noreferrer" target="_blank"></code> has the same behavior as <code>&lt;a href="..." rel="noreferrer noopener" target="_blank"></code>.</p>

  


  <h5 id=link-type-pingback><span class=secno>4.6.6.14</span> Link type "<dfn><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 the Pingback
  1.0 specification. <a href=#refsPINGBACK>[PINGBACK]</a></p>


  <h5 id=link-type-preconnect><span class=secno>4.6.6.15</span> Link type "<dfn><code>preconnect</code></dfn>"<a href=#link-type-preconnect class=self-link></a></h5>

  <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. User agents must implement the
  processing model of the <code id=link-type-preconnect:link-type-preconnect-3><a href=#link-type-preconnect>preconnect</a></code> keyword described in
  <cite>Resource Hints</cite>. <a href=#refsRESOURCEHINTS>[RESOURCEHINTS]</a></p>

  <p>There is no default type for resources given by the <code id=link-type-preconnect:link-type-preconnect-4><a href=#link-type-preconnect>preconnect</a></code> keyword.</p>


  <h5 id=link-type-prefetch><span class=secno>4.6.6.16</span> Link type "<dfn><code>prefetch</code></dfn>"<a href=#link-type-prefetch class=self-link></a></h5>

  <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 is likely to be
  beneficial, as it is highly likely that the user will require this resource for future
  navigations. User agents must implement the processing model of the <code id=link-type-prefetch:link-type-prefetch-3><a href=#link-type-prefetch>prefetch</a></code> keyword described in <cite>Resource Hints</cite>.
  <a href=#refsRESOURCEHINTS>[RESOURCEHINTS]</a></p>

  <p>There is no default type for resources given by the <code id=link-type-prefetch:link-type-prefetch-4><a href=#link-type-prefetch>prefetch</a></code>
  keyword.</p>


  <h5 id=link-type-preload><span class=secno>4.6.6.17</span> Link type "<dfn><code>preload</code></dfn>"<a href=#link-type-preload class=self-link></a></h5>

  <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 must
  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/#concept-request-priority id=link-type-preload: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=link-type-preload:concept-potential-destination-translate data-x-internal=concept-potential-destination-translate>corresponding</a> <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>), as it is highly likely that the user
  will require this resource for the current navigation. User agents must implement
  the processing model of the <code id=link-type-preload:link-type-preload-3><a href=#link-type-preload>preload</a></code> keyword described in
  <cite>Preload</cite>, as well as in this specification's <a href=#concept-link-obtain id=link-type-preload:concept-link-obtain>obtain
  the resource</a> algorithm. <a href=#refsPRELOAD>[PRELOAD]</a></p>

  <p>There is no default type for resources given by the <code id=link-type-preload:link-type-preload-4><a href=#link-type-preload>preload</a></code>
  keyword.</p>


  <h5 id=link-type-prerender><span class=secno>4.6.6.18</span> Link type "<dfn><code>prerender</code></dfn>"<a href=#link-type-prerender class=self-link></a></h5>

  <p>The <code id=link-type-prerender:link-type-prerender><a href=#link-type-prerender>prerender</a></code> keyword may be used with <code id=link-type-prerender:the-link-element><a href=#the-link-element>link</a></code>
  elements. This keyword creates an <a href=#external-resource-link id=link-type-prerender:external-resource-link>external resource
  link</a>. This keyword is <a href=#body-ok id=link-type-prerender:body-ok>body-ok</a>.</p>

  <p>The <code id=link-type-prerender:link-type-prerender-2><a href=#link-type-prerender>prerender</a></code> keyword indicates that the specified resource
  might be required by the next navigation, and so it may be beneficial to not only preemptively
  <a href=https://fetch.spec.whatwg.org/#concept-fetch id=link-type-prerender:concept-fetch data-x-internal=concept-fetch>fetch</a> the resource, but also to process it, e.g. by <a href=https://fetch.spec.whatwg.org/#concept-fetch id=link-type-prerender:concept-fetch-2 data-x-internal=concept-fetch>fetching</a> its subresources or performing some rendering. User agents must implement the processing model of the <code id=link-type-prerender:link-type-prerender-3><a href=#link-type-prerender>prerender</a></code> keyword described in <cite>Resource Hints</cite>.
  <a href=#refsRESOURCEHINTS>[RESOURCEHINTS]</a></p>

  <p>There is no default type for resources given by the <code id=link-type-prerender:link-type-prerender-4><a href=#link-type-prerender>prerender</a></code> keyword.</p>


  <h5 id=link-type-search><span class=secno>4.6.6.19</span> Link type "<dfn><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>, and <code id=link-type-search:the-area-element><a href=#the-area-element>area</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.6.20</span> Link type "<dfn><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 CSS style sheet that describes how to present the document.</p>

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

  

  <p>The appropriate times to <a href=#concept-link-obtain id=link-type-stylesheet:concept-link-obtain>obtain</a> the resource are:

  
  <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-4><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>.<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-5><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>.<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-6><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.<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-7><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.<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-8><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 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.<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-9><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>, 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 set, removed, or
   changed.<li><p>When the <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> 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.</ul>

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

  <p>Once a resource has been <a href=#concept-link-obtain id=link-type-stylesheet:concept-link-obtain-2>obtained</a>, if its <a href=#content-type id=link-type-stylesheet:content-type-3>Content-Type metadata</a> is <code id=link-type-stylesheet:text/css-3><a href=#text/css>text/css</a></code>, then run these
  steps:</p>

  
  

  <ol><li><p>Let <var>element</var> be the <code id=link-type-stylesheet:the-link-element-10><a href=#the-link-element>link</a></code> element that created the
   <a href=#external-resource-link id=link-type-stylesheet:external-resource-link-9>external resource link</a>.<li><p>If <var>element</var> has an <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>, <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> in question.<li><p>If <var>element</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=#concept-link-obtain id=link-type-stylesheet:concept-link-obtain-3>obtained</a>, it has become appropriate to <a href=#concept-link-obtain id=link-type-stylesheet:concept-link-obtain-4>obtain</a> it again (meaning this algorithm is about to be
   invoked again for a newly obtained resource), then return.<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><dd><p><code id=link-type-stylesheet:text/css-4><a href=#text/css>text/css</a></code><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><dd>

      <p>The <a href=#resulting-url-string id=link-type-stylesheet:resulting-url-string>resulting URL string</a> determined during the <a href=#concept-link-obtain id=link-type-stylesheet:concept-link-obtain-5>obtain</a> algorithm.</p>

      <p class=note>This is before any redirects get applied.</p>

     <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><dd><p><var>element</var><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><dd>

      <p>The <code id=link-type-stylesheet:attr-link-media><a href=#attr-link-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. The CSSOM specification defines what happens
      when the attribute is dynamically set, changed, or removed.</p>

     <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><dd>

      <p>The <code id=link-type-stylesheet:attr-link-title><a href=#attr-link-title>title</a></code> attribute of <var>element</var>, if
      <var>element</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>

     <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><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>; unset otherwise.<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><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.<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><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><dd><p>null<dt><a href=https://drafts.csswg.org/cssom/#concept-css-style-sheet-disabled-flag id=link-type-stylesheet:concept-css-style-sheet-disabeld-flag data-x-internal=concept-css-style-sheet-disabeld-flag>disabled flag</a><dd><p>Left at its default value.<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><dd>
      <p>Left uninitialized.</p>

      <p class=XXX>This doesn't seem right. Presumably we should be using the
      response body? Tracked as <a href=https://github.com/whatwg/html/issues/2997>issue #2997</a>.</p>
     </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 the element 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><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></ol>

   </ol>

  



  <h5 id=link-type-tag><span class=secno>4.6.6.21</span> Link type "<dfn><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>&quot;en&quot;</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>&quot;https://en.wikipedia.org/wiki/Gemstone&quot;</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>&quot;en&quot;</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>&quot;https://upload.wikimedia.org/wikipedia/commons/b/b0/Trains_de_la_Bernina_en_hiver_2.jpg&quot;</c->
         <c- e>alt</c-><c- o>=</c-><c- s>&quot;The 802 was red with pantographs and tall vents on the side.&quot;</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>&quot;topic&quot;</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>&quot;https://en.wikipedia.org/wiki/Rhaetian_Railway_Gem_4/4&quot;</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=sequential-link-types><span class=secno>4.6.6.22</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.6.22.1</span> Link type "<dfn><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>, and <code id=link-type-next:the-area-element><a href=#the-area-element>area</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 implement one of the processing models described in <cite>Resource
  Hints</cite>, i.e. 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>,
  <code id=link-type-next:link-type-prefetch><a href=#link-type-prefetch>prefetch</a></code>, or <code id=link-type-next:link-type-prerender><a href=#link-type-prerender>prerender</a></code>
  keywords. Which resource hint 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> hint when trying to conserve data, battery power, or
  processing power, or may wish to pick a resource hint depending on heuristic analysis of past
  user behavior in similar scenarios. <a href=#refsRESOURCEHINTS>[RESOURCEHINTS]</a></p>


  <h6 id=link-type-prev><span class=secno>4.6.6.22.2</span> Link type "<dfn><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>, and <code id=link-type-prev:the-area-element><a href=#the-area-element>area</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.6.23</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 in the <a href=http://microformats.org/wiki/existing-rel-values#HTML5_link_type_extensions>microformats
  wiki existing-rel-values page</a>. <a href=#refsMFREL>[MFREL]</a></p>

  <p>Anyone is free to edit the <span>microformats wiki existing-rel-values page</span> at
  any time to add a type. Extension types must be specified with the following information:</p>

  <dl><dt>Keyword<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>

   <dt>Effect on... <code id=other-link-types:the-link-element><a href=#the-link-element>link</a></code><dd>

    <p>One of the following:</p>

    <dl><dt>Not allowed<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.<dt>Hyperlink<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>.<dt>External Resource<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>.</dl>

   <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><dd>

    <p>One of the following:</p>

    <dl><dt>Not allowed<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.<dt>Hyperlink<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>.<dt>External Resource<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>.<dt>Hyperlink Annotation<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.</dl>

   <dt>Brief description<dd><p>A short non-normative description of what the keyword's meaning is.<dt>Specification<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.<dt>Synonyms<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.<dt>Status<dd>

    <p>One of the following:</p>

    <dl><dt>Proposed<dd>The keyword has not received wide peer review and approval. Someone has proposed it and is,
     or soon will be, using it.<dt>Ratified<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.<dt>Discontinued<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.</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>

   </dl>

  

  <p>Conformance checkers must use the information given on the <span>microformats wiki
  existing-rel-values page</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=http://microformats.org/wiki/existing-rel-values#HTML5_link_type_extensions>microformats
  wiki existing-rel-values page</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><code>ins</code></dfn> element<a href=#the-ins-element class=self-link></a></h4>

  <dl class=element><dt><a href=#concept-element-categories id=the-ins-element:concept-element-categories>Categories</a>:<dd><a href=#flow-content-2 id=the-ins-element:flow-content-2>Flow content</a>.<dd><a href=#phrasing-content-2 id=the-ins-element:phrasing-content-2>Phrasing content</a>.<dd><a href=#palpable-content-2 id=the-ins-element:palpable-content-2>Palpable content</a>.<dt><a href=#concept-element-contexts id=the-ins-element:concept-element-contexts>Contexts in which this element can be used</a>:<dd>Where <a href=#phrasing-content-2 id=the-ins-element:phrasing-content-2-2>phrasing content</a> is expected.<dt><a href=#concept-element-content-model id=the-ins-element:concept-element-content-model>Content model</a>:<dd><a href=#transparent id=the-ins-element:transparent>Transparent</a>.<dt><a href=#concept-element-tag-omission id=the-ins-element:concept-element-tag-omission>Tag omission in text/html</a>:<dd>Neither tag is omissible.<dt><a href=#concept-element-attributes id=the-ins-element:concept-element-attributes>Content attributes</a>:<dd><a href=#global-attributes id=the-ins-element:global-attributes>Global attributes</a><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><code id=the-ins-element:attr-mod-datetime><a href=#attr-mod-datetime>datetime</a></code> — Date and (optionally) time of the change<dt><a href=#concept-element-dom id=the-ins-element:concept-element-dom>DOM interface</a>:<dd>Uses <code id=the-ins-element:htmlmodelement><a href=#htmlmodelement>HTMLModElement</a></code>.</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&apos;t do this --&gt;</c->
 <c- p>&lt;</c-><c- f>ins</c-> <c- e>datetime</c-><c- o>=</c-><c- s>&quot;2005-03-16 00:00Z&quot;</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>&quot;2007-12-19 00:00Z&quot;</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>&quot;2005-03-16 00:00Z&quot;</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>&quot;2005-03-16 00:00Z&quot;</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>&quot;2007-12-19 00:00Z&quot;</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><code>del</code></dfn> element<a href=#the-del-element class=self-link></a></h4>

  <dl class=element><dt><a href=#concept-element-categories id=the-del-element:concept-element-categories>Categories</a>:<dd><a href=#flow-content-2 id=the-del-element:flow-content-2>Flow content</a>.<dd><a href=#phrasing-content-2 id=the-del-element:phrasing-content-2>Phrasing content</a>.<dt><a href=#concept-element-contexts id=the-del-element:concept-element-contexts>Contexts in which this element can be used</a>:<dd>Where <a href=#phrasing-content-2 id=the-del-element:phrasing-content-2-2>phrasing content</a> is expected.<dt><a href=#concept-element-content-model id=the-del-element:concept-element-content-model>Content model</a>:<dd><a href=#transparent id=the-del-element:transparent>Transparent</a>.<dt><a href=#concept-element-tag-omission id=the-del-element:concept-element-tag-omission>Tag omission in text/html</a>:<dd>Neither tag is omissible.<dt><a href=#concept-element-attributes id=the-del-element:concept-element-attributes>Content attributes</a>:<dd><a href=#global-attributes id=the-del-element:global-attributes>Global attributes</a><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><code id=the-del-element:attr-mod-datetime><a href=#attr-mod-datetime>datetime</a></code> — Date and (optionally) time of the change<dt><a href=#concept-element-dom id=the-del-element:concept-element-dom>DOM interface</a>:<dd>Uses <code id=the-del-element:htmlmodelement><a href=#htmlmodelement>HTMLModElement</a></code>.</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>&quot;2009-10-11T01:25-07:00&quot;</c-><c- p>&gt;</c->Watch Walter Lewin&apos;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>&quot;2009-10-10T23:38-07:00&quot;</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 id=attr-mod-cite><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=#parse-a-url id=attributes-common-to-ins-and-del-elements:parse-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 id=attr-mod-datetime><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>

  

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

  

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

  <pre><code class='idl'>[<c- g>Exposed</c->=<c- n>Window</c->,
 <a href='#htmlconstructor' id='attributes-common-to-ins-and-del-elements:htmlconstructor'><c- g>HTMLConstructor</c-></a>]
<c- b>interface</c-> <dfn id='htmlmodelement'><c- g>HTMLModElement</c-></dfn> : <a href='#htmlelement' id='attributes-common-to-ins-and-del-elements:htmlelement'><c- n>HTMLElement</c-></a> {
  [<a href='#cereactions' id='attributes-common-to-ins-and-del-elements:cereactions'><c- g>CEReactions</c-></a>] <c- b>attribute</c-> <c- b>USVString</c-> <a href='#dom-mod-cite' id='attributes-common-to-ins-and-del-elements:dom-mod-cite'><c- g>cite</c-></a>;
  [<a href='#cereactions' id='attributes-common-to-ins-and-del-elements:cereactions-2'><c- g>CEReactions</c-></a>] <c- b>attribute</c-> <c- b>DOMString</c-> <a href='#dom-mod-datetime' id='attributes-common-to-ins-and-del-elements:dom-mod-datetime'><c- g>dateTime</c-></a>;
};</code></pre>

  <p>The <dfn id=dom-mod-cite><code>cite</code></dfn> IDL attribute must <a href=#reflect id=attributes-common-to-ins-and-del-elements:reflect>reflect</a>
  the element's <code id=attributes-common-to-ins-and-del-elements:attr-mod-cite-2><a href=#attr-mod-cite>cite</a></code> content attribute. The <dfn id=dom-mod-datetime><code>dateTime</code></dfn> IDL attribute must <a href=#reflect id=attributes-common-to-ins-and-del-elements:reflect-2>reflect</a> the
  element's <code id=attributes-common-to-ins-and-del-elements:attr-mod-datetime-3><a href=#attr-mod-datetime>datetime</a></code> content attribute.</p>

  



  <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&apos;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- p>&lt;</c-><c- f>del</c-><c- p>&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>&quot;2008-02-12T15:20Z&quot;</c-><c- p>&gt;</c-><em>Bug 225:
 Rain detector doesn&apos;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>&quot;2008-03-01T20:22Z&quot;</c-><c- p>&gt;&lt;</c-><c- f>ins</c-> <c- e>datetime</c-><c- o>=</c-><c- s>&quot;2008-02-14T12:02Z&quot;</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>&quot;2008-02-16T13:50Z&quot;</c-><c- p>&gt;</c-><em>Bug 230:
 Water heater doesn&apos;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>&quot;2008-02-20T21:15Z&quot;</c-><c- p>&gt;&lt;</c-><c- f>ins</c-> <c- e>datetime</c-><c- o>=</c-><c- s>&quot;2008-02-16T14:25Z&quot;</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>&quot;/edits/r192&quot;</c-> <c- e>datetime</c-><c- o>=</c-><c- s>&quot;2011-05-02 14:23Z&quot;</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>&quot;/edits/r192&quot;</c-> <c- e>datetime</c-><c- o>=</c-><c- s>&quot;2011-05-02 14:23Z&quot;</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>&quot;/edits/r192&quot;</c-> <c- e>datetime</c-><c- o>=</c-><c- s>&quot;2011-05-02 14:23Z&quot;</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>&quot;/edits/r192&quot;</c-> <c- e>datetime</c-><c- o>=</c-><c- s>&quot;2011-05-02 14:23Z&quot;</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><code>picture</code></dfn> element<a href=#the-picture-element class=self-link></a></h4><div class=status><input onclick=toggleStatus(this) value=⋰ type=button><p class=support><strong>Support:</strong> picture<span class="and_chr yes"><span>Chrome for Android</span> <span>67+</span></span><span class="chrome yes"><span>Chrome</span> <span>38+</span></span><span class="ios_saf yes"><span>iOS Safari</span> <span>9.3+</span></span><span class="and_uc yes"><span>UC Browser for Android</span> <span>11.8+</span></span><span class="firefox yes"><span>Firefox</span> <span>38+</span></span><span class="ie no"><span>IE</span> <span>None</span></span><span class="op_mini no"><span>Opera Mini</span> <span>None</span></span><span class="safari yes"><span>Safari</span> <span>9.1+</span></span><span class="edge yes"><span>Edge</span> <span>13+</span></span><span class="samsung yes"><span>Samsung Internet</span> <span>4+</span></span><span class="opera yes"><span>Opera</span> <span>25+</span></span><span class="android yes"><span>Android Browser</span> <span>67+</span></span><p class=caniuse>Source: <a href="https://caniuse.com/#feat=picture">caniuse.com</a></div>

  <dl class=element><dt><a href=#concept-element-categories id=the-picture-element:concept-element-categories>Categories</a>:<dd><a href=#flow-content-2 id=the-picture-element:flow-content-2>Flow content</a>.<dd><a href=#phrasing-content-2 id=the-picture-element:phrasing-content-2>Phrasing content</a>.<dd><a href=#embedded-content-category id=the-picture-element:embedded-content-category>Embedded content</a>.<dt><a href=#concept-element-contexts id=the-picture-element:concept-element-contexts>Contexts in which this element can be used</a>:<dd>Where <a href=#embedded-content-category id=the-picture-element:embedded-content-category-2>embedded content</a> is expected.<dt><a href=#concept-element-content-model id=the-picture-element:concept-element-content-model>Content model</a>:<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>.<dt><a href=#concept-element-tag-omission id=the-picture-element:concept-element-tag-omission>Tag omission in text/html</a>:<dd>Neither tag is omissible.<dt><a href=#concept-element-attributes id=the-picture-element:concept-element-attributes>Content attributes</a>:<dd><a href=#global-attributes id=the-picture-element:global-attributes>Global attributes</a><dt><a href=#concept-element-dom id=the-picture-element:concept-element-dom>DOM interface</a>:<dd>
    <pre><code class='idl'>[<c- g>Exposed</c->=<c- n>Window</c->,
 <a href='#htmlconstructor' id='the-picture-element:htmlconstructor'><c- g>HTMLConstructor</c-></a>]
<c- b>interface</c-> <dfn id='htmlpictureelement'><c- g>HTMLPictureElement</c-></dfn> : <a href='#htmlelement' id='the-picture-element:htmlelement'><c- n>HTMLElement</c-></a> {};</code></pre>
   </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/visuren.html#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><code>source</code></dfn> element<a href=#the-source-element class=self-link></a></h4>

  <dl class=element><dt><a href=#concept-element-categories id=the-source-element:concept-element-categories>Categories</a>:<dd>None.<dt><a href=#concept-element-contexts id=the-source-element:concept-element-contexts>Contexts in which this element can be used</a>:<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>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.<dt><a href=#concept-element-content-model id=the-source-element:concept-element-content-model>Content model</a>:<dd><a href=#concept-content-nothing id=the-source-element:concept-content-nothing>Nothing</a>.<dt><a href=#concept-element-tag-omission id=the-source-element:concept-element-tag-omission>Tag omission in text/html</a>:<dd>No <a href=#syntax-end-tag id=the-source-element:syntax-end-tag>end tag</a>.<dt><a href=#concept-element-attributes id=the-source-element:concept-element-attributes>Content attributes</a>:<dd><a href=#global-attributes id=the-source-element:global-attributes>Global attributes</a><dd><code id=the-source-element:attr-source-src><a href=#attr-source-src>src</a></code> — Address of the resource<dd><code id=the-source-element:attr-source-type><a href=#attr-source-type>type</a></code> — Type of embedded resource<dd><code id=the-source-element:attr-source-srcset><a href=#attr-source-srcset>srcset</a></code> — Images to use in different situations (e.g. high-resolution displays, small monitors, etc)<dd><code id=the-source-element:attr-source-sizes><a href=#attr-source-sizes>sizes</a></code> — Image sizes for different page layouts<dd><code id=the-source-element:attr-source-media><a href=#attr-source-media>media</a></code> — Applicable media<dt><a href=#concept-element-dom id=the-source-element:concept-element-dom>DOM interface</a>:<dd>
    <pre><code class='idl'>[<c- g>Exposed</c->=<c- n>Window</c->,
 <a href='#htmlconstructor' id='the-source-element:htmlconstructor'><c- g>HTMLConstructor</c-></a>]
<c- b>interface</c-> <dfn id='htmlsourceelement'><c- g>HTMLSourceElement</c-></dfn> : <a href='#htmlelement' id='the-source-element:htmlelement'><c- n>HTMLElement</c-></a> {
  [<a href='#cereactions' id='the-source-element:cereactions'><c- g>CEReactions</c-></a>] <c- b>attribute</c-> <c- b>USVString</c-> <a href='#dom-source-src' id='the-source-element:dom-source-src'><c- g>src</c-></a>;
  [<a href='#cereactions' id='the-source-element:cereactions-2'><c- g>CEReactions</c-></a>] <c- b>attribute</c-> <c- b>DOMString</c-> <a href='#dom-source-type' id='the-source-element:dom-source-type'><c- g>type</c-></a>;
  [<a href='#cereactions' id='the-source-element:cereactions-3'><c- g>CEReactions</c-></a>] <c- b>attribute</c-> <c- b>USVString</c-> <a href='#dom-source-srcset' id='the-source-element:dom-source-srcset'><c- g>srcset</c-></a>;
  [<a href='#cereactions' id='the-source-element:cereactions-4'><c- g>CEReactions</c-></a>] <c- b>attribute</c-> <c- b>DOMString</c-> <a href='#dom-source-sizes' id='the-source-element:dom-source-sizes'><c- g>sizes</c-></a>;
  [<a href='#cereactions' id='the-source-element:cereactions-5'><c- g>CEReactions</c-></a>] <c- b>attribute</c-> <c- b>DOMString</c-> <a href='#dom-source-media' id='the-source-element:dom-source-media'><c- g>media</c-></a>;
};</code></pre>
   </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 id=attr-source-type><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 remainder of the requirements depend on whether the parent is a <code id=the-source-element:the-picture-element-2><a href=#the-picture-element>picture</a></code>
  element or a <a href=#media-element id=the-source-element:media-element-3>media element</a>:</p>

  <dl class=switch><dt><code id=the-source-element:the-source-element-2><a href=#the-source-element>source</a></code> element's parent is a <code id=the-source-element:the-picture-element-3><a href=#the-picture-element>picture</a></code> element<dd>
    <p>The <dfn id=attr-source-srcset><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-3><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 <dfn id=attr-source-sizes><code>sizes</code></dfn> attribute must also be present, and is a
    <a href=#sizes-attribute id=the-source-element:sizes-attribute>sizes attribute</a>. The <code id=the-source-element:attr-source-sizes-2><a href=#attr-source-sizes>sizes</a></code> attribute
    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-4><a href=#the-source-element>source</a></code> element is selected.</p>

    <p>The <dfn id=attr-source-media><code>media</code></dfn> attributes 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-5><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>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-6><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-7><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-8><a href=#the-source-element>source</a></code> element has a following sibling <code id=the-source-element:the-source-element-9><a href=#the-source-element>source</a></code> element or
    <code id=the-source-element:the-img-element-3><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-2><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>".<li><p>A <code id=the-source-element:attr-source-type-4><a href=#attr-source-type>type</a></code> attribute specified.</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>
   <dt><code id=the-source-element:the-source-element-10><a href=#the-source-element>source</a></code> element's parent is a <a href=#media-element id=the-source-element:media-element-4>media element</a><dd>
    <p>The <dfn id=attr-source-src><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 class=note>Dynamically modifying a <code id=the-source-element:the-source-element-11><a href=#the-source-element>source</a></code> element and its attribute when the
    element is already inserted in a <code id=the-source-element:the-video-element><a href=#the-video-element>video</a></code> or <code id=the-source-element:the-audio-element><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-5>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-12><a href=#the-source-element>source</a></code> elements manually after the document has
    been parsed is an unnecessarily complicated approach.</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>

    <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-6><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<dd><pre><code class='html'><c- p>&lt;</c-><c- f>source</c-> <c- e>src</c-><c- o>=</c-><c- s>&apos;video.mp4&apos;</c-> <c- e>type</c-><c- o>=</c-><c- s>&apos;video/mp4; codecs=&quot;avc1.42E01E, mp4a.40.2&quot;&apos;</c-><c- p>&gt;</c-></code></pre><dt>H.264 Extended profile video (baseline-compatible) level 3 and Low-Complexity AAC audio in MP4 container<dd><pre><code class='html'><c- p>&lt;</c-><c- f>source</c-> <c- e>src</c-><c- o>=</c-><c- s>&apos;video.mp4&apos;</c-> <c- e>type</c-><c- o>=</c-><c- s>&apos;video/mp4; codecs=&quot;avc1.58A01E, mp4a.40.2&quot;&apos;</c-><c- p>&gt;</c-></code></pre><dt>H.264 Main profile video level 3 and Low-Complexity AAC audio in MP4 container<dd><pre><code class='html'><c- p>&lt;</c-><c- f>source</c-> <c- e>src</c-><c- o>=</c-><c- s>&apos;video.mp4&apos;</c-> <c- e>type</c-><c- o>=</c-><c- s>&apos;video/mp4; codecs=&quot;avc1.4D401E, mp4a.40.2&quot;&apos;</c-><c- p>&gt;</c-></code></pre><dt>H.264 'High' profile video (incompatible with main, baseline, or extended profiles) level 3 and Low-Complexity AAC audio in MP4 container<dd><pre><code class='html'><c- p>&lt;</c-><c- f>source</c-> <c- e>src</c-><c- o>=</c-><c- s>&apos;video.mp4&apos;</c-> <c- e>type</c-><c- o>=</c-><c- s>&apos;video/mp4; codecs=&quot;avc1.64001E, mp4a.40.2&quot;&apos;</c-><c- p>&gt;</c-></code></pre><dt>MPEG-4 Visual Simple Profile Level 0 video and Low-Complexity AAC audio in MP4 container<dd><pre><code class='html'><c- p>&lt;</c-><c- f>source</c-> <c- e>src</c-><c- o>=</c-><c- s>&apos;video.mp4&apos;</c-> <c- e>type</c-><c- o>=</c-><c- s>&apos;video/mp4; codecs=&quot;mp4v.20.8, mp4a.40.2&quot;&apos;</c-><c- p>&gt;</c-></code></pre><dt>MPEG-4 Advanced Simple Profile Level 0 video and Low-Complexity AAC audio in MP4 container<dd><pre><code class='html'><c- p>&lt;</c-><c- f>source</c-> <c- e>src</c-><c- o>=</c-><c- s>&apos;video.mp4&apos;</c-> <c- e>type</c-><c- o>=</c-><c- s>&apos;video/mp4; codecs=&quot;mp4v.20.240, mp4a.40.2&quot;&apos;</c-><c- p>&gt;</c-></code></pre><dt>MPEG-4 Visual Simple Profile Level 0 video and AMR audio in 3GPP container<dd><pre><code class='html'><c- p>&lt;</c-><c- f>source</c-> <c- e>src</c-><c- o>=</c-><c- s>&apos;video.3gp&apos;</c-> <c- e>type</c-><c- o>=</c-><c- s>&apos;video/3gpp; codecs=&quot;mp4v.20.8, samr&quot;&apos;</c-><c- p>&gt;</c-></code></pre><dt>Theora video and Vorbis audio in Ogg container<dd><pre><code class='html'><c- p>&lt;</c-><c- f>source</c-> <c- e>src</c-><c- o>=</c-><c- s>&apos;video.ogv&apos;</c-> <c- e>type</c-><c- o>=</c-><c- s>&apos;video/ogg; codecs=&quot;theora, vorbis&quot;&apos;</c-><c- p>&gt;</c-></code></pre><dt>Theora video and Speex audio in Ogg container<dd><pre><code class='html'><c- p>&lt;</c-><c- f>source</c-> <c- e>src</c-><c- o>=</c-><c- s>&apos;video.ogv&apos;</c-> <c- e>type</c-><c- o>=</c-><c- s>&apos;video/ogg; codecs=&quot;theora, speex&quot;&apos;</c-><c- p>&gt;</c-></code></pre><dt>Vorbis audio alone in Ogg container<dd><pre><code class='html'><c- p>&lt;</c-><c- f>source</c-> <c- e>src</c-><c- o>=</c-><c- s>&apos;audio.ogg&apos;</c-> <c- e>type</c-><c- o>=</c-><c- s>&apos;audio/ogg; codecs=vorbis&apos;</c-><c- p>&gt;</c-></code></pre><dt>Speex audio alone in Ogg container<dd><pre><code class='html'><c- p>&lt;</c-><c- f>source</c-> <c- e>src</c-><c- o>=</c-><c- s>&apos;audio.spx&apos;</c-> <c- e>type</c-><c- o>=</c-><c- s>&apos;audio/ogg; codecs=speex&apos;</c-><c- p>&gt;</c-></code></pre><dt>FLAC audio alone in Ogg container<dd><pre><code class='html'><c- p>&lt;</c-><c- f>source</c-> <c- e>src</c-><c- o>=</c-><c- s>&apos;audio.oga&apos;</c-> <c- e>type</c-><c- o>=</c-><c- s>&apos;audio/ogg; codecs=flac&apos;</c-><c- p>&gt;</c-></code></pre><dt>Dirac video and Vorbis audio in Ogg container<dd><pre><code class='html'><c- p>&lt;</c-><c- f>source</c-> <c- e>src</c-><c- o>=</c-><c- s>&apos;video.ogv&apos;</c-> <c- e>type</c-><c- o>=</c-><c- s>&apos;video/ogg; codecs=&quot;dirac, vorbis&quot;&apos;</c-><c- p>&gt;</c-></code></pre></dl>
    </div>

    <p>The <code id=the-source-element:attr-source-srcset-4><a href=#attr-source-srcset>srcset</a></code>, <code id=the-source-element:attr-source-sizes-3><a href=#attr-source-sizes>sizes</a></code>, and <code id=the-source-element:attr-source-media-3><a href=#attr-source-media>media</a></code>
    attributes must not be present.</p>
   </dl>

  

  <p>If a <code id=the-source-element:the-source-element-13><a href=#the-source-element>source</a></code> <a href=#nodes-are-inserted id=the-source-element:nodes-are-inserted>element is inserted</a> as a
  child of a <a href=#media-element id=the-source-element:media-element-6>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>, the user agent must invoke the <a href=#media-element id=the-source-element:media-element-7>media
  element</a>'s <a href=#concept-media-load-algorithm id=the-source-element:concept-media-load-algorithm>resource selection
  algorithm</a>.</p>

  <p>The IDL attributes <dfn id=dom-source-src><code>src</code></dfn>, <dfn id=dom-source-type><code>type</code></dfn>, <dfn id=dom-source-srcset><code>srcset</code></dfn>, <dfn id=dom-source-sizes><code>sizes</code></dfn> and <dfn id=dom-source-media><code>media</code></dfn> must <a href=#reflect id=the-source-element:reflect>reflect</a> the respective
  content attributes of the same name.</p>

  

  <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-14><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>&apos;video.mp4&apos;</c-> <c- e>type</c-><c- o>=</c-><c- s>&apos;video/mp4; codecs=&quot;avc1.42E01E, mp4a.40.2&quot;&apos;</c-><c- p>&gt;</c->
 <c- p>&lt;</c-><c- f>source</c-> <c- e>src</c-><c- o>=</c-><c- s>&apos;video.ogv&apos;</c-> <c- e>type</c-><c- o>=</c-><c- s>&apos;video/ogg; codecs=&quot;theora, vorbis&quot;&apos;</c->
         <c- e>onerror</c-><c- o>=</c-><c- s>&quot;fallback(parentNode)&quot;</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 data-dfn-type=element data-lt=img><span class=secno>4.8.3</span> The <dfn><code>img</code></dfn> element<a href=#the-img-element class=self-link></a></h4>

  <dl class=element><dt><a href=#concept-element-categories id=the-img-element:concept-element-categories>Categories</a>:<dd><a href=#flow-content-2 id=the-img-element:flow-content-2>Flow content</a>.<dd><a href=#phrasing-content-2 id=the-img-element:phrasing-content-2>Phrasing content</a>.<dd><a href=#embedded-content-category id=the-img-element:embedded-content-category>Embedded content</a>.<dd><a href=#form-associated-element id=the-img-element:form-associated-element>Form-associated element</a>.<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><a href=#palpable-content-2 id=the-img-element:palpable-content-2>Palpable content</a>.<dt><a href=#concept-element-contexts id=the-img-element:concept-element-contexts>Contexts in which this element can be used</a>:<dd>Where <a href=#embedded-content-category id=the-img-element:embedded-content-category-2>embedded content</a> is expected.<dt><a href=#concept-element-content-model id=the-img-element:concept-element-content-model>Content model</a>:<dd><a href=#concept-content-nothing id=the-img-element:concept-content-nothing>Nothing</a>.<dt><a href=#concept-element-tag-omission id=the-img-element:concept-element-tag-omission>Tag omission in text/html</a>:<dd>No <a href=#syntax-end-tag id=the-img-element:syntax-end-tag>end tag</a>.<dt><a href=#concept-element-attributes id=the-img-element:concept-element-attributes>Content attributes</a>:<dd><a href=#global-attributes id=the-img-element:global-attributes>Global attributes</a><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><code id=the-img-element:attr-img-src><a href=#attr-img-src>src</a></code> — Address of the resource<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><code id=the-img-element:attr-img-sizes><a href=#attr-img-sizes>sizes</a></code> — Image sizes for different page layouts<dd><code id=the-img-element:attr-img-crossorigin><a href=#attr-img-crossorigin>crossorigin</a></code> — How the element handles crossorigin requests<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><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><code id=the-img-element:attr-dim-width><a href=#attr-dim-width>width</a></code> — Horizontal dimension<dd><code id=the-img-element:attr-dim-height><a href=#attr-dim-height>height</a></code> — Vertical dimension<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><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<dt><a href=#concept-element-dom id=the-img-element:concept-element-dom>DOM interface</a>:<dd>
    <pre><code class='idl'>[<c- g>Exposed</c->=<c- n>Window</c->,
 <a href='#htmlconstructor' id='the-img-element:htmlconstructor'><c- g>HTMLConstructor</c-></a>,
 <c- g>NamedConstructor</c->=<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'><c- g>HTMLImageElement</c-></dfn> : <a href='#htmlelement' id='the-img-element:htmlelement'><c- n>HTMLElement</c-></a> {
  [<a href='#cereactions' id='the-img-element:cereactions'><c- g>CEReactions</c-></a>] <c- b>attribute</c-> <c- b>DOMString</c-> <a href='#dom-img-alt' id='the-img-element:dom-img-alt'><c- g>alt</c-></a>;
  [<a href='#cereactions' id='the-img-element:cereactions-2'><c- g>CEReactions</c-></a>] <c- b>attribute</c-> <c- b>USVString</c-> <a href='#dom-img-src' id='the-img-element:dom-img-src'><c- g>src</c-></a>;
  [<a href='#cereactions' id='the-img-element:cereactions-3'><c- g>CEReactions</c-></a>] <c- b>attribute</c-> <c- b>USVString</c-> <a href='#dom-img-srcset' id='the-img-element:dom-img-srcset'><c- g>srcset</c-></a>;
  [<a href='#cereactions' id='the-img-element:cereactions-4'><c- g>CEReactions</c-></a>] <c- b>attribute</c-> <c- b>DOMString</c-> <a href='#dom-img-sizes' id='the-img-element:dom-img-sizes'><c- g>sizes</c-></a>;
  [<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>] <c- b>attribute</c-> <c- b>DOMString</c-> <a href='#dom-img-usemap' id='the-img-element:dom-img-usemap'><c- g>useMap</c-></a>;
  [<a href='#cereactions' id='the-img-element:cereactions-7'><c- g>CEReactions</c-></a>] <c- b>attribute</c-> <c- b>boolean</c-> <a href='#dom-img-ismap' id='the-img-element:dom-img-ismap'><c- g>isMap</c-></a>;
  [<a href='#cereactions' id='the-img-element:cereactions-8'><c- g>CEReactions</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>] <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>;

  <c- b>Promise</c->&lt;<c- b>void</c->&gt; <a href='#dom-img-decode' id='the-img-element:dom-img-decode'><c- g>decode</c-></a>();
};</code></pre>
   </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>The image given by the <dfn id=attr-img-src><code>src</code></dfn> and <dfn id=attr-img-srcset><code>srcset</code></dfn> attributes, and any previous sibling
  <code id=the-img-element:the-source-element><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><a href=#the-picture-element>picture</a></code> element, is the embedded content; the value of the <dfn id=attr-img-alt><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-2><a href=#the-img-element>img</a></code>
  element's <a href=#fallback-content id=the-img-element:fallback-content>fallback content</a>).<div class=status><input onclick=toggleStatus(this) value=⋰ type=button><p class=support><strong>Support:</strong> srcset<span class="and_chr yes"><span>Chrome for Android</span> <span>67+</span></span><span class="chrome yes"><span>Chrome</span> <span>38+</span></span><span class="ios_saf yes"><span>iOS Safari</span> <span>9.0+</span></span><span class="and_uc yes"><span>UC Browser for Android</span> <span>11.8+</span></span><span class="firefox yes"><span>Firefox</span> <span>38+</span></span><span class="ie no"><span>IE</span> <span>None</span></span><span class="op_mini no"><span>Opera Mini</span> <span>None</span></span><span class="safari yes"><span>Safari</span> <span>9+</span></span><span class="edge yes"><span>Edge</span> <span>16+</span></span><span class="samsung yes"><span>Samsung Internet</span> <span>4+</span></span><span class="opera yes"><span>Opera</span> <span>25+</span></span><span class="android yes"><span>Android Browser</span> <span>67+</span></span><p class=caniuse>Source: <a href="https://caniuse.com/#feat=srcset">caniuse.com</a></div>

  <p>The requirements on the <code id=the-img-element:attr-img-alt-2><a href=#attr-img-alt>alt</a></code> attribute's value are described
  <a href=#alt>in a separate section</a>.</p>

  <p>The <code id=the-img-element:attr-img-src-2><a href=#attr-img-src>src</a></code> attribute must be present, and 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 so forth. <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-2><a href=#attr-img-srcset>srcset</a></code> attribute may also be present, and 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-3><a href=#attr-img-srcset>srcset</a></code> attribute and the <code id=the-img-element:attr-img-src-3><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-2><a href=#the-source-element>source</a></code> element was selected).</p>

  <p>If the <code id=the-img-element:attr-img-srcset-4><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 <dfn id=attr-img-sizes><code>sizes</code></dfn> attribute must also
  be present, and is a <a href=#sizes-attribute id=the-img-element:sizes-attribute>sizes attribute</a>. The <code id=the-img-element:attr-img-sizes-2><a href=#attr-img-sizes>sizes</a></code>
  attribute 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-3><a href=#the-source-element>source</a></code> element was selected).</p>

  <p>The <dfn id=attr-img-crossorigin><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 id=attr-img-referrerpolicy><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-2 data-x-internal=concept-fetch>fetching</a> the image. <a href=#refsREFERRERPOLICY>[REFERRERPOLICY]</a></p>

  <p>The <dfn id=attr-img-decoding><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>

  <hr>

  <p>The <code id=the-img-element:the-img-element-3><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-4><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>

  <p>What an <code id=the-img-element:the-img-element-5><a href=#the-img-element>img</a></code> element represents depends on the <code id=the-img-element:attr-img-src-4><a href=#attr-img-src>src</a></code> attribute and the <code id=the-img-element:attr-img-alt-3><a href=#attr-img-alt>alt</a></code>
  attribute.</p>

  <dl class=switch><dt>If the <code id=the-img-element:attr-img-src-5><a href=#attr-img-src>src</a></code> attribute is set and the <code id=the-img-element:attr-img-alt-4><a href=#attr-img-alt>alt</a></code> attribute is set to the empty string<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>

   <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 a value that isn't empty<dd>

    <p>The image is a key part of the content; the <code id=the-img-element:attr-img-alt-6><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-7><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>

   <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-8><a href=#attr-img-alt>alt</a></code> attribute is not<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-9><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-8><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.<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-6><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.<li><p>Return nothing. (There is no caption information.)</ol>

   <dt>If the <code id=the-img-element:attr-img-src-9><a href=#attr-img-src>src</a></code> attribute is not set and either the <code id=the-img-element:attr-img-alt-10><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-11><a href=#attr-img-alt>alt</a></code> attribute is not set at all<dd>

    <p>The element <a href=#represents id=the-img-element:represents-7>represents</a> nothing.</p>

   <dt>Otherwise<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-12><a href=#attr-img-alt>alt</a></code> attribute.</p>

   </dl>

  <p>The <code id=the-img-element:attr-img-alt-13><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-14><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-15><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-7><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 id=attr-img-ismap><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-4><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-2><a href=#the-picture-element>picture</a></code> element.</p>

  <p>The <code id=the-img-element:the-img-element-8><a href=#the-img-element>img</a></code> element supports <a href=#dimension-attributes id=the-img-element:dimension-attributes>dimension
  attributes</a>.</p>

  

  <p>The <dfn id=dom-img-alt><code>alt</code></dfn>, <dfn id=dom-img-src><code>src</code></dfn>, <dfn id=dom-img-srcset><code>srcset</code></dfn> and <dfn id=dom-img-sizes><code>sizes</code></dfn> IDL attributes must <a href=#reflect id=the-img-element:reflect>reflect</a> the
  respective content attributes of the same name.</p>

  <p>The <dfn id=dom-img-crossorigin><code>crossOrigin</code></dfn> IDL attribute must
  <a href=#reflect id=the-img-element:reflect-2>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>

  <p>The <dfn id=dom-img-usemap><code>useMap</code></dfn> IDL attribute must
  <a href=#reflect id=the-img-element:reflect-3>reflect</a> the <code id=the-img-element:attr-hyperlink-usemap-5><a href=#attr-hyperlink-usemap>usemap</a></code> content attribute.</p>

  <p>The <dfn id=dom-img-ismap><code>isMap</code></dfn> IDL attribute must <a href=#reflect id=the-img-element:reflect-4>reflect</a>
  the <code id=the-img-element:attr-img-ismap-4><a href=#attr-img-ismap>ismap</a></code> content attribute.</p>

  <p>The <dfn id=dom-img-referrerpolicy><code>referrerPolicy</code></dfn> IDL attribute must
  <a href=#reflect id=the-img-element:reflect-5>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>

  <p>The <dfn id=dom-img-decoding><code>decoding</code></dfn> IDL attribute must
  <a href=#reflect id=the-img-element:reflect-6>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>

  <dl class=domintro><dt><var>image</var> . <code id=dom-img-width-dev><a href=#dom-img-width>width</a></code> [ = <var>value</var> ]<dt><var>image</var> . <code id=dom-img-height-dev><a href=#dom-img-height>height</a></code> [ = <var>value</var> ]<dd>


    <p>These attributes return the actual rendered dimensions of the
    image, or zero if the dimensions are not known.</p>

    <p>They can be set, to change the corresponding content
    attributes.</p>

   <dt><var>image</var> . <code id=dom-img-naturalwidth-dev><a href=#dom-img-naturalwidth>naturalWidth</a></code><dt><var>image</var> . <code id=dom-img-naturalheight-dev><a href=#dom-img-naturalheight>naturalHeight</a></code><dd>


    <p>These attributes return the intrinsic dimensions of the image,
    or zero if the dimensions are not known.</p>

   <dt><var>image</var> . <code id=dom-img-complete-dev><a href=#dom-img-complete>complete</a></code><dd>


    <p>Returns true if the image has been completely downloaded or if
    no image is specified; otherwise, returns false.</p>

   <dt><var>image</var> . <code id=dom-img-currentsrc-dev><a href=#dom-img-currentsrc>currentSrc</a></code><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>

   <dt><var>image</var> . <code id=dom-img-decoding-dev><a href=#dom-img-decoding>decoding</a></code><dd>

     <p>Returns the <a href=#image-decoding-hint id=the-img-element:image-decoding-hint-2>image decoding hint</a> set for this image.</p>

   <dt><var>image</var> . <code id=dom-img-decode-dev><a href=#dom-img-decode>decode</a></code>()<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://heycam.github.io/webidl/#encodingerror data-x-internal=encodingerror>"<code>EncodingError</code>"</a>
    <code id=the-img-element:domexception><a data-x-internal=domexception href=https://heycam.github.io/webidl/#dfn-DOMException>DOMException</a></code> if the image cannot be decoded.</p>

   <dt><var>image</var> = new <code id=dom-image-dev><a href=#dom-image>Image</a></code>( [ <var>width</var> [, <var>height</var> ] ] )<dd>


    <p>Returns a new <code id=the-img-element:the-img-element-9><a href=#the-img-element>img</a></code> element, with the <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 set to the values
    passed in the relevant arguments, if applicable.</p>

   </dl>

  

  <p>The IDL attributes <dfn id=dom-img-width><code>width</code></dfn> and <dfn id=dom-img-height><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>, and
  is being rendered to a visual medium; or else the <a href=#density-corrected-intrinsic-width-and-height id=the-img-element:density-corrected-intrinsic-width-and-height>density-corrected intrinsic 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 id=the-img-element:intrinsic-dimensions href=https://drafts.csswg.org/css2/conform.html#intrinsic data-x-internal=intrinsic-dimensions>intrinsic dimensions</a> and is <i id=the-img-element:img-available-4><a href=#img-available>available</a></i> but not being
  rendered to a visual medium; 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 id=the-img-element:intrinsic-dimensions-2 href=https://drafts.csswg.org/css2/conform.html#intrinsic data-x-internal=intrinsic-dimensions>intrinsic dimensions</a>. <a href=#refsCSS>[CSS]</a></p>

  <p>On setting, they must act as if they <a href=#reflect id=the-img-element:reflect-7>reflected</a> the respective
  content attributes of the same name.</p>

  <p>The IDL attributes <dfn id=dom-img-naturalwidth><code>naturalWidth</code></dfn> and
  <dfn id=dom-img-naturalheight><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-2>density-corrected intrinsic 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 id=the-img-element:intrinsic-dimensions-3 href=https://drafts.csswg.org/css2/conform.html#intrinsic data-x-internal=intrinsic-dimensions>intrinsic dimensions</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><div class=status><input onclick=toggleStatus(this) value=⋰ type=button><p class=support><strong>Support:</strong> img-naturalwidth-naturalheight<span class="and_chr yes"><span>Chrome for Android</span> <span>67+</span></span><span class="chrome yes"><span>Chrome</span> <span>4+</span></span><span class="ios_saf yes"><span>iOS Safari</span> <span>3.2+</span></span><span class="and_uc yes"><span>UC Browser for Android</span> <span>11.8+</span></span><span class="firefox yes"><span>Firefox</span> <span>2+</span></span><span class="ie yes"><span>IE</span> <span>9+</span></span><span class="op_mini yes"><span>Opera Mini</span> <span>all+</span></span><span class="safari yes"><span>Safari</span> <span>3.1+</span></span><span class="edge yes"><span>Edge</span> <span>12+</span></span><span class="samsung yes"><span>Samsung Internet</span> <span>4+</span></span><span class="opera yes"><span>Opera</span> <span>9+</span></span><span class="android yes"><span>Android Browser</span> <span>2.1+</span></span><p class=caniuse>Source: <a href="https://caniuse.com/#feat=img-naturalwidth-naturalheight">caniuse.com</a></div>

  <p>The IDL attribute <dfn id=dom-img-complete><code>complete</code></dfn> must return true if
  any of the following conditions is true:</p>

  <ul class=brief><li>Both the <code id=the-img-element:attr-img-src-10><a href=#attr-img-src>src</a></code> attribute and the <code id=the-img-element:attr-img-srcset-5><a href=#attr-img-srcset>srcset</a></code> attribute are omitted.

   <li>The <code id=the-img-element:attr-img-srcset-6><a href=#attr-img-srcset>srcset</a></code> attribute is omitted and the <code id=the-img-element:attr-img-src-11><a href=#attr-img-src>src</a></code> attribute's value is the empty string. 

   <li>The final <a href=#concept-task id=the-img-element:concept-task>task</a> that is <a href=#queue-a-task id=the-img-element:queue-a-task>queued</a> by the <a href=#networking-task-source id=the-img-element:networking-task-source>networking task source</a> once the resource has been fetched
   has been <a href=#queue-a-task id=the-img-element:queue-a-task-2>queued</a>.

   <li>The <code id=the-img-element:the-img-element-10><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>.

   <li>The <code id=the-img-element:the-img-element-11><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>.

  </ul>

  <p>Otherwise, the attribute must return false.</p>

  <p class=note>The value of <code id=the-img-element:dom-img-complete-2><a href=#dom-img-complete>complete</a></code> can thus change while
  a <a href=#concept-script id=the-img-element:concept-script>script</a> is executing.</p>

  <p>The <dfn id=dom-img-currentsrc><code>currentSrc</code></dfn> IDL attribute
  must return the <code id=the-img-element:the-img-element-12><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>

  <p>The <dfn id=dom-img-decode><code>decode()</code></dfn> method, when invoked, must perform
  the following steps:</p>

  <ol><li><p>Let <var>promise</var> be a new promise.<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>&quot;stars.jpg&quot;</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>If any of the following conditions are true about this <code id=the-img-element:the-img-element-13><a href=#the-img-element>img</a></code> element:</p>

      <ul class=brief><li><p>its <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 an <a href=#active-document id=the-img-element:active-document>active document</a>;<li><p>its <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>,</ul>

      <p>then reject <var>promise</var> with an <a id=the-img-element:encodingerror-2 href=https://heycam.github.io/webidl/#encodingerror data-x-internal=encodingerror>"<code>EncodingError</code>"</a>
      <code id=the-img-element:domexception-2><a data-x-internal=domexception href=https://heycam.github.io/webidl/#dfn-DOMException>DOMException</a></code>.</p>
     <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-14><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 an <a href=#active-document id=the-img-element:active-document-2>active
       document</a><dt>This <code id=the-img-element:the-img-element-15><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>This <code id=the-img-element:the-img-element-16><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><dd>
        <p>Reject <var>promise</var> with an <a id=the-img-element:encodingerror-3 href=https://heycam.github.io/webidl/#encodingerror data-x-internal=encodingerror>"<code>EncodingError</code>"</a>
        <code id=the-img-element:domexception-3><a data-x-internal=domexception href=https://heycam.github.io/webidl/#dfn-DOMException>DOMException</a></code>.</p>
       <dt>This <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-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><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), resolve <var>promise</var> with undefined.</p>

        <p>If decoding fails (for example due to invalid image data), reject <var>promise</var> with
        an <a id=the-img-element:encodingerror-4 href=https://heycam.github.io/webidl/#encodingerror data-x-internal=encodingerror>"<code>EncodingError</code>"</a> <code id=the-img-element:domexception-4><a data-x-internal=domexception href=https://heycam.github.io/webidl/#dfn-DOMException>DOMException</a></code>.</p>

        <p>If the decoding process completes successfully, resolve <var>promise</var> with
        undefined.</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>
       </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>
     </ol>
   <li><p>Return <var>promise</var>.</ol>

  

  <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-18><a href=#the-img-element>img</a></code> element and then displaying it might look like the following:</p>

   <pre><code class='js'><c- kr>const</c-> img <c- o>=</c-> <c- k>new</c-> Image<c- p>();</c->
img<c- p>.</c->src <c- o>=</c-> <c- u>&quot;nebula.jpg&quot;</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>&quot;Could not load the nebula :(&quot;</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- kr>const</c-> img <c- o>=</c-> <c- k>new</c-> Image<c- p>();</c->
img<c- p>.</c->src <c- o>=</c-> <c- u>&quot;nebula.jpg&quot;</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>&quot;Could not load the nebula :(&quot;</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- kr>const</c-> container <c- o>=</c-> document<c- p>.</c->querySelector<c- p>(</c-><c- u>&quot;#container&quot;</c-><c- p>);</c->

<c- kr>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- kr>const</c-> img <c- o>=</c-> <c- k>new</c-> Image<c- p>();</c->
img<c- p>.</c->src <c- o>=</c-> <c- u>&quot;supernova.jpg&quot;</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>

  

  <p>A constructor 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 constructor 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>.<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 id=the-img-element:the-img-element-19><a href=#the-img-element>img</a></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>.<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-3><a href=#attr-dim-width>width</a></code>"
   and <var>width</var>.<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-3><a href=#attr-dim-height>height</a></code>" and <var>height</var>.<li><p>Return <var>img</var>.</ol>

  

  <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-16><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>&quot;carouge.svg&quot;</c-> <c- e>alt</c-><c- o>=</c-><c- s>&quot;&quot;</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>&quot;carouge.svg&quot;</c-> <c- e>alt</c-><c- o>=</c-><c- s>&quot;Carouge&quot;</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>&quot;carouge.svg&quot;</c-> <c- e>alt</c-><c- o>=</c-><c- s>&quot;The coat of arms depicts a lion, sitting in front of a tree.&quot;</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>&quot;carouge.svg&quot;</c-> <c- e>alt</c-><c- o>=</c-><c- s>&quot;&quot;</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>&quot;carouge.svg&quot;</c-> <c- e>alt</c-><c- o>=</c-><c- s>&quot;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.&quot;</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&apos;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>&quot;last-uploaded-coat-of-arms.cgi&quot;</c-> <c- e>title</c-><c- o>=</c-><c- s>&quot;User-uploaded coat of arms.&quot;</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>&quot;fluffy.jpg&quot;</c-> <c- e>alt</c-><c- o>=</c-><c- s>&quot;She likes playing with a ball of yarn.&quot;</c-><c- p>&gt;</c->
 <c- p>&lt;</c-><c- f>p</c-><c- p>&gt;</c->She&apos;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>&quot;fluffy.jpg&quot;</c-> <c- e>alt</c-><c- o>=</c-><c- s>&quot;A cat flying by, chasing a ball of yarn, can be</c->
<c- s> photographed quite nicely using this technique.&quot;</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&apos;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&apos;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>&quot;fluffy.jpg&quot;</c-> <c- e>alt</c-><c- o>=</c-><c- s>&quot;Fluffy, my cat, tends to keep itself busy.&quot;</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>&quot;fluffy.jpg&quot;</c-> <c- e>alt</c-><c- o>=</c-><c- s>&quot;&quot;</c-> <c- e>title</c-><c- o>=</c-><c- s>&quot;Fluffy&quot;</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&apos;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>&quot;/uploads/100-marie-lloyd.jpg&quot;</c-> <c- e>alt</c-><c- o>=</c-><c- s>&quot;&quot;</c-> <c- e>width</c-><c- o>=</c-><c- s>&quot;100&quot;</c-> <c- e>height</c-><c- o>=</c-><c- s>&quot;150&quot;</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>&quot;/wiki/Marie_Lloyd&quot;</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>&quot;/wiki/Music_hall&quot;</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/visuren.html#viewport data-x-internal=viewport>viewport</a> size.</p>

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

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

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

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

     </ul>

   <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/visuren.html#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/visuren.html#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/visuren.html#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>

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

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

   </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.<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.</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<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/visuren.html#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&apos;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>&quot;/uploads/100-marie-lloyd.jpg&quot;</c-></strong>
     <strong><c- e>srcset</c-><c- o>=</c-><c- s>&quot;/uploads/150-marie-lloyd.jpg 1.5x, /uploads/200-marie-lloyd.jpg 2x&quot;</c-></strong>
     <c- e>alt</c-><c- o>=</c-><c- s>&quot;&quot;</c-> <c- e>width</c-><c- o>=</c-><c- s>&quot;100&quot;</c-> <c- e>height</c-><c- o>=</c-><c- s>&quot;150&quot;</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>&quot;/wiki/Marie_Lloyd&quot;</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>&quot;/wiki/Music_hall&quot;</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>

   <dt><a href=#viewport-based-selection id=introduction-3:viewport-based-selection-2>Viewport-based selection</a><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/visuren.html#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>&quot;100vw&quot;</c-> <c- e>srcset</c-><c- o>=</c-><c- s>&quot;wolf-400.jpg 400w, wolf-800.jpg 800w, wolf-1600.jpg 1600w&quot;</c-></strong>
     <c- e>src</c-><c- o>=</c-><c- s>&quot;wolf-400.jpg&quot;</c-> <c- e>alt</c-><c- o>=</c-><c- s>&quot;The rad wolf&quot;</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/visuren.html#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/visuren.html#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>&quot;(max-width: 30em) 100vw, (max-width: 50em) 50vw, calc(33vw - 100px)&quot;</c-></strong>
     <strong><c- e>srcset</c-><c- o>=</c-><c- s>&quot;swing-200.jpg 200w, swing-400.jpg 400w, swing-800.jpg 800w, swing-1600.jpg 1600w&quot;</c-></strong>
     <c- e>src</c-><c- o>=</c-><c- s>&quot;swing-400.jpg&quot;</c-> <c- e>alt</c-><c- o>=</c-><c- s>&quot;Kettlebell Swing&quot;</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></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/visuren.html#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/visuren.html#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/visuren.html#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/visuren.html#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>

   <dt><a href=#art-direction id=introduction-3:art-direction-3>Art direction</a>-based selection<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>&quot;(min-width: 45em)&quot;</c-></strong> <c- e>srcset</c-><c- o>=</c-><c- s>&quot;large.jpg&quot;</c-><c- p>&gt;</c->
  <c- p>&lt;</c-><c- f>source</c-> <strong><c- e>media</c-><c- o>=</c-><c- s>&quot;(min-width: 32em)&quot;</c-></strong> <c- e>srcset</c-><c- o>=</c-><c- s>&quot;med.jpg&quot;</c-><c- p>&gt;</c->
  <c- p>&lt;</c-><c- f>img</c-> <c- e>src</c-><c- o>=</c-><c- s>&quot;small.jpg&quot;</c-> <c- e>alt</c-><c- o>=</c-><c- s>&quot;The wolf runs through the snow.&quot;</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/visuren.html#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>&quot;(max-width: 500px)&quot;</c-> <c- e>srcset</c-><c- o>=</c-><c- s>&quot;banner-phone.jpeg, banner-phone-HD.jpeg 2x&quot;</c-><c- p>&gt;</c->
  <c- p>&lt;</c-><c- f>img</c-> <c- e>src</c-><c- o>=</c-><c- s>&quot;banner.jpeg&quot;</c-> <c- e>srcset</c-><c- o>=</c-><c- s>&quot;banner-HD.jpeg 2x&quot;</c-> <c- e>alt</c-><c- o>=</c-><c- s>&quot;The Breakfast Combo&quot;</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>

   <dt><a href=#image-format-based-selection id=introduction-3:image-format-based-selection>Image format-based selection</a><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&apos;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>&quot;/uploads/100-marie-lloyd.webp&quot;</c-> <strong><c- e>type</c-><c- o>=</c-><c- s>&quot;image/webp&quot;</c-></strong><c- p>&gt;</c->
 <c- p>&lt;</c-><c- f>source</c-> <c- e>srcset</c-><c- o>=</c-><c- s>&quot;/uploads/100-marie-lloyd.jxr&quot;</c-> <strong><c- e>type</c-><c- o>=</c-><c- s>&quot;image/vnd.ms-photo&quot;</c-></strong><c- p>&gt;</c->
 <c- p>&lt;</c-><c- f>img</c-> <c- e>src</c-><c- o>=</c-><c- s>&quot;/uploads/100-marie-lloyd.jpg&quot;</c-> <c- e>alt</c-><c- o>=</c-><c- s>&quot;&quot;</c-> <c- e>width</c-><c- o>=</c-><c- s>&quot;100&quot;</c-> <c- e>height</c-><c- o>=</c-><c- s>&quot;150&quot;</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>&quot;/wiki/Marie_Lloyd&quot;</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>&quot;/wiki/Music_hall&quot;</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>

   </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/visuren.html#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>&quot;a-square.png&quot;</c-> <c- e>media</c-><c- o>=</c-><c- s>&quot;(max-width: 600px)&quot;</c-><c- p>&gt;</c->
  <c- p>&lt;</c-><c- f>img</c-> <c- e>src</c-><c- o>=</c-><c- s>&quot;a-rectangle.png&quot;</c-> <c- e>alt</c-><c- o>=</c-><c- s>&quot;Barney Frank wears a suit and glasses.&quot;</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>&quot;a-square.png&quot;</c-> <c- e>media</c-><c- o>=</c-><c- s>&quot;(max-width: 600px)&quot;</c-><c- p>&gt;</c->
  <c- p>&lt;</c-><c- f>img</c-> <c- e>src</c-><c- o>=</c-><c- s>&quot;a-rectangle.png&quot;</c-> <c- e>alt</c-><c- o>=</c-><c- s>&quot;Barney Frank wears a suit and glasses.&quot;</c-> <c- e>id</c-><c- o>=</c-><c- s>&quot;a&quot;</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 to provide the width and height for
  legacy user agents, using CSS just for the user agents that support <code id=adaptive-images:the-picture-element-2><a href=#the-picture-element>picture</a></code>:</p>

  <pre><code class='html'><c- p>&lt;</c-><c- f>style</c-> <c- e>media</c-><c- o>=</c-><c- s>&quot;(max-width: 600px)&quot;</c-><c- p>&gt;</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>&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>&quot;a-square.png&quot;</c-> <c- e>media</c-><c- o>=</c-><c- s>&quot;(max-width: 600px)&quot;</c-><c- p>&gt;</c->
  <c- p>&lt;</c-><c- f>img</c-> <c- e>src</c-><c- o>=</c-><c- s>&quot;a-rectangle.png&quot;</c-> <c- e>width</c-><c- o>=</c-><c- s>&quot;300&quot;</c-> <c- e>height</c-><c- o>=</c-><c- s>&quot;150&quot;</c->
  <c- e>alt</c-><c- o>=</c-><c- s>&quot;Barney Frank wears a suit and glasses.&quot;</c-> <c- e>id</c-><c- o>=</c-><c- s>&quot;a&quot;</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-2><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-3><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>&quot;pear-mobile.jpeg&quot;</c-> <c- e>media</c-><c- o>=</c-><c- s>&quot;(max-width: 720px)&quot;</c-><c- p>&gt;</c->
 <c- p>&lt;</c-><c- f>source</c-> <c- e>srcset</c-><c- o>=</c-><c- s>&quot;pear-tablet.jpeg&quot;</c-> <c- e>media</c-><c- o>=</c-><c- s>&quot;(max-width: 1280px)&quot;</c-><c- p>&gt;</c->
 <c- p>&lt;</c-><c- f>img</c-> <c- e>src</c-><c- o>=</c-><c- s>&quot;pear-desktop.jpeg&quot;</c-> <c- e>alt</c-><c- o>=</c-><c- s>&quot;The pear is juicy.&quot;</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><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>&quot;pear-mobile.jpeg&quot;</c-> <c- e>media</c-><c- o>=</c-><c- s>&quot;(max-width: 720px)&quot;</c-><c- p>&gt;</c->
 <c- p>&lt;</c-><c- f>source</c-> <c- e>srcset</c-><c- o>=</c-><c- s>&quot;pear-tablet.jpeg&quot;</c-> <c- e>media</c-><c- o>=</c-><c- s>&quot;(max-width: 1280px)&quot;</c-><c- p>&gt;</c->
 <c- p>&lt;</c-><c- f>source</c-> <c- e>srcset</c-><c- o>=</c-><c- s>&quot;pear-desktop.jpeg&quot;</c-><c- p>&gt;</c->
 <c- p>&lt;</c-><c- f>img</c-> <c- e>src</c-><c- o>=</c-><c- s>&quot;pear-mobile.jpeg&quot;</c-> <c- e>alt</c-><c- o>=</c-><c- s>&quot;The pear is juicy.&quot;</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-4><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>&quot;pear-mobile.jpeg&quot;</c-> <c- e>media</c-><c- o>=</c-><c- s>&quot;(max-width: 720px)&quot;</c-><c- p>&gt;</c->
 <c- p>&lt;</c-><c- f>source</c-> <c- e>srcset</c-><c- o>=</c-><c- s>&quot;pear-tablet.jpeg&quot;</c-> <c- e>media</c-><c- o>=</c-><c- s>&quot;(max-width: 1280px)&quot;</c-><c- p>&gt;</c->
 <c- p>&lt;</c-><c- f>source</c-> <c- e>srcset</c-><c- o>=</c-><c- s>&quot;pear-desktop.jpeg&quot;</c-><c- p>&gt;</c->
 <c- p>&lt;</c-><c- f>img</c-> <c- e>src</c-><c- o>=</c-><c- s>&quot;pear-tablet.jpeg&quot;</c-> <c- e>alt</c-><c- o>=</c-><c- s>&quot;The pear is juicy.&quot;</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/visuren.html#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>&quot;pear-desktop.jpeg&quot;</c-> <c- e>media</c-><c- o>=</c-><c- s>&quot;(min-width: 1281px)&quot;</c-><c- p>&gt;</c->
 <c- p>&lt;</c-><c- f>source</c-> <c- e>srcset</c-><c- o>=</c-><c- s>&quot;pear-tablet.jpeg&quot;</c-> <c- e>media</c-><c- o>=</c-><c- s>&quot;(min-width: 721px)&quot;</c-><c- p>&gt;</c->
 <c- p>&lt;</c-><c- f>img</c-> <c- e>src</c-><c- o>=</c-><c- s>&quot;pear-mobile.jpeg&quot;</c-> <c- e>alt</c-><c- o>=</c-><c- s>&quot;The pear is juicy.&quot;</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> and <code id=attributes-common-to-source-and-img-elements:the-img-element><a href=#the-img-element>img</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>

  <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>.<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.<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>.<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.<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.</ul>

   <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>.</ol>

  <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 href=#intrinsic-width id=srcset-attributes:intrinsic-width>intrinsic 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 an <a href=#intrinsic-width id=srcset-attributes:intrinsic-width-2>intrinsic width</a>.</p>

  <p>If an element has a <a href=#srcset-attribute id=srcset-attributes:srcset-attribute>srcset 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>

  <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'><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'><c- p>&lt;</c-><c- f>source-size</c-><c- p>&gt;</c-></dfn> = <a href='https://drafts.csswg.org/mediaqueries/#typedef-media-condition' data-x-internal='media-condition' id='sizes-attributes: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>
<dfn id='source-size-value'><c- p>&lt;</c-><c- f>source-size-value</c-><c- p>&gt;</c-></dfn> = <a href='https://drafts.csswg.org/css-values/#lengths' data-x-internal='length' id='sizes-attributes:length'><c- p>&lt;</c-><c- f>length</c-><c- p>&gt;</c-></a></code></pre>

  <p>A <a href=#source-size-value id=sizes-attributes:source-size-value-3>&lt;source-size-value></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>

  <p>The <a href=#source-size-value id=sizes-attributes:source-size-value-4>&lt;source-size-value></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></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></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/visuren.html#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>

  <p>The <a href=#task-source id=images-processing-model:task-source>task source</a> for the <a href=#concept-task id=images-processing-model:concept-task>tasks</a> <a href=#queue-a-task id=images-processing-model:queue-a-task>queued</a> by algorithms in this section is the <a href=#dom-manipulation-task-source id=images-processing-model:dom-manipulation-task-source>DOM manipulation
  task source</a>.</p>

  <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>image request</dfn> has a <dfn id=img-req-state>state</dfn>, <dfn id=img-req-url>current URL</dfn>, and <dfn id=img-req-data>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><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.<dt><dfn id=img-inc>Partially available</dfn><dd>The user agent has obtained some of the image data and at least the image dimensions are
   available.<dt><dfn id=img-all>Completely available</dfn><dd>The user agent has obtained all of the image data and at least the image dimensions are
   available.<dt><dfn id=img-error>Broken</dfn><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).</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>

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

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

  <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 intrinsic 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 intrinsic height</a>
  (if any), and whose appearance is the intrinsic appearance of the image.</p>

  <hr>

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

  <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 undefined.</p>

  <p>When an <code id=images-processing-model:the-img-element-8><a href=#the-img-element>img</a></code> element has a <a href=#current-pixel-density id=images-processing-model:current-pixel-density>current pixel density</a> that is not 1.0, the
  element's image data must be treated as if its resolution, in device pixels per <a href=https://drafts.csswg.org/css-values/#px id="images-processing-model:'px'" data-x-internal="'px'">CSS pixels</a>, was the <a href=#current-pixel-density id=images-processing-model:current-pixel-density-2>current pixel density</a>. The image's
  <dfn id=density-corrected-intrinsic-width-and-height>density-corrected intrinsic width and height</dfn> are the <a href=https://drafts.csswg.org/css2/conform.html#intrinsic id=images-processing-model:intrinsic-dimensions data-x-internal=intrinsic-dimensions>intrinsic width and height</a> after taking into account the <a href=#current-pixel-density id=images-processing-model:current-pixel-density-3>current pixel
  density</a>.</p>

  <p class=example>For example, if the <a href=#current-pixel-density id=images-processing-model:current-pixel-density-4>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 id=images-processing-model:intrinsic-dimensions-2 href=https://drafts.csswg.org/css2/conform.html#intrinsic data-x-internal=intrinsic-dimensions>intrinsic dimensions</a> of 96 <a href=https://drafts.csswg.org/css-values/#px id="images-processing-model:'px'-2" data-x-internal="'px'">CSS
  pixels</a> by 192 <a href=https://drafts.csswg.org/css-values/#px id="images-processing-model:'px'-3" data-x-internal="'px'">CSS pixels</a>.</p>

  <p>An <code id=images-processing-model:the-img-element-9><a href=#the-img-element>img</a></code> element is 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></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/visuren.html#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/visuren.html#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>In a <a href=#browsing-context id=when-to-obtain-images:browsing-context>browsing context</a> where <a href=#concept-bc-noscript id=when-to-obtain-images:concept-bc-noscript>scripting is
  disabled</a>, user agents may obtain images immediately or on demand. In a <a href=#browsing-context id=when-to-obtain-images:browsing-context-2>browsing
  context</a> where <a href=#concept-bc-noscript id=when-to-obtain-images:concept-bc-noscript-2>scripting is enabled</a>, user agents
  must obtain images immediately.</p>

  <p>A user agent that obtains images immediately must synchronously
  <a href=#update-the-image-data id=when-to-obtain-images:update-the-image-data>update the image data</a> of an <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>

  <p>A user agent that obtains images on demand 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>


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

  <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.<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.<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.<li><p>The <a href=#nodes-are-inserted id=reacting-to-dom-mutations:nodes-are-inserted>element is inserted</a> into or
   <a href=#nodes-are-removed id=reacting-to-dom-mutations:nodes-are-removed>removed</a> from a <code id=reacting-to-dom-mutations:the-picture-element><a href=#the-picture-element>picture</a></code> parent element.<li><p>The element's parent is a <code id=reacting-to-dom-mutations:the-picture-element-2><a href=#the-picture-element>picture</a></code> element and a <code id=reacting-to-dom-mutations:the-source-element><a href=#the-source-element>source</a></code> <a href=#nodes-are-inserted id=reacting-to-dom-mutations:nodes-are-inserted-2>element is inserted</a> as a previous sibling.<li><p>The element's parent is a <code id=reacting-to-dom-mutations:the-picture-element-3><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 was a previous sibling is <a href=#nodes-are-removed id=reacting-to-dom-mutations:nodes-are-removed-2>removed</a>.<li><p>The element's parent is a <code id=reacting-to-dom-mutations:the-picture-element-4><a href=#the-picture-element>picture</a></code> element and a <code id=reacting-to-dom-mutations:the-source-element-3><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>, or <code id=reacting-to-dom-mutations:attr-source-type><a href=#attr-source-type>type</a></code> attributes set, changed, or removed.<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.</ul>


  <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://tools.ietf.org/html/rfc7234#section-5.2>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 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>State
     <th>Description
   <tbody><tr><td><dfn id=attr-img-decoding-sync><code>sync</code></dfn>
     <td><dfn id=attr-img-decoding-sync-state>Sync</dfn>
     <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.
    <tr><td><dfn id=attr-img-decoding-async><code>async</code></dfn>
     <td><dfn id=attr-img-decoding-async-state>Async</dfn>
     <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.
    <tr><td><dfn id=attr-img-decoding-auto><code>auto</code></dfn>
     <td><dfn id=attr-img-decoding-auto-state>Auto</dfn>
     <td>Indicates no preference in decoding mode (the default).
  </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>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,
  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 the <a href=#active-document id=updating-the-image-data:active-document>active document</a>,
    then:</p>

    <ol><li><p>Continue running this algorithm <a href=#in-parallel id=updating-the-image-data:in-parallel>in parallel</a>.<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 the <a href=#active-document id=updating-the-image-data:active-document-2>active document</a>.<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.<li><p><a href=#queue-a-microtask id=updating-the-image-data:queue-a-microtask>Queue a microtask</a> to continue this algorithm.</ol>
   <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 <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 <a href=#pending-request id=updating-the-image-data:pending-request-2>pending request</a> to null, and
   return.<li><p>Let <var>selected source</var> be null and <var>selected pixel density</var> be undefined.

   <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.<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>.<li>
    <p>If <var>selected source</var> is not null, then:</p>

    <ol><li><p><a href=#parse-a-url id=updating-the-image-data:parse-a-url>Parse</a> <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>. If that is not successful, then abort this inner set of
     steps. Otherwise, let <var>urlString</var> be the <a href=#resulting-url-string id=updating-the-image-data:resulting-url-string>resulting URL string</a>.<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=#concept-origin id=updating-the-image-data:concept-origin>origin</a>.<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.<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-3>current request</a> and the
       <a href=#pending-request id=updating-the-image-data:pending-request-3>pending request</a>.<li><p>Set <a href=#pending-request id=updating-the-image-data:pending-request-4>pending request</a> to null.<li><p>Let <a href=#current-request id=updating-the-image-data:current-request-4>current request</a> be 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>.<li><p>Update the presentation of the image appropriately.<li><p>Set <a href=#current-request id=updating-the-image-data:current-request-5>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>.<li>
        <p><a href=#queue-a-task id=updating-the-image-data:queue-a-task>Queue a task</a> to:</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>.<li><p>Set <a href=#current-request id=updating-the-image-data:current-request-6>current request</a>'s <a href=#img-req-url id=updating-the-image-data:img-req-url>current URL</a> to
         <var>urlString</var>.<li><p><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-4><a href=#the-img-element>img</a></code> element.</ol>
       <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.</ol>
     </ol>
   <li><p><a href=#await-a-stable-state id=updating-the-image-data:await-a-stable-state>Await a stable state</a>, allowing the <a href=#concept-task id=updating-the-image-data:concept-task>task</a> that invoked this algorithm to continue.
   The <a href=#synchronous-section id=updating-the-image-data:synchronous-section>synchronous
   section</a> consists of all the remaining steps of this algorithm until the algorithm says the
   <a href=#synchronous-section id=updating-the-image-data:synchronous-section-2>synchronous section</a> has ended. (Steps in <a href=#synchronous-section id=updating-the-image-data:synchronous-section-3>synchronous sections</a> are marked with ⌛.)<li>
    <p>⌛ If another instance of this algorithm for this <code id=updating-the-image-data:the-img-element-5><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><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.<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-7>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-8>current request</a> and the <a href=#pending-request id=updating-the-image-data:pending-request-5>pending request</a>,
     and set <a href=#pending-request id=updating-the-image-data:pending-request-6>pending request</a> to null.<li><p>⌛ <a href=#queue-a-task id=updating-the-image-data:queue-a-task-2>Queue a task</a> to change the <a href=#current-request id=updating-the-image-data:current-request-9>current request</a>'s <a href=#img-req-url id=updating-the-image-data:img-req-url-2>current URL</a> to the empty string, and then, if 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>, <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-6><a href=#the-img-element>img</a></code> element.<li><p>⌛ Return.</ol>
   <li><p>⌛ <a href=#queue-a-task id=updating-the-image-data:queue-a-task-3>Queue a task</a> to <a id=updating-the-image-data:fire-a-progress-event href=https://xhr.spec.whatwg.org/#concept-event-fire-progress data-x-internal=fire-a-progress-event>fire a progress event</a> named <code id=updating-the-image-data:event-loadstart><a href=#event-loadstart>loadstart</a></code> at the <code id=updating-the-image-data:the-img-element-7><a href=#the-img-element>img</a></code> element.<li>
    <p>⌛ <a href=#parse-a-url id=updating-the-image-data:parse-a-url-2>Parse</a> <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>, and let <var>urlString</var> be the <a href=#resulting-url-string id=updating-the-image-data:resulting-url-string-2>resulting URL
    string</a>. If that is not successful, 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-10>current request</a> and
     the <a href=#pending-request id=updating-the-image-data:pending-request-7>pending request</a>.<li><p>⌛ Set the <a href=#current-request id=updating-the-image-data:current-request-11>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>.<li><p>⌛ Set <a href=#pending-request id=updating-the-image-data:pending-request-8>pending request</a> to null.<li><p>⌛ <a href=#queue-a-task id=updating-the-image-data:queue-a-task-4>Queue a task</a> to change the <a href=#current-request id=updating-the-image-data:current-request-12>current request</a>'s <a href=#img-req-url id=updating-the-image-data:img-req-url-3>current URL</a> to <var>selected source</var>, <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-8><a href=#the-img-element>img</a></code> element and then <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-loadend><a href=#event-loadend>loadend</a></code> at the <code id=updating-the-image-data:the-img-element-9><a href=#the-img-element>img</a></code> element.<li><p>⌛ Return.</ol>
   <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-4>current URL</a>, then
   return.<li><p>⌛ If <var>urlString</var> is the same as 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-5>current URL</a> and <a href=#current-request id=updating-the-image-data:current-request-14>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-a-task id=updating-the-image-data:queue-a-task-5>queue a
   task</a> 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.<li><p>⌛ If the <a href=#pending-request id=updating-the-image-data:pending-request-12>pending request</a> is not null, then <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-13>pending request</a>.<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-6>current URL</a> is <var>urlString</var>.<li><p>⌛ If <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-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-16>current request</a> to <var>image request</var>. Otherwise, set the <a href=#pending-request id=updating-the-image-data:pending-request-14>pending
   request</a> to <var>image request</var>.<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.<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>.<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>".<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.<li>
    
    <p>⌛ <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>. Let this 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 be associated with <var>image
    request</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 <a href=#concept-origin id=updating-the-image-data:concept-origin-2>origin</a> of the image itself (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>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-6>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-3>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>

    <p>If the resource is <a href=#cors-same-origin id=updating-the-image-data:cors-same-origin-2>CORS-same-origin</a>, each <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-7>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, if <var>image request</var> is the <a href=#current-request id=updating-the-image-data:current-request-17>current
    request</a>, must <a id=updating-the-image-data:fire-a-progress-event-2 href=https://xhr.spec.whatwg.org/#concept-event-fire-progress data-x-internal=fire-a-progress-event>fire a progress event</a> named <code id=updating-the-image-data:event-progress><a href=#event-progress>progress</a></code> at the <code id=updating-the-image-data:the-img-element-10><a href=#the-img-element>img</a></code> element.</p>
   <li><p>End the <a href=#synchronous-section id=updating-the-image-data:synchronous-section-4>synchronous section</a>, continuing the remaining steps <a href=#in-parallel id=updating-the-image-data:in-parallel-2>in
   parallel</a>, but without missing any data from fetching.<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><dd>

      <p>The next <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-8>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 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-15>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>,
        <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><p>Otherwise, if <var>image request</var> is the <a href=#pending-request id=updating-the-image-data:pending-request-16>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>.<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>.<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>
       </ol>

      <p>Each <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-9>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 update the presentation of the image, but as each new body part comes in, it must
      replace the previous image. Once one body part has been completely decoded, the user agent
      must set the <code id=updating-the-image-data:the-img-element-11><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> and
      <a href=#queue-a-task id=updating-the-image-data:queue-a-task-10>queue a task</a> to <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-load-2><a href=#event-load>load</a></code> at the <code id=updating-the-image-data:the-img-element-12><a href=#the-img-element>img</a></code> element.</p>
      

      <p class=note>The <code id=updating-the-image-data:event-progress-2><a href=#event-progress>progress</a></code> and <code id=updating-the-image-data:event-loadend-2><a href=#event-loadend>loadend</a></code> events are not fired for
      <code id=updating-the-image-data:multipart/x-mixed-replace-2><a href=#multipart/x-mixed-replace>multipart/x-mixed-replace</a></code> image streams.</p>

     <dt>If the resource type and data corresponds to a supported image format, <a href=#img-determine-type>as described below</a><dd>

      <p>The next <a href=#concept-task id=updating-the-image-data:concept-task-6>task</a> that is <a href=#queue-a-task id=updating-the-image-data:queue-a-task-11>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 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 <a href=#pending-request id=updating-the-image-data:pending-request-17>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>.<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 <a href=#current-request id=updating-the-image-data:current-request-26>current request</a>, update the
       <code id=updating-the-image-data:the-img-element-13><a href=#the-img-element>img</a></code> element's presentation appropriately 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>.<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 <a href=#pending-request id=updating-the-image-data:pending-request-18>pending request</a>, <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-19>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-3>upgrade the pending request to the current request</a>, set <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>, <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-3><a href=#event-error>error</a></code> at the <code id=updating-the-image-data:the-img-element-14><a href=#the-img-element>img</a></code> element, <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-loadend-3><a href=#event-loadend>loadend</a></code> at the <code id=updating-the-image-data:the-img-element-15><a href=#the-img-element>img</a></code> element.<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 <a href=#current-request id=updating-the-image-data:current-request-29>current request</a>, <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>, <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-4><a href=#event-error>error</a></code> at the <code id=updating-the-image-data:the-img-element-16><a href=#the-img-element>img</a></code> element,
        <a href=https://dom.spec.whatwg.org/#concept-event-fire id=updating-the-image-data:concept-event-fire-9 data-x-internal=concept-event-fire>fire an event</a> named <code id=updating-the-image-data:event-loadend-4><a href=#event-loadend>loadend</a></code> at the <code id=updating-the-image-data:the-img-element-17><a href=#the-img-element>img</a></code> element.</p>

       </ol>

      <p id=img-load>That <a href=#concept-task id=updating-the-image-data:concept-task-7>task</a>, and each subsequent <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-12>queued</a> by the
      <a href=#networking-task-source id=updating-the-image-data:networking-task-source-6>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-9>task</a> that is <a href=#queue-a-task id=updating-the-image-data:queue-a-task-13>queued</a> by the <a href=#networking-task-source id=updating-the-image-data:networking-task-source-7>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-20>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
       update the <code id=updating-the-image-data:the-img-element-18><a href=#the-img-element>img</a></code> element's presentation appropriately.<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.<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.<li><p><a href=#fire-a-progress-event-or-event id=updating-the-image-data:fire-a-progress-event-or-event>Fire a progress event or 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-19><a href=#the-img-element>img</a></code> element, depending on the resource in <var>image request</var>.<li><p><a href=#fire-a-progress-event-or-event id=updating-the-image-data:fire-a-progress-event-or-event-2>Fire a progress event or event</a> named <code id=updating-the-image-data:event-loadend-5><a href=#event-loadend>loadend</a></code>
       at the <code id=updating-the-image-data:the-img-element-20><a href=#the-img-element>img</a></code> element, depending on the resource in <var>image request</var>.</ol>

     <dt>Otherwise<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-21>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-22>pending request</a>, and
     then <a href=#queue-a-task id=updating-the-image-data:queue-a-task-14>queue a task</a> to first <a href=https://dom.spec.whatwg.org/#concept-event-fire id=updating-the-image-data:concept-event-fire-10 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-21><a href=#the-img-element>img</a></code> element and then <a href=https://dom.spec.whatwg.org/#concept-event-fire id=updating-the-image-data:concept-event-fire-11 data-x-internal=concept-event-fire>fire an event</a> named <code id=updating-the-image-data:event-loadend-6><a href=#event-loadend>loadend</a></code> at the <code id=updating-the-image-data:the-img-element-22><a href=#the-img-element>img</a></code> element.</dl>
   </ol>

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

  <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> <var>image request</var> means to run the following steps:</p>

  <ol><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.<li><p>Abort any instance of the <a href=https://fetch.spec.whatwg.org/#concept-fetch id=updating-the-image-data:concept-fetch-3 data-x-internal=concept-fetch>fetching</a> algorithm for
   <var>image request</var>, discarding any pending tasks generated by that algorithm.</ol>

  <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-23><a href=#the-img-element>img</a></code> element means to run the following steps:</p>

  <ol><li><p>Let the <code id=updating-the-image-data:the-img-element-24><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> be the <a href=#pending-request id=updating-the-image-data:pending-request-23>pending request</a>.<li><p>Let the <code id=updating-the-image-data:the-img-element-25><a href=#the-img-element>img</a></code> element's <a href=#pending-request id=updating-the-image-data:pending-request-24>pending request</a> be null.</ol>

  <p>To <dfn id=fire-a-progress-event-or-event>fire a progress event or event</dfn> named <var>type</var> at an element <var>e</var>,
  depending on resource <var>r</var>, means to <a id=updating-the-image-data:fire-a-progress-event-3 href=https://xhr.spec.whatwg.org/#concept-event-fire-progress data-x-internal=fire-a-progress-event>fire a progress event</a> named
  <var>type</var> at <var>e</var> if <var>r</var> is <a href=#cors-same-origin id=updating-the-image-data:cors-same-origin-3>CORS-same-origin</a>, and otherwise
  <a href=https://dom.spec.whatwg.org/#concept-event-fire id=updating-the-image-data:concept-event-fire-12 data-x-internal=concept-event-fire>fire an event</a> named <var>type</var> at <var>e</var>.</p>


  <h6 id=selecting-an-image-source><span class=secno>4.8.4.3.6</span> Selecting an image source<a href=#selecting-an-image-source class=self-link></a></h6>

  <p>When asked to <dfn id=select-an-image-source>select an image source</dfn> for a given <code id=selecting-an-image-source:the-img-element><a href=#the-img-element>img</a></code> element <var>el</var>,
  user agents must do the following:</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>.<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.<li><p>Otherwise, take <var>el</var>'s <a href=#source-set id=selecting-an-image-source:source-set-2>source set</a>
   and let it be <var>source set</var>.<li><p>If an entry <var>b</var> in <var>source set</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>source set</var>, then remove
   entry <var>b</var>. Repeat this step until none of the entries in <var>source set</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.<li><p>In a user agent-specific manner,
   choose one <a href=#image-source id=selecting-an-image-source:image-source>image source</a> from <var>source set</var>.
   Let this be <var>selected source</var>.<li><p>Return <var>selected source</var> and its associated pixel density.</ol>


  <h6 id=updating-the-source-set><span class=secno>4.8.4.3.7</span> Updating the source set<a href=#updating-the-source-set class=self-link></a></h6>

  <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> 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>.<li><p>If <var>el</var> has a parent node and that is a <code id=updating-the-source-set:the-picture-element><a href=#the-picture-element>picture</a></code> element,
   let <var>elements</var> be an array containing <var>el</var>'s parent node's child elements, retaining relative order.
   Otherwise, let <var>elements</var> be array containing only <var>el</var>.<li><p>If <var>el</var> has a <code id=updating-the-source-set:attr-dim-width><a href=#attr-dim-width>width</a></code> attribute, and parsing
   that attribute's value using the <a href=#rules-for-parsing-dimension-values id=updating-the-source-set:rules-for-parsing-dimension-values>rules for parsing dimension values</a> doesn't generate
   an error or a percentage value, then let <var>width</var> be the returned integer value.
   Otherwise, let <var>width</var> be null.<li>

    <p>Iterate through <var>elements</var>,
    doing the following for each item <var>child</var>:</p>

    <ol><li>

      <p>If <var>child</var> is <var>el</var>:</p>

      <ol><li><p>If <var>child</var> has a <code id=updating-the-source-set:attr-img-srcset><a href=#attr-img-srcset>srcset</a></code> attribute,
       <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 the returned <a href=#source-set id=updating-the-source-set:source-set-3>source set</a> be <var>source set</var>.
       Otherwise, let <var>source set</var> be an empty <a href=#source-set id=updating-the-source-set:source-set-4>source set</a>.<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 the fallback width <var>width</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.<li><p>If <var>child</var> has a <code id=updating-the-source-set:attr-img-src><a href=#attr-img-src>src</a></code> attribute
       whose value is not the empty string
       and <var>source set</var> does not contain an
       <a href=#image-source id=updating-the-source-set:image-source>image source</a> with a <a href=#pixel-density-descriptor id=updating-the-source-set:pixel-density-descriptor>pixel density descriptor</a> value of 1,
       and no <a href=#image-source id=updating-the-source-set:image-source-2>image source</a> with a <a href=#width-descriptor id=updating-the-source-set:width-descriptor>width descriptor</a>,
       append <var>child</var>'s <code id=updating-the-source-set:attr-img-src-2><a href=#attr-img-src>src</a></code> attribute value to <var>source set</var>.<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>.<li><p>Let <var>el</var>'s <a href=#source-set id=updating-the-source-set:source-set-5>source set</a> be <var>source set</var>.<li><p>Return.</ol>

     <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, continue to the next child.
     Otherwise, <var>child</var> is a <code id=updating-the-source-set:the-source-element-2><a href=#the-source-element>source</a></code> element.<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, continue to the next child.<li><p><a href=#parse-a-srcset-attribute id=updating-the-source-set:parse-a-srcset-attribute-2>Parse <var>child</var>'s srcset attribute</a> and
     let the returned <a href=#source-set id=updating-the-source-set:source-set-6>source set</a> be <var>source set</var>.<li><p>If <var>source set</var> has zero <a href=#image-source id=updating-the-source-set:image-source-3>image sources</a>,
     continue to the next child.<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>,
     continue to the next child.<li><p><a href=#parse-a-sizes-attribute id=updating-the-source-set:parse-a-sizes-attribute-2>Parse <var>child</var>'s sizes attribute</a>
     with the fallback width <var>width</var>, and let <var>source set</var>'s <a href=#source-size-2 id=updating-the-source-set:source-size-2-2>source
     size</a> be the returned value.<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>, continue to the next child.<li><p><a href=#normalise-the-source-densities id=updating-the-source-set:normalise-the-source-densities-2>Normalize the source densities</a> of <var>source set</var>.<li><p>Let <var>el</var>'s <a href=#source-set id=updating-the-source-set:source-set-7>source set</a> be <var>source set</var>.<li><p>Return.</ol>

   </ol>

  <p class=note>Each <code id=updating-the-source-set:the-img-element-2><a href=#the-img-element>img</a></code> element independently considers its previous sibling
  <code id=updating-the-source-set:the-source-element-3><a href=#the-source-element>source</a></code> elements plus the <code id=updating-the-source-set:the-img-element-3><a href=#the-img-element>img</a></code> element itself for selecting an <a href=#image-source id=updating-the-source-set:image-source-4>image
  source</a>, ignoring any other (invalid) elements, including other <code id=updating-the-source-set:the-img-element-4><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-4><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-5><a href=#the-img-element>img</a></code> element.</p>


  <h6 id=parsing-a-srcset-attribute><span class=secno>4.8.4.3.8</span> Parsing a srcset attribute<a href=#parsing-a-srcset-attribute class=self-link></a></h6>

  <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.<li><p>Let <var>position</var> be a pointer into <var>input</var>,
   initially pointing at the start of the string.<li><p>Let <var>candidates</var> be an initially empty <a href=#source-set id=parsing-a-srcset-attribute:source-set>source set</a>.<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>.<li><p>If <var>position</var> is past the end of <var>input</var>,
   return <var>candidates</var>.<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 that be <var>url</var>.<li><p>Let <var>descriptors</var> be a new empty list.<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>.</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>.<li><p>Let <var>current descriptor</var> be the empty string.<li><p>Let <var>state</var> be <i>in descriptor</i>.<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><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><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>.<dt>U+002C COMMA (,)<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>.<dt>U+0028 LEFT PARENTHESIS (()<dd><p>Append <var>c</var> to <var>current descriptor</var>.
         Set <var>state</var> to <i>in parens</i>.<dt>EOF<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>.<dt>Anything else<dd><p>Append <var>c</var> to <var>current descriptor</var>.</dl>

       <dt><i>In parens</i><dd>

        <p>Do the following, depending on the value of <var>c</var>:</p>

        <dl class=switch><dt>U+0029 RIGHT PARENTHESIS ())<dd><p>Append <var>c</var> to <var>current descriptor</var>.
         Set <var>state</var> to <i>in descriptor</i>.<dt>EOF<dd><p>Append <var>current descriptor</var> to <var>descriptors</var>.
         Jump to the step labeled <i>descriptor parser</i>.<dt>Anything else<dd><p>Append <var>c</var> to <var>current descriptor</var>.</dl>

       <dt><i>After descriptor</i><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><dd><p>Stay in this state.<dt>EOF<dd><p>Jump to the step labeled <i>descriptor parser</i>.<dt>Anything else<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>.</dl>

       </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>

     </ol>

   <li><p><i>Descriptor parser</i>: Let <var>error</var> be <i>no</i>.<li><p>Let <var>width</var> be <i>absent</i>.<li><p>Let <var>density</var> be <i>absent</i>.<li><p>Let <var>future-compat-h</var> be <i>absent</i>.<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<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><p>If <var>width</var> and <var>density</var>
       are not both <i>absent</i>,
       then let <var>error</var> be <i>yes</i>.<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 zero, let <var>error</var> be <i>yes</i>.
       Otherwise, let <var>width</var> be the result.</ol>

     <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<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>.<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 zero, 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 zero,
        the <a id=parsing-a-srcset-attribute:intrinsic-dimensions href=https://drafts.csswg.org/css2/conform.html#intrinsic data-x-internal=intrinsic-dimensions>intrinsic dimensions</a> will be infinite.
        User agents are expected to have limits in how big images can be rendered,
        which is allowed by the <a href=#hardwareLimitations>hardware limitations</a> clause.</p>

       </ol>

     <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<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>.<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 zero, let <var>error</var> be <i>yes</i>.
       Otherwise, let <var>future-compat-h</var> be the result.</ol>

     <dt>Anything else<dd><p>Let <var>error</var> be <i>yes</i>.</dl>

   <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>.<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>.<li><p>Return to the step labeled <i>splitting loop</i>.</ol>


  <h6 id=parsing-a-sizes-attribute><span class=secno>4.8.4.3.9</span> Parsing a sizes attribute<a href=#parsing-a-sizes-attribute class=self-link></a></h6>

  <p>When asked to <dfn id=parse-a-sizes-attribute>parse a sizes attribute</dfn> from an element, with a fallback width
  <var>width</var>, <a id=parsing-a-sizes-attribute:parse-a-comma-separated-list-of-component-values href=https://drafts.csswg.org/css-syntax/#parse-a-comma-separated-list-of-component-values data-x-internal=parse-a-comma-separated-list-of-component-values>parse a comma-separated list of component values</a> from the value of
  the element's <a href=#sizes-attribute id=parsing-a-sizes-attribute:sizes-attribute>sizes attribute</a> (or the empty string, if the attribute is
  absent), and let <var>unparsed sizes list</var> be the result. <a href=#refsCSSSYNTAX>[CSSSYNTAX]</a></p>

  <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></a>s
   from the end of <var>unparsed size</var>.
   If <var>unparsed size</var> is now empty,
   that is a <a href=#concept-microsyntax-parse-error id=parsing-a-sizes-attribute:concept-microsyntax-parse-error>parse error</a>;
   continue to the next iteration of this algorithm.<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></a>,
   let <var>size</var> be 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>;
   continue to the next iteration of this algorithm.<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></a>s
   from the end of <var>unparsed size</var>.
   If <var>unparsed size</var> is now empty,
   return <var>size</var> and exit this algorithm.
   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>.<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></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></a> evaluates to false,
   continue to the next iteration of this algorithm. <a href=#refsMQ>[MQ]</a><li><p>Return <var>size</var> and exit this algorithm.</ol>

  <p>If the above algorithm exhausts <var>unparsed sizes list</var> without returning a
  <var>size</var> value, follow these steps:</p>

  <ol><li><p>If <var>width</var> is not null, return a <a id=parsing-a-sizes-attribute:length href=https://drafts.csswg.org/css-values/#lengths data-x-internal=length>&lt;length></a> with the value
   <var>width</var> and the unit <a id="parsing-a-sizes-attribute:'px'" href=https://drafts.csswg.org/css-values/#px data-x-internal="'px'">'px'</a>.<li><p>Return <code>100vw</code>.</ol>

  <p class=note>While a <a href=#valid-source-size-list id=parsing-a-sizes-attribute:valid-source-size-list>valid source size list</a> only contains a bare <a href=#source-size-value id=parsing-a-sizes-attribute:source-size-value-2>&lt;source-size-value></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></a>)
  as the last entry in the <a href=#source-size-list id=parsing-a-sizes-attribute:source-size-list>&lt;source-size-list></a>,
  the parsing algorithm technically allows such at any point in the list,
  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.</p>


  <h6 id=normalizing-the-source-densities><span class=secno>4.8.4.3.10</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>

  <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>.<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>, continue to the next
     <a href=#image-source id=normalizing-the-source-densities:image-source-5>image source</a>.<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 the <a href=#source-size-2 id=normalizing-the-source-densities:source-size-2-2>source size</a> 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-3>source size</a> is zero,
      the density would be infinity,
      which results in the <a id=normalizing-the-source-densities:intrinsic-dimensions href=https://drafts.csswg.org/css2/conform.html#intrinsic data-x-internal=intrinsic-dimensions>intrinsic dimensions</a> being zero by zero.</p>

     <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>.</ol>

   </ol>


  <h6 id=reacting-to-environment-changes><span class=secno>4.8.4.3.11</span> Reacting to environment changes<a href=#reacting-to-environment-changes class=self-link></a></h6>

  <p id=img-environment-changes>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 react to changes in the environment. (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/visuren.html#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 intrinsic width and height</a> match the
  new <a id=reacting-to-environment-changes:viewport-2 href=https://drafts.csswg.org/css2/visuren.html#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 ⌛.)<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 the <a href=#active-document id=reacting-to-environment-changes:active-document>active
   document</a>, 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
   the <a href=#pending-request id=reacting-to-environment-changes:pending-request>pending request</a> is not null, then return.<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.<li><p>⌛ If <var>selected source</var> is null, then return.<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.<li><p>⌛ <a href=#parse-a-url id=reacting-to-environment-changes:parse-a-url>Parse</a> <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>, and let <var>urlString</var> be the <a href=#resulting-url-string id=reacting-to-environment-changes:resulting-url-string>resulting URL
   string</a>. If that is not successful, then return.<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.<li><p>⌛ Let <var>origin</var> be the <a href=#concept-origin id=reacting-to-environment-changes:concept-origin>origin</a> of 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>.<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>.<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>.<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><li><p>⌛ Let the element's <a href=#pending-request id=reacting-to-environment-changes:pending-request-2>pending request</a> be <var>image request</var>.<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>.<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>.<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>, <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>.<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.<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>.<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 let <a href=#pending-request id=reacting-to-environment-changes:pending-request-3>pending request</a> be null and abort
     these steps.<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
     <a href=#concept-origin id=reacting-to-environment-changes:concept-origin-2>origin</a> of the image itself (e.g., when used on a <code id=reacting-to-environment-changes:the-canvas-element><a href=#the-canvas-element>canvas</a></code>).</ol>

   <li>

    <p><a href=#queue-a-task id=reacting-to-environment-changes:queue-a-task>Queue a task</a> to run these steps:</p>

    <ol><li><p>If the <code id=reacting-to-environment-changes:the-img-element-6><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 let <a href=#pending-request id=reacting-to-environment-changes:pending-request-4>pending request</a> be null and abort these
     steps.</p>

     <li><p>Let the <code id=reacting-to-environment-changes:the-img-element-7><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> be <var>selected source</var>
     and the <code id=reacting-to-environment-changes:the-img-element-8><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> be <var>selected pixel density</var>.<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>.<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.<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>.<li><p>Update the <code id=reacting-to-environment-changes:the-img-element-9><a href=#the-img-element>img</a></code> element's presentation appropriately.<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-10><a href=#the-img-element>img</a></code> element.</ol>

   </ol>

  


  <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 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 <a href=#the-a-element id=a-link-or-button-containing-nothing-but-the-image:the-a-element>a</a> 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>&quot;green.html&quot;</c-><c- p>&gt;</c-><strong><c- p>&lt;</c-><c- f>img</c-> <c- e>src</c-><c- o>=</c-><c- s>&quot;green.jpeg&quot;</c-> <c- e>alt</c-><c- o>=</c-><c- s>&quot;Green&quot;</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>&quot;blue.html&quot;</c-><c- p>&gt;</c-><strong><c- p>&lt;</c-><c- f>img</c-> <c- e>src</c-><c- o>=</c-><c- s>&quot;blue.jpeg&quot;</c-> <c- e>alt</c-><c- o>=</c-><c- s>&quot;Blue&quot;</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>&quot;red.html&quot;</c-><c- p>&gt;</c-><strong><c- p>&lt;</c-><c- f>img</c-> <c- e>src</c-><c- o>=</c-><c- s>&quot;red.jpeg&quot;</c-> <c- e>alt</c-><c- o>=</c-><c- s>&quot;Red&quot;</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>&quot;rgb&quot;</c-><c- p>&gt;</c-><strong><c- p>&lt;</c-><c- f>img</c-> <c- e>src</c-><c- o>=</c-><c- s>&quot;red&quot;</c-> <c- e>alt</c-><c- o>=</c-><c- s>&quot;RGB&quot;</c-><c- p>&gt;&lt;</c-><c- f>img</c-> <c- e>src</c-><c- o>=</c-><c- s>&quot;green&quot;</c-> <c- e>alt</c-><c- o>=</c-><c- s>&quot;&quot;</c-><c- p>&gt;&lt;</c-><c- f>img</c-> <c- e>src</c-><c- o>=</c-><c- s>&quot;blue&quot;</c-> <c- e>alt</c-><c- o>=</c-><c- s>&quot;&quot;</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>&quot;cmyk&quot;</c-><c- p>&gt;</c-><strong><c- p>&lt;</c-><c- f>img</c-> <c- e>src</c-><c- o>=</c-><c- s>&quot;cyan&quot;</c-> <c- e>alt</c-><c- o>=</c-><c- s>&quot;CMYK&quot;</c-><c- p>&gt;&lt;</c-><c- f>img</c-> <c- e>src</c-><c- o>=</c-><c- s>&quot;magenta&quot;</c-> <c- e>alt</c-><c- o>=</c-><c- s>&quot;&quot;</c-><c- p>&gt;&lt;</c-><c- f>img</c-> <c- e>src</c-><c- o>=</c-><c- s>&quot;yellow&quot;</c-> <c- e>alt</c-><c- o>=</c-><c- s>&quot;&quot;</c-><c- p>&gt;&lt;</c-><c- f>img</c-> <c- e>src</c-><c- o>=</c-><c- s>&quot;black&quot;</c-> <c- e>alt</c-><c- o>=</c-><c- s>&quot;&quot;</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>&quot;rgb&quot;</c-><c- p>&gt;</c-><strong><c- p>&lt;</c-><c- f>img</c-> <c- e>src</c-><c- o>=</c-><c- s>&quot;red&quot;</c-> <c- e>alt</c-><c- o>=</c-><c- s>&quot;R&quot;</c-><c- p>&gt;&lt;</c-><c- f>img</c-> <c- e>src</c-><c- o>=</c-><c- s>&quot;green&quot;</c-> <c- e>alt</c-><c- o>=</c-><c- s>&quot;G&quot;</c-><c- p>&gt;&lt;</c-><c- f>img</c-> <c- e>src</c-><c- o>=</c-><c- s>&quot;blue&quot;</c-> <c- e>alt</c-><c- o>=</c-><c- s>&quot;B&quot;</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>&quot;cmyk&quot;</c-><c- p>&gt;</c-><strong><c- p>&lt;</c-><c- f>img</c-> <c- e>src</c-><c- o>=</c-><c- s>&quot;cyan&quot;</c-> <c- e>alt</c-><c- o>=</c-><c- s>&quot;C&quot;</c-><c- p>&gt;&lt;</c-><c- f>img</c-> <c- e>src</c-><c- o>=</c-><c- s>&quot;magenta&quot;</c-> <c- e>alt</c-><c- o>=</c-><c- s>&quot;M&quot;</c-><c- p>&gt;&lt;</c-><c- f>img</c-> <c- e>src</c-><c- o>=</c-><c- s>&quot;yellow&quot;</c-> <c- e>alt</c-><c- o>=</c-><c- s>&quot;Y&quot;</c-><c- p>&gt;&lt;</c-><c- f>img</c-> <c- e>src</c-><c- o>=</c-><c- s>&quot;black&quot;</c-> <c- e>alt</c-><c- o>=</c-><c- s>&quot;K&quot;</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>&quot;rgb&quot;</c-><c- p>&gt;</c-><strong><c- p>&lt;</c-><c- f>img</c-> <c- e>src</c-><c- o>=</c-><c- s>&quot;red&quot;</c-> <c- e>alt</c-><c- o>=</c-><c- s>&quot;sRGB profile&quot;</c-><c- p>&gt;&lt;</c-><c- f>img</c-> <c- e>src</c-><c- o>=</c-><c- s>&quot;green&quot;</c-> <c- e>alt</c-><c- o>=</c-><c- s>&quot;&quot;</c-><c- p>&gt;&lt;</c-><c- f>img</c-> <c- e>src</c-><c- o>=</c-><c- s>&quot;blue&quot;</c-> <c- e>alt</c-><c- o>=</c-><c- s>&quot;&quot;</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>&quot;cmyk&quot;</c-><c- p>&gt;</c-><strong><c- p>&lt;</c-><c- f>img</c-> <c- e>src</c-><c- o>=</c-><c- s>&quot;cyan&quot;</c-> <c- e>alt</c-><c- o>=</c-><c- s>&quot;CMYK profile&quot;</c-><c- p>&gt;&lt;</c-><c- f>img</c-> <c- e>src</c-><c- o>=</c-><c- s>&quot;magenta&quot;</c-> <c- e>alt</c-><c- o>=</c-><c- s>&quot;&quot;</c-><c- p>&gt;&lt;</c-><c- f>img</c-> <c- e>src</c-><c- o>=</c-><c- s>&quot;yellow&quot;</c-> <c- e>alt</c-><c- o>=</c-><c- s>&quot;&quot;</c-><c- p>&gt;&lt;</c-><c- f>img</c-> <c- e>src</c-><c- o>=</c-><c- s>&quot;black&quot;</c-> <c- e>alt</c-><c- o>=</c-><c- s>&quot;&quot;</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>&quot;images/parsing-model-overview.svg&quot;</c-> <c- e>alt</c-><c- o>=</c-><c- s>&quot;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.&quot;</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>&quot;house.jpeg&quot;</c-> <c- e>alt</c-><c- o>=</c-><c- s>&quot;The house is white, with a boarded front door.&quot;</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>&quot;house.jpeg&quot;</c-> <c- e>alt</c-><c- o>=</c-><c- s>&quot;A white house, with a boarded front door.&quot;</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>&quot;/help/&quot;</c-><c- p>&gt;</c-><strong><c- p>&lt;</c-><c- f>img</c-> <c- e>src</c-><c- o>=</c-><c- s>&quot;/icons/help.png&quot;</c-> <c- e>alt</c-><c- o>=</c-><c- s>&quot;&quot;</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>&quot;/configure/&quot;</c-><c- p>&gt;</c-><strong><c- p>&lt;</c-><c- f>img</c-> <c- e>src</c-><c- o>=</c-><c- s>&quot;/icons/configuration.png&quot;</c-> <c- e>alt</c-><c- o>=</c-><c- s>&quot;&quot;</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>&quot;movies.png&quot;</c-> <c- e>alt</c-><c- o>=</c-><c- s>&quot;Movies&quot;</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>&quot;podcasts.png&quot;</c-> <c- e>alt</c-><c- o>=</c-><c- s>&quot;Podcasts&quot;</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&apos; 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>&quot;XYZ.gif&quot;</c-> <c- e>alt</c-><c- o>=</c-><c- s>&quot;The XYZ company&quot;</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:

   <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>&quot;alpha.gif&quot;</c->
 <c- e>alt</c-><c- o>=</c-><c- s>&quot;&quot;</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>&quot;alpha-large.gif&quot;</c-> <c- e>alt</c-><c- o>=</c-><c- s>&quot;&quot;</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>&quot;/images/logo&quot;</c-> <c- e>alt</c-><c- o>=</c-><c- s>&quot;It consists of a green circle with a</c->
<c- s>green question mark centered inside it.&quot;</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&apos;m
sure everyone will rush to adopt those specifications now! They could
at least have tried for some sort of, I don&apos;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>&quot;earthdayheading.png&quot;</c-> <c- e>alt</c-><c- o>=</c-><c- s>&quot;Earth Day&quot;</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>&quot;initials/o.svg&quot;</c-> <c- e>alt</c-><c- o>=</c-><c- s>&quot;O&quot;</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>&quot;euro.png&quot;</c-> <c- e>alt</c-><c- o>=</c-><c- s>&quot;euro &quot;</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>&quot;images/parsing-model-overview.svg&quot;</c-> <c- e>alt</c-><c- o>=</c-><c- s>&quot;&quot;</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=&quot;&quot; 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>&quot;images/parsing-model-overview.svg&quot;</c-> <c- e>alt</c-><c- o>=</c-><c- s>&quot;&quot;</c->
        <c- e>title</c-><c- o>=</c-><c- s>&quot;Flowchart representation of the parsing model.&quot;</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>&quot;images/parsing-model-overview.svg&quot;</c-> <c- e>alt</c-><c- o>=</c-><c- s>&quot;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.&quot;</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>&quot;images/parsing-model-overview.svg&quot;</c->
        <c- e>alt</c-><c- o>=</c-><c- s>&quot;Flowchart representation of the parsing model.&quot;</c-><c- p>&gt;&lt;/</c-><c- f>p</c-><c- p>&gt;</c->
<c- c>&lt;!-- Never put the image&apos;s caption in the alt=&quot;&quot; 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>&quot;rendering-mode-pie-chart.png&quot;</c-> <c- e>alt</c-><c- o>=</c-><c- s>&quot;&quot;</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 that, through a style sheet, is floated to the right. 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, in part influenced by whether the image colors 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>&quot;alexsalmond.jpeg&quot;</c-> <c- e>alt</c-><c- o>=</c-><c- s>&quot;&quot;</c-><c- p>&gt;</c-></strong> Ahead of today&apos;s referendum,
the First Minister of Scotland, Alex Salmond, wrote an open letter to all
registered voters. In it, he admitted that all countries make mistakes.<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>&quot;alexsalmond.jpeg&quot;</c-> <c- e>alt</c-><c- o>=</c-><c- s>&quot;Alex Salmond is sad.&quot;</c-><c- p>&gt;</c-></strong>
Ahead of today&apos;s referendum, the First Minister of Scotland, Alex Salmond,
wrote an open letter to all registered voters. In it, he admitted that all
countries make mistakes.<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>&quot;alexsalmond.jpeg&quot;</c-> <c- e>alt</c-><c- o>=</c-><c- s>&quot;Alex Salmond is ecstatic!&quot;</c-><c- p>&gt;</c-></strong>
Ahead of today&apos;s referendum, the First Minister of Scotland, Alex Salmond,
wrote an open letter to all registered voters. In it, he admitted that all
countries make mistakes.<c- p>&lt;/</c-><c- f>p</c-><c- p>&gt;</c-></code></pre>

   <p>Whether the individual was "sad" or "ecstatic" makes a difference to how the rest of the
   paragraph is to be interpreted: is he likely saying that he is resigned to the populace making a
   bad choice in the upcoming referendum, or is he saying that the election was a mistake but the
   likely turnout will make it irrelevant? 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&apos;s referendum, the First Minister of Scotland, Alex Salmond,
wrote an open letter to all registered voters. In it, he admitted that all
countries make mistakes.<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>&quot;alexsalmond.jpeg&quot;</c->
      <c- e>alt</c-><c- o>=</c-><c- s>&quot;A high forehead, cheerful disposition, and dark hair round out Alex Salmond&apos;s face.&quot;</c-><c- p>&gt;</c->
 <c- p>&lt;</c-><c- f>figcaption</c-><c- p>&gt;</c-> Alex Salmond, SNP. 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>&quot;shalott.jpeg&quot;</c-> <c- e>alt</c-><c- o>=</c-><c- s>&quot;&quot;</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&apos;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>&quot;logo1.png&quot;</c-> <c- e>alt</c-><c- o>=</c-><c- s>&quot;XYZ Corp&quot;</c-><c- p>&gt;&lt;</c-><c- f>img</c-> <c- e>src</c-><c- o>=</c-><c- s>&quot;logo2.png&quot;</c-> <c- e>alt</c-><c- o>=</c-><c- s>&quot;&quot;</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>&quot;1&quot;</c-> <c- e>alt</c-><c- o>=</c-><c- s>&quot;3 out of 5&quot;</c->
  <c- p>&gt;&lt;</c-><c- f>img</c-> <c- e>src</c-><c- o>=</c-><c- s>&quot;1&quot;</c-> <c- e>alt</c-><c- o>=</c-><c- s>&quot;&quot;</c-><c- p>&gt;&lt;</c-><c- f>img</c-> <c- e>src</c-><c- o>=</c-><c- s>&quot;1&quot;</c-> <c- e>alt</c-><c- o>=</c-><c- s>&quot;&quot;</c-><c- p>&gt;&lt;</c-><c- f>img</c-> <c- e>src</c-><c- o>=</c-><c- s>&quot;0&quot;</c-> <c- e>alt</c-><c- o>=</c-><c- s>&quot;&quot;</c->
  <c- p>&gt;&lt;</c-><c- f>img</c-> <c- e>src</c-><c- o>=</c-><c- s>&quot;0&quot;</c-> <c- e>alt</c-><c- o>=</c-><c- s>&quot;&quot;</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>&quot;?go=left&quot;</c-> <c- p>&gt;&lt;</c-><c- f>img</c-> <c- e>src</c-><c- o>=</c-><c- s>&quot;fsm-left.png&quot;</c->  <c- e>alt</c-><c- o>=</c-><c- s>&quot;Left side. &quot;</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>&quot;fsm-middle.png&quot;</c-> <c- e>alt</c-><c- o>=</c-><c- s>&quot;&quot;</c->
  <c- p>&gt;&lt;</c-><c- f>a</c-> <c- e>href</c-><c- o>=</c-><c- s>&quot;?go=right&quot;</c-><c- p>&gt;&lt;</c-><c- f>img</c-> <c- e>src</c-><c- o>=</c-><c- s>&quot;fsm-right.png&quot;</c-> <c- e>alt</c-><c- o>=</c-><c- s>&quot;Right side.&quot;</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<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>&quot;KDE%20Light%20desktop.png&quot;</c->
      <c- e>alt</c-><c- o>=</c-><c- s>&quot;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.&quot;</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>&quot;sales.gif&quot;</c->
     <c- e>title</c-><c- o>=</c-><c- s>&quot;Sales graph&quot;</c->
     <c- e>alt</c-><c- o>=</c-><c- s>&quot;From 1998 to 2005, sales increased by the following percentages</c->
<c- s>     with each year: 624%, 75%, 138%, 40%, 35%, 9%, 21%&quot;</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>

   <dt>Images that defy a complete description<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>&quot;/commons/a/a7/Rorschach1.jpg&quot;</c-> <c- e>alt</c-><c- o>=</c-><c- s>&quot;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.&quot;</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>&quot;/commons/a/a7/Rorschach1.jpg&quot;</c-> <c- e>alt</c-><c- o>=</c-><c- s>&quot;A black outline</c->
<c- s> of the first of the ten cards in the Rorschach inkblot test.&quot;</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>&quot;ms1.jpeg&quot;</c-> <c- e>alt</c-><c- o>=</c-><c- s>&quot;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.&quot;</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>&quot;bio&quot;</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>&quot;headpics/asimov.jpeg&quot;</c-> <c- e>alt</c-><c- o>=</c-><c- s>&quot;Isaac Asimov had dark hair, a tall forehead, and wore glasses.</c->
<c- s> Later in life, he wore long white sideburns.&quot;</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>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>

   <dt id=unknown-images>Images whose contents are not known<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.<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>

     </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>&quot;1100670787_6a7c664aef.jpg&quot;</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>&quot;photo2.jpeg&quot;</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>&quot;photo2.jpeg&quot;</c-> <c- e>alt</c-><c- o>=</c-><c- s>&quot;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.&quot;</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>&quot;captcha.cgi?id=8934&quot;</c-> <c- e>title</c-><c- o>=</c-><c- s>&quot;CAPTCHA&quot;</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>&quot;?audio&quot;</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>&quot;2421.png&quot;</c-> <c- e>title</c-><c- o>=</c-><c- s>&quot;Image 640 by 100, filename &apos;banner.gif&apos;&quot;</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>&quot;alt2421&quot;</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>&quot;2422.png&quot;</c-> <c- e>title</c-><c- o>=</c-><c- s>&quot;Image 200 by 480, filename &apos;ad3.gif&apos;&quot;</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>&quot;alt2422&quot;</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>

   </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 e-mail 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,
  e-mails sent to public mailing lists, or software documentation.</i></p>

  <p>When an image is included in a private communication (such as an HTML e-mail) 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 e-mail 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 file name 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>.<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>).<li><p>The conformance checker has been configured to assume that the document is an e-mail or
   document intended for a specific person who is known to be able to view images.<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.)</ul>

  


  <h4 id=the-iframe-element data-dfn-type=element data-lt=iframe><span class=secno>4.8.5</span> The
  <dfn><code>iframe</code></dfn> element<a href=#the-iframe-element class=self-link></a></h4>

  <dl class=element><dt><a href=#concept-element-categories id=the-iframe-element:concept-element-categories>Categories</a>:<dd><a href=#flow-content-2 id=the-iframe-element:flow-content-2>Flow content</a>.<dd><a href=#phrasing-content-2 id=the-iframe-element:phrasing-content-2>Phrasing content</a>.<dd><a href=#embedded-content-category id=the-iframe-element:embedded-content-category>Embedded content</a>.<dd><a href=#interactive-content-2 id=the-iframe-element:interactive-content-2>Interactive content</a>.<dd><a href=#palpable-content-2 id=the-iframe-element:palpable-content-2>Palpable content</a>.<dt><a href=#concept-element-contexts id=the-iframe-element:concept-element-contexts>Contexts in which this element can be used</a>:<dd>Where <a href=#embedded-content-category id=the-iframe-element:embedded-content-category-2>embedded content</a> is expected.<dt><a href=#concept-element-content-model id=the-iframe-element:concept-element-content-model>Content model</a>:<dd><a href=#concept-content-nothing id=the-iframe-element:concept-content-nothing>Nothing</a>.<dt><a href=#concept-element-tag-omission id=the-iframe-element:concept-element-tag-omission>Tag omission in text/html</a>:<dd>Neither tag is omissible.<dt><a href=#concept-element-attributes id=the-iframe-element:concept-element-attributes>Content attributes</a>:<dd><a href=#global-attributes id=the-iframe-element:global-attributes>Global attributes</a><dd><code id=the-iframe-element:attr-iframe-src><a href=#attr-iframe-src>src</a></code> — Address of the resource<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><code id=the-iframe-element:attr-iframe-name><a href=#attr-iframe-name>name</a></code> — Name of <a href=#nested-browsing-context id=the-iframe-element:nested-browsing-context>nested browsing context</a><dd><code id=the-iframe-element:attr-iframe-sandbox><a href=#attr-iframe-sandbox>sandbox</a></code> — Security rules for nested content<dd><code id=the-iframe-element:attr-iframe-allow><a href=#attr-iframe-allow>allow</a></code> — <a href=https://wicg.github.io/feature-policy/#feature-policy id=the-iframe-element:concept-feature-policy data-x-internal=concept-feature-policy>Feature 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><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><code id=the-iframe-element:attr-iframe-allowpaymentrequest><a href=#attr-iframe-allowpaymentrequest>allowpaymentrequest</a></code> — Whether the <code id=the-iframe-element:the-iframe-element-4><a href=#the-iframe-element>iframe</a></code>'s contents are allowed to use the <code id=the-iframe-element:paymentrequest><a data-x-internal=paymentrequest href=https://w3c.github.io/payment-request/#dom-paymentrequest>PaymentRequest</a></code> interface to make payment requests<dd><code id=the-iframe-element:attr-iframe-allowusermedia><a href=#attr-iframe-allowusermedia>allowusermedia</a></code> — Whether to allow the <code id=the-iframe-element:the-iframe-element-5><a href=#the-iframe-element>iframe</a></code>'s contents to use <code id=the-iframe-element:dom-mediadevices-getusermedia><a data-x-internal=dom-mediadevices-getusermedia href=https://w3c.github.io/mediacapture-main/#dom-mediadevices-getusermedia>getUserMedia()</a></code><dd><code id=the-iframe-element:attr-dim-width><a href=#attr-dim-width>width</a></code> — Horizontal dimension<dd><code id=the-iframe-element:attr-dim-height><a href=#attr-dim-height>height</a></code> — Vertical dimension<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<dt><a href=#concept-element-dom id=the-iframe-element:concept-element-dom>DOM interface</a>:<dd>
    <pre><code class='idl'>[<c- g>Exposed</c->=<c- n>Window</c->,
 <a href='#htmlconstructor' id='the-iframe-element:htmlconstructor'><c- g>HTMLConstructor</c-></a>]
<c- b>interface</c-> <dfn id='htmliframeelement'><c- g>HTMLIFrameElement</c-></dfn> : <a href='#htmlelement' id='the-iframe-element:htmlelement'><c- n>HTMLElement</c-></a> {
  [<a href='#cereactions' id='the-iframe-element:cereactions'><c- g>CEReactions</c-></a>] <c- b>attribute</c-> <c- b>USVString</c-> <a href='#dom-iframe-src' id='the-iframe-element:dom-iframe-src'><c- g>src</c-></a>;
  [<a href='#cereactions' id='the-iframe-element:cereactions-2'><c- g>CEReactions</c-></a>] <c- b>attribute</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>] <c- b>attribute</c-> <c- b>DOMString</c-> <a href='#dom-iframe-name' id='the-iframe-element:dom-iframe-name'><c- g>name</c-></a>;
  [<c- g>SameObject</c->, <c- g>PutForwards</c->=<a href='https://dom.spec.whatwg.org/#dom-domtokenlist-value' data-x-internal='dom-domtokenlist-value' id='the-iframe-element:dom-domtokenlist-value'><c- n>value</c-></a>] <c- b>readonly</c-> <c- b>attribute</c-> <a href='https://dom.spec.whatwg.org/#interface-domtokenlist' data-x-internal='domtokenlist' id='the-iframe-element:domtokenlist'><c- n>DOMTokenList</c-></a> <a href='#dom-iframe-sandbox' id='the-iframe-element:dom-iframe-sandbox'><c- g>sandbox</c-></a>;
  [<a href='#cereactions' id='the-iframe-element:cereactions-4'><c- g>CEReactions</c-></a>] <c- b>attribute</c-> <c- b>DOMString</c-> <a href='#dom-iframe-allow' id='the-iframe-element:dom-iframe-allow'><c- g>allow</c-></a>;
  [<a href='#cereactions' id='the-iframe-element:cereactions-5'><c- g>CEReactions</c-></a>] <c- b>attribute</c-> <c- b>boolean</c-> <a href='#dom-iframe-allowfullscreen' id='the-iframe-element:dom-iframe-allowfullscreen'><c- g>allowFullscreen</c-></a>;
  [<a href='#cereactions' id='the-iframe-element:cereactions-6'><c- g>CEReactions</c-></a>] <c- b>attribute</c-> <c- b>boolean</c-> <a href='#dom-iframe-allowpaymentrequest' id='the-iframe-element:dom-iframe-allowpaymentrequest'><c- g>allowPaymentRequest</c-></a>;
  [<a href='#cereactions' id='the-iframe-element:cereactions-7'><c- g>CEReactions</c-></a>] <c- b>attribute</c-> <c- b>boolean</c-> <a href='#dom-iframe-allowusermedia' id='the-iframe-element:dom-iframe-allowusermedia'><c- g>allowUserMedia</c-></a>;
  [<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-dim-width' id='the-iframe-element:dom-dim-width'><c- g>width</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-dim-height' id='the-iframe-element:dom-dim-height'><c- g>height</c-></a>;
  [<a href='#cereactions' id='the-iframe-element:cereactions-10'><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>;
  <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>();
};</code></pre>
   </dl>

  

  <p>The <code id=the-iframe-element:the-iframe-element-6><a href=#the-iframe-element>iframe</a></code> element <a href=#represents id=the-iframe-element:represents>represents</a> a <a href=#nested-browsing-context id=the-iframe-element:nested-browsing-context-2>nested browsing
  context</a>.</p>


  

  <p>The <dfn id=attr-iframe-src><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 <a href=#nested-browsing-context id=the-iframe-element:nested-browsing-context-3>nested browsing context</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-7><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>

  <p>The <dfn data-dfn-for=iframe id=attr-iframe-srcdoc data-dfn-type=element-attr data-export=""><code>srcdoc</code></dfn> attribute gives the content of the page that the
  <a href=#nested-browsing-context id=the-iframe-element:nested-browsing-context-4>nested browsing context</a> is to contain. The value of the attribute is the source of
  <dfn id=an-iframe-srcdoc-document data-export="">an <code>iframe</code> <code>srcdoc</code>
  document</dfn>.<div class=status><input onclick=toggleStatus(this) value=⋰ type=button><p class=support><strong>Support:</strong> iframe-srcdoc<span class="and_chr yes"><span>Chrome for Android</span> <span>67+</span></span><span class="chrome yes"><span>Chrome</span> <span>20+</span></span><span class="ios_saf yes"><span>iOS Safari</span> <span>6.0+</span></span><span class="and_uc yes"><span>UC Browser for Android</span> <span>11.8+</span></span><span class="firefox yes"><span>Firefox</span> <span>25+</span></span><span class="ie no"><span>IE</span> <span>None</span></span><span class="op_mini no"><span>Opera Mini</span> <span>None</span></span><span class="safari yes"><span>Safari</span> <span>6+</span></span><span class="edge yes"><span>Edge</span> <span>18+</span></span><span class="samsung yes"><span>Samsung Internet</span> <span>4+</span></span><span class="opera yes"><span>Opera</span> <span>15+</span></span><span class="android yes"><span>Android Browser</span> <span>4.4+</span></span><p class=caniuse>Source: <a href="https://caniuse.com/#feat=iframe-srcdoc">caniuse.com</a></div>

  <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>Optionally, a <a href=#syntax-doctype id=the-iframe-element:syntax-doctype>DOCTYPE</a>.

   <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>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>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>.</ol>

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

  <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&apos;ve finally found a publisher, and so now I
 have my own magazine! Isn&apos;t that awesome?! The first issue will come
 out in September, and we have articles about getting food, and about
 getting in boxes, it&apos;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>&quot;/users/cap&quot;</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>&quot;/users/ch&quot;</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>&quot;&lt;p&gt;did you get a cover picture yet?&quot;</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>&quot;/users/cap&quot;</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>&quot;&lt;p&gt;Yeah, you can see it &lt;a href=&quot;</c->/<c- e>gallery</c->?<c- e>mode</c-><c- o>=</c-><c- s>cover&amp;amp;amp;page=1&quot;</c-><c- p>&gt;</c->in my gallery<c- p>&lt;/</c-><c- f>a</c-><c- p>&gt;</c->.&quot;&gt;<c- p>&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>&quot;/users/ch&quot;</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>&quot;&lt;p&gt;hey that&apos;s earl&apos;s table.</c->
<c- s>&lt;p&gt;you should get earl&amp;amp;amp;me on the next cover.&quot;</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> 

  <p>When an <code id=the-iframe-element:the-iframe-element-8><a href=#the-iframe-element>iframe</a></code> element is <a href=#insert-an-element-into-a-document id=the-iframe-element:insert-an-element-into-a-document>inserted
  into a document</a> that has a <a href=#concept-document-bc id=the-iframe-element:concept-document-bc>browsing context</a>, the
  user agent must <a href=#creating-a-new-browsing-context id=the-iframe-element:creating-a-new-browsing-context>create a new browsing
  context</a>, set the element's <a href=#nested-browsing-context id=the-iframe-element:nested-browsing-context-5>nested browsing context</a> to the newly-created
  <a href=#browsing-context id=the-iframe-element:browsing-context>browsing context</a>, and then <a href=#process-the-iframe-attributes id=the-iframe-element:process-the-iframe-attributes>process the <code>iframe</code> attributes</a>
  for the "first time".</p>

  <p>When an <code id=the-iframe-element:the-iframe-element-9><a href=#the-iframe-element>iframe</a></code> element is <a href=#remove-an-element-from-a-document id=the-iframe-element:remove-an-element-from-a-document>removed
  from a document</a>, the user agent must <a href=#a-browsing-context-is-discarded id=the-iframe-element:a-browsing-context-is-discarded>discard</a> the element's <a href=#nested-browsing-context id=the-iframe-element:nested-browsing-context-6>nested browsing context</a>, if it is not null,
  and then set the element's <a href=#nested-browsing-context id=the-iframe-element:nested-browsing-context-7>nested browsing context</a> to null.</p>

  <p class=note>This happens without any <code id=the-iframe-element:event-unload><a href=#event-unload>unload</a></code> events firing
  (the <a href=#nested-browsing-context id=the-iframe-element:nested-browsing-context-8>nested browsing context</a> and its <code id=the-iframe-element:document-3><a href=#document>Document</a></code> are <em><a href=#a-browsing-context-is-discarded id=the-iframe-element:a-browsing-context-is-discarded-2>discarded</a></em>, not <em><a href=#unload-a-document id=the-iframe-element:unload-a-document>unloaded</a></em>).</p>

  

  <p>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=#nested-browsing-context id=the-iframe-element:nested-browsing-context-9>nested browsing context</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>

  <p>Similarly, whenever an <code id=the-iframe-element:the-iframe-element-11><a href=#the-iframe-element>iframe</a></code> element with a non-null <a href=#nested-browsing-context id=the-iframe-element:nested-browsing-context-10>nested browsing
  context</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> 

  <p>When the user agent is to <dfn id=process-the-iframe-attributes>process the <code>iframe</code> attributes</dfn>, it must run
  the first appropriate steps from the following list:</p>

  <dl class=switch><dt>If the <code id=the-iframe-element:attr-iframe-srcdoc-12><a href=#attr-iframe-srcdoc>srcdoc</a></code> attribute is specified<dd>

    <p><a href=#navigate id=the-iframe-element:navigate>Navigate</a> the element's <a href=#nested-browsing-context id=the-iframe-element:nested-browsing-context-11>nested browsing context</a>
    to a new <a href=https://fetch.spec.whatwg.org/#concept-response id=the-iframe-element:concept-response data-x-internal=concept-response>response</a> whose <a href=https://fetch.spec.whatwg.org/#concept-response-url-list id=the-iframe-element:concept-response-url-list data-x-internal=concept-response-url-list>url list</a> consists of <code id=the-iframe-element:about:srcdoc><a href=#about:srcdoc>about:srcdoc</a></code>, <a href=https://fetch.spec.whatwg.org/#concept-response-header-list id=the-iframe-element:concept-response-header-list data-x-internal=concept-response-header-list>header list</a> consists of `<code>Content-Type</code>`/`<code id=the-iframe-element:text/html><a href=#text/html>text/html</a></code>, <a href=https://fetch.spec.whatwg.org/#concept-response-body id=the-iframe-element:concept-response-body data-x-internal=concept-response-body>body</a> is the value of the attribute, <a href=https://fetch.spec.whatwg.org/#concept-response-csp-list id=the-iframe-element:concept-response-csp-list data-x-internal=concept-response-csp-list>CSP list</a> is the <a href=#concept-document-csp-list id=the-iframe-element:concept-document-csp-list>CSP list</a> of the <code id=the-iframe-element:the-iframe-element-12><a href=#the-iframe-element>iframe</a></code> element'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>, <a href=https://fetch.spec.whatwg.org/#concept-response-https-state id=the-iframe-element:concept-response-https-state data-x-internal=concept-response-https-state>HTTPS state</a> is the <a href=#concept-document-https-state id=the-iframe-element:concept-document-https-state>HTTPS state</a> of the <code id=the-iframe-element:the-iframe-element-13><a href=#the-iframe-element>iframe</a></code> element'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>.

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

   <dt>Otherwise, if the element has no <code id=the-iframe-element:attr-iframe-src-5><a href=#attr-iframe-src>src</a></code> attribute
   specified, and the user agent is processing the <code id=the-iframe-element:the-iframe-element-14><a href=#the-iframe-element>iframe</a></code>'s attributes for the "first
   time"<dd>

    <p><a href=#queue-a-task id=the-iframe-element:queue-a-task>Queue a task</a> to run the <a href=#iframe-load-event-steps id=the-iframe-element:iframe-load-event-steps>iframe load event steps</a>.</p>

    <p>The <a href=#task-source id=the-iframe-element:task-source>task source</a> for this <a href=#concept-task id=the-iframe-element:concept-task>task</a> is the
    <a href=#dom-manipulation-task-source id=the-iframe-element:dom-manipulation-task-source>DOM manipulation task source</a>.</p>

   <dt>Otherwise<dd><p>Run the <a href=#otherwise-steps-for-iframe-or-frame-elements id=the-iframe-element:otherwise-steps-for-iframe-or-frame-elements>otherwise steps for <code>iframe</code> or <code>frame</code>
   elements</a>.</dl>

  <p>The <dfn id=otherwise-steps-for-iframe-or-frame-elements>otherwise steps for <code>iframe</code> or <code>frame</code> elements</dfn> are as
  follows:</p>

  <ol><li>
    <p>If the element has no <code id=the-iframe-element:attr-iframe-src-6><a href=#attr-iframe-src>src</a></code> attribute specified, or its
    value is the empty string, let <var>url</var> be the <a id=the-iframe-element:url-3 href=https://url.spec.whatwg.org/#concept-url data-x-internal=url>URL</a>
    "<code id=the-iframe-element:about:blank><a href=#about:blank>about:blank</a></code>".</p>
    

    <p>Otherwise, <a href=#parse-a-url id=the-iframe-element:parse-a-url>parse</a> the value of the <code id=the-iframe-element:attr-iframe-src-7><a href=#attr-iframe-src>src</a></code> attribute, relative to the element'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>.</p>

    <p>If that is not successful, then let <var>url</var> be the <a id=the-iframe-element:url-4 href=https://url.spec.whatwg.org/#concept-url data-x-internal=url>URL</a>
    "<code id=the-iframe-element:about:blank-2><a href=#about:blank>about:blank</a></code>". Otherwise, let <var>url</var> be the <a href=#resulting-url-record id=the-iframe-element:resulting-url-record>resulting URL
    record</a>.</p>
   <li><p>If there exists an <a href=#ancestor-browsing-context id=the-iframe-element:ancestor-browsing-context>ancestor browsing context</a> whose <a href=#active-document id=the-iframe-element:active-document>active
   document</a>'s <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>, ignoring <a href=https://url.spec.whatwg.org/#concept-url-fragment id=the-iframe-element:concept-url-fragment data-x-internal=concept-url-fragment>fragments</a>, is equal to <var>url</var>, then return.<li><p>Let <var>resource</var> be a new <a href=https://fetch.spec.whatwg.org/#concept-request id=the-iframe-element:concept-request data-x-internal=concept-request>request</a> whose <a href=https://fetch.spec.whatwg.org/#concept-request-url id=the-iframe-element: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-referrer-policy id=the-iframe-element:concept-request-referrer-policy data-x-internal=concept-request-referrer-policy>referrer policy</a> is the current state of the
   element's <code id=the-iframe-element:attr-iframe-referrerpolicy-2><a href=#attr-iframe-referrerpolicy>referrerpolicy</a></code> content
   attribute.<li><p><a href=#navigate id=the-iframe-element:navigate-2>Navigate</a> the element's <a href=#nested-browsing-context id=the-iframe-element:nested-browsing-context-12>nested browsing
   context</a> to <var>resource</var>.</ol>

  <p>Any <a href=#navigate id=the-iframe-element:navigate-3>navigation</a> required of the user agent 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 must use the <code id=the-iframe-element:the-iframe-element-15><a href=#the-iframe-element>iframe</a></code> element'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=#browsing-context id=the-iframe-element:browsing-context-2>browsing context</a> as the <a href=#source-browsing-context id=the-iframe-element:source-browsing-context>source browsing
  context</a>.</p>

  <p>Furthermore, if the <a href=#active-document id=the-iframe-element:active-document-2>active document</a> of the element's <a href=#nested-browsing-context id=the-iframe-element:nested-browsing-context-13>nested browsing
  context</a> before such a <a href=#navigate id=the-iframe-element:navigate-4>navigation</a> was not <a href=#completely-loaded id=the-iframe-element:completely-loaded>completely
  loaded</a> at the time of the new <a href=#navigate id=the-iframe-element:navigate-5>navigation</a>, then the <a href=#navigate id=the-iframe-element:navigate-6>navigation</a> must be completed with <a href=#replacement-enabled id=the-iframe-element:replacement-enabled>replacement enabled</a>.</p>

  <p>Similarly, if the <a href=#nested-browsing-context id=the-iframe-element:nested-browsing-context-14>nested browsing context</a>'s <a href=#session-history id=the-iframe-element:session-history>session history</a> contained
  only one <code id=the-iframe-element:document-5><a href=#document>Document</a></code> when the <a href=#process-the-iframe-attributes id=the-iframe-element:process-the-iframe-attributes-5>process the <code>iframe</code> attributes</a>
  algorithm was invoked, and that was the <code id=the-iframe-element:about:blank-3><a href=#about:blank>about:blank</a></code> <code id=the-iframe-element:document-6><a href=#document>Document</a></code> created
  when the <a href=#nested-browsing-context id=the-iframe-element:nested-browsing-context-15>nested browsing context</a> was created, then any <a href=#navigate id=the-iframe-element:navigate-7>navigation</a> required of the user agent in that algorithm must be completed
  with <a href=#replacement-enabled id=the-iframe-element:replacement-enabled-2>replacement enabled</a>.</p> 

  <p>When a <code id=the-iframe-element:document-7><a href=#document>Document</a></code> in an <code id=the-iframe-element:the-iframe-element-16><a href=#the-iframe-element>iframe</a></code> is marked as <a href=#completely-loaded id=the-iframe-element:completely-loaded-2>completely
  loaded</a>, the user agent must run the <a href=#iframe-load-event-steps id=the-iframe-element:iframe-load-event-steps-2>iframe load event steps</a>.</p>

  <p class=note>A <code id=the-iframe-element:event-load><a href=#event-load>load</a></code> event is also fired at the
  <code id=the-iframe-element:the-iframe-element-17><a href=#the-iframe-element>iframe</a></code> element when it is created if no other data is loaded in it.</p>

  <p>Each <code id=the-iframe-element:document-8><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-9><a href=#document>Document</a></code> is created, these flags must be unset for
  that <code id=the-iframe-element:document-10><a href=#document>Document</a></code>.</p>

  <p>The <dfn id=iframe-load-event-steps>iframe load event steps</dfn> are as follows:</p>

  <ol><li><p>Let <var>child document</var> be the <a href=#active-document id=the-iframe-element:active-document-3>active document</a> of the
   <code id=the-iframe-element:the-iframe-element-18><a href=#the-iframe-element>iframe</a></code> element's <a href=#nested-browsing-context id=the-iframe-element:nested-browsing-context-16>nested browsing context</a> (which cannot be null at this
   point).<li><p>If <var>child document</var> has its <a href=#mute-iframe-load id=the-iframe-element:mute-iframe-load>mute iframe load</a> flag set,
   return.<li><p>Set <var>child document</var>'s <a href=#iframe-load-in-progress id=the-iframe-element:iframe-load-in-progress>iframe load in progress</a>
   flag.<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-2><a href=#event-load>load</a></code> at the <code id=the-iframe-element:the-iframe-element-19><a href=#the-iframe-element>iframe</a></code> element.<li><p>Unset <var>child document</var>'s <a href=#iframe-load-in-progress id=the-iframe-element:iframe-load-in-progress-2>iframe load in progress</a>
   flag.</ol>

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

  <p>When the <code id=the-iframe-element:the-iframe-element-20><a href=#the-iframe-element>iframe</a></code>'s <a href=#browsing-context id=the-iframe-element:browsing-context-3>browsing context</a>'s <a href=#active-document id=the-iframe-element:active-document-4>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>, and when anything in the <code id=the-iframe-element:the-iframe-element-21><a href=#the-iframe-element>iframe</a></code> is <a href=#delay-the-load-event id=the-iframe-element:delay-the-load-event>delaying the load event</a> of the <code id=the-iframe-element:the-iframe-element-22><a href=#the-iframe-element>iframe</a></code>'s
  <a href=#browsing-context id=the-iframe-element:browsing-context-4>browsing context</a>'s <a href=#active-document id=the-iframe-element:active-document-5>active document</a>, and when the <code id=the-iframe-element:the-iframe-element-23><a href=#the-iframe-element>iframe</a></code>'s
  <a href=#browsing-context id=the-iframe-element:browsing-context-5>browsing context</a> is in the <a href=#delaying-load-events-mode id=the-iframe-element:delaying-load-events-mode>delaying <code>load</code> events
  mode</a>, the <code id=the-iframe-element:the-iframe-element-24><a href=#the-iframe-element>iframe</a></code> must <a href=#delay-the-load-event id=the-iframe-element:delay-the-load-event-2>delay the load event</a> of its document.</p>

  <p class=note>If, during the handling of the <code id=the-iframe-element:event-load-3><a href=#event-load>load</a></code> event, the
  <a href=#browsing-context id=the-iframe-element:browsing-context-6>browsing context</a> in the <code id=the-iframe-element:the-iframe-element-25><a href=#the-iframe-element>iframe</a></code> is again <a href=#navigate id=the-iframe-element:navigate-8>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>

  

  

  <p class=note>If, when the element is created, the <code id=the-iframe-element:attr-iframe-srcdoc-13><a href=#attr-iframe-srcdoc>srcdoc</a></code> attribute is not set, and the <code id=the-iframe-element:attr-iframe-src-8><a href=#attr-iframe-src>src</a></code> attribute is either also not set or set but its value cannot be
  <a href=#parse-a-url id=the-iframe-element:parse-a-url-2>parsed</a>, the browsing context will remain at the initial
  <code id=the-iframe-element:about:blank-4><a href=#about:blank>about:blank</a></code> page.</p>

  <p class=note>If the user <a href=#navigate id=the-iframe-element:navigate-9>navigates</a> away from this page, the
  <code id=the-iframe-element:the-iframe-element-26><a href=#the-iframe-element>iframe</a></code>'s corresponding <code id=the-iframe-element:windowproxy-2><a href=#windowproxy>WindowProxy</a></code> 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-11><a href=#document>Document</a></code> objects, but the <code id=the-iframe-element:attr-iframe-src-9><a href=#attr-iframe-src>src</a></code> attribute will not change.</p>


  <hr> 

  <p>The <dfn id=attr-iframe-name><code>name</code></dfn> attribute, if present, must be a
  <a href=#valid-browsing-context-name id=the-iframe-element:valid-browsing-context-name>valid browsing context name</a>. The given value is used to name the <a href=#nested-browsing-context id=the-iframe-element:nested-browsing-context-17>nested
  browsing context</a>. When the browsing context is created, if the attribute
  is present, the <a href=#browsing-context-name id=the-iframe-element:browsing-context-name>browsing context name</a> must be set to the value of this attribute;
  otherwise, the <a href=#browsing-context-name id=the-iframe-element:browsing-context-name-2>browsing context name</a> must be set to the empty string.</p>

  

  <p>Whenever the <code id=the-iframe-element:attr-iframe-name-2><a href=#attr-iframe-name>name</a></code> attribute is set, the nested
  <a href=#browsing-context id=the-iframe-element:browsing-context-7>browsing context</a>'s <a href=#browsing-context-name id=the-iframe-element:browsing-context-name-3>name</a> must be changed to
  the new value. If the attribute is removed, the <a href=#browsing-context-name id=the-iframe-element:browsing-context-name-4>browsing context name</a> must be set to
  the empty string.</p>

  


  <hr> 

  <p>The <dfn id=attr-iframe-sandbox><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-27><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 <code id=the-iframe-element:attr-iframe-sandbox-allow-forms><a href=#attr-iframe-sandbox-allow-forms>allow-forms</a></code>, <code id=the-iframe-element:attr-iframe-sandbox-allow-modals><a href=#attr-iframe-sandbox-allow-modals>allow-modals</a></code>, <code id=the-iframe-element:attr-iframe-sandbox-allow-orientation-lock><a href=#attr-iframe-sandbox-allow-orientation-lock>allow-orientation-lock</a></code>, <code id=the-iframe-element:attr-iframe-sandbox-allow-pointer-lock><a href=#attr-iframe-sandbox-allow-pointer-lock>allow-pointer-lock</a></code>, <code id=the-iframe-element:attr-iframe-sandbox-allow-popups><a href=#attr-iframe-sandbox-allow-popups>allow-popups</a></code>, <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>,
  <code id=the-iframe-element:attr-iframe-sandbox-allow-presentation><a href=#attr-iframe-sandbox-allow-presentation>allow-presentation</a></code>, <code id=the-iframe-element:attr-iframe-sandbox-allow-same-origin><a href=#attr-iframe-sandbox-allow-same-origin>allow-same-origin</a></code>, <code id=the-iframe-element:attr-iframe-sandbox-allow-scripts><a href=#attr-iframe-sandbox-allow-scripts>allow-scripts</a></code>, <code id=the-iframe-element:attr-iframe-sandbox-allow-top-navigation><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><a href=#attr-iframe-sandbox-allow-top-navigation-by-user-activation>allow-top-navigation-by-user-activation</a></code>.<div class=status><input onclick=toggleStatus(this) value=⋰ type=button><p class=support><strong>Support:</strong> iframe-sandbox<span class="and_chr yes"><span>Chrome for Android</span> <span>67+</span></span><span class="chrome yes"><span>Chrome</span> <span>4+</span></span><span class="ios_saf yes"><span>iOS Safari</span> <span>4.2+</span></span><span class="and_uc yes"><span>UC Browser for Android</span> <span>11.8+</span></span><span class="firefox yes"><span>Firefox</span> <span>28+</span></span><span class="ie yes"><span>IE</span> <span>10+</span></span><span class="op_mini no"><span>Opera Mini</span> <span>None</span></span><span class="safari yes"><span>Safari</span> <span>5+</span></span><span class="edge yes"><span>Edge</span> <span>12+</span></span><span class="samsung yes"><span>Samsung Internet</span> <span>4+</span></span><span class="opera yes"><span>Opera</span> <span>15+</span></span><span class="android yes"><span>Android Browser</span> <span>2.2+</span></span><p class=caniuse>Source: <a href="https://caniuse.com/#feat=iframe-sandbox">caniuse.com</a></div>

  <p>When the attribute is set, the content is treated as being from a unique <a href=#concept-origin id=the-iframe-element:concept-origin-2>origin</a>,
  forms, scripts, and various potentially annoying APIs are disabled, links are prevented from
  targeting other <a href=#browsing-context id=the-iframe-element:browsing-context-8>browsing contexts</a>, and plugins are secured.
  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 a unique
  origin; 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-10>navigate</a> its <a href=#top-level-browsing-context id=the-iframe-element:top-level-browsing-context>top-level browsing context</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 only allows such <a href=#navigate id=the-iframe-element:navigate-11>navigation</a> when
  <a href=#triggered-by-user-activation id=the-iframe-element:triggered-by-user-activation>triggered by user activation</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. <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 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-3><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>same origin</a> as the page containing the <code id=the-iframe-element:the-iframe-element-28><a href=#the-iframe-element>iframe</a></code>
  allows the embedded page to simply remove the <code id=the-iframe-element:attr-iframe-sandbox-4><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=#nested-browsing-context id=the-iframe-element:nested-browsing-context-18>nested browsing context</a> of
  the <code id=the-iframe-element:the-iframe-element-29><a href=#the-iframe-element>iframe</a></code> is <a href=#navigate id=the-iframe-element:navigate-12>navigated</a>. Removing them, or removing the
  entire <code id=the-iframe-element:attr-iframe-sandbox-5><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-30><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-31><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-6><a href=#attr-iframe-sandbox>sandbox</a></code>
  attribute.</p>

  

  

  <p>When an <code id=the-iframe-element:the-iframe-element-32><a href=#the-iframe-element>iframe</a></code> element with a <code id=the-iframe-element:attr-iframe-sandbox-7><a href=#attr-iframe-sandbox>sandbox</a></code>
  attribute has its <a href=#nested-browsing-context id=the-iframe-element:nested-browsing-context-19>nested browsing context</a> created (before the initial
  <code id=the-iframe-element:about:blank-5><a href=#about:blank>about:blank</a></code> <code id=the-iframe-element:document-12><a href=#document>Document</a></code> is created), and when an <code id=the-iframe-element:the-iframe-element-33><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 <a href=#nested-browsing-context id=the-iframe-element:nested-browsing-context-20>nested browsing context</a>, the user agent must <a href=#parse-a-sandboxing-directive id=the-iframe-element:parse-a-sandboxing-directive>parse the sandboxing directive</a> using the attribute's value as the
  <var>input</var> and the <code id=the-iframe-element:the-iframe-element-34><a href=#the-iframe-element>iframe</a></code> element's <a href=#nested-browsing-context id=the-iframe-element:nested-browsing-context-21>nested browsing context</a>'s
  <a href=#iframe-sandboxing-flag-set id=the-iframe-element:iframe-sandboxing-flag-set><code>iframe</code> sandboxing flag set</a> as the output.</p>

  <p>When an <code id=the-iframe-element:the-iframe-element-35><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=#nested-browsing-context id=the-iframe-element:nested-browsing-context-22>nested browsing context</a>, the user agent
  must empty the <code id=the-iframe-element:the-iframe-element-36><a href=#the-iframe-element>iframe</a></code> element's <a href=#nested-browsing-context id=the-iframe-element:nested-browsing-context-23>nested browsing context</a>'s
  <a href=#iframe-sandboxing-flag-set id=the-iframe-element:iframe-sandboxing-flag-set-2><code>iframe</code> sandboxing flag set</a> as the output.</p>

  

  <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&apos;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>&quot;https://usercontent.example.net/getusercontent.cgi?id=12193&quot;</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>&quot;allow-same-origin allow-forms allow-scripts&quot;</c->
        <c- e>src</c-><c- o>=</c-><c- s>&quot;https://maps.example.com/embedded.html&quot;</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>&quot;allow-same-origin allow-forms&quot;</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>&quot;allow-scripts&quot;</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-2><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-37><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-38><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-39><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-40><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-41><a href=#the-iframe-element>iframe</a></code> in B had 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> 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=#nested-browsing-context id=the-iframe-element:nested-browsing-context-24>nested browsing context</a> in the <code id=the-iframe-element:the-iframe-element-42><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 id=attr-iframe-allow><code>allow</code></dfn> attribute, when specified,
  determines the <a href=https://wicg.github.io/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-feature-policy id=the-iframe-element:concept-document-feature-policy>feature policy</a> for a
  <a href=#document id=the-iframe-element:document-13>Document</a> in the <code id=the-iframe-element:the-iframe-element-43><a href=#the-iframe-element>iframe</a></code>'s <a href=#nested-browsing-context id=the-iframe-element:nested-browsing-context-25>nested browsing context</a> is
  initialized. Its value must be a <a href=https://wicg.github.io/feature-policy/#serialized-feature-policy id=the-iframe-element:concept-serialized-feature-policy data-x-internal=concept-serialized-feature-policy>serialized
  feature policy</a>. <a href=#refsFEATUREPOLICY>[FEATUREPOLICY]</a>

  <div class=example>
   <p>In this example, an <code id=the-iframe-element:the-iframe-element-44><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>&quot;https://maps.example.com/&quot;</c-> <c- e>allow</c-><c- o>=</c-><c- s>&quot;geolocation&quot;</c-><c- p>&gt;&lt;/</c-><c- f>iframe</c-><c- p>&gt;</c-></code></pre>
  </div>

  <p>The <dfn id=attr-iframe-allowfullscreen><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-14><a href=#document>Document</a></code> objects in
  the <code id=the-iframe-element:the-iframe-element-45><a href=#the-iframe-element>iframe</a></code> element's <a href=#browsing-context id=the-iframe-element:browsing-context-9>browsing context</a> will be initialized with a
  <a href=#concept-document-feature-policy id=the-iframe-element:concept-document-feature-policy-2>feature policy</a> which allows the "<code>fullscreen</code>" feature to be used from any <a href=#concept-origin id=the-iframe-element:concept-origin-3>origin</a>. This is enforced by
  the <a href=https://wicg.github.io/feature-policy/#process-feature-policy-attributes id=the-iframe-element:process-feature-policy-attributes data-x-internal=process-feature-policy-attributes>Process feature policy attributes</a>
  algorithm. <a href=#refsFEATUREPOLICY>[FEATUREPOLICY]</a>

  <div class=example>

   <p>Here, an <code id=the-iframe-element:the-iframe-element-46><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>&quot;/usericons/1627591962735&quot;</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>&quot;/posts/3095182851&quot;</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>&quot;#acl-3095182851&quot;</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>&quot;https://video.example.com/embed?id=92469812&quot;</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>The <dfn id=attr-iframe-allowpaymentrequest><code>allowpaymentrequest</code></dfn>
  attribute is a <a href=#boolean-attribute id=the-iframe-element:boolean-attribute-2>boolean attribute</a>. When specified, it indicates that
  <code id=the-iframe-element:document-15><a href=#document>Document</a></code> objects in the <code id=the-iframe-element:the-iframe-element-47><a href=#the-iframe-element>iframe</a></code> element's <a href=#browsing-context id=the-iframe-element:browsing-context-10>browsing context</a>
  will be initialized with a <a href=#concept-document-feature-policy id=the-iframe-element:concept-document-feature-policy-3>feature policy</a>
  which allows the "<code>payment</code>" feature to be used to make payment requests from
  any <a href=#concept-origin id=the-iframe-element:concept-origin-4>origin</a>. This is enforced by the <a href=https://wicg.github.io/feature-policy/#process-feature-policy-attributes id=the-iframe-element:process-feature-policy-attributes-2 data-x-internal=process-feature-policy-attributes>Process feature policy attributes</a> algorithm.
  <a href=#refsFEATUREPOLICY>[FEATUREPOLICY]</a>

  <p>The <dfn id=attr-iframe-allowusermedia><code>allowusermedia</code></dfn> attribute is a
  <a href=#boolean-attribute id=the-iframe-element:boolean-attribute-3>boolean attribute</a>. When specified, it indicates that <code id=the-iframe-element:document-16><a href=#document>Document</a></code> objects in
  the <code id=the-iframe-element:the-iframe-element-48><a href=#the-iframe-element>iframe</a></code> element's <a href=#browsing-context id=the-iframe-element:browsing-context-11>browsing context</a> will be initialized with a <a href=#concept-document-feature-policy id=the-iframe-element:concept-document-feature-policy-4>feature policy</a> which allows the "<code>camera</code>" and "<code>microphone</code>" features to be used to call
  <code id=the-iframe-element:dom-mediadevices-getusermedia-2><a data-x-internal=dom-mediadevices-getusermedia href=https://w3c.github.io/mediacapture-main/#dom-mediadevices-getusermedia>getUserMedia()</a></code> from any <a href=#concept-origin id=the-iframe-element:concept-origin-5>origin</a>.
  This is enforced by the <a href=https://wicg.github.io/feature-policy/#process-feature-policy-attributes id=the-iframe-element:process-feature-policy-attributes-3 data-x-internal=process-feature-policy-attributes>Process feature policy
  attributes</a> algorithm. <a href=#refsFEATUREPOLICY>[FEATUREPOLICY]</a>

  <p class=note>None of these attributes, <code id=the-iframe-element:attr-iframe-allow-3><a href=#attr-iframe-allow>allow</a></code>,
  <code id=the-iframe-element:attr-iframe-allowfullscreen-3><a href=#attr-iframe-allowfullscreen>allowfullscreen</a></code>, <code id=the-iframe-element:attr-iframe-allowpaymentrequest-2><a href=#attr-iframe-allowpaymentrequest>allowpaymentrequest</a></code> or <code id=the-iframe-element:attr-iframe-allowusermedia-2><a href=#attr-iframe-allowusermedia>allowusermedia</a></code>, can grant access to a feature in a
  <a href=#nested-browsing-context id=the-iframe-element:nested-browsing-context-26>nested browsing context</a> if the <code id=the-iframe-element:the-iframe-element-49><a href=#the-iframe-element>iframe</a></code> element'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> is not already allowed to use that feature.</p>

  
   <p id=fullscreen-logic>To determine whether a <code id=the-iframe-element:document-17><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> has no <a href=#concept-document-bc id=the-iframe-element:concept-document-bc-2>browsing context</a>,
    then return false.<li><p>If <var>document</var>'s <a href=#concept-document-bc id=the-iframe-element:concept-document-bc-3>browsing context</a>'s
    <a href=#active-document id=the-iframe-element:active-document-6>active document</a> is not <var>document</var>, then return false.<li><p>If the result of running <a href=https://wicg.github.io/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=#concept-origin id=the-iframe-element:concept-origin-6>origin</a> is "<code>Enabled</code>", then return true.<li><p>Return false.</ol>
  

  <p class=warning>Because they only influence the <a href=#concept-document-feature-policy id=the-iframe-element:concept-document-feature-policy-5>feature policy</a> of the <a href=#nested-browsing-context id=the-iframe-element:nested-browsing-context-27>nested browsing
  context</a>'s <a href=#active-document id=the-iframe-element:active-document-7>active document</a>, the <code id=the-iframe-element:attr-iframe-allow-4><a href=#attr-iframe-allow>allow</a></code>,
  <code id=the-iframe-element:attr-iframe-allowfullscreen-4><a href=#attr-iframe-allowfullscreen>allowfullscreen</a></code>, <code id=the-iframe-element:attr-iframe-allowpaymentrequest-3><a href=#attr-iframe-allowpaymentrequest>allowpaymentrequest</a></code> and <code id=the-iframe-element:attr-iframe-allowusermedia-3><a href=#attr-iframe-allowusermedia>allowusermedia</a></code> attributes only take effect when the
  <a href=#nested-browsing-context id=the-iframe-element:nested-browsing-context-28>nested browsing context</a> of the <code id=the-iframe-element:the-iframe-element-50><a href=#the-iframe-element>iframe</a></code> is <a href=#navigate id=the-iframe-element:navigate-13>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-51><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-52><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=#creating-a-new-browsing-context id=the-iframe-element:creating-a-new-browsing-context-2>create</a> a nested <a href=#browsing-context id=the-iframe-element:browsing-context-12>browsing context</a>, regardless of whether the specified initial
  contents are successfully used.</p>

  <hr> 

  <p>The <dfn id=attr-iframe-referrerpolicy><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-2 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-6>processing the <code>iframe</code>
  attributes</a>. <a href=#refsREFERRERPOLICY>[REFERRERPOLICY]</a></p>

  <hr> 

  <p>Descendants of <code id=the-iframe-element:the-iframe-element-53><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-54><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-55><a href=#the-iframe-element>iframe</a></code> elements as
  text.</p>


  

  <hr> 

  <p>The IDL attributes <dfn id=dom-iframe-src><code>src</code></dfn>, <dfn id=dom-iframe-srcdoc><code>srcdoc</code></dfn>, <dfn id=dom-iframe-name><code>name</code></dfn>, <dfn id=dom-iframe-sandbox><code>sandbox</code></dfn>, and <dfn id=dom-iframe-allow><code>allow</code></dfn> must <a href=#reflect id=the-iframe-element:reflect>reflect</a> the respective content
  attributes of the same name.</p>

  <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-2><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>

  <p>The <dfn id=dom-iframe-allowfullscreen><code>allowFullscreen</code></dfn> IDL attribute
  must <a href=#reflect id=the-iframe-element:reflect-2>reflect</a> the <code id=the-iframe-element:attr-iframe-allowfullscreen-5><a href=#attr-iframe-allowfullscreen>allowfullscreen</a></code>
  content attribute.</p>

  <p>The <dfn id=dom-iframe-allowpaymentrequest><code>allowPaymentRequest</code></dfn> IDL
  attribute must <a href=#reflect id=the-iframe-element:reflect-3>reflect</a> the <code id=the-iframe-element:attr-iframe-allowpaymentrequest-4><a href=#attr-iframe-allowpaymentrequest>allowpaymentrequest</a></code> content attribute.</p>

  <p>The <dfn id=dom-iframe-allowusermedia><code>allowUserMedia</code></dfn> IDL attribute
  must <a href=#reflect id=the-iframe-element:reflect-4>reflect</a> the <code id=the-iframe-element:attr-iframe-allowusermedia-4><a href=#attr-iframe-allowusermedia>allowusermedia</a></code>
  content attribute.</p>

  <p>The <dfn id=dom-iframe-referrerpolicy><code>referrerPolicy</code></dfn> IDL attribute
  must <a href=#reflect id=the-iframe-element:reflect-5>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>

  <p>The <dfn id=dom-iframe-contentdocument><code>contentDocument</code></dfn> IDL attribute,
  on getting, must return the <code id=the-iframe-element:the-iframe-element-56><a href=#the-iframe-element>iframe</a></code> element's <a href=#concept-bcc-content-document id=the-iframe-element:concept-bcc-content-document>content document</a>.</p>

  <p>The <dfn id=dom-iframe-contentwindow><code>contentWindow</code></dfn> IDL attribute must
  return the <code id=the-iframe-element:windowproxy-3><a href=#windowproxy>WindowProxy</a></code> object of the <code id=the-iframe-element:the-iframe-element-57><a href=#the-iframe-element>iframe</a></code> element's <a href=#nested-browsing-context id=the-iframe-element:nested-browsing-context-29>nested
  browsing context</a>, if its <a href=#nested-browsing-context id=the-iframe-element:nested-browsing-context-30>nested browsing context</a> is non-null, or null
  otherwise.</p>

  

  <div class=example>

   <p>Here is an example of a page using an <code id=the-iframe-element:the-iframe-element-58><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>&quot;https://ads.example.com/?customerid=923513721&amp;amp;format=banner&quot;</c->
        <c- e>width</c-><c- o>=</c-><c- s>&quot;468&quot;</c-> <c- e>height</c-><c- o>=</c-><c- s>&quot;60&quot;</c-><c- p>&gt;&lt;/</c-><c- f>iframe</c-><c- p>&gt;</c-></code></pre>

  </div>




  <h4 id=the-embed-element data-dfn-type=element data-lt=embed><span class=secno>4.8.6</span> The <dfn><code>embed</code></dfn> element<a href=#the-embed-element class=self-link></a></h4>



  <dl class=element><dt><a href=#concept-element-categories id=the-embed-element:concept-element-categories>Categories</a>:<dd><a href=#flow-content-2 id=the-embed-element:flow-content-2>Flow content</a>.<dd><a href=#phrasing-content-2 id=the-embed-element:phrasing-content-2>Phrasing content</a>.<dd><a href=#embedded-content-category id=the-embed-element:embedded-content-category>Embedded content</a>.<dd><a href=#interactive-content-2 id=the-embed-element:interactive-content-2>Interactive content</a>.<dd><a href=#palpable-content-2 id=the-embed-element:palpable-content-2>Palpable content</a>.<dt><a href=#concept-element-contexts id=the-embed-element:concept-element-contexts>Contexts in which this element can be used</a>:<dd>Where <a href=#embedded-content-category id=the-embed-element:embedded-content-category-2>embedded content</a> is expected.<dt><a href=#concept-element-content-model id=the-embed-element:concept-element-content-model>Content model</a>:<dd><a href=#concept-content-nothing id=the-embed-element:concept-content-nothing>Nothing</a>.<dt><a href=#concept-element-tag-omission id=the-embed-element:concept-element-tag-omission>Tag omission in text/html</a>:<dd>No <a href=#syntax-end-tag id=the-embed-element:syntax-end-tag>end tag</a>.<dt><a href=#concept-element-attributes id=the-embed-element:concept-element-attributes>Content attributes</a>:<dd><a href=#global-attributes id=the-embed-element:global-attributes>Global attributes</a><dd><code id=the-embed-element:attr-embed-src><a href=#attr-embed-src>src</a></code> — Address of the resource<dd><code id=the-embed-element:attr-embed-type><a href=#attr-embed-type>type</a></code> — Type of embedded resource<dd><code id=the-embed-element:attr-dim-width><a href=#attr-dim-width>width</a></code> — Horizontal dimension<dd><code id=the-embed-element:attr-dim-height><a href=#attr-dim-height>height</a></code> — Vertical dimension<dd>Any other attribute that has no namespace (see prose).<dt><a href=#concept-element-dom id=the-embed-element:concept-element-dom>DOM interface</a>:<dd>
    <pre><code class='idl'>[<c- g>Exposed</c->=<c- n>Window</c->,
 <a href='#htmlconstructor' id='the-embed-element:htmlconstructor'><c- g>HTMLConstructor</c-></a>]
<c- b>interface</c-> <dfn id='htmlembedelement'><c- g>HTMLEmbedElement</c-></dfn> : <a href='#htmlelement' id='the-embed-element:htmlelement'><c- n>HTMLElement</c-></a> {
  [<a href='#cereactions' id='the-embed-element:cereactions'><c- g>CEReactions</c-></a>] <c- b>attribute</c-> <c- b>USVString</c-> <a href='#dom-embed-src' id='the-embed-element:dom-embed-src'><c- g>src</c-></a>;
  [<a href='#cereactions' id='the-embed-element:cereactions-2'><c- g>CEReactions</c-></a>] <c- b>attribute</c-> <c- b>DOMString</c-> <a href='#dom-embed-type' id='the-embed-element:dom-embed-type'><c- g>type</c-></a>;
  [<a href='#cereactions' id='the-embed-element:cereactions-3'><c- g>CEReactions</c-></a>] <c- b>attribute</c-> <c- b>DOMString</c-> <a href='#dom-dim-width' id='the-embed-element:dom-dim-width'><c- g>width</c-></a>;
  [<a href='#cereactions' id='the-embed-element:cereactions-4'><c- g>CEReactions</c-></a>] <c- b>attribute</c-> <c- b>DOMString</c-> <a href='#dom-dim-height' id='the-embed-element:dom-dim-height'><c- g>height</c-></a>;
  <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>();
};</code></pre>
    
    <p>Depending on the type of content instantiated by the
    <code id=the-embed-element:the-embed-element><a href=#the-embed-element>embed</a></code> element, the node may also support other
    interfaces.</p>
    
   </dl>

  <p>The <code id=the-embed-element:the-embed-element-2><a href=#the-embed-element>embed</a></code> element provides an integration point for an external (typically
  non-HTML) application or interactive content.</p>

  <p>The <dfn id=attr-embed-src><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-3><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 id=attr-embed-type><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>

  

  <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-4><a href=#the-embed-element>embed</a></code> element <a href=#represents id=the-embed-element:represents>represents</a>
  nothing:</p>

  <ul class=brief><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.<li><p>The element has a <a href=#media-element id=the-embed-element:media-element>media element</a> ancestor.<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>.</ul>

  <p>An <code id=the-embed-element:the-embed-element-5><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 class=brief><li>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>.<li>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>.<li>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).<li>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.<li>The element is not a descendant of a <a href=#media-element id=the-embed-element:media-element-2>media element</a>.<li>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>.<li>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>.</ul>

  <p>Whenever an <code id=the-embed-element:the-embed-element-6><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-7><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> and 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-a-task id=the-embed-element:queue-a-task>queue a task</a> using the <dfn id=embed-task-source>embed task source</dfn> 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>

  <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-8><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.<li><p>If the <a id=the-embed-element:should-element-be-blocked-a-priori-by-content-security-policy href=https://w3c.github.io/webappsec-csp/#should-plugin-element-be-blocked-a-priori-by-content-security-policy data-x-internal=should-element-be-blocked-a-priori-by-content-security-policy>Should element be blocked <i lang=la>a priori</i> by Content Security
   Policy?</a> algorithm returns "<code>Blocked</code>" when executed on
   <var>element</var>, then return. <a href=#refsCSP>[CSP]</a><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=#parse-a-url id=the-embed-element:parse-a-url>parsing</a> the value
     of <var>element</var>'s <code id=the-embed-element:attr-embed-src-9><a href=#attr-embed-src>src</a></code> attribute, 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>.<li><p>If <var>url</var> is failure, then return.<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>", 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.<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>.</p>

      <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-4 href=https://dom.spec.whatwg.org/#concept-node-document data-x-internal=node-document>node document</a>.</p>

      <p>To <a id=the-embed-element:process-response href=https://fetch.spec.whatwg.org/#process-response data-x-internal=process-response>process response</a> for the <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.<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>.<li>
        <p>Switch on <var>type</var>:</p>

        <dl class=switch><dt>null<dd>
          <ol><li><p><a href=#display-no-plugin id=the-embed-element:display-no-plugin>Display no plugin</a> for <var>element</var>.</ol>
         <dt><code id=the-embed-element:image/svg+xml><a href=#image/svg+xml>image/svg+xml</a></code><dd>
          <ol><li>
            <p>If <var>element</var>'s <a href=#nested-browsing-context id=the-embed-element:nested-browsing-context>nested browsing context</a> is null, then:</p>

            <ol><li><p>Set <var>element</var>'s <a href=#nested-browsing-context id=the-embed-element:nested-browsing-context-2>nested browsing context</a> to a <a href=#creating-a-new-browsing-context id=the-embed-element:creating-a-new-browsing-context>newly-created browsing
             context</a>.<li><p>If <var>element</var> has a <code id=the-embed-element:attr-embed-name><a href=#attr-embed-name>name</a></code>
             attribute, then set the <a href=#browsing-context-name id=the-embed-element:browsing-context-name>browsing context name</a> of <var>element</var>'s new
             <a href=#nested-browsing-context id=the-embed-element:nested-browsing-context-3>nested browsing context</a> to the value of this attribute.</ol>
           <li>
            <p><a href=#navigate id=the-embed-element:navigate>Navigate</a> <var>element</var>'s <a href=#nested-browsing-context id=the-embed-element:nested-browsing-context-4>nested browsing context</a> to
            <var>response</var>, with <a href=#replacement-enabled id=the-embed-element:replacement-enabled>replacement enabled</a>, and with
            <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>'s <a href=#concept-document-bc id=the-embed-element:concept-document-bc>browsing context</a> as the <a href=#source-browsing-context id=the-embed-element:source-browsing-context>source browsing
            context</a>.</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 browsing context gets further navigated to other
            locations.</p>
           <li><p><var>embed</var> element now <a href=#represents id=the-embed-element:represents-2>represents</a> its <a href=#nested-browsing-context id=the-embed-element:nested-browsing-context-5>nested browsing
           context</a>.<li><p>When the <code id=the-embed-element:document-2><a href=#document>Document</a></code> of the <a href=#nested-browsing-context id=the-embed-element:nested-browsing-context-6>nested browsing context</a> is
           marked as <a href=#completely-loaded id=the-embed-element:completely-loaded>completely loaded</a>, <a href=#queue-a-task id=the-embed-element:queue-a-task-2>queue a task</a> to <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>.</ol>
         <dt>Otherwise<dd>
          <ol><li><p><a href=#display-a-plugin id=the-embed-element:display-a-plugin>Display a plugin</a> for <var>element</var>, given <var>type</var> and
           <var>response</var>.</ol>
         </dl>
       </ol>
     </ol>
   <li>
    <p>Otherwise:</p>

    <ol><li><p>Let <var>type</var> be the value of <var>element</var>'s <code id=the-embed-element:attr-embed-type-8><a href=#attr-embed-type>type</a></code> attribute.<li><p>If <var>type</var> is a type that a <a href=#plugin id=the-embed-element:plugin-2>plugin</a> supports, then <a href=#display-a-plugin id=the-embed-element:display-a-plugin-2>display a
     plugin</a> for <var>element</var> given <var>type</var>.<li><p>Otherwise, <a href=#display-no-plugin id=the-embed-element:display-no-plugin-2>display no plugin</a> for <var>element</var>.</ol>
   </ol>

  <p>To determine the <dfn id=concept-embed-type>type of the content</dfn> given an
  <code id=the-embed-element:the-embed-element-9><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-9><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-3>plugin</a> supports, then return the value of the
   <code id=the-embed-element:attr-embed-type-10><a href=#attr-embed-type>type</a></code> attribute.<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 data-x-internal=concept-response-url>url</a> matches a pattern that a <a href=#plugin id=the-embed-element:plugin-4>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><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-5>plugin</a> supports, then return that
   value.<li><p>Return null.</ol>
  

  <p class=note>It is intentional that the above algorithm allows <var>response</var> to be 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> or 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>

  <p>To <dfn id=display-a-plugin>display a plugin</dfn> for an <code id=the-embed-element:the-embed-element-10><a href=#the-embed-element>embed</a></code> element <var>element</var>, given a
  string <var>type</var> and optionally  a <a href=https://fetch.spec.whatwg.org/#concept-response id=the-embed-element:concept-response-3 data-x-internal=concept-response>response</a>
  <var>response</var>:</p>

  <ol><li>
    <p>If <var>element</var>'s <a href=#nested-browsing-context id=the-embed-element:nested-browsing-context-7>nested browsing context</a> is not null, then:</p>

    <ol><li><p><a href=#a-browsing-context-is-discarded id=the-embed-element:a-browsing-context-is-discarded>Discard</a> <var>element</var>'s
     <a href=#nested-browsing-context id=the-embed-element:nested-browsing-context-8>nested browsing context</a>.<li><p>Set <var>element</var>'s <a href=#nested-browsing-context id=the-embed-element:nested-browsing-context-9>nested browsing context</a> to null.</ol>
   <li><p>Find and instantiate an appropriate <a href=#plugin id=the-embed-element:plugin-6>plugin</a> based on <var>type</var>,
   replacing any previously-instantiated plugin for <var>element</var>. If <var>response</var> was
   given, forward it to the plugin.<li><p><var>element</var> now <a href=#represents id=the-embed-element:represents-3>represents</a> this <a href=#plugin id=the-embed-element:plugin-7>plugin</a> instance.<li><p>Once the plugin, and <var>response</var> if given, are completely loaded, <a href=#queue-a-task id=the-embed-element:queue-a-task-3>queue a
   task</a> to <a href=https://dom.spec.whatwg.org/#concept-event-fire id=the-embed-element:concept-event-fire-2 data-x-internal=concept-event-fire>fire an event</a> named <code id=the-embed-element:event-load-2><a href=#event-load>load</a></code> at <var>element</var>.</ol>

  <p>To <dfn id=display-no-plugin>display no plugin</dfn> for an <code id=the-embed-element:the-embed-element-11><a href=#the-embed-element>embed</a></code> element <var>element</var>:</p>

  <ol><li>
    <p>If <var>element</var>'s <a href=#nested-browsing-context id=the-embed-element:nested-browsing-context-10>nested browsing context</a> is not null, then:</p>

    <ol><li><p><a href=#a-browsing-context-is-discarded id=the-embed-element:a-browsing-context-is-discarded-2>Discard</a> <var>element</var>'s
     <a href=#nested-browsing-context id=the-embed-element:nested-browsing-context-11>nested browsing context</a>.<li><p>Set <var>element</var>'s <a href=#nested-browsing-context id=the-embed-element:nested-browsing-context-12>nested browsing context</a> to null.</ol>
   <li><p>Display an indication that no <a href=#plugin id=the-embed-element:plugin-8>plugin</a> could be found for <var>element</var>,
   replacing any previously-instantiated plugin for <var>element</var>.<li><p><var>element</var> now <a href=#represents id=the-embed-element:represents-4>represents</a> nothing.</ol>

  <p class=note>The <code id=the-embed-element:the-embed-element-12><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>

  <p>Whenever an <code id=the-embed-element:the-embed-element-13><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-9>plugin</a> that had been instantiated for that element must be unloaded.</p>

  <p id=sandboxPluginEmbed>When a <a href=#plugin id=the-embed-element:plugin-10>plugin</a> is to be instantiated but it cannot be <a href=#concept-plugin-secure id=the-embed-element:concept-plugin-secure>secured</a> and the <a href=#sandboxed-plugins-browsing-context-flag id=the-embed-element:sandboxed-plugins-browsing-context-flag>sandboxed plugins browsing context
  flag</a> is set on the <code id=the-embed-element:the-embed-element-14><a href=#the-embed-element>embed</a></code> element's <a id=the-embed-element:node-document-6 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=the-embed-element:active-sandboxing-flag-set>active
  sandboxing flag set</a>, then the user agent must not instantiate the <a href=#plugin id=the-embed-element:plugin-11>plugin</a>, and
  must instead render the <code id=the-embed-element:the-embed-element-15><a href=#the-embed-element>embed</a></code> element in a manner that conveys that the
  <a href=#plugin id=the-embed-element:plugin-12>plugin</a> was disabled. The user agent may offer the user the option to override the
  sandbox and instantiate the <a href=#plugin id=the-embed-element:plugin-13>plugin</a> anyway; if the user invokes such an option, the
  user agent must act as if the conditions above did not apply for the purposes of this element.</p>

  <p class=warning>Plugins that cannot be <a href=#concept-plugin-secure id=the-embed-element:concept-plugin-secure-2>secured</a> are
  disabled in sandboxed browsing contexts because they might not honor the restrictions imposed by
  the sandbox (e.g. they might allow scripting even when scripting in the sandbox is disabled). User
  agents should convey the danger of overriding the sandbox to the user if an option to do so is
  provided.</p>

  <p>When an <code id=the-embed-element:the-embed-element-16><a href=#the-embed-element>embed</a></code> element has a non-null <a href=#nested-browsing-context id=the-embed-element:nested-browsing-context-13>nested browsing context</a>: if the
  <code id=the-embed-element:the-embed-element-17><a href=#the-embed-element>embed</a></code> element's <a href=#nested-browsing-context id=the-embed-element:nested-browsing-context-14>nested browsing context</a>'s <a href=#active-document id=the-embed-element:active-document>active document</a>
  is not <a href=#ready-for-post-load-tasks id=the-embed-element:ready-for-post-load-tasks>ready for post-load tasks</a>, and when anything is <a href=#delay-the-load-event id=the-embed-element:delay-the-load-event-2>delaying the load event</a> of the <code id=the-embed-element:the-embed-element-18><a href=#the-embed-element>embed</a></code> element's <a href=#browsing-context id=the-embed-element:browsing-context>browsing
  context</a>'s <a href=#active-document id=the-embed-element:active-document-2>active document</a>, and when the <code id=the-embed-element:the-embed-element-19><a href=#the-embed-element>embed</a></code> element's
  <a href=#browsing-context id=the-embed-element:browsing-context-2>browsing context</a> is in the <a href=#delaying-load-events-mode id=the-embed-element:delaying-load-events-mode>delaying <code>load</code>
  events mode</a>, the <code id=the-embed-element:the-embed-element-20><a href=#the-embed-element>embed</a></code> must <a href=#delay-the-load-event id=the-embed-element:delay-the-load-event-3>delay the load event</a> of its
  document.</p>

  <p>The <a href=#task-source id=the-embed-element:task-source>task source</a> for the <a href=#concept-task id=the-embed-element:concept-task-3>tasks</a> mentioned in this
  section is the <a href=#dom-manipulation-task-source id=the-embed-element:dom-manipulation-task-source>DOM manipulation task source</a>.</p>

  

  <p>Any namespace-less attribute other than <code id=the-embed-element:attr-embed-name-2><a href=#attr-embed-name>name</a></code>, <code id=the-embed-element:attr-embed-align><a href=#attr-embed-align>align</a></code>, <code id=the-embed-element:attr-embed-hspace><a href=#attr-embed-hspace>hspace</a></code>, and <code id=the-embed-element:attr-embed-vspace><a href=#attr-embed-vspace>vspace</a></code>  may be
  specified on the <code id=the-embed-element:the-embed-element-21><a href=#the-embed-element>embed</a></code> element, so long as its name is <a href=#xml-compatible id=the-embed-element:xml-compatible>XML-compatible</a>
  and contains no <a href=https://infra.spec.whatwg.org/#ascii-upper-alpha id=the-embed-element:uppercase-ascii-letters data-x-internal=uppercase-ascii-letters>ASCII upper alphas</a>. These attributes are
  then passed as parameters to the <a href=#plugin id=the-embed-element:plugin-14>plugin</a>.</p>

  <p class=note>All attributes in <a id=the-embed-element:html-documents href=https://dom.spec.whatwg.org/#html-document data-x-internal=html-documents>HTML documents</a> get lowercased automatically, so the
  restriction on uppercase letters doesn't affect such documents.</p>

  <p class=note>The four exceptions are to exclude legacy attributes that have side-effects beyond
  just sending parameters to the <a href=#plugin id=the-embed-element:plugin-15>plugin</a>.</p>

  

  <p>The user agent should pass the names and values of all the attributes of the <code id=the-embed-element:the-embed-element-22><a href=#the-embed-element>embed</a></code>
  element that have no namespace to the <a href=#plugin id=the-embed-element:plugin-16>plugin</a> used, when one is instantiated.</p>

  <p>The <code id=the-embed-element:htmlembedelement><a href=#htmlembedelement>HTMLEmbedElement</a></code> object representing the element must expose the scriptable
  interface of the <a href=#plugin id=the-embed-element:plugin-17>plugin</a> instantiated for the <code id=the-embed-element:the-embed-element-23><a href=#the-embed-element>embed</a></code> element, if any.</p>

  

  <p>The <code id=the-embed-element:the-embed-element-24><a href=#the-embed-element>embed</a></code> element supports <a href=#dimension-attributes id=the-embed-element:dimension-attributes>dimension attributes</a>.</p>

  

  <p>The IDL attributes <dfn id=dom-embed-src><code>src</code></dfn> and <dfn id=dom-embed-type><code>type</code></dfn> each must <a href=#reflect id=the-embed-element:reflect>reflect</a> the respective
  content attributes of the same name.</p>

  

  <div class=example>

   <p>Here's a way to embed a resource that requires a proprietary plugin, like Flash:</p>

   <pre><code class='html'><c- p>&lt;</c-><c- f>embed</c-> <c- e>src</c-><c- o>=</c-><c- s>&quot;catgame.swf&quot;</c-><c- p>&gt;</c-></code></pre>

   <p>If the user does not have the plugin (for example if the plugin vendor doesn't support the
   user's platform), then the user will be unable to use the resource.</p>

   <p>To pass the plugin a parameter "quality" with the value "high", an attribute can be
   specified:</p>

   <pre><code class='html'><c- p>&lt;</c-><c- f>embed</c-> <c- e>src</c-><c- o>=</c-><c- s>&quot;catgame.swf&quot;</c-> <c- e>quality</c-><c- o>=</c-><c- s>&quot;high&quot;</c-><c- p>&gt;</c-></code></pre>

   <p>This would be equivalent to the following, when using an <code id=the-embed-element:the-object-element-3><a href=#the-object-element>object</a></code> element
   instead:</p>

   <pre><code class='html'><c- p>&lt;</c-><c- f>object</c-> <c- e>data</c-><c- o>=</c-><c- s>&quot;catgame.swf&quot;</c-><c- p>&gt;</c->
 <c- p>&lt;</c-><c- f>param</c-> <c- e>name</c-><c- o>=</c-><c- s>&quot;quality&quot;</c-> <c- e>value</c-><c- o>=</c-><c- s>&quot;high&quot;</c-><c- p>&gt;</c->
<c- p>&lt;/</c-><c- f>object</c-><c- p>&gt;</c-></code></pre>

  </div>




  <h4 id=the-object-element data-dfn-type=element data-lt=object><span class=secno>4.8.7</span> The <dfn><code>object</code></dfn> element<a href=#the-object-element class=self-link></a></h4>

  <dl class=element><dt><a href=#concept-element-categories id=the-object-element:concept-element-categories>Categories</a>:<dd><a href=#flow-content-2 id=the-object-element:flow-content-2>Flow content</a>.<dd><a href=#phrasing-content-2 id=the-object-element:phrasing-content-2>Phrasing content</a>.<dd><a href=#embedded-content-category id=the-object-element:embedded-content-category>Embedded content</a>.<dd>If the element has a <code id=the-object-element:attr-hyperlink-usemap><a href=#attr-hyperlink-usemap>usemap</a></code> attribute: <a href=#interactive-content-2 id=the-object-element:interactive-content-2>Interactive content</a>.<dd><a href=#category-listed id=the-object-element:category-listed>Listed</a> and <a href=#category-submit id=the-object-element:category-submit>submittable</a> <a href=#form-associated-element id=the-object-element:form-associated-element>form-associated element</a>.<dd><a href=#palpable-content-2 id=the-object-element:palpable-content-2>Palpable content</a>.<dt><a href=#concept-element-contexts id=the-object-element:concept-element-contexts>Contexts in which this element can be used</a>:<dd>Where <a href=#embedded-content-category id=the-object-element:embedded-content-category-2>embedded content</a> is expected.<dt><a href=#concept-element-content-model id=the-object-element:concept-element-content-model>Content model</a>:<dd>Zero or more <code id=the-object-element:the-param-element><a href=#the-param-element>param</a></code> elements, then, <a href=#transparent id=the-object-element:transparent>transparent</a>.<dt><a href=#concept-element-tag-omission id=the-object-element:concept-element-tag-omission>Tag omission in text/html</a>:<dd>Neither tag is omissible.<dt><a href=#concept-element-attributes id=the-object-element:concept-element-attributes>Content attributes</a>:<dd><a href=#global-attributes id=the-object-element:global-attributes>Global attributes</a><dd><code id=the-object-element:attr-object-data><a href=#attr-object-data>data</a></code> — Address of the resource<dd><code id=the-object-element:attr-object-type><a href=#attr-object-type>type</a></code> — Type of embedded resource<dd><code id=the-object-element:attr-object-typemustmatch><a href=#attr-object-typemustmatch>typemustmatch</a></code> — Whether the <code id=the-object-element:attr-object-type-2><a href=#attr-object-type>type</a></code> attribute and the <a href=#content-type id=the-object-element:content-type>Content-Type</a> value need to match for the resource to be used<dd><code id=the-object-element:attr-object-name><a href=#attr-object-name>name</a></code> — Name of <a href=#nested-browsing-context id=the-object-element:nested-browsing-context>nested browsing context</a><dd><code id=the-object-element:attr-hyperlink-usemap-2><a href=#attr-hyperlink-usemap>usemap</a></code> — Name of <a href=#image-map id=the-object-element:image-map>image map</a> to use<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><code id=the-object-element:attr-dim-width><a href=#attr-dim-width>width</a></code> — Horizontal dimension<dd><code id=the-object-element:attr-dim-height><a href=#attr-dim-height>height</a></code> — Vertical dimension<dt><a href=#concept-element-dom id=the-object-element:concept-element-dom>DOM interface</a>:<dd>
    <pre><code class='idl'>[<c- g>Exposed</c->=<c- n>Window</c->,
 <a href='#htmlconstructor' id='the-object-element:htmlconstructor'><c- g>HTMLConstructor</c-></a>]
<c- b>interface</c-> <dfn id='htmlobjectelement'><c- g>HTMLObjectElement</c-></dfn> : <a href='#htmlelement' id='the-object-element:htmlelement'><c- n>HTMLElement</c-></a> {
  [<a href='#cereactions' id='the-object-element:cereactions'><c- g>CEReactions</c-></a>] <c- b>attribute</c-> <c- b>USVString</c-> <a href='#dom-object-data' id='the-object-element:dom-object-data'><c- g>data</c-></a>;
  [<a href='#cereactions' id='the-object-element:cereactions-2'><c- g>CEReactions</c-></a>] <c- b>attribute</c-> <c- b>DOMString</c-> <a href='#dom-object-type' id='the-object-element:dom-object-type'><c- g>type</c-></a>;
  [<a href='#cereactions' id='the-object-element:cereactions-3'><c- g>CEReactions</c-></a>] <c- b>attribute</c-> <c- b>boolean</c-> <a href='#dom-object-typemustmatch' id='the-object-element:dom-object-typemustmatch'><c- g>typeMustMatch</c-></a>;
  [<a href='#cereactions' id='the-object-element:cereactions-4'><c- g>CEReactions</c-></a>] <c- b>attribute</c-> <c- b>DOMString</c-> <a href='#dom-object-name' id='the-object-element:dom-object-name'><c- g>name</c-></a>;
  [<a href='#cereactions' id='the-object-element:cereactions-5'><c- g>CEReactions</c-></a>] <c- b>attribute</c-> <c- b>DOMString</c-> <a href='#dom-object-usemap' id='the-object-element:dom-object-usemap'><c- g>useMap</c-></a>;
  <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-6'><c- g>CEReactions</c-></a>] <c- b>attribute</c-> <c- b>DOMString</c-> <a href='#dom-dim-width' id='the-object-element:dom-dim-width'><c- g>width</c-></a>;
  [<a href='#cereactions' id='the-object-element:cereactions-7'><c- g>CEReactions</c-></a>] <c- b>attribute</c-> <c- b>DOMString</c-> <a href='#dom-dim-height' id='the-object-element:dom-dim-height'><c- g>height</c-></a>;
  <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>void</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->);
};</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>
    
   </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, as a <a href=#nested-browsing-context id=the-object-element:nested-browsing-context-2>nested browsing
  context</a>, or as an external resource to be processed by a <a href=#plugin id=the-object-element:plugin>plugin</a>.</p>

  <p>The <dfn id=attr-object-data><code>data</code></dfn> attribute, if present, 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. If present, the attribute must be 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 class=warning>Authors who reference resources from other <a href=#concept-origin id=the-object-element:concept-origin>origins</a>
  that they do not trust are urged to use the <code id=the-object-element:attr-object-typemustmatch-2><a href=#attr-object-typemustmatch>typemustmatch</a></code> attribute defined below. Without that
  attribute, it is possible in certain cases for an attacker on the remote host to use the plugin
  mechanism to run arbitrary scripts, even if the author has used features such as the Flash
  "allowScriptAccess" parameter.</p> 

  <p>The <dfn id=attr-object-type><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>At least one of either the <code id=the-object-element:attr-object-data-2><a href=#attr-object-data>data</a></code> attribute or the <code id=the-object-element:attr-object-type-3><a href=#attr-object-type>type</a></code> attribute must be present.</p>

  <p>If the <code id=the-object-element:names:-the-itemprop-attribute><a href=#names:-the-itemprop-attribute>itemprop</a></code> attribute is specified on an <code id=the-object-element:the-object-element-3><a href=#the-object-element>object</a></code>
  element, then the <code id=the-object-element:attr-object-data-3><a href=#attr-object-data>data</a></code> attribute must also be specified.</p>

  <p>The <dfn id=attr-object-typemustmatch><code>typemustmatch</code></dfn> attribute is a
  <a href=#boolean-attribute id=the-object-element:boolean-attribute>boolean attribute</a> whose presence indicates that the resource specified by the <code id=the-object-element:attr-object-data-4><a href=#attr-object-data>data</a></code> attribute is only to be used if the value of the <code id=the-object-element:attr-object-type-4><a href=#attr-object-type>type</a></code> attribute and the <a href=#content-type id=the-object-element:content-type-2>Content-Type</a> of the
  aforementioned resource match.</p>

  <p>The <code id=the-object-element:attr-object-typemustmatch-3><a href=#attr-object-typemustmatch>typemustmatch</a></code> attribute must not be
  specified unless both the <code id=the-object-element:attr-object-data-5><a href=#attr-object-data>data</a></code> attribute and the <code id=the-object-element:attr-object-type-5><a href=#attr-object-type>type</a></code> attribute are present.</p>

  <p>The <dfn id=attr-object-name><code>name</code></dfn> attribute, if present, must be a
  <a href=#valid-browsing-context-name id=the-object-element:valid-browsing-context-name>valid browsing context name</a>. The given value is used to name the <a href=#nested-browsing-context id=the-object-element:nested-browsing-context-3>nested
  browsing context</a>, if applicable.</p>

  

  <p>Whenever one of the following conditions occur:</p>

  <ul><li>the element is created,

   <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>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>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>one of the element's ancestor <code id=the-object-element:the-object-element-4><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>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>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-6><a href=#attr-object-data>data</a></code> attribute is set, changed, or removed,

   <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-7><a href=#attr-object-data>data</a></code> attribute are present, and its <code id=the-object-element:attr-object-type-6><a href=#attr-object-type>type</a></code> attribute is set, changed, or removed,

   <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,

  </ul> 

  <p>...the user agent must <a href=#queue-a-task id=the-object-element:queue-a-task>queue a task</a> 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-2>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>

    <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> that has a <a href=#concept-document-bc id=the-object-element:concept-document-bc>browsing context</a>, 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>, or if the <a id=the-object-element:should-element-be-blocked-a-priori-by-content-security-policy href=https://w3c.github.io/webappsec-csp/#should-plugin-element-be-blocked-a-priori-by-content-security-policy data-x-internal=should-element-be-blocked-a-priori-by-content-security-policy>Should element be blocked
    <i lang=la>a priori</i> by Content Security Policy?</a> algorithm returns "<code>Blocked</code>" when executed on the element, then jump to the step below labeled
    <i>fallback</i>. <a href=#refsCSP>[CSP]</a></p>

   <li>

    

    <p>If the <code id=the-object-element:attr-object-classid-4><a href=#attr-object-classid>classid</a></code> attribute is present, and has a
    value that isn't the empty string, then: if the user agent can find a <a href=#plugin id=the-object-element:plugin-2>plugin</a>
    suitable according to the value of the <code id=the-object-element:attr-object-classid-5><a href=#attr-object-classid>classid</a></code>
    attribute, and either <a href=#sandboxPluginObject>plugins aren't being sandboxed</a> or that
    <a href=#plugin id=the-object-element:plugin-3>plugin</a> can be <a href=#concept-plugin-secure id=the-object-element:concept-plugin-secure>secured</a>, then that
    <a href=#plugin id=the-object-element:plugin-4>plugin</a> <a href=#object-plugin>should be used</a>, and the value of the <code id=the-object-element:attr-object-data-8><a href=#attr-object-data>data</a></code> attribute, if any, should be passed to the
    <a href=#plugin id=the-object-element:plugin-5>plugin</a>. If no suitable <a href=#plugin id=the-object-element:plugin-6>plugin</a> can be found, or if the
    <a href=#plugin id=the-object-element:plugin-7>plugin</a> reports an error, jump to the step below labeled <i>fallback</i>.</p>

    

   <li><p>If the <code id=the-object-element:attr-object-data-9><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-7><a href=#attr-object-type>type</a></code> attribute is present and its value is
     not a type that the user agent supports, and is not a type that the user agent can find a
     <a href=#plugin id=the-object-element:plugin-8>plugin</a> for, then the user agent may jump to the step below labeled <i>fallback</i>
     without fetching the content to examine its real type.<li><p><a href=#parse-a-url id=the-object-element:parse-a-url>Parse</a> the <a id=the-object-element:url-2 href=https://url.spec.whatwg.org/#concept-url data-x-internal=url>URL</a> specified by the <code id=the-object-element:attr-object-data-10><a href=#attr-object-data>data</a></code> attribute, 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>.<li><p>If that failed, <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, then jump to the step below labeled
     <i>fallback</i>.<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 the <a href=#resulting-url-record id=the-object-element:resulting-url-record>resulting URL record</a>,
     <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>", 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.<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-3>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>

      <p>For the purposes of the <a href=#application-cache id=the-object-element:application-cache>application cache</a> networking model, this fetch
      operation is not for a <a href=#child-browsing-context id=the-object-element:child-browsing-context>child browsing context</a> (though it might end up being used
      for one after all, as defined below).</p>

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

        <p>If the <code id=the-object-element:the-object-element-8><a href=#the-object-element>object</a></code> element has a <code id=the-object-element:attr-object-type-8><a href=#attr-object-type>type</a></code>
        attribute and a <code id=the-object-element:attr-object-typemustmatch-4><a href=#attr-object-typemustmatch>typemustmatch</a></code> attribute, and
        the resource has <a href=#content-type id=the-object-element:content-type-3>associated Content-Type metadata</a>, and the
        type specified in <a href=#content-type id=the-object-element:content-type-4>the resource's Content-Type metadata</a> is
        an <a id=the-object-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 value of the element's <code id=the-object-element:attr-object-type-9><a href=#attr-object-type>type</a></code> attribute, then let <var>resource type</var>
        be that type and jump to the step below labeled <i>handler</i>.</p>

        

       <li>

        <p>If the <code id=the-object-element:the-object-element-9><a href=#the-object-element>object</a></code> element has a <code id=the-object-element:attr-object-typemustmatch-5><a href=#attr-object-typemustmatch>typemustmatch</a></code> attribute, jump to the step below
        labeled <i>handler</i>.</p>

       <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-5>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-6>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 plugin, but the remote site overrides that and instead
        furnishes the user agent with a resource that triggers a different plugin with different
        security characteristics. </p>

       <li>

        <p>If there is a <code id=the-object-element:attr-object-type-10><a href=#attr-object-type>type</a></code> attribute present on the
        <code id=the-object-element:the-object-element-10><a href=#the-object-element>object</a></code> element, and that attribute's value is not a type that the user agent
        supports, but it <em>is</em> a type that a <a href=#plugin id=the-object-element:plugin-9>plugin</a> supports, then let the <var>resource type</var> be the type specified in that <code id=the-object-element:attr-object-type-11><a href=#attr-object-type>type</a></code> attribute, and jump to the step below labeled
        <i>handler</i>.</p>

       <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-7>associated Content-Type
         metadata</a><dd>

          <ol><li>

            <p>Let <var>binary</var> be false.</p>

           <li>

            <p>If the type specified in <a href=#content-type id=the-object-element:content-type-8>the resource's Content-Type
            metadata</a> is "<code id=the-object-element:text/plain><a data-x-internal=text/plain href=https://tools.ietf.org/html/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://tools.ietf.org/html/rfc2046#section-4.1.3>text/plain</a></code>, then set <var>binary</var> to true.</p>

           <li>

            <p>If the type specified in <a href=#content-type id=the-object-element:content-type-9>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://tools.ietf.org/html/rfc2046#section-4.5.1>application/octet-stream</a></code>", then set <var>binary</var> to true.</p>

           <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-10>the resource's
            Content-Type metadata</a>, and jump to the step below labeled <i>handler</i>.</p>

           <li>

            <p>If there is a <code id=the-object-element:attr-object-type-12><a href=#attr-object-type>type</a></code> attribute present on the
            <code id=the-object-element:the-object-element-11><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://tools.ietf.org/html/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 a <a href=#plugin id=the-object-element:plugin-10>plugin</a> supports, or 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-13><a href=#attr-object-type>type</a></code> attribute.</p>

             <li>

              <p>Jump to the step below labeled <i>handler</i>.</p>

             </ol>

           </ol>

         <dt>Otherwise, if the resource does not have <a href=#content-type id=the-object-element:content-type-11>associated
         Content-Type metadata</a><dd>

          <ol><li>

            <p>If there is a <code id=the-object-element:attr-object-type-14><a href=#attr-object-type>type</a></code> attribute present on the
            <code id=the-object-element:the-object-element-12><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-15><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>

            <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://tools.ietf.org/html/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>

           </ol>

         </dl>

       <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-3 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-11>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>

        
        

       </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><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 not a type that the user agent supports, but
       it <em>is</em> a type that a <a href=#plugin id=the-object-element:plugin-12>plugin</a> supports<dd>

        <p>If the <code id=the-object-element:the-object-element-13><a href=#the-object-element>object</a></code> element's <a href=#nested-browsing-context id=the-object-element:nested-browsing-context-4>nested browsing context</a> is non-null,
        then it must be <a href=#a-browsing-context-is-discarded id=the-object-element:a-browsing-context-is-discarded>discarded</a> and then set
        to null.</p>

        <p>If <a href=#sandboxPluginObject>plugins are being sandboxed</a> and the plugin that
        supports <var>resource type</var> cannot be <a href=#concept-plugin-secure id=the-object-element:concept-plugin-secure-2>secured</a>, jump to the step below labeled <i>fallback</i>.</p>

        <p>Otherwise, the user agent should <a href=#object-plugin>use the plugin that supports
        <var>resource type</var></a> and pass the content of the resource to that
        <a href=#plugin id=the-object-element:plugin-13>plugin</a>. If the <a href=#plugin id=the-object-element:plugin-14>plugin</a> reports an error, then jump to the step
        below labeled <i>fallback</i>.</p>

       <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>"<dd>

        <p>If the <code id=the-object-element:the-object-element-14><a href=#the-object-element>object</a></code> element's <a href=#nested-browsing-context id=the-object-element:nested-browsing-context-5>nested browsing context</a> is null, set
        the element's <a href=#nested-browsing-context id=the-object-element:nested-browsing-context-6>nested browsing context</a> to a <a href=#creating-a-new-browsing-context id=the-object-element:creating-a-new-browsing-context>newly-created browsing context</a>.</p>

        <p>The <code id=the-object-element:the-object-element-15><a href=#the-object-element>object</a></code> element must be associated with a newly created <a href=#nested-browsing-context id=the-object-element:nested-browsing-context-7>nested
        browsing context</a>, if it does not already have one.</p>

        <p>If the <a id=the-object-element:url-4 href=https://url.spec.whatwg.org/#concept-url data-x-internal=url>URL</a> of the given resource is not <code id=the-object-element:about:blank><a href=#about:blank>about:blank</a></code>, the
        element's <a href=#nested-browsing-context id=the-object-element:nested-browsing-context-8>nested browsing context</a> must then be <a href=#navigate id=the-object-element:navigate>navigated</a> to that resource, with
        <a href=#replacement-enabled id=the-object-element:replacement-enabled>replacement enabled</a>, and with the <code id=the-object-element:the-object-element-16><a href=#the-object-element>object</a></code> 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>'s <a href=#concept-document-bc id=the-object-element:concept-document-bc-2>browsing context</a> as the
        <a href=#source-browsing-context id=the-object-element:source-browsing-context>source browsing context</a>. (The <code id=the-object-element:attr-object-data-11><a href=#attr-object-data>data</a></code>
        attribute of the <code id=the-object-element:the-object-element-17><a href=#the-object-element>object</a></code> element doesn't get updated if the browsing context
        gets further navigated to other locations.)</p>

        <p>If the <a id=the-object-element:url-5 href=https://url.spec.whatwg.org/#concept-url data-x-internal=url>URL</a> of the given resource <em>is</em> <code id=the-object-element:about:blank-2><a href=#about:blank>about:blank</a></code>, then,
        instead, the user agent must <a href=#queue-a-task id=the-object-element:queue-a-task-5>queue a task</a> 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 <code id=the-object-element:the-object-element-18><a href=#the-object-element>object</a></code> element. <span class=note>No <code id=the-object-element:event-load-2><a href=#event-load>load</a></code> event is fired at the <code id=the-object-element:about:blank-3><a href=#about:blank>about:blank</a></code> document
        itself.</span></p>

        <p>The <code id=the-object-element:the-object-element-19><a href=#the-object-element>object</a></code> element <a href=#represents id=the-object-element:represents>represents</a> the <a href=#nested-browsing-context id=the-object-element:nested-browsing-context-9>nested browsing
        context</a>.</p>

        <p>If the <code id=the-object-element:attr-object-name-2><a href=#attr-object-name>name</a></code> attribute is present, the
        <code id=the-object-element:the-object-element-20><a href=#the-object-element>object</a></code> element's <a href=#nested-browsing-context id=the-object-element:nested-browsing-context-10>nested browsing context</a>'s <a href=#browsing-context-name id=the-object-element:browsing-context-name>browsing context
        name</a> must be set to the value of this attribute; otherwise, the <a href=#browsing-context-name id=the-object-element:browsing-context-name-2>browsing
        context name</a> must be set to the empty string.</p>

        <p class=note>In certain situations, e.g., if the resource was fetched from an
        <a href=#application-cache id=the-object-element:application-cache-2>application cache</a> but it is an HTML file with a <code id=the-object-element:attr-html-manifest><a href=#attr-html-manifest>manifest</a></code> attribute that points to a different <a href=#concept-appcache-manifest id=the-object-element:concept-appcache-manifest>application cache manifest</a>, the <a href=#navigate id=the-object-element:navigate-2>navigation</a> of the <a href=#browsing-context id=the-object-element:browsing-context>browsing context</a> will be restarted
        so as to load the resource afresh from the network or a different <a href=#application-cache id=the-object-element:application-cache-3>application
        cache</a>. Even if the resource is then found to have a different type, it is still used
        as part of a <a href=#nested-browsing-context id=the-object-element:nested-browsing-context-11>nested browsing context</a>: only the <a href=#navigate id=the-object-element:navigate-3>navigate</a> algorithm
        is restarted, not this <code id=the-object-element:the-object-element-21><a href=#the-object-element>object</a></code> algorithm.</p>

        

       <dt>If the <var>resource type</var> starts with "<code>image/</code>", and support
       for images has not been disabled<dd>

        <p>If the <code id=the-object-element:the-object-element-22><a href=#the-object-element>object</a></code> element's <a href=#nested-browsing-context id=the-object-element:nested-browsing-context-12>nested browsing context</a> is non-null,
        then it must be <a href=#a-browsing-context-is-discarded id=the-object-element:a-browsing-context-is-discarded-2>discarded</a> and then set
        to null.</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-23><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>

       <dt>Otherwise<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>

       </dl>

     <li><p>The element's contents are not part of what the <code id=the-object-element:the-object-element-24><a href=#the-object-element>object</a></code> element
     represents.</p>

     <li>

      <p>Return. Once the resource is completely loaded, <a href=#queue-a-task id=the-object-element:queue-a-task-6>queue a task</a> to
      <a href=https://dom.spec.whatwg.org/#concept-event-fire id=the-object-element:concept-event-fire-4 data-x-internal=concept-event-fire>fire an event</a> named <code id=the-object-element:event-load-3><a href=#event-load>load</a></code> at the element.</p>

     </ol>

   <li><p>If the <code id=the-object-element:attr-object-data-12><a href=#attr-object-data>data</a></code> attribute is absent but the <code id=the-object-element:attr-object-type-16><a href=#attr-object-type>type</a></code> attribute is present, and the user agent can find a
   <a href=#plugin id=the-object-element:plugin-15>plugin</a> suitable according to the value of the <code id=the-object-element:attr-object-type-17><a href=#attr-object-type>type</a></code> attribute, and either <a href=#sandboxPluginObject>plugins aren't being sandboxed</a> or the <a href=#plugin id=the-object-element:plugin-16>plugin</a> can be
   <a href=#concept-plugin-secure id=the-object-element:concept-plugin-secure-3>secured</a>, then that <a href=#plugin id=the-object-element:plugin-17>plugin</a> <a href=#object-plugin>should be used</a>. If these conditions cannot be met, or if the
   <a href=#plugin id=the-object-element:plugin-18>plugin</a> reports an error, jump to the step below labeled <i>fallback</i>. Otherwise
   return; once the plugin is completely loaded, <a href=#queue-a-task id=the-object-element:queue-a-task-7>queue a task</a> to <a href=https://dom.spec.whatwg.org/#concept-event-fire id=the-object-element:concept-event-fire-5 data-x-internal=concept-event-fire>fire an event</a> named <code id=the-object-element:event-load-4><a href=#event-load>load</a></code> at
   the element.<li><p><i>Fallback</i>: The <code id=the-object-element:the-object-element-25><a href=#the-object-element>object</a></code> element <a href=#represents id=the-object-element:represents-3>represents</a> the element's
   children, ignoring any leading <code id=the-object-element:the-param-element-2><a href=#the-param-element>param</a></code> element children. This is the element's
   <a href=#fallback-content id=the-object-element:fallback-content-5>fallback content</a>. If the element has an instantiated <a href=#plugin id=the-object-element:plugin-19>plugin</a>, then
   unload it. If the element's <a href=#nested-browsing-context id=the-object-element:nested-browsing-context-13>nested browsing context</a> is non-null, then it must be
   <a href=#a-browsing-context-is-discarded id=the-object-element:a-browsing-context-is-discarded-3>discarded</a> and then set to null.</ol>

  <p id=object-plugin>When the algorithm above instantiates a <a href=#plugin id=the-object-element:plugin-20>plugin</a>, the user agent
  should pass to the <a href=#plugin id=the-object-element:plugin-21>plugin</a> used the names and values of all the attributes on the
  element, in the order they were added to the element, with the attributes added by the parser
  being ordered in source order, followed by a parameter named "PARAM" whose value is null, followed
  by all the names and values of <a href=#concept-param-parameter id=the-object-element:concept-param-parameter>parameters</a> given by
  <code id=the-object-element:the-param-element-3><a href=#the-param-element>param</a></code> elements that are children of the <code id=the-object-element:the-object-element-26><a href=#the-object-element>object</a></code> element, in <a id=the-object-element:tree-order href=https://dom.spec.whatwg.org/#concept-tree-order data-x-internal=tree-order>tree
  order</a>. If the <a href=#plugin id=the-object-element:plugin-22>plugin</a> supports a scriptable interface, the
  <code id=the-object-element:htmlobjectelement><a href=#htmlobjectelement>HTMLObjectElement</a></code> object representing the element should expose that interface. The
  <code id=the-object-element:the-object-element-27><a href=#the-object-element>object</a></code> element <a href=#represents id=the-object-element:represents-4>represents</a> the <a href=#plugin id=the-object-element:plugin-23>plugin</a>. The
  <a href=#plugin id=the-object-element:plugin-24>plugin</a> is not a nested <a href=#browsing-context id=the-object-element:browsing-context-2>browsing context</a>.</p>

  <p id=sandboxPluginObject>Plugins are considered sandboxed for the purpose of an
  <code id=the-object-element:the-object-element-28><a href=#the-object-element>object</a></code> element if the <a href=#sandboxed-plugins-browsing-context-flag id=the-object-element:sandboxed-plugins-browsing-context-flag>sandboxed plugins browsing context flag</a> is set on
  the <code id=the-object-element:the-object-element-29><a href=#the-object-element>object</a></code> element's <a id=the-object-element:node-document-8 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=the-object-element:active-sandboxing-flag-set>active sandboxing flag
  set</a>.</p>

  <p>Due to the algorithm above, the contents of <code id=the-object-element:the-object-element-30><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-31><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>When an <code id=the-object-element:the-object-element-32><a href=#the-object-element>object</a></code> element's <a href=#nested-browsing-context id=the-object-element:nested-browsing-context-14>nested browsing context</a> is non-null: if the
  <code id=the-object-element:the-object-element-33><a href=#the-object-element>object</a></code> element's <a href=#nested-browsing-context id=the-object-element:nested-browsing-context-15>nested browsing context</a>'s <a href=#active-document id=the-object-element:active-document>active document</a>
  is not <a href=#ready-for-post-load-tasks id=the-object-element:ready-for-post-load-tasks>ready for post-load tasks</a>, and when anything is <a href=#delay-the-load-event id=the-object-element:delay-the-load-event-3>delaying the load event</a> of the <code id=the-object-element:the-object-element-34><a href=#the-object-element>object</a></code> element's <a href=#browsing-context id=the-object-element:browsing-context-3>browsing
  context</a>'s <a href=#active-document id=the-object-element:active-document-2>active document</a>, and when the <code id=the-object-element:the-object-element-35><a href=#the-object-element>object</a></code> element's
  <a href=#browsing-context id=the-object-element:browsing-context-4>browsing context</a> is in the <a href=#delaying-load-events-mode id=the-object-element:delaying-load-events-mode>delaying <code>load</code>
  events mode</a>, the <code id=the-object-element:the-object-element-36><a href=#the-object-element>object</a></code> must <a href=#delay-the-load-event id=the-object-element:delay-the-load-event-4>delay the load event</a> of its
  document.</p>

  <p>The <a href=#task-source id=the-object-element:task-source>task source</a> for the <a href=#concept-task id=the-object-element:concept-task-4>tasks</a> mentioned in this
  section is the <a href=#dom-manipulation-task-source id=the-object-element:dom-manipulation-task-source>DOM manipulation task source</a>.</p>

  

  <p>The <code id=the-object-element:attr-hyperlink-usemap-3><a href=#attr-hyperlink-usemap>usemap</a></code> attribute, if present while the
  <code id=the-object-element:the-object-element-37><a href=#the-object-element>object</a></code> element represents an image, can indicate that the object has an associated
  <a href=#image-map id=the-object-element:image-map-2>image map</a>. The attribute must be ignored if the
  <code id=the-object-element:the-object-element-38><a href=#the-object-element>object</a></code> element doesn't represent an image.</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-39><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><strong>Constraint validation</strong>: <code id=the-object-element:the-object-element-40><a href=#the-object-element>object</a></code> elements are always <a href=#barred-from-constraint-validation id=the-object-element:barred-from-constraint-validation>barred
  from constraint validation</a>.</p>

  

  <p>The <code id=the-object-element:the-object-element-41><a href=#the-object-element>object</a></code> element supports <a href=#dimension-attributes id=the-object-element:dimension-attributes>dimension attributes</a>.</p>

  

  <p>The IDL attributes <dfn id=dom-object-data><code>data</code></dfn>, <dfn id=dom-object-type><code>type</code></dfn> and <dfn id=dom-object-name><code>name</code></dfn> each must <a href=#reflect id=the-object-element:reflect>reflect</a> the respective
  content attributes of the same name. The <dfn id=dom-object-typemustmatch><code>typeMustMatch</code></dfn> IDL attribute must
  <a href=#reflect id=the-object-element:reflect-2>reflect</a> the <code id=the-object-element:attr-object-typemustmatch-6><a href=#attr-object-typemustmatch>typemustmatch</a></code> content
  attribute. The <dfn id=dom-object-usemap><code>useMap</code></dfn> IDL attribute must
  <a href=#reflect id=the-object-element:reflect-3>reflect</a> the <code id=the-object-element:attr-hyperlink-usemap-4><a href=#attr-hyperlink-usemap>usemap</a></code> content attribute.</p>

  <p>The <dfn id=dom-object-contentdocument><code>contentDocument</code></dfn> IDL attribute,
  on getting, must return the <code id=the-object-element:the-object-element-42><a href=#the-object-element>object</a></code> element's <a href=#concept-bcc-content-document id=the-object-element:concept-bcc-content-document>content document</a>.</p>

  <p>The <dfn id=dom-object-contentwindow><code>contentWindow</code></dfn> IDL attribute must
  return the <code id=the-object-element:windowproxy-2><a href=#windowproxy>WindowProxy</a></code> object of the <code id=the-object-element:the-object-element-43><a href=#the-object-element>object</a></code> element's <a href=#nested-browsing-context id=the-object-element:nested-browsing-context-16>nested
  browsing context</a>, if its <a href=#nested-browsing-context id=the-object-element:nested-browsing-context-17>nested browsing context</a> is non-null; otherwise, it
  must return null.</p>

  <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-44><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>&quot;clock.html&quot;</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>

  <div class=example>

   <p>The following example shows how a plugin can be used in HTML (in this case the Flash plugin,
   to show a video file). Fallback is provided for users who do not have Flash enabled, in this case
   using the <code id=the-object-element:the-video-element><a href=#the-video-element>video</a></code> element to show the video for those using user agents that support
   <code id=the-object-element:the-video-element-2><a href=#the-video-element>video</a></code>, and finally providing a link to the video for those who have neither Flash
   nor a <code id=the-object-element:the-video-element-3><a href=#the-video-element>video</a></code>-capable browser.</p>

   <pre><code class='html'><c- p>&lt;</c-><c- f>p</c-><c- p>&gt;</c->Look at my video:
 <c- p>&lt;</c-><c- f>object</c-> <c- e>type</c-><c- o>=</c-><c- s>&quot;application/x-shockwave-flash&quot;</c-><c- p>&gt;</c->
  <c- p>&lt;</c-><c- f>param</c-> <c- e>name</c-><c- o>=</c-><c- s>movie</c-> <c- e>value</c-><c- o>=</c-><c- s>&quot;https://video.example.com/library/watch.swf&quot;</c-><c- p>&gt;</c->
  <c- p>&lt;</c-><c- f>param</c-> <c- e>name</c-><c- o>=</c-><c- s>allowfullscreen</c-> <c- e>value</c-><c- o>=</c-><c- s>true</c-><c- p>&gt;</c->
  <c- p>&lt;</c-><c- f>param</c-> <c- e>name</c-><c- o>=</c-><c- s>flashvars</c-> <c- e>value</c-><c- o>=</c-><c- s>&quot;https://video.example.com/vids/315981&quot;</c-><c- p>&gt;</c->
  <c- p>&lt;</c-><c- f>video</c-> <c- e>controls</c-> <c- e>src</c-><c- o>=</c-><c- s>&quot;https://video.example.com/vids/315981&quot;</c-><c- p>&gt;</c->
   <c- p>&lt;</c-><c- f>a</c-> <c- e>href</c-><c- o>=</c-><c- s>&quot;https://video.example.com/vids/315981&quot;</c-><c- p>&gt;</c->View video<c- p>&lt;/</c-><c- f>a</c-><c- p>&gt;</c->.
  <c- p>&lt;/</c-><c- f>video</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-></code></pre>

  </div>



  <h4 id=the-param-element><span class=secno>4.8.8</span> The <dfn><code>param</code></dfn> element<a href=#the-param-element class=self-link></a></h4>

  <dl class=element><dt><a href=#concept-element-categories id=the-param-element:concept-element-categories>Categories</a>:<dd>None.<dt><a href=#concept-element-contexts id=the-param-element:concept-element-contexts>Contexts in which this element can be used</a>:<dd>As a child of an <code id=the-param-element:the-object-element><a href=#the-object-element>object</a></code> element, before any <a href=#flow-content-2 id=the-param-element:flow-content-2>flow content</a>.<dt><a href=#concept-element-content-model id=the-param-element:concept-element-content-model>Content model</a>:<dd><a href=#concept-content-nothing id=the-param-element:concept-content-nothing>Nothing</a>.<dt><a href=#concept-element-tag-omission id=the-param-element:concept-element-tag-omission>Tag omission in text/html</a>:<dd>No <a href=#syntax-end-tag id=the-param-element:syntax-end-tag>end tag</a>.<dt><a href=#concept-element-attributes id=the-param-element:concept-element-attributes>Content attributes</a>:<dd><a href=#global-attributes id=the-param-element:global-attributes>Global attributes</a><dd><code id=the-param-element:attr-param-name><a href=#attr-param-name>name</a></code> — Name of parameter<dd><code id=the-param-element:attr-param-value><a href=#attr-param-value>value</a></code> — Value of parameter<dt><a href=#concept-element-dom id=the-param-element:concept-element-dom>DOM interface</a>:<dd>
    <pre><code class='idl'>[<c- g>Exposed</c->=<c- n>Window</c->,
 <a href='#htmlconstructor' id='the-param-element:htmlconstructor'><c- g>HTMLConstructor</c-></a>]
<c- b>interface</c-> <dfn id='htmlparamelement'><c- g>HTMLParamElement</c-></dfn> : <a href='#htmlelement' id='the-param-element:htmlelement'><c- n>HTMLElement</c-></a> {
  [<a href='#cereactions' id='the-param-element:cereactions'><c- g>CEReactions</c-></a>] <c- b>attribute</c-> <c- b>DOMString</c-> <a href='#dom-param-name' id='the-param-element:dom-param-name'><c- g>name</c-></a>;
  [<a href='#cereactions' id='the-param-element:cereactions-2'><c- g>CEReactions</c-></a>] <c- b>attribute</c-> <c- b>DOMString</c-> <a href='#dom-param-value' id='the-param-element:dom-param-value'><c- g>value</c-></a>;
};</code></pre>
   </dl>

  <p>The <code id=the-param-element:the-param-element><a href=#the-param-element>param</a></code> element defines parameters for plugins invoked by <code id=the-param-element:the-object-element-2><a href=#the-object-element>object</a></code>
  elements. It does not <a href=#represents id=the-param-element:represents>represent</a> anything on its own.</p>

  <p>The <dfn id=attr-param-name><code>name</code></dfn> attribute gives the name of the
  parameter.</p>

  <p>The <dfn id=attr-param-value><code>value</code></dfn> attribute gives the value of the
  parameter.</p>

  <p>Both attributes must be present. They may have any value.</p>

  

  <p>If both attributes are present, and if the parent element of the <code id=the-param-element:the-param-element-2><a href=#the-param-element>param</a></code> is an
  <code id=the-param-element:the-object-element-3><a href=#the-object-element>object</a></code> element, then the element defines a <dfn id=concept-param-parameter>parameter</dfn> with the given name-value pair.</p>

  <p>If either the name or value of a <a href=#concept-param-parameter id=the-param-element:concept-param-parameter>parameter</a> defined
  by a <code id=the-param-element:the-param-element-3><a href=#the-param-element>param</a></code> element that is the child of an <code id=the-param-element:the-object-element-4><a href=#the-object-element>object</a></code> element that
  <a href=#represents id=the-param-element:represents-2>represents</a> an instantiated <a href=#plugin id=the-param-element:plugin>plugin</a> changes, and if that
  <a href=#plugin id=the-param-element:plugin-2>plugin</a> is communicating with the user agent using an API that features the ability to
  update the <a href=#plugin id=the-param-element:plugin-3>plugin</a> when the name or value of a <a href=#concept-param-parameter id=the-param-element:concept-param-parameter-2>parameter</a> so changes, then the user agent must
  appropriately exercise that ability to notify the <a href=#plugin id=the-param-element:plugin-4>plugin</a> of the change.</p>

  <p>The IDL attributes <dfn id=dom-param-name><code>name</code></dfn> and <dfn id=dom-param-value><code>value</code></dfn> must both <a href=#reflect id=the-param-element:reflect>reflect</a> the respective
  content attributes of the same name.</p>

  

  <div class=example>

   <p>The following example shows how the <code id=the-param-element:the-param-element-4><a href=#the-param-element>param</a></code> element can be used to pass a parameter
   to a plugin, in this case the O3D plugin.</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>&quot;en&quot;</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->O3D Utah Teapot<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->
    <c- p>&lt;</c-><c- f>object</c-> <c- e>type</c-><c- o>=</c-><c- s>&quot;application/vnd.o3d.auto&quot;</c-><c- p>&gt;</c->
     <strong><c- p>&lt;</c-><c- f>param</c-> <c- e>name</c-><c- o>=</c-><c- s>&quot;o3d_features&quot;</c-> <c- e>value</c-><c- o>=</c-><c- s>&quot;FloatingPointTextures&quot;</c-><c- p>&gt;</c-></strong>
     <c- p>&lt;</c-><c- f>img</c-> <c- e>src</c-><c- o>=</c-><c- s>&quot;o3d-teapot.png&quot;</c->
          <c- e>title</c-><c- o>=</c-><c- s>&quot;3D Utah Teapot illustration rendered using O3D.&quot;</c->
          <c- e>alt</c-><c- o>=</c-><c- s>&quot;When O3D renders the Utah Teapot, it appears as a squat</c->
<c- s>          teapot with a shiny metallic finish on which the</c->
<c- s>          surroundings are reflected, with a faint shadow caused by</c->
<c- s>          the lighting.&quot;</c-><c- p>&gt;</c->
     <c- p>&lt;</c-><c- f>p</c-><c- p>&gt;</c->To see the teapot actually rendered by O3D on your
     computer, please download and install the <c- p>&lt;</c-><c- f>a</c->
     <c- e>href</c-><c- o>=</c-><c- s>&quot;http://code.google.com/apis/o3d/docs/gettingstarted.html#install&quot;</c-><c- p>&gt;</c->O3D plugin<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>object</c-><c- p>&gt;</c->
    <c- p>&lt;</c-><c- f>script</c-> <c- e>src</c-><c- o>=</c-><c- s>&quot;o3d-teapot.js&quot;</c-><c- p>&gt;&lt;/</c-><c- f>script</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=the-video-element><span class=secno>4.8.9</span> The <dfn id=video><code>video</code></dfn> element<a href=#the-video-element class=self-link></a></h4><div class=status><input onclick=toggleStatus(this) value=⋰ type=button><p class=support><strong>Support:</strong> video<span class="and_chr yes"><span>Chrome for Android</span> <span>67+</span></span><span class="chrome yes"><span>Chrome</span> <span>4+</span></span><span class="ios_saf yes"><span>iOS Safari</span> <span>3.2+</span></span><span class="and_uc yes"><span>UC Browser for Android</span> <span>11.8+</span></span><span class="firefox yes"><span>Firefox</span> <span>20+</span></span><span class="ie yes"><span>IE</span> <span>9+</span></span><span class="op_mini no"><span>Opera Mini</span> <span>None</span></span><span class="safari yes"><span>Safari</span> <span>4+</span></span><span class="edge yes"><span>Edge</span> <span>12+</span></span><span class="samsung yes"><span>Samsung Internet</span> <span>4+</span></span><span class="opera yes"><span>Opera</span> <span>10.5+</span></span><span class="android yes"><span>Android Browser</span> <span>2.3+</span></span><p class=caniuse>Source: <a href="https://caniuse.com/#feat=video">caniuse.com</a></div>

  <dl class=element><dt><a href=#concept-element-categories id=the-video-element:concept-element-categories>Categories</a>:<dd><a href=#flow-content-2 id=the-video-element:flow-content-2>Flow content</a>.<dd><a href=#phrasing-content-2 id=the-video-element:phrasing-content-2>Phrasing content</a>.<dd><a href=#embedded-content-category id=the-video-element:embedded-content-category>Embedded content</a>.<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><a href=#palpable-content-2 id=the-video-element:palpable-content-2>Palpable content</a>.<dt><a href=#concept-element-contexts id=the-video-element:concept-element-contexts>Contexts in which this element can be used</a>:<dd>Where <a href=#embedded-content-category id=the-video-element:embedded-content-category-2>embedded content</a> is expected.<dt><a href=#concept-element-content-model id=the-video-element:concept-element-content-model>Content model</a>:<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>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.<dt><a href=#concept-element-tag-omission id=the-video-element:concept-element-tag-omission>Tag omission in text/html</a>:<dd>Neither tag is omissible.<dt><a href=#concept-element-attributes id=the-video-element:concept-element-attributes>Content attributes</a>:<dd><a href=#global-attributes id=the-video-element:global-attributes>Global attributes</a><dd><code id=the-video-element:attr-media-src-3><a href=#attr-media-src>src</a></code> — Address of the resource<dd><code id=the-video-element:attr-media-crossorigin><a href=#attr-media-crossorigin>crossorigin</a></code> — How the element handles crossorigin requests<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><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><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><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><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><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><code id=the-video-element:attr-media-controls-2><a href=#attr-media-controls>controls</a></code> — Show user agent controls<dd><code id=the-video-element:attr-dim-width><a href=#attr-dim-width>width</a></code> — Horizontal dimension<dd><code id=the-video-element:attr-dim-height><a href=#attr-dim-height>height</a></code> — Vertical dimension<dt><a href=#concept-element-dom id=the-video-element:concept-element-dom>DOM interface</a>:<dd>
    <pre><code class='idl'>[<c- g>Exposed</c->=<c- n>Window</c->,
 <a href='#htmlconstructor' id='the-video-element:htmlconstructor'><c- g>HTMLConstructor</c-></a>]
<c- b>interface</c-> <dfn id='htmlvideoelement'><c- g>HTMLVideoElement</c-></dfn> : <a href='#htmlmediaelement' id='the-video-element:htmlmediaelement'><c- n>HTMLMediaElement</c-></a> {
  [<a href='#cereactions' id='the-video-element:cereactions'><c- g>CEReactions</c-></a>] <c- b>attribute</c-> <c- b>unsigned</c-> <c- b>long</c-> <a href='#dom-dim-width' id='the-video-element:dom-dim-width'><c- g>width</c-></a>;
  [<a href='#cereactions' id='the-video-element:cereactions-2'><c- g>CEReactions</c-></a>] <c- b>attribute</c-> <c- b>unsigned</c-> <c- b>long</c-> <a href='#dom-dim-height' id='the-video-element:dom-dim-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-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>] <c- b>attribute</c-> <c- b>USVString</c-> <a href='#dom-video-poster' id='the-video-element:dom-video-poster'><c- g>poster</c-></a>;
  [<a href='#cereactions' id='the-video-element:cereactions-4'><c- g>CEReactions</c-></a>] <c- b>attribute</c-> <c- b>boolean</c-> <a href='#dom-video-playsinline' id='the-video-element:dom-video-playsinline'><c- g>playsInline</c-></a>;
};</code></pre>
   </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 legacy video plugins can be tried, or to show text 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-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 id=attr-video-poster><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>

  

  <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>.<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.<li><p><a href=#parse-a-url id=the-video-element:parse-a-url>Parse</a> 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>. If this fails, then there is no <a href=#poster-frame id=the-video-element:poster-frame-3>poster frame</a>; return.<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 the <a href=#resulting-url-record id=the-video-element:resulting-url-record>resulting URL record</a>,
   <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/#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.

   <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>.<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>.</ol>

  

  <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 id=attr-video-playsinline><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>
  attributes 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>

  <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)<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:intrinsic-dimensions href=https://drafts.csswg.org/css2/conform.html#intrinsic data-x-internal=intrinsic-dimensions>intrinsic dimensions</a>.<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<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.<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>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)<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.<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><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>.<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>)<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.</dl>

  <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>intrinsic 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>intrinsic
  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><var>video</var> . <code id=dom-video-videowidth-dev><a href=#dom-video-videowidth>videoWidth</a></code><dt><var>video</var> . <code id=dom-video-videoheight-dev><a href=#dom-video-videoheight>videoHeight</a></code><dd>

    <p>These attributes return the intrinsic dimensions of the video,
    or zero if the dimensions are not known.</p>

   </dl>

  

  <p>The <dfn id=concept-video-intrinsic-width>intrinsic width</dfn> and <dfn id=concept-video-intrinsic-height>intrinsic 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>

  <p>The <dfn id=dom-video-videowidth><code>videoWidth</code></dfn> IDL attribute must return
  the <a href=#concept-video-intrinsic-width id=the-video-element:concept-video-intrinsic-width-2>intrinsic 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 id=dom-video-videoheight><code>videoHeight</code></dfn> IDL attribute must return the <a href=#concept-video-intrinsic-height id=the-video-element:concept-video-intrinsic-height-2>intrinsic 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>

  <p id=dimUpdate>Whenever the <a href=#concept-video-intrinsic-width id=the-video-element:concept-video-intrinsic-width-3>intrinsic width</a>
  or <a href=#concept-video-intrinsic-height id=the-video-element:concept-video-intrinsic-height-3>intrinsic 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-task id=the-video-element:queue-a-task>queue a task</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-4>media element</a>.</p>

  

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

  <p>The <a href=#intrinsic-width id=the-video-element:intrinsic-width>intrinsic 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 href=#intrinsic-width id=the-video-element:intrinsic-width-2>intrinsic 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>intrinsic width</a> of the video resource, if that is
  available; otherwise the <a href=#intrinsic-width id=the-video-element:intrinsic-width-3>intrinsic width</a> is missing.</p>

  <p>The <a href=#intrinsic-height id=the-video-element:intrinsic-height>intrinsic 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 href=#intrinsic-height id=the-video-element:intrinsic-height-2>intrinsic 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>intrinsic height</a> of the video resource, if that is
  available; otherwise the <a href=#intrinsic-height id=the-video-element:intrinsic-height-3>intrinsic height</a> is missing.</p>

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

  <p>A <code id=the-video-element:the-video-element-23><a href=#the-video-element>video</a></code> element is said to <dfn id=intersect-the-viewport>intersect the viewport</dfn> when it is
  <a href=#being-rendered id=the-video-element:being-rendered>being rendered</a> and its associated CSS layout box intersects the
  <a id=the-video-element:viewport href=https://drafts.csswg.org/css2/visuren.html#viewport data-x-internal=viewport>viewport</a>.</p>

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

  <p>The <dfn id=dom-video-poster><code>poster</code></dfn> IDL attribute must
  <a href=#reflect id=the-video-element:reflect>reflect</a> the <code id=the-video-element:attr-video-poster-6><a href=#attr-video-poster>poster</a></code> content attribute.</p>

  <p>The <dfn id=dom-video-playsinline><code>playsInline</code></dfn> IDL attribute must
  <a href=#reflect id=the-video-element:reflect-2>reflect</a> the <code id=the-video-element:attr-video-playsinline-5><a href=#attr-video-playsinline>playsinline</a></code> content
  attribute.</p>

  

  <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>&apos;You aborted the video playback.&apos;</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>&apos;A network error caused the video download to fail part-way.&apos;</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>&apos;The video playback was aborted due to a corruption problem or because the video used features your browser did not support.&apos;</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>&apos;The video could not be loaded, either because the server or network failed or because the format is not supported.&apos;</c-><c- p>);</c->
       <c- k>break</c-><c- p>;</c->
     <c- k>default</c-><c- o>:</c->
       alert<c- p>(</c-><c- t>&apos;An unknown error occurred.&apos;</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>&quot;tgif.vid&quot;</c-> <c- e>autoplay</c-> <c- e>controls</c-> <c- e>onerror</c-><c- o>=</c-><c- s>&quot;failed(event)&quot;</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>&quot;tgif.vid&quot;</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.10</span> The <dfn id=audio><code>audio</code></dfn> element<a href=#the-audio-element class=self-link></a></h4><div class=status><input onclick=toggleStatus(this) value=⋰ type=button><p class=support><strong>Support:</strong> audio<span class="and_chr yes"><span>Chrome for Android</span> <span>67+</span></span><span class="chrome yes"><span>Chrome</span> <span>4+</span></span><span class="ios_saf yes"><span>iOS Safari</span> <span>4.0+</span></span><span class="and_uc yes"><span>UC Browser for Android</span> <span>11.8+</span></span><span class="firefox yes"><span>Firefox</span> <span>20+</span></span><span class="ie yes"><span>IE</span> <span>9+</span></span><span class="op_mini no"><span>Opera Mini</span> <span>None</span></span><span class="safari yes"><span>Safari</span> <span>4+</span></span><span class="edge yes"><span>Edge</span> <span>12+</span></span><span class="samsung yes"><span>Samsung Internet</span> <span>4+</span></span><span class="opera yes"><span>Opera</span> <span>10.5+</span></span><span class="android yes"><span>Android Browser</span> <span>2.3+</span></span><p class=caniuse>Source: <a href="https://caniuse.com/#feat=audio">caniuse.com</a></div>

  <dl class=element><dt><a href=#concept-element-categories id=the-audio-element:concept-element-categories>Categories</a>:<dd><a href=#flow-content-2 id=the-audio-element:flow-content-2>Flow content</a>.<dd><a href=#phrasing-content-2 id=the-audio-element:phrasing-content-2>Phrasing content</a>.<dd><a href=#embedded-content-category id=the-audio-element:embedded-content-category>Embedded content</a>.<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>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>.<dt><a href=#concept-element-contexts id=the-audio-element:concept-element-contexts>Contexts in which this element can be used</a>:<dd>Where <a href=#embedded-content-category id=the-audio-element:embedded-content-category-2>embedded content</a> is expected.<dt><a href=#concept-element-content-model id=the-audio-element:concept-element-content-model>Content model</a>:<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>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.<dt><a href=#concept-element-tag-omission id=the-audio-element:concept-element-tag-omission>Tag omission in text/html</a>:<dd>Neither tag is omissible.<dt><a href=#concept-element-attributes id=the-audio-element:concept-element-attributes>Content attributes</a>:<dd><a href=#global-attributes id=the-audio-element:global-attributes>Global attributes</a><dd><code id=the-audio-element:attr-media-src-3><a href=#attr-media-src>src</a></code> — Address of the resource<dd><code id=the-audio-element:attr-media-crossorigin><a href=#attr-media-crossorigin>crossorigin</a></code> — How the element handles crossorigin requests<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><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><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><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><code id=the-audio-element:attr-media-controls-3><a href=#attr-media-controls>controls</a></code> — Show user agent controls<dt><a href=#concept-element-dom id=the-audio-element:concept-element-dom>DOM interface</a>:<dd>
    <pre><code class='idl'>[<c- g>Exposed</c->=<c- n>Window</c->,
 <a href='#htmlconstructor' id='the-audio-element:htmlconstructor'><c- g>HTMLConstructor</c-></a>,
 <c- g>NamedConstructor</c->=<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'><c- g>HTMLAudioElement</c-></dfn> : <a href='#htmlmediaelement' id='the-audio-element:htmlmediaelement'><c- n>HTMLMediaElement</c-></a> {};</code></pre>
   </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 legacy audio plugins can be tried, or to show text 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-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><var>audio</var> = new <code id=dom-audio-dev><a href=#dom-audio>Audio</a></code>( [ <var>url</var> ] )<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>

   </dl>

  

  <p>A constructor 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 constructor 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>.<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 id=the-audio-element:the-audio-element-8><a href=#the-audio-element>audio</a></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>.<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>".<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.)<li><p>Return <var>audio</var>.</ol>

  



  



  <h4 id=the-track-element><span class=secno>4.8.11</span> The <dfn><code>track</code></dfn> element<a href=#the-track-element class=self-link></a></h4>

  <dl class=element><dt><a href=#concept-element-categories id=the-track-element:concept-element-categories>Categories</a>:<dd>None.<dt><a href=#concept-element-contexts id=the-track-element:concept-element-contexts>Contexts in which this element can be used</a>:<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>.<dt><a href=#concept-element-content-model id=the-track-element:concept-element-content-model>Content model</a>:<dd><a href=#concept-content-nothing id=the-track-element:concept-content-nothing>Nothing</a>.<dt><a href=#concept-element-tag-omission id=the-track-element:concept-element-tag-omission>Tag omission in text/html</a>:<dd>No <a href=#syntax-end-tag id=the-track-element:syntax-end-tag>end tag</a>.<dt><a href=#concept-element-attributes id=the-track-element:concept-element-attributes>Content attributes</a>:<dd><a href=#global-attributes id=the-track-element:global-attributes>Global attributes</a><dd><code id=the-track-element:attr-track-kind><a href=#attr-track-kind>kind</a></code> — The type of text track<dd><code id=the-track-element:attr-track-src><a href=#attr-track-src>src</a></code> — Address of the resource<dd><code id=the-track-element:attr-track-srclang><a href=#attr-track-srclang>srclang</a></code> — Language of the text track<dd><code id=the-track-element:attr-track-label><a href=#attr-track-label>label</a></code> — User-visible label<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<dt><a href=#concept-element-dom id=the-track-element:concept-element-dom>DOM interface</a>:<dd>
    <pre><code class='idl'>[<c- g>Exposed</c->=<c- n>Window</c->,
 <a href='#htmlconstructor' id='the-track-element:htmlconstructor'><c- g>HTMLConstructor</c-></a>]
<c- b>interface</c-> <dfn id='htmltrackelement'><c- g>HTMLTrackElement</c-></dfn> : <a href='#htmlelement' id='the-track-element:htmlelement'><c- n>HTMLElement</c-></a> {
  [<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>] <c- b>attribute</c-> <c- b>USVString</c-> <a href='#dom-track-src' id='the-track-element:dom-track-src'><c- g>src</c-></a>;
  [<a href='#cereactions' id='the-track-element:cereactions-3'><c- g>CEReactions</c-></a>] <c- b>attribute</c-> <c- b>DOMString</c-> <a href='#dom-track-srclang' id='the-track-element:dom-track-srclang'><c- g>srclang</c-></a>;
  [<a href='#cereactions' id='the-track-element:cereactions-4'><c- g>CEReactions</c-></a>] <c- b>attribute</c-> <c- b>DOMString</c-> <a href='#dom-track-label' id='the-track-element:dom-track-label'><c- g>label</c-></a>;
  [<a href='#cereactions' id='the-track-element:cereactions-5'><c- g>CEReactions</c-></a>] <c- b>attribute</c-> <c- b>boolean</c-> <a href='#dom-track-default' id='the-track-element:dom-track-default'><c- g>default</c-></a>;

  <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>
   </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 id=attr-track-kind><code>kind</code></dfn> attribute is an <a href=#enumerated-attribute id=the-track-element:enumerated-attribute>enumerated
  attribute</a>. The following table lists the keywords defined for this attribute. The keyword
  given in the first cell of each row maps to the state given in the second cell.</p>

  <table><thead><tr><th>Keyword
     <th>State
     <th>Brief description
   <tbody><tr><td><dfn id=attr-track-kind-keyword-subtitles><code>subtitles</code></dfn>
     <td><dfn id=attr-track-kind-subtitles>Subtitles</dfn>
     <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.
    <tr><td><dfn id=attr-track-kind-keyword-captions><code>captions</code></dfn>
     <td><dfn id=attr-track-kind-captions>Captions</dfn>
     <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.
    <tr><td><dfn id=attr-track-kind-keyword-descriptions><code>descriptions</code></dfn>
     <td><dfn id=attr-track-kind-descriptions>Descriptions</dfn>
     <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.
    <tr><td><dfn id=attr-track-kind-keyword-chapters><code>chapters</code></dfn>
     <td><dfn id=attr-track-kind-chapters>Chapters metadata</dfn>
     <td rowspan=2>
      Tracks intended for use from script.
      Not displayed by the user agent.
    <tr><td><dfn id=attr-track-kind-keyword-metadata><code>metadata</code></dfn>
     <td><dfn id=attr-track-kind-metadata>Metadata</dfn>
  </table>

  <p>The attribute may be omitted. The <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. The <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>

  <p>The <dfn id=attr-track-src><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>If the element has a <code id=the-track-element:attr-track-src-2><a href=#attr-track-src>src</a></code> attribute whose value is not the
  empty string and whose value, when the attribute was set, could be successfully <a href=#parse-a-url id=the-track-element:parse-a-url>parsed</a> 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>, then the
  element's <dfn id=track-url>track URL</dfn> is the <a href=#resulting-url-string id=the-track-element:resulting-url-string>resulting URL string</a>. Otherwise, the element's
  <a href=#track-url id=the-track-element:track-url>track URL</a> is the empty string.</p>

  

  <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 id=attr-track-srclang><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>

  

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

  

  <p>The <dfn id=attr-track-label><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>

  

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

  

  <p>The <dfn id=attr-track-default><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><var>track</var> . <code id=dom-track-readystate-dev><a href=#dom-track-readystate>readyState</a></code><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><var>track</var> . <code id=dom-track-none-dev><a href=#dom-track-none>NONE</a></code> (0)<dd>
      <p>The <a href=#text-track-not-loaded id=the-track-element:text-track-not-loaded>text track not loaded</a> state.</p>
     <dt><var>track</var> . <code id=dom-track-loading-dev><a href=#dom-track-loading>LOADING</a></code> (1)<dd>
      <p>The <a href=#text-track-loading id=the-track-element:text-track-loading>text track loading</a> state.</p>
     <dt><var>track</var> . <code id=dom-track-loaded-dev><a href=#dom-track-loaded>LOADED</a></code> (2)<dd>
      <p>The <a href=#text-track-loaded id=the-track-element:text-track-loaded>text track loaded</a> state.</p>
     <dt><var>track</var> . <code id=dom-track-error-dev><a href=#dom-track-error>ERROR</a></code> (3)<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>
     </dl>
   <dt><var>track</var> . <code id=dom-track-track-dev><a href=#dom-track-track>track</a></code><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>

   </dl>

  

  <p>The <dfn id=dom-track-readystate><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 id=dom-track-none><code>NONE</code></dfn> (numeric value 0)<dd>The <a href=#text-track-not-loaded id=the-track-element:text-track-not-loaded-2>text track not loaded</a> state.<dt><dfn id=dom-track-loading><code>LOADING</code></dfn> (numeric value 1)<dd>The <a href=#text-track-loading id=the-track-element:text-track-loading-2>text track loading</a> state.<dt><dfn id=dom-track-loaded><code>LOADED</code></dfn> (numeric value 2)<dd>The <a href=#text-track-loaded id=the-track-element:text-track-loaded-2>text track loaded</a> state.<dt><dfn id=dom-track-error><code>ERROR</code></dfn> (numeric value 3)<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.</dl>

  <p>The <dfn id=dom-track-track><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>

  <p>The <dfn id=dom-track-src><code>src</code></dfn>, <dfn id=dom-track-srclang><code>srclang</code></dfn>, <dfn id=dom-track-label><code>label</code></dfn>, and <dfn id=dom-track-default><code>default</code></dfn> IDL attributes must <a href=#reflect id=the-track-element:reflect>reflect</a> the
  respective content attributes of the same name. The <dfn id=dom-track-kind><code>kind</code></dfn> IDL attribute must <a href=#reflect id=the-track-element:reflect-2>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 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>&quot;brave.webm&quot;</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>&quot;English&quot;</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>&quot;English for the Hard of Hearing&quot;</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>&quot;Français&quot;</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>&quot;Deutsch&quot;</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.12</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>media elements</dfn>.</p>

  <pre><code class='idl'><c- b>enum</c-> <dfn id='canplaytyperesult'><c- g>CanPlayTypeResult</c-></dfn> { <c- s>&quot;&quot;</c-> /* <a href='#dom-canplaytyperesult-nil' id='media-elements:dom-canplaytyperesult-nil'>empty string</a> */, <c- s>&quot;</c-><a href='#dom-canplaytyperesult-maybe' id='media-elements:dom-canplaytyperesult-maybe'><c- s>maybe</c-></a><c- s>&quot;</c->, <c- s>&quot;</c-><a href='#dom-canplaytyperesult-probably' id='media-elements:dom-canplaytyperesult-probably'><c- s>probably</c-></a><c- s>&quot;</c-> };
<c- b>typedef</c-> (<a href='https://w3c.github.io/mediacapture-main/getusermedia.html#idl-def-mediastream' data-x-internal='mediastream' id='media-elements:mediastream'><c- n>MediaStream</c-></a> <c- b>or</c-> <a href='https://w3c.github.io/media-source/#idl-def-mediasource' data-x-internal='mediasource' id='media-elements:mediasource'><c- n>MediaSource</c-></a> <c- b>or</c-> <a href='https://w3c.github.io/FileAPI/#dfn-Blob' data-x-internal='blob' id='media-elements:blob'><c- n>Blob</c-></a>) <dfn id='mediaprovider'><c- g>MediaProvider</c-></dfn>;

[<c- g>Exposed</c->=<c- n>Window</c->]
<c- b>interface</c-> <dfn id='htmlmediaelement'><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>] <c- b>attribute</c-> <c- b>USVString</c-> <a href='#dom-media-src' id='media-elements:dom-media-src'><c- g>src</c-></a>;
  <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>void</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>void</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://heycam.github.io/webidl/#idl-object' data-x-internal='idl-object' id='media-elements: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>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>] <c- b>attribute</c-> <c- b>boolean</c-> <a href='#dom-media-autoplay' id='media-elements:dom-media-autoplay'><c- g>autoplay</c-></a>;
  [<a href='#cereactions' id='media-elements:cereactions-5'><c- g>CEReactions</c-></a>] <c- b>attribute</c-> <c- b>boolean</c-> <a href='#dom-media-loop' id='media-elements:dom-media-loop'><c- g>loop</c-></a>;
  <c- b>Promise</c->&lt;<c- b>void</c->&gt; <a href='#dom-media-play' id='media-elements:dom-media-play'><c- g>play</c-></a>();
  <c- b>void</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>] <c- b>attribute</c-> <c- b>boolean</c-> <a href='#dom-media-controls' id='media-elements:dom-media-controls'><c- g>controls</c-></a>;
  <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>] <c- b>attribute</c-> <c- b>boolean</c-> <a href='#dom-media-defaultmuted' id='media-elements:dom-media-defaultmuted'><c- g>defaultMuted</c-></a>;

  // 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-> = &quot;&quot;, <c- b>optional</c-> <c- b>DOMString</c-> <c- g>language</c-> = &quot;&quot;);
};</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><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 id=media-data>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> 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-2>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-3>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>Except where otherwise explicitly specified, the <a href=#task-source id=media-elements:task-source>task source</a> for all the tasks
  <a href=#queue-a-task id=media-elements:queue-a-task>queued</a> in this section and its subsections is the <dfn id=media-element-event-task-source>media
  element event task source</dfn> of the <a href=#media-element id=media-elements:media-element-5>media element</a> in question.</p>

  



  <h5 id=error-codes><span class=secno>4.8.12.1</span> Error codes<a href=#error-codes class=self-link></a></h5>

  <dl class=domintro><dt><var>media</var> . <code id=dom-media-error-dev><a href=#dom-media-error>error</a></code><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>

   </dl>

  

  <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 id=dom-media-error><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>

  

  <pre><code class='idl'>[<c- g>Exposed</c->=<c- n>Window</c->]
<c- b>interface</c-> <dfn id='mediaerror'><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><var>media</var> . <code id=error-codes:dom-media-error><a href=#dom-media-error>error</a></code> . <code id=dom-mediaerror-code-dev><a href=#dom-mediaerror-code>code</a></code><dd>

    <p>Returns the current error's error code, from the list below.</p>

   <dt><var>media</var> . <code id=error-codes:dom-media-error-2><a href=#dom-media-error>error</a></code> . <code id=dom-mediaerror-message-dev><a href=#dom-mediaerror-message>message</a></code><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>

   </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 id=dom-mediaerror-media_err_aborted><code>MEDIA_ERR_ABORTED</code></dfn> (numeric value 1)<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.<dt><dfn id=dom-mediaerror-media_err_network><code>MEDIA_ERR_NETWORK</code></dfn> (numeric value 2)<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.<dt><dfn id=dom-mediaerror-media_err_decode><code>MEDIA_ERR_DECODE</code></dfn> (numeric value 3)<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.<dt><dfn id=dom-mediaerror-media_err_src_not_supported><code>MEDIA_ERR_SRC_NOT_SUPPORTED</code></dfn> (numeric value 4)<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.</dl>

  

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

  <p>The <dfn id=dom-mediaerror-code><code>code</code></dfn> attribute of a
  <code id=error-codes:mediaerror-5><a href=#mediaerror>MediaError</a></code> object must return this <code id=error-codes:mediaerror-6><a href=#mediaerror>MediaError</a></code> object's <a href=#concept-mediaerror-code id=error-codes:concept-mediaerror-code-2>code</a>.</p>

  <p>The <dfn id=dom-mediaerror-message><code>message</code></dfn> attribute of a
  <code id=error-codes:mediaerror-7><a href=#mediaerror>MediaError</a></code> object must return this <code id=error-codes:mediaerror-8><a href=#mediaerror>MediaError</a></code> object's <a href=#concept-mediaerror-message id=error-codes:concept-mediaerror-message-3>message</a>.</p>

  




  <h5 id=location-of-the-media-resource><span class=secno>4.8.12.2</span> Location of the media resource<a href=#location-of-the-media-resource class=self-link></a></h5>

  <p>The <dfn id=attr-media-src><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 id=attr-media-crossorigin><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>

  

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

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

  <p>The <dfn id=dom-media-src><code>src</code></dfn> IDL attribute on <a href=#media-element id=location-of-the-media-resource:media-element-8>media elements</a> must <a href=#reflect id=location-of-the-media-resource:reflect>reflect</a> the content attribute of the same
  name.</p>

  <p>The <dfn id=dom-media-crossorigin><code>crossOrigin</code></dfn> IDL attribute must
  <a href=#reflect id=location-of-the-media-resource:reflect-2>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>

  

  <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-9>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-10>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><var>media</var> . <code id=dom-media-srcobject-dev><a href=#dom-media-srcobject>srcObject</a></code> [ = <var>source</var> ]<dd>

    <p>Allows the <a href=#media-element id=location-of-the-media-resource:media-element-11>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>

   <dt><var>media</var> . <code id=dom-media-currentsrc-dev><a href=#dom-media-currentsrc>currentSrc</a></code><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>

   </dl>

  

  <p>The <dfn id=dom-media-currentsrc><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>

  <p>The <dfn id=dom-media-srcobject><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>

  

  <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.12.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://tools.ietf.org/html/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://tools.ietf.org/html/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><var>media</var> . <code id=dom-navigator-canplaytype-dev><a href=#dom-navigator-canplaytype>canPlayType</a></code>(<var>type</var>)<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>

   </dl>

  

  <p>The <dfn id=dom-navigator-canplaytype><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://tools.ietf.org/html/rfc2046#section-4.5.1>application/octet-stream</a></code>"; it must return "<dfn id=dom-canplaytyperesult-probably><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 id=dom-canplaytyperesult-maybe><code>maybe</code></dfn>" otherwise. Implementors 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 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 or a plugin:</p>

   <pre><code class='html'><c- p>&lt;</c-><c- f>section</c-> <c- e>id</c-><c- o>=</c-><c- s>&quot;video&quot;</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>&quot;playing-cats.nfv&quot;</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>var</c-> videoSection <c- o>=</c-> document<c- p>.</c->getElementById<c- p>(</c-><c- t>&apos;video&apos;</c-><c- p>);</c->
 <c- a>var</c-> videoElement <c- o>=</c-> document<c- p>.</c->createElement<c- p>(</c-><c- t>&apos;video&apos;</c-><c- p>);</c->
 <c- a>var</c-> support <c- o>=</c-> videoElement<c- p>.</c->canPlayType<c- p>(</c-><c- t>&apos;video/x-new-fictional-format;codecs=&quot;kittens,bunnies&quot;&apos;</c-><c- p>);</c->
 <c- k>if</c-> <c- p>(</c->support <c- o>!=</c-> <c- u>&quot;probably&quot;</c-> <c- o>&amp;&amp;</c-> <c- u>&quot;New Fictional Video Plugin&quot;</c-> <c- k>in</c-> navigator<c- p>.</c->plugins<c- p>)</c-> <c- p>{</c->
   <c- c1>// not confident of browser support</c->
   <c- c1>// but we have a plugin</c->
   <c- c1>// so use plugin instead</c->
   videoElement <c- o>=</c-> document<c- p>.</c->createElement<c- p>(</c-><c- u>&quot;embed&quot;</c-><c- p>);</c->
 <c- p>}</c-> <c- k>else</c-> <c- k>if</c-> <c- p>(</c->support <c- o>==</c-> <c- u>&quot;&quot;</c-><c- p>)</c-> <c- p>{</c->
   <c- c1>// no support from browser and no plugin</c->
   <c- c1>// do nothing</c->
   videoElement <c- o>=</c-> <c- kc>null</c-><c- p>;</c->
 <c- p>}</c->
 <c- k>if</c-> <c- p>(</c->videoElement<c- p>)</c-> <c- p>{</c->
   <c- k>while</c-> <c- p>(</c->videoSection<c- p>.</c->hasChildNodes<c- p>())</c->
     videoSection<c- p>.</c->removeChild<c- p>(</c->videoSection<c- p>.</c->firstChild<c- p>);</c->
   videoElement<c- p>.</c->setAttribute<c- p>(</c-><c- u>&quot;src&quot;</c-><c- p>,</c-> <c- u>&quot;playing-cats.nfv&quot;</c-><c- p>);</c->
   videoSection<c- p>.</c->appendChild<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.12.4</span> Network states<a href=#network-states class=self-link></a></h5>

  <dl class=domintro><dt><var>media</var> . <code id=dom-media-networkstate-dev><a href=#dom-media-networkstate>networkState</a></code><dd>

    <p>Returns the current state of network activity for the element, from the codes in the list
    below.</p>

   </dl>

  

  <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 id=dom-media-networkstate><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>

  

  <dl><dt><dfn id=dom-media-network_empty><code>NETWORK_EMPTY</code></dfn> (numeric value 0)<dd>The element has not yet been initialized. All attributes are in their initial states.<dt><dfn id=dom-media-network_idle><code>NETWORK_IDLE</code></dfn> (numeric value 1)<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.<dt><dfn id=dom-media-network_loading><code>NETWORK_LOADING</code></dfn> (numeric value 2)<dd>The user agent is actively trying to download data.<dt><dfn id=dom-media-network_no_source><code>NETWORK_NO_SOURCE</code></dfn> (numeric value 3)<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.</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.12.5</span> Loading the media resource<a href=#loading-the-media-resource class=self-link></a></h5>

  <dl class=domintro><dt><var>media</var> . <code id=dom-media-load-dev><a href=#dom-media-load>load</a></code>()<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>

   </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>

  <p>When the <dfn id=dom-media-load><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>

  <p>The <dfn id=media-element-load-algorithm>media element load algorithm</dfn> consists of the following steps.</p>

  <ol><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.<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-3>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>.<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.<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><p>If the <a href=#media-element id=loading-the-media-resource:media-element-4>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-task id=loading-the-media-resource:queue-a-task>queue a task</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-5>media element</a>.<li>

    <p>If the <a href=#media-element id=loading-the-media-resource:media-element-6>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-task id=loading-the-media-resource:queue-a-task-2>Queue a task</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-7>media
     element</a>.<li><p>If a fetching process is in progress for the <a href=#media-element id=loading-the-media-resource:media-element-8>media
     element</a>, the user agent should stop it.<li><p>If the <a href=#media-element id=loading-the-media-resource:media-element-9>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.<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>.<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.<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.<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://heycam.github.io/webidl/#aborterror data-x-internal=aborterror>"<code>AbortError</code>"</a>
       <code id=loading-the-media-resource:domexception><a data-x-internal=domexception href=https://heycam.github.io/webidl/#dfn-DOMException>DOMException</a></code>.</ol>

     <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.<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-task id=loading-the-media-resource:queue-a-task-3>queue a task</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-10>media element</a>.</p>

     <li><p>Set the <a href=#timeline-offset id=loading-the-media-resource:timeline-offset>timeline offset</a> to Not-a-Number (NaN).<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>

     </ol>

   <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.<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.<li><p>Invoke the <a href=#media-element id=loading-the-media-resource:media-element-11>media element</a>'s <a href=#concept-media-load-algorithm id=loading-the-media-resource:concept-media-load-algorithm-2>resource selection algorithm</a>.<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>

   </ol>

  <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-12>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.<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.<li><p>Set the <a href=#media-element id=loading-the-media-resource:media-element-13>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>).<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 ⌛.)<li>

    <p>⌛ If the <a href=#media-element id=loading-the-media-resource:media-element-14>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>

    <p>⌛ If the <a href=#media-element id=loading-the-media-resource:media-element-15>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-16>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-17>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-18>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: 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>, and return; the
    <a href=#synchronous-section id=loading-the-media-resource:synchronous-section-5>synchronous section</a> ends.</p>

   <li><p>⌛ Set the <a href=#media-element id=loading-the-media-resource:media-element-19>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>.<li><p>⌛ <a href=#queue-a-task id=loading-the-media-resource:queue-a-task-4>Queue a task</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-20>media
   element</a>.<li>

    <p>Run the appropriate steps from the following list:</p>

    <dl class=switch><dt>If <var>mode</var> is <i>object</i><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.<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>.<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.<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-task id=loading-the-media-resource:queue-a-task-5>queue a
       task</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.<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.<li><p>Return. The element won't attempt to load another resource until this
       algorithm is triggered again.</ol>

     <dt>If <var>mode</var> is <i>attribute</i><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.<li><p>⌛ Let <var>urlString</var> and <var>urlRecord</var> be the <a href=#resulting-url-string id=loading-the-media-resource:resulting-url-string>resulting URL
       string</a> and the <a href=#resulting-url-record id=loading-the-media-resource:resulting-url-record>resulting URL record</a>, respectively, that would have
       resulted from <a href=#parse-a-url id=loading-the-media-resource:parse-a-url>parsing</a> the <a id=loading-the-media-resource:url href=https://url.spec.whatwg.org/#concept-url data-x-internal=url>URL</a> specified by 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-21>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><p>⌛ If <var>urlString</var> was obtained successfully, set the <code id=loading-the-media-resource:dom-media-currentsrc-2><a href=#dom-media-currentsrc>currentSrc</a></code> attribute to <var>urlString</var>.<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>.<li><p>If <var>urlRecord</var> was obtained successfully, 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.<li><p><i>Failed with attribute</i>: Reaching this step indicates that the media resource
       failed to load or that the given <a id=loading-the-media-resource:url-2 href=https://url.spec.whatwg.org/#concept-url data-x-internal=url>URL</a> could not be <a href=#parse-a-url id=loading-the-media-resource:parse-a-url-2>parsed</a>. <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-task id=loading-the-media-resource:queue-a-task-6>queue a task</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.<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.<li><p>Return. The element won't attempt to load another resource until this
       algorithm is triggered again.</ol>

     <dt>Otherwise (<var>mode</var> is <i>children</i>)<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-22>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 <a href=#nodes-are-inserted id=loading-the-media-resource:nodes-are-inserted>nodes are inserted</a> and <a href=#nodes-are-removed id=loading-the-media-resource:nodes-are-removed>removed</a> into the <a href=#media-element id=loading-the-media-resource:media-element-23>media element</a>, <var>pointer</var> must be updated as follows:</p>

        <dl><dt>If a new <a href=#nodes-are-inserted id=loading-the-media-resource:nodes-are-inserted-2>node is inserted</a> between the two nodes that define <var>pointer</var><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>.<dt>If the node before <var>pointer</var> is removed<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.<dt>If the node after <var>pointer</var> is removed<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.</dl>

        <p>Other changes don't affect <var>pointer</var>.</p>

       <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.<li><p>⌛ Let <var>urlString</var> and <var>urlRecord</var> be the <a href=#resulting-url-string id=loading-the-media-resource:resulting-url-string-2>resulting URL
       string</a> and the <a href=#resulting-url-record id=loading-the-media-resource:resulting-url-record-2>resulting URL record</a>, respectively, that would have
       resulted from <a href=#parse-a-url id=loading-the-media-resource:parse-a-url-3>parsing</a> the <a id=loading-the-media-resource:url-3 href=https://url.spec.whatwg.org/#concept-url data-x-internal=url>URL</a> specified by
       <var>candidate</var>'s <code id=loading-the-media-resource:attr-source-src-3><a href=#attr-source-src>src</a></code> attribute's value relative
       to the <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-source-src-4><a href=#attr-source-src>src</a></code> attribute was last changed.</p> 

       <li><p>⌛ If <var>urlString</var> was not obtained successfully, 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.<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-11>synchronous section</a>, and jump down to the <i>failed with elements</i> step below.<li><p>⌛ Set the <code id=loading-the-media-resource:dom-media-currentsrc-3><a href=#dom-media-currentsrc>currentSrc</a></code> attribute to
       <var>urlString</var>.<li><p>End the <a href=#synchronous-section id=loading-the-media-resource:synchronous-section-12>synchronous section</a>, continuing the remaining steps
       <a href=#in-parallel id=loading-the-media-resource:in-parallel-4>in parallel</a>.<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.<li><p><i>Failed with elements</i>: <a href=#queue-a-task id=loading-the-media-resource:queue-a-task-7>Queue a task</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 the <var>candidate</var> element.<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-13>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-14>synchronous section</a> has ended. (Steps in <a href=#synchronous-section id=loading-the-media-resource:synchronous-section-15>synchronous sections</a> are marked with ⌛.)<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>.<li><p>⌛ <i>Find next candidate</i>: Let <var>candidate</var> be
       null.<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.<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.<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.<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.<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.<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.<li><p>⌛ <a href=#queue-a-task id=loading-the-media-resource:queue-a-task-8>Queue a task</a> to 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>.<li><p>End the <a href=#synchronous-section id=loading-the-media-resource:synchronous-section-16>synchronous section</a>, continuing the remaining steps
       <a href=#in-parallel id=loading-the-media-resource:in-parallel-5>in parallel</a>.<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.)<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-17>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-18>synchronous section</a> has ended. (Steps in <a href=#synchronous-section id=loading-the-media-resource:synchronous-section-19>synchronous sections</a> are marked with ⌛.)<li><p>⌛ 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> back to true (this
       <a href=#delay-the-load-event id=loading-the-media-resource:delay-the-load-event-4>delays the load event</a> again, in case it hasn't been
       fired yet).</p>

       <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>.<li><p>⌛ Jump back to the <i>find next candidate</i> step above.</ol>

     </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>.<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>.<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.<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.<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-24>media element</a>.<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://heycam.github.io/webidl/#notsupportederror data-x-internal=notsupportederror>"<code>NotSupportedError</code>"</a> <code id=loading-the-media-resource:domexception-2><a data-x-internal=domexception href=https://heycam.github.io/webidl/#dfn-DOMException>DOMException</a></code>.<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> to false. This stops <a href=#delay-the-load-event id=loading-the-media-resource:delay-the-load-event-5>delaying the load event</a>.</ol>

   </ol>

  <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-25>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>If the algorithm was invoked with <a href=#media-provider-object id=loading-the-media-resource:media-provider-object-2>media provider object</a> or a <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> whose <a href=https://url.spec.whatwg.org/#concept-url-object id=loading-the-media-resource:concept-url-object data-x-internal=concept-url-object>object</a> is a <a href=#media-provider-object id=loading-the-media-resource:media-provider-object-3>media provider
   object</a>, then let <var>mode</var> be <i>local</i>. Otherwise let <var>mode</var> be
   <i>remote</i>.<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-3>media
   resource</a>.<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-26>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>

    <p>Run the appropriate steps from the following list:</p>

    <dl class=switch><dt>If <var>mode</var> is remote<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>.<li><p><a href=#queue-a-task id=loading-the-media-resource:queue-a-task-9>Queue a task</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.<li><p><a href=#queue-a-task id=loading-the-media-resource:queue-a-task-10>Queue a task</a> to 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>.<li><p>Wait for the task to be run.<li><p>Wait for an implementation-defined event (e.g. the user requesting that the media
         element begin playback).<li><p>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> back to true (this <a href=#delay-the-load-event id=loading-the-media-resource:delay-the-load-event-7>delays the load event</a> again, in case it hasn't been fired
         yet).</p>

         <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>.</ol>

       <li>
        <p>Let <var>destination</var> be "<code>audio</code>" if the <a href=#media-element id=loading-the-media-resource:media-element-27>media
        element</a> is an <code id=loading-the-media-resource:the-audio-element><a href=#the-audio-element>audio</a></code> element and to "<code>video</code>"
        otherwise.</p>

        <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
        <a href=#media-element id=loading-the-media-resource:media-element-28>media element</a>'s <code id=loading-the-media-resource:attr-media-crossorigin><a href=#attr-media-crossorigin>crossorigin</a></code>
        content attribute value.

        <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-29>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>

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

        <p>The <var>response</var>'s <a href=#unsafe-response id=loading-the-media-resource:unsafe-response>unsafe response</a> obtained in this fashion, if any,
        contains the <a href=#media-data id=loading-the-media-resource:media-data>media data</a>. It 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>CORS-cross-origin</a>; this affects whether subtitles referenced in the <a href=#media-data id=loading-the-media-resource:media-data-2>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>

        <p>The <dfn id=stall-timeout>stall timeout</dfn> is a user-agent defined length of time, which should be
        about three seconds. When a <a href=#media-element id=loading-the-media-resource:media-element-30>media element</a> that is actively attempting to obtain
        <a href=#media-data id=loading-the-media-resource:media-data-3>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>stall timeout</a>, the user agent must <a href=#queue-a-task id=loading-the-media-resource:queue-a-task-11>queue a task</a> to <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>

        <p>User agents may allow users to selectively block or slow <a href=#media-data id=loading-the-media-resource:media-data-4>media data</a> downloads.
        When a <a href=#media-element id=loading-the-media-resource:media-element-31>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-32>media element</a>'s download has
        been suspended, the user agent must <a href=#queue-a-task id=loading-the-media-resource:queue-a-task-12>queue a task</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-task id=loading-the-media-resource:queue-a-task-13>queue a task</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-task id=loading-the-media-resource:queue-a-task-14>queue a task</a> to 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> to
        false. This stops <a href=#delay-the-load-event id=loading-the-media-resource:delay-the-load-event-8>delaying the load event</a>.</p>

        <p>The user agent may use whatever means necessary to fetch the resource (within the constraints
        put forward by this and other specifications); for example, reconnecting to the server in the
        face of network errors, using HTTP range retrieval requests, or switching to a streaming
        protocol. The user agent must consider a resource erroneous only if it has given up trying to
        fetch it.</p>

        <p>To determine the format of the <a href=#media-resource id=loading-the-media-resource:media-resource-4>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-task id=loading-the-media-resource:queue-a-task-15>queue a task</a> to <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>

        <p>The <a href=#networking-task-source id=loading-the-media-resource:networking-task-source>networking task source</a> <a href=#concept-task id=loading-the-media-resource:concept-task-7>tasks</a> to
        process the data as it is being fetched must each <a href=#immediately id=loading-the-media-resource:immediately>immediately</a> <a href=#queue-a-task id=loading-the-media-resource:queue-a-task-16>queue a task</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
        <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 the <a href=#networking-task-source id=loading-the-media-resource:networking-task-source-2>networking task
        source</a>.)</p>

        <p>When the <a href=#networking-task-source id=loading-the-media-resource:networking-task-source-3>networking task source</a> has <a href=#queue-a-task id=loading-the-media-resource:queue-a-task-17>queued</a> the last <a href=#concept-task id=loading-the-media-resource:concept-task-8>task</a> as part of fetching the
        <a href=#media-resource id=loading-the-media-resource:media-resource-5>media resource</a> (i.e. once the download has completed), if the fetching process
        completes 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>

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

       </ol>

     <dt>Otherwise (<var>mode</var> is <i>local</i>)<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-5>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-task id=loading-the-media-resource:queue-a-task-18>queue
      a task</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>

     </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-6>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>If the <a href=#media-data id=loading-the-media-resource:media-data-7>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<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.<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>

      </ol>

     <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<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.<li><p>Update the <a href=#media-element id=loading-the-media-resource:media-element-33>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.<li><p>Let <var>enable</var> be <i>unknown</i>.<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-4 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><p>If <var>enable</var> is still <i>unknown</i>, then, if the <a href=#media-element id=loading-the-media-resource:media-element-34>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>.<li><p>If <var>enable</var> is <i>true</i>, then enable this audio track,
       otherwise, do not enable this audio track.<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.</ol>

     <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<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.<li><p>Update the <a href=#media-element id=loading-the-media-resource:media-element-35>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.<li><p>Let <var>enable</var> be <i>unknown</i>.<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-5 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><p>If <var>enable</var> is still <i>unknown</i>, then, if the <a href=#media-element id=loading-the-media-resource:media-element-36>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>.<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><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.</ol>

     <dt id=getting-media-metadata>Once enough of the <a href=#media-data id=loading-the-media-resource:media-data-8>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<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-9>media data</a>.</p>

       <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><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>.<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-task id=loading-the-media-resource:queue-a-task-19>queue a task</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>

        <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-task id=loading-the-media-resource:queue-a-task-20>queue a task</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-37>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>

        <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><p>Let <var>jumped</var> be false.<li><p>If the <a href=#media-element id=loading-the-media-resource:media-element-38>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.<li><p>Let the <a href=#media-element id=loading-the-media-resource:media-element-39>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> be zero.<li><p>Let the <var>initial playback position</var> be zero.<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-6 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><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>.<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>.</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-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 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> 

     <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)<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-40>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-41>media element</a>.</p>

      <p>If the user agent ever discards any <a href=#media-data id=loading-the-media-resource:media-data-10>media data</a> and then needs to resume the
      network activity to obtain it again, then it must <a href=#queue-a-task id=loading-the-media-resource:queue-a-task-21>queue a task</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>

     <dt>If the connection is interrupted after some <a href=#media-data id=loading-the-media-resource:media-data-11>media data</a> has been received,
     causing the user agent to give up trying to fetch the resource<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-42>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.<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>.<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.<li><p>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>.<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-43>media element</a>.<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>.</ol>

     <dt id=fatal-decode-error>If the <a href=#media-data id=loading-the-media-resource:media-data-12>media data</a> is corrupted<dd>

      <p>Fatal errors in decoding the <a href=#media-data id=loading-the-media-resource:media-data-13>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-44>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.<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>.<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.<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>.<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-45>media element</a>.<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>.</ol>

     <dt>If the <a href=#media-data id=loading-the-media-resource:media-data-14>media data</a> fetching process is aborted by the user<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.<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>.<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-46>media element</a>.<li>

        <p>If the <a href=#media-element id=loading-the-media-resource:media-element-47>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><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>.<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>.</ol>

     <dt id=non-fatal-media-error>If the <a href=#media-data id=loading-the-media-resource:media-data-15>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<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>

      

     <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<dd>

      <p>If the <a href=#media-data id=loading-the-media-resource:media-data-16>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>

     </dl>

   <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>.</ol>

  <p>When a <a href=#media-element id=loading-the-media-resource:media-element-48>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-49>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-50>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-51>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>

  

  <hr>

  <p>The <dfn id=attr-media-preload><code>preload</code></dfn> attribute is an <a href=#enumerated-attribute id=loading-the-media-resource:enumerated-attribute>enumerated
  attribute</a>. The following table lists the keywords and states for the attribute — the
  keywords in the left column map to the states in the cell in the second column on the same row as
  the keyword. 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 below are to be interpreted with that in
  mind.</p>

  <table><thead><tr><th> Keyword
     <th> State
     <th> Brief description
   <tbody><tr><td><dfn id=attr-media-preload-none><code>none</code></dfn>
     <td><dfn id=attr-media-preload-none-state>None</dfn>
     <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").
    <tr><td><dfn id=attr-media-preload-metadata><code>metadata</code></dfn>
     <td><dfn id=attr-media-preload-metadata-state>Metadata</dfn>
     <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-52>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.
    <tr><td><dfn id=attr-media-preload-auto><code>auto</code></dfn>
     <td><dfn id=attr-media-preload-auto-state>Automatic</dfn>
     <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.
  </table>

  <p>The empty string is also a valid keyword, and maps to the <a href=#attr-media-preload-auto-state id=loading-the-media-resource:attr-media-preload-auto-state>Automatic</a> state. 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 user-agent defined, 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>

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

  <p>The <dfn id=dom-media-preload><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>

  

  <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><var>media</var> . <code id=dom-media-buffered-dev><a href=#dom-media-buffered>buffered</a></code><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>

   </dl>

  

  <p>The <dfn id=dom-media-buffered><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. Users agents must accurately determine the ranges available, even for media streams
  where this can only be determined by tedious inspection.</p>

  <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.12.6</span> Offsets into the media resource<a href=#offsets-into-the-media-resource class=self-link></a></h5>

  <dl class=domintro><dt><var>media</var> . <code id=dom-media-duration-dev><a href=#dom-media-duration>duration</a></code><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>

   <dt><var>media</var> . <code id=dom-media-currenttime-dev><a href=#dom-media-currenttime>currentTime</a></code> [ = <var>value</var> ]<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>

   </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>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 a user-agent-defined manner.
  <a href=#fingerprinting-vector id=offsets-into-the-media-resource:fingerprinting-vector class=fingerprint title="There is a potential fingerprinting vector here."><img alt="(This is a fingerprinting vector.)" src=/images/fingerprint.png width=46 height=64></a>
  </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.github.io/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.github.io/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>

  <p>The <dfn id=dom-media-currenttime><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>

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

  <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-task id=offsets-into-the-media-resource:queue-a-task>queue a task</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>

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

  
  

  <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-task id=offsets-into-the-media-resource:queue-a-task-2>queue a
  task</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.<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-9>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.</ol>

  <p>The <dfn id=dom-media-duration><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>

  <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 equal to or greater than <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>

  <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-task id=offsets-into-the-media-resource:queue-a-task-3>queue a task</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-10>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>

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

  <p>The <dfn id=dom-media-getstartdate><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>

  

  <hr>

  <p>The <dfn id=attr-media-loop><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-11>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>

  

  <p>The <dfn id=dom-media-loop><code>loop</code></dfn> IDL attribute must <a href=#reflect id=offsets-into-the-media-resource:reflect>reflect</a>
  the content attribute of the same name.</p>

  



  <h5 id=ready-states><span class=secno>4.8.12.7</span> Ready states<a href=#ready-states class=self-link></a></h5>

  <dl class=domintro><dt><var>media</var> . <code id=dom-media-readystate-dev><a href=#dom-media-readystate>readyState</a></code><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>

   </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 id=dom-media-have_nothing><code>HAVE_NOTHING</code></dfn> (numeric value 0)<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.<dt><dfn id=dom-media-have_metadata><code>HAVE_METADATA</code></dfn> (numeric value 1)<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>.<dt><dfn id=dom-media-have_current_data><code>HAVE_CURRENT_DATA</code></dfn> (numeric value 2)<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>.<dt><dfn id=dom-media-have_future_data><code>HAVE_FUTURE_DATA</code></dfn> (numeric value 3)<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.<dt><dfn id=dom-media-have_enough_data><code>HAVE_ENOUGH_DATA</code></dfn> (numeric value 4)<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>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.)</ul>

   </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>

  

  <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><dd id=fire-loadedmetadata>

      <p><a href=#queue-a-task id=ready-states:queue-a-task>Queue a task</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>

     <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<dd>

      <p id=fire-loadeddata>If this is the first time this occurs for this <a href=#media-element id=ready-states:media-element-4>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-task id=ready-states:queue-a-task-2>queue a task</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>

     <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<dd>

      <p id=fire-waiting-when-waiting>If the <a href=#media-element id=ready-states:media-element-5>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-task id=ready-states:queue-a-task-3>queue a task</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-task id=ready-states:queue-a-task-4>queue
      a task</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>

     <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><dd>

      <p>The user agent must <a href=#queue-a-task id=ready-states:queue-a-task-5>queue a task</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>

     <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><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-task id=ready-states:queue-a-task-6>queue a task</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-task id=ready-states:queue-a-task-7>queue a task</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>

      <p class=note>This specification doesn't 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>

      <ol><li>Set the <code id=ready-states:dom-media-paused-3><a href=#dom-media-paused>paused</a></code> attribute to false.<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><a href=#queue-a-task id=ready-states:queue-a-task-8>Queue a task</a> 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><a href=#notify-about-playing id=ready-states:notify-about-playing-3>Notify about playing</a> for the element.</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>

      <p class=note>This specification doesn't 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>

      <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><a href=#queue-a-task id=ready-states:queue-a-task-9>Queue a task</a> 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.</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>

     </dl>

   </ol>

  

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

  

  <p>The <dfn id=dom-media-readystate><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-6>media element</a>.</p>

  

  <p>The <dfn id=attr-media-autoplay><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>

  

  <p>The <dfn id=dom-media-autoplay><code>autoplay</code></dfn> IDL attribute must
  <a href=#reflect id=ready-states:reflect>reflect</a> the content attribute of the same name.</p>

  



  <h5 id=playing-the-media-resource><span class=secno>4.8.12.8</span> Playing the media resource<a href=#playing-the-media-resource class=self-link></a></h5>

  <dl class=domintro><dt><var>media</var> . <code id=dom-media-paused-dev><a href=#dom-media-paused>paused</a></code><dd>

    <p>Returns true if playback is paused; false otherwise.</p>

   <dt><var>media</var> . <code id=dom-media-ended-dev><a href=#dom-media-ended>ended</a></code><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>

   <dt><var>media</var> . <code id=dom-media-defaultplaybackrate-dev><a href=#dom-media-defaultplaybackrate>defaultPlaybackRate</a></code> [ = <var>value</var> ]<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>

   <dt><var>media</var> . <code id=dom-media-playbackrate-dev><a href=#dom-media-playbackrate>playbackRate</a></code> [ = <var>value</var> ]<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>

   <dt><var>media</var> . <code id=dom-media-played-dev><a href=#dom-media-played>played</a></code><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-3>media
    resource</a> that the user agent has played.</p>

   <dt><var>media</var> . <code id=dom-media-play-dev><a href=#dom-media-play>play</a></code>()<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-4>media resource</a> and beginning playback if necessary. If the playback had ended, will
    restart it from the start.</p>

   <dt><var>media</var> . <code id=dom-media-pause-dev><a href=#dom-media-pause>pause</a></code>()<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-5>media resource</a> if necessary.</p>

   </dl>

  

  <p>The <dfn id=dom-media-paused><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>

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

  <p>A <a href=#media-element id=playing-the-media-resource:media-element-3>media element</a> is said to be <dfn id=potentially-playing>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>

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

  <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 conditions are met:</p>

  <ul class=brief><li>Its <a href=#can-autoplay-flag id=playing-the-media-resource:can-autoplay-flag>can autoplay flag</a> is true.<li>Its <code id=playing-the-media-resource:dom-media-paused-4><a href=#dom-media-paused>paused</a></code> attribute is true.<li>It has an <code id=playing-the-media-resource:attr-media-autoplay><a href=#attr-media-autoplay>autoplay</a></code> attribute specified.<li>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.<li>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.</ul>

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

  <p class=note>For example, a user agent could require that playback is <a href=#triggered-by-user-activation id=playing-the-media-resource:triggered-by-user-activation>triggered by user
  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>

  <p>A <a href=#media-element id=playing-the-media-resource:media-element-6>media element</a> is said to have <dfn id=ended-playback>ended playback</dfn> when:</p>

  <ul><li>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

   <li>

    <p>Either:

    <ul><li>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-6>media resource</a>,
     and

     <li>The <a href=#direction-of-playback id=playing-the-media-resource:direction-of-playback>direction of playback</a> is forwards, and

     <li>The <a href=#media-element id=playing-the-media-resource:media-element-7>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.

    </ul>

    <p>Or:

    <ul><li>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

     <li>The <a href=#direction-of-playback id=playing-the-media-resource:direction-of-playback-2>direction of playback</a> is backwards.

    </ul>

   </ul>

  <p>The <dfn id=dom-media-ended><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-8>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>

  <p>A <a href=#media-element id=playing-the-media-resource:media-element-9>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>

  <p>A <a href=#media-element id=playing-the-media-resource:media-element-10>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-7>media resource</a> where the user has to make a selection for the resource to
  continue.</p>

  <p>It is possible for a <a href=#media-element id=playing-the-media-resource:media-element-11>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>

  <p>When a <a href=#media-element id=playing-the-media-resource:media-element-12>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-task id=playing-the-media-resource:queue-a-task>queue a
  task</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>

  <p>A <a href=#media-element id=playing-the-media-resource:media-element-13>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-8>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-9>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-10>media resource</a> but has a length longer than
  that segment.</p>

  <p class=example>One example of when a <a href=#media-element id=playing-the-media-resource:media-element-14>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>

  <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-11>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-15>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-12>media resource</a> and return.<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>.<li>

    <p><a href=#queue-a-task id=playing-the-media-resource:queue-a-task-2>Queue a task</a> to run these 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-16>media element</a>.<li>

      <p>If the <a href=#media-element id=playing-the-media-resource:media-element-17>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.<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-18>media element</a>.<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://heycam.github.io/webidl/#aborterror data-x-internal=aborterror>"<code>AbortError</code>"</a>
       <code id=playing-the-media-resource:domexception><a data-x-internal=domexception href=https://heycam.github.io/webidl/#dfn-DOMException>DOMException</a></code>.</ol>

     <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-19>media element</a>.</ol>

   </ol>

  <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-13>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-task id=playing-the-media-resource:queue-a-task-3>queue a task</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>

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

  <p>The <dfn id=dom-media-defaultplaybackrate><code>defaultPlaybackRate</code></dfn> attribute
  gives the desired speed at which the <a href=#media-resource id=playing-the-media-resource:media-resource-14>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>

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

  <p>The <dfn id=dom-media-playbackrate><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-15>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://heycam.github.io/webidl/#notsupportederror data-x-internal=notsupportederror>"<code>NotSupportedError</code>"</a> <code id=playing-the-media-resource:domexception-2><a data-x-internal=domexception href=https://heycam.github.io/webidl/#dfn-DOMException>DOMException</a></code>.<li><p>Set <code id=playing-the-media-resource:dom-media-playbackrate><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.</ol>

  <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-2><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-task id=playing-the-media-resource:queue-a-task-4>queue a task</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-20>media
  element</a>.</p>

  <hr>

  <p>The <dfn id=dom-media-played><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-16>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>

  <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-21>media element</a> has a <dfn id=list-of-pending-play-promises>list of pending play promises</dfn>, which must
  initially be empty.</p>

  <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-22>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.<li><p>Copy the <a href=#media-element id=playing-the-media-resource:media-element-23>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>.<li><p>Clear the <a href=#media-element id=playing-the-media-resource:media-element-24>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>.<li>Return <var>promises</var>.</ol>

  <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-25>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>

  <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-26>media element</a> with a list of
  promise <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>

  <p>To <dfn id=notify-about-playing>notify about playing</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><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.<li>

    <p><a href=#queue-a-task id=playing-the-media-resource:queue-a-task-5>Queue a task</a> to run these 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.<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>.</ol>

   </ol>

  <p>When the <dfn id=dom-media-play><code>play()</code></dfn> method on a <a href=#media-element id=playing-the-media-resource:media-element-28>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-29>media element</a> is not <a href=#allowed-to-play id=playing-the-media-resource:allowed-to-play>allowed to play</a>, return a promise
   rejected with a <a id=playing-the-media-resource:notallowederror href=https://heycam.github.io/webidl/#notallowederror data-x-internal=notallowederror>"<code>NotAllowedError</code>"</a> <code id=playing-the-media-resource:domexception-3><a data-x-internal=domexception href=https://heycam.github.io/webidl/#dfn-DOMException>DOMException</a></code>.<li>

    <p>If the <a href=#media-element id=playing-the-media-resource:media-element-30>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>, return a
    promise rejected with a <a id=playing-the-media-resource:notsupportederror-2 href=https://heycam.github.io/webidl/#notsupportederror data-x-internal=notsupportederror>"<code>NotSupportedError</code>"</a> <code id=playing-the-media-resource:domexception-4><a data-x-internal=domexception href=https://heycam.github.io/webidl/#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><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>.<li><p>If the <a href=#media-element id=playing-the-media-resource:media-element-31>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-32>media element</a>'s
   <a href=#concept-media-load-algorithm id=playing-the-media-resource:concept-media-load-algorithm>resource selection algorithm</a>.<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-17>media resource</a>.</p>

    <p class=note>This <a href=#seekUpdate>will cause</a> the user agent to <a href=#queue-a-task id=playing-the-media-resource:queue-a-task-6>queue a
    task</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-33>media element</a>.</p>
    

   <li>

    <p>If the <a href=#media-element id=playing-the-media-resource:media-element-34>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.<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.<li><p><a href=#queue-a-task id=playing-the-media-resource:queue-a-task-7>Queue a task</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.<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-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-task id=playing-the-media-resource:queue-a-task-8>queue a task</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-36>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>

     </ol>

   <li>

    <p>Otherwise, if the <a href=#media-element id=playing-the-media-resource:media-element-37>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-task id=playing-the-media-resource:queue-a-task-9>queue a task</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><p>Set the <a href=#media-element id=playing-the-media-resource:media-element-38>media element</a>'s <a href=#can-autoplay-flag id=playing-the-media-resource:can-autoplay-flag-2>can autoplay flag</a> to false.<li><p>Return <var>promise</var>.</ol>

  <hr>

  <p>When the <dfn id=dom-media-pause><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-39>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-40>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-41>media element</a>'s
   <a href=#concept-media-load-algorithm id=playing-the-media-resource:concept-media-load-algorithm-2>resource selection algorithm</a>.<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-42>media element</a>.</ol>

  <p>The <dfn id=internal-pause-steps>internal pause steps</dfn> for a <a href=#media-element id=playing-the-media-resource:media-element-43>media element</a> are as follows:</p>

  <ol><li><p>Set the <a href=#media-element id=playing-the-media-resource:media-element-44>media element</a>'s <a href=#can-autoplay-flag id=playing-the-media-resource:can-autoplay-flag-3>can autoplay flag</a> to false.<li><p>If the <a href=#media-element id=playing-the-media-resource:media-element-45>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.<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.<li>

      <p><a href=#queue-a-task id=playing-the-media-resource:queue-a-task-10>Queue a task</a> to run these 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.<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.<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://heycam.github.io/webidl/#aborterror data-x-internal=aborterror>"<code>AbortError</code>"</a> <code id=playing-the-media-resource:domexception-5><a data-x-internal=domexception href=https://heycam.github.io/webidl/#dfn-DOMException>DOMException</a></code>.</ol>

     <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>.</ol>

   </ol>

  <hr>

  <p>If the element's <code id=playing-the-media-resource:dom-media-playbackrate-3><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>

  <p id=media-playback>When a <a href=#media-element id=playing-the-media-resource:media-element-46>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-4><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-5><a href=#dom-media-playbackrate>playbackRate</a></code> is negative.)</p>

  <p class=note>The element's <code id=playing-the-media-resource:dom-media-playbackrate-6><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>

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

  <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-7><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-8><a href=#dom-media-playbackrate>playbackRate</a></code> is not 1.0, the user agent may apply pitch
  adjustments to the audio as necessary to render it faithfully.</p>

  <p>When a <a href=#media-element id=playing-the-media-resource:media-element-47>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>

  <p>When a <a href=#media-element id=playing-the-media-resource:media-element-48>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>

  <p><a href=#media-element id=playing-the-media-resource:media-element-49>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>

  <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-18>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-19>media resource</a>.</p>

  <hr>

  <p>Each <a href=#media-element id=playing-the-media-resource:media-element-50>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-51>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-52>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-53>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-54>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-55>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-56>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>

  <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-57>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-58>media element</a>, if the <a href=#media-element id=playing-the-media-resource:media-element-59>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>

  <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-60>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. 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 — if one iteration takes a long time, this can cause
  certain <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".)</p>

  <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-61>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>.<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-62>media element</a> that are not present in <var>current cues</var>.<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-63>media element</a>, if this is not the first
   time it has run.<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.<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-64>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>.<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-task id=playing-the-media-resource:queue-a-task-11>queue a
   task</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.<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.<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-65>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>

    <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.<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>.<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>.<li><p>Add <var>track</var> to <var>affected tracks</var>.</ol>

   <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>.<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>.<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>.<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><p><a href=#queue-a-task id=playing-the-media-resource:queue-a-task-12>Queue</a> each <a href=#concept-task id=playing-the-media-resource:concept-task-12>task</a> in
   <var>events</var>, in list order.<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-66>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><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-task id=playing-the-media-resource:queue-a-task-13>queue a task</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.<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>.<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></ol>

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

  <p class=note>If the <a href=#media-element id=playing-the-media-resource:media-element-67>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>

  <p>When a <a href=#media-element id=playing-the-media-resource:media-element-68>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-69>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
   ⌛.)<li><p>⌛ If the <a href=#media-element id=playing-the-media-resource:media-element-70>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.<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-71>media element</a>.</p>

  </ol>

  



  <h5 id=seeking><span class=secno>4.8.12.9</span> Seeking<a href=#seeking class=self-link></a></h5>

  <dl class=domintro><dt><var>media</var> . <code id=dom-media-seeking-dev><a href=#dom-media-seeking>seeking</a></code><dd>

    <p>Returns true if the user agent is currently seeking.</p>

   <dt><var>media</var> . <code id=dom-media-seekable-dev><a href=#dom-media-seekable>seekable</a></code><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>

   <dt><var>media</var> . <code id=dom-media-fastseek-dev><a href=#dom-media-fastseek>fastSeek</a></code>( <var>time</var> )<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>

   </dl>

  

  <p>The <dfn id=dom-media-seeking><code>seeking</code></dfn> attribute must initially have the
  value false.</p>

  <p>The <dfn id=dom-media-fastseek><code>fastSeek()</code></dfn> method must <a href=#dom-media-seek id=seeking:dom-media-seek>seek</a> to the time given by the method's argument, with the
  <i>approximate-for-speed</i> flag set.</p>

  <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.<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.<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.<li><p>Set the <code id=seeking:dom-media-seeking-2><a href=#dom-media-seeking>seeking</a></code> IDL attribute to true.<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.<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.<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.<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.<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><p><a href=#queue-a-task id=seeking:queue-a-task>Queue a task</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.<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-3>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><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.<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 ⌛.)<li><p>⌛ Set the <code id=seeking:dom-media-seeking-4><a href=#dom-media-seeking>seeking</a></code> IDL attribute to
   false.<li><p>⌛ Run the <a href=#time-marches-on id=seeking:time-marches-on>time marches on</a> steps.<li id=seekUpdate><p>⌛ <a href=#queue-a-task id=seeking:queue-a-task-2>Queue a task</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.<li><p>⌛ <a href=#queue-a-task id=seeking:queue-a-task-3>Queue a task</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.</ol>

  <hr>

  <p>The <dfn id=dom-media-seekable><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>

  <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-4>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.12.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><var>media</var> . <code id=dom-media-audiotracks-dev><a href=#dom-media-audiotracks>audioTracks</a></code><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>

   <dt><var>media</var> . <code id=dom-media-videotracks-dev><a href=#dom-media-videotracks>videoTracks</a></code><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>

   </dl>

  

  <p>The <dfn id=dom-media-audiotracks><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>

  <p>The <dfn id=dom-media-videotracks><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>

  <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.12.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=status><input onclick=toggleStatus(this) value=⋰ type=button><p class=support><strong>Support:</strong> audiotracks<span class="and_chr no"><span>Chrome for Android</span> <span>None</span></span><span class="chrome no"><span>Chrome</span> <span>None</span></span><span class="ios_saf yes"><span>iOS Safari</span> <span>7.0+</span></span><span class="and_uc no"><span>UC Browser for Android</span> <span>None</span></span><span class="firefox no"><span>Firefox</span> <span>None</span></span><span class="ie yes"><span>IE</span> <span>10+</span></span><span class="op_mini no"><span>Opera Mini</span> <span>None</span></span><span class="safari yes"><span>Safari</span> <span>6.1+</span></span><span class="edge yes"><span>Edge</span> <span>12+</span></span><span class="samsung no"><span>Samsung Internet</span> <span>None</span></span><span class="opera no"><span>Opera</span> <span>None</span></span><span class="android no"><span>Android Browser</span> <span>None</span></span><p class=caniuse>Source: <a href="https://caniuse.com/#feat=audiotracks">caniuse.com</a></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>

  <pre><code class='idl'>[<c- g>Exposed</c->=<c- n>Window</c->]
<c- b>interface</c-> <dfn id='audiotracklist'><c- g>AudioTrackList</c-></dfn> : <a href='https://dom.spec.whatwg.org/#interface-eventtarget' data-x-internal='eventtarget' id='audiotracklist-and-videotracklist-objects: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'><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'><c- g>VideoTrackList</c-></dfn> : <a href='https://dom.spec.whatwg.org/#interface-eventtarget' data-x-internal='eventtarget' id='audiotracklist-and-videotracklist-objects:eventtarget-2'><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'><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><var>media</var> . <code id=audiotracklist-and-videotracklist-objects:dom-media-audiotracks><a href=#dom-media-audiotracks>audioTracks</a></code> . <code id=dom-audiotracklist-length-dev><a href=#dom-audiotracklist-length>length</a></code><dt><var>media</var> . <code id=audiotracklist-and-videotracklist-objects:dom-media-videotracks><a href=#dom-media-videotracks>videoTracks</a></code> . <code id=dom-videotracklist-length-dev><a href=#dom-videotracklist-length>length</a></code><dd>

    <p>Returns the number of tracks in the list.</p>

   <dt><var>audioTrack</var> = <var>media</var> . <code id=audiotracklist-and-videotracklist-objects:dom-media-audiotracks-2><a href=#dom-media-audiotracks>audioTracks</a></code>[<var>index</var>]<dt><var>videoTrack</var> = <var>media</var> . <code id=audiotracklist-and-videotracklist-objects:dom-media-videotracks-2><a href=#dom-media-videotracks>videoTracks</a></code>[<var>index</var>]<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>

   <dt><var>audioTrack</var> = <var>media</var> . <code id=audiotracklist-and-videotracklist-objects:dom-media-audiotracks-3><a href=#dom-media-audiotracks>audioTracks</a></code> . <code id=dom-audiotracklist-gettrackbyid-dev><a href=#dom-audiotracklist-gettrackbyid>getTrackById</a></code>( <var>id</var> )<dt><var>videoTrack</var> = <var>media</var> . <code id=audiotracklist-and-videotracklist-objects:dom-media-videotracks-3><a href=#dom-media-videotracks>videoTracks</a></code> . <code id=dom-videotracklist-gettrackbyid-dev><a href=#dom-videotracklist-gettrackbyid>getTrackById</a></code>( <var>id</var> )<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>

   <dt><var>audioTrack</var> . <code id=dom-audiotrack-id-dev><a href=#dom-audiotrack-id>id</a></code><dt><var>videoTrack</var> . <code id=dom-videotrack-id-dev><a href=#dom-videotrack-id>id</a></code><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>

   <dt><var>audioTrack</var> . <code id=dom-audiotrack-kind-dev><a href=#dom-audiotrack-kind>kind</a></code><dt><var>videoTrack</var> . <code id=dom-videotrack-kind-dev><a href=#dom-videotrack-kind>kind</a></code><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>

   <dt><var>audioTrack</var> . <code id=dom-audiotrack-label-dev><a href=#dom-audiotrack-label>label</a></code><dt><var>videoTrack</var> . <code id=dom-videotrack-label-dev><a href=#dom-videotrack-label>label</a></code><dd>

    <p>Returns the label of the given track, if known, or the empty string otherwise.</p>

   <dt><var>audioTrack</var> . <code id=dom-audiotrack-language-dev><a href=#dom-audiotrack-language>language</a></code><dt><var>videoTrack</var> . <code id=dom-videotrack-language-dev><a href=#dom-videotrack-language>language</a></code><dd>

    <p>Returns the language of the given track, if known, or the empty string otherwise.</p>

   <dt><var>audioTrack</var> . <code id=dom-audiotrack-enabled-dev><a href=#dom-audiotrack-enabled>enabled</a></code> [ = <var>value</var> ]<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>

   <dt><var>media</var> . <code id=audiotracklist-and-videotracklist-objects:dom-media-videotracks-4><a href=#dom-media-videotracks>videoTracks</a></code> . <code id=dom-videotracklist-selectedindex-dev><a href=#dom-videotracklist-selectedindex>selectedIndex</a></code><dd>

    <p>Returns the index of the currently selected track, if any, or −1 otherwise.</p>

   <dt><var>videoTrack</var> . <code id=dom-videotrack-selected-dev><a href=#dom-videotrack-selected>selected</a></code> [ = <var>value</var> ]<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>

   </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>

  <p>The <dfn id=dom-audiotracklist-length><code>AudioTrackList.length</code></dfn> and <dfn id=dom-videotracklist-length><code>VideoTrackList.length</code></dfn> attributes must return
  the number of tracks represented by their objects at the time of getting.</p>

  <p>The <a id=audiotracklist-and-videotracklist-objects:supported-property-indices href=https://heycam.github.io/webidl/#dfn-supported-property-indices data-x-internal=supported-property-indices>supported property indices</a> of <code id=audiotracklist-and-videotracklist-objects:audiotracklist-5><a href=#audiotracklist>AudioTrackList</a></code> and
  <code id=audiotracklist-and-videotracklist-objects:videotracklist-5><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-6><a href=#audiotracklist>AudioTrackList</a></code> or <code id=audiotracklist-and-videotracklist-objects:videotracklist-6><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://heycam.github.io/webidl/#dfn-supported-property-indices data-x-internal=supported-property-indices>supported property indices</a>.</p>

  <p id=dom-tracklist-item>To <a id=audiotracklist-and-videotracklist-objects:determine-the-value-of-an-indexed-property href=https://heycam.github.io/webidl/#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-7><a href=#audiotracklist>AudioTrackList</a></code> or <code id=audiotracklist-and-videotracklist-objects:videotracklist-7><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>

  <p>The <dfn id=dom-audiotracklist-gettrackbyid><code>AudioTrackList.getTrackById(<var>id</var>)</code></dfn> and <dfn id=dom-videotracklist-gettrackbyid><code>VideoTrackList.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-8><a href=#audiotracklist>AudioTrackList</a></code> or
  <code id=audiotracklist-and-videotracklist-objects:videotracklist-8><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>

  <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-9><a href=#audiotracklist>AudioTrackList</a></code> or <code id=audiotracklist-and-videotracklist-objects:videotracklist-9><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-10><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>

  <p>The <dfn id=dom-audiotrack-id><code>AudioTrack.id</code></dfn> and <dfn id=dom-videotrack-id><code>VideoTrack.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>

  <p class=example>For example, in Ogg files, this would be the Name header field of the track. <a href=#refsOGGSKELETONHEADERS>[OGGSKELETONHEADERS]</a></p>

  <p>The <dfn id=dom-audiotrack-kind><code>AudioTrack.kind</code></dfn> and <dfn id=dom-videotrack-kind><code>VideoTrack.kind</code></dfn> attributes must return the category
  of the track, if it has one, or the empty string otherwise.</p>

  <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-11><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-11><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. The <cite>Sourcing In-band
  Media Resource Tracks from Media Containers into HTML</cite> specification 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:dom-audiotrack-kind-2><a href=#dom-audiotrack-kind>AudioTrack.kind</a></code> and <code id=audiotracklist-and-videotracklist-objects:dom-videotrack-kind-2><a href=#dom-videotrack-kind>VideoTrack.kind</a></code></caption><thead><tr><th>Category
     <th>Definition
     <th>Applies to...<th>Examples
   <tbody><tr><td>"<dfn id=value-track-kind-alternate><code>alternative</code></dfn>"
     <td>A possible alternative to the main track, e.g. a different take of a song (audio), or a different angle (video).
     <td>Audio and video.
     <td>Ogg: "audio/alternate" or "video/alternate"; DASH: "alternate" without "main" and "commentary" roles, and, for audio, without the "dub" role (other roles ignored).

    <tr><td>"<dfn id=value-track-kind-caption><code>captions</code></dfn>"
     <td>A version of the main video track with captions burnt in. (For legacy content; new content would use text tracks.)
     <td>Video only.
     <td>DASH: "caption" and "main" roles together (other roles ignored).

    <tr><td>"<dfn id=value-track-kind-descriptions><code>descriptions</code></dfn>"
     <td>An audio description of a video track.
     <td>Audio only.
     <td>Ogg: "audio/audiodesc".

    <tr><td>"<dfn id=value-track-kind-main><code>main</code></dfn>"
     <td>The primary audio or video track.
     <td>Audio and video.
     <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).

    <tr><td>"<dfn id=value-track-kind-main-desc><code>main-desc</code></dfn>"
     <td>The primary audio track, mixed with audio descriptions.
     <td>Audio only.
     <td>AC3 audio in MPEG-2 TS: bsmod=2 and full_svc=1. 

    <tr><td>"<dfn id=value-track-kind-sign><code>sign</code></dfn>"
     <td>A sign-language interpretation of an audio track.
     <td>Video only.
     <td>Ogg: "video/sign".

    <tr><td>"<dfn id=value-track-kind-subtitle><code>subtitles</code></dfn>"
     <td>A version of the main video track with subtitles burnt in. (For legacy content; new content would use text tracks.)
     <td>Video only.
     <td>DASH: "subtitle" and "main" roles together (other roles ignored).

    <tr><td>"<dfn id=value-track-kind-translation><code>translation</code></dfn>"
     <td>A translated version of the main audio track.
     <td>Audio only.
     <td>Ogg: "audio/dub". DASH: "dub" and "main" roles together (other roles ignored).

    <tr><td>"<dfn id=value-track-kind-commentary><code>commentary</code></dfn>"
     <td>Commentary on the primary audio or video track, e.g. a director's commentary.
     <td>Audio and video.
     <td>DASH: "commentary" role without "main" role (other roles ignored).

    <tr><td>"<dfn id=value-track-kind-none><code></code></dfn>" (empty string)
     <td>No explicit kind, or the kind given by the track's metadata is not recognized by the user agent.
     <td>Audio and video.
     <td>

  </table>

  

  <p>The <dfn id=dom-audiotrack-label><code>AudioTrack.label</code></dfn> and <dfn id=dom-videotrack-label><code>VideoTrack.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>

  <p>The <dfn id=dom-audiotrack-language><code>AudioTrack.language</code></dfn> and <dfn id=dom-videotrack-language><code>VideoTrack.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>

  <p>The <dfn id=dom-audiotrack-enabled><code>AudioTrack.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-10><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-12><a href=#audiotrack>AudioTrack</a></code> object.)</p>

  <p id=toggle-audio-track>Whenever an audio track in an <code id=audiotracklist-and-videotracklist-objects:audiotracklist-11><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-task id=audiotracklist-and-videotracklist-objects:queue-a-task>queue a task</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-12><a href=#audiotracklist>AudioTrackList</a></code> object.</p>

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

  <p>The <dfn id=dom-videotracklist-selectedindex><code>VideoTrackList.selectedIndex</code></dfn> attribute
  must return the index of the currently selected track, if any. If the <code id=audiotracklist-and-videotracklist-objects:videotracklist-11><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>

  <p>The <dfn id=dom-videotrack-selected><code>VideoTrack.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-12><a href=#videotracklist>VideoTrackList</a></code>, then all the other <code id=audiotracklist-and-videotracklist-objects:videotrack-12><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-13><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-13><a href=#videotrack>VideoTrack</a></code> object.)</p>

  <p id=toggle-video-track>Whenever a track in a <code id=audiotracklist-and-videotracklist-objects:videotracklist-14><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-15><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-task id=audiotracklist-and-videotracklist-objects:queue-a-task-2>queue a
  task</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-16><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-a-task id=audiotracklist-and-videotracklist-objects:queue-a-task-3>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>

  <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-13><a href=#audiotracklist>AudioTrackList</a></code> and <code id=audiotracklist-and-videotracklist-objects:videotracklist-17><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><a href=#event-handler-event-type id=audiotracklist-and-videotracklist-objects:event-handler-event-type-2>Event handler event type</a>
   <tbody><tr><td><dfn id=handler-tracklist-onchange><code>onchange</code></dfn> <td> <code id=audiotracklist-and-videotracklist-objects:event-media-change-3><a href=#event-media-change>change</a></code>
    <tr><td><dfn id=handler-tracklist-onaddtrack><code>onaddtrack</code></dfn> <td> <code id=audiotracklist-and-videotracklist-objects:event-media-addtrack><a href=#event-media-addtrack>addtrack</a></code>
    <tr><td><dfn id=handler-tracklist-onremovetrack><code>onremovetrack</code></dfn> <td> <code id=audiotracklist-and-videotracklist-objects:event-media-removetrack><a href=#event-media-removetrack>removetrack</a></code>
  </table>

  

  


  <h6 id=selecting-specific-audio-and-video-tracks-declaratively><span class=secno>4.8.12.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>&quot;myvideo#track=Alternative&quot;</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.12.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.12.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 class=brief><li>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>.<li>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.<li>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.</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>

   <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><dfn id=dom-texttrack-kind-captions><code>captions</code></dfn>
     <li><dfn id=dom-texttrack-kind-descriptions><code>descriptions</code></dfn>
     <li><dfn id=dom-texttrack-kind-chapters><code>chapters</code></dfn>
     <li><dfn id=dom-texttrack-kind-metadata><code>metadata</code></dfn>
    </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>

   <dt><dfn id=text-track-label>A label</dfn>

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

   <dt><dfn id=text-track-in-band-metadata-track-dispatch-type>An in-band metadata track dispatch type</dfn>

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

   <dt><dfn id=text-track-language>A language</dfn>

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

   <dt><dfn id=text-track-readiness-state>A readiness state</dfn>

   <dd>

    <p>One of the following:</p>

    <dl><dt><dfn id=text-track-not-loaded>Not loaded</dfn>

     <dd>

      <p>Indicates that the text track's cues have not been obtained.</p>

     <dt><dfn id=text-track-loading>Loading</dfn>

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

     <dt><dfn id=text-track-loaded>Loaded</dfn>

     <dd>

      <p>Indicates that the text track has been loaded with no fatal errors.</p>

     <dt><dfn id=text-track-failed-to-load>Failed to load</dfn>

     <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=#parse-a-url id=text-track-model:parse-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>

     </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>

   <dt><dfn id=text-track-mode>A mode</dfn>

   <dd>

    <p>One of the following:</p>

    <dl><dt><dfn id=text-track-disabled>Disabled</dfn>

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

     <dt><dfn id=text-track-hidden>Hidden</dfn>

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

     <dt><dfn id=text-track-showing>Showing</dfn>

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

     </dl>

   <dt><dfn id=text-track-list-of-cues>A list of zero or more cues</dfn>

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

   </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>

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

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

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

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

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

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

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

    <p><a href=#queue-a-task id=text-track-model:queue-a-task>Queue a task</a> to run these steps:</p>

    <ol><li><p>Unset the <a href=#media-element id=text-track-model:media-element-14>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>.<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-15>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.</ol>

   <li><p>If the <a href=#media-element id=text-track-model:media-element-16>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.</ol>

  <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>
   <dd>
    <p>An arbitrary string.</p>
   <dt><dfn id=text-track-cue-start-time>A start time</dfn>
   <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>
   <dt><dfn id=text-track-cue-end-time>An end time</dfn>
   <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.</p>
   <dt><dfn id=text-track-cue-pause-on-exit-flag>A pause-on-exit flag</dfn>
   <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>
   <dt>Some additional format-specific data<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>
   </dl>

  <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>text track cue end
  time</a> can be negative. (The <a href=#current-playback-position id=text-track-model:current-playback-position>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>
   <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>

    <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-17>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-18>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> <dt>The <dfn id=text-track-cue-display-state>display state</dfn>
   <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>

   </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-19>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-20>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-2>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-3>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.12.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 the <cite>Sourcing In-band Media Resource Tracks from Media
  Containers into HTML</cite> specification. <a href=#refsINBAND>[INBAND]</a></p>

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

    <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<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><dt>If the <a href=#media-resource id=sourcing-in-band-text-tracks:media-resource-6>media resource</a> is a WebM file<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><dt>If the <a href=#media-resource id=sourcing-in-band-text-tracks:media-resource-7>media resource</a> is an MPEG-2 file<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 the MPEG-2
     specification. 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>

     <dt>If the <a href=#media-resource id=sourcing-in-band-text-tracks:media-resource-8>media resource</a> is an MPEG-4 file<dd>Let 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 be the <i>stsd box</i>, if any.

     If the file has no <i>stsd box</i>, or if the <i>stsd box</i> 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 the <i>stsd box</i> 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 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 the <i>stsd
     box</i>, or the empty string if that field is absent in that box.

     Otherwise, if the <i>stsd box</i> 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 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 the <i>stsd box</i>, or the empty string if that field is absent in
     that box.

     <a href=#refsMPEG4>[MPEG4]</a>

     </dl>

   <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.<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>.<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><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>.<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.</ol>

  

  

  



  

  <h6 id=sourcing-out-of-band-text-tracks><span class=secno>4.8.12.11.3</span> Sourcing out-of-band text tracks<a href=#sourcing-out-of-band-text-tracks class=self-link></a></h6>

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

  <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>String
   <tbody><tr><td><a href=#attr-track-kind-subtitles id=sourcing-out-of-band-text-tracks:attr-track-kind-subtitles>Subtitles</a>
     <td><code id=sourcing-out-of-band-text-tracks:dom-texttrack-kind-subtitles><a href=#dom-texttrack-kind-subtitles>subtitles</a></code>
    <tr><td><a href=#attr-track-kind-captions id=sourcing-out-of-band-text-tracks:attr-track-kind-captions>Captions</a>
     <td><code id=sourcing-out-of-band-text-tracks:dom-texttrack-kind-captions><a href=#dom-texttrack-kind-captions>captions</a></code>
    <tr><td><a href=#attr-track-kind-descriptions id=sourcing-out-of-band-text-tracks:attr-track-kind-descriptions>Descriptions</a>
     <td><code id=sourcing-out-of-band-text-tracks:dom-texttrack-kind-descriptions><a href=#dom-texttrack-kind-descriptions>descriptions</a></code>
    <tr><td><a href=#attr-track-kind-chapters id=sourcing-out-of-band-text-tracks:attr-track-kind-chapters>Chapters metadata</a>
     <td><code id=sourcing-out-of-band-text-tracks:dom-texttrack-kind-chapters><a href=#dom-texttrack-kind-chapters>chapters</a></code>
    <tr><td><a href=#attr-track-kind-metadata id=sourcing-out-of-band-text-tracks:attr-track-kind-metadata>Metadata</a>
     <td><code id=sourcing-out-of-band-text-tracks:dom-texttrack-kind-metadata><a href=#dom-texttrack-kind-metadata>metadata</a></code>
  </table>

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

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

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

  <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-task id=sourcing-out-of-band-text-tracks:queue-a-task>queue a task</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-3>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>

  <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-4>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-5>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-task id=sourcing-out-of-band-text-tracks:queue-a-task-2>queue a task</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-6>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>
  

  <hr>

  <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-7>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-task id=sourcing-out-of-band-text-tracks:queue-a-task-3>queue a
  task</a> to run the following steps for the <a href=#media-element id=sourcing-out-of-band-text-tracks:media-element-8>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.<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.<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.</ol>

  <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-9>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>.<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>.<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-10>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><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.</ol>

  <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-11>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>.<li><p>If <var>candidates</var> is empty, then return.<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.<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>

   </ol>

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

  <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>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>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-12>media
   element</a>.</ul>

  <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.<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.<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-13>media
   element</a> as a parent, return.<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.<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 ⌛.)<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>.<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.<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-14>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-15>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>.<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>.<li>

    <p>If <var>URL</var> is not the empty string, then:

    <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.<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>.<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>.</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-4>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. Implementors 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 specification's 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-a-task id=sourcing-out-of-band-text-tracks:queue-a-task-5>queue a task</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. This
    <a href=#concept-task id=sourcing-out-of-band-text-tracks:concept-task-3>task</a> must use the <a href=#dom-manipulation-task-source id=sourcing-out-of-band-text-tracks:dom-manipulation-task-source>DOM manipulation task
    source</a>.</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 the XML specification requires
    be detected and reported to the application), then the <a href=#concept-task id=sourcing-out-of-band-text-tracks:concept-task-4>task</a>
    that is <a href=#queue-a-task id=sourcing-out-of-band-text-tracks:queue-a-task-6>queued</a> by 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-5>task</a> that is <a href=#queue-a-task id=sourcing-out-of-band-text-tracks:queue-a-task-7>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>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></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-6>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-a-task id=sourcing-out-of-band-text-tracks:queue-a-task-8>queue a task</a> 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-22><a href=#the-track-element>track</a></code> element. This <a href=#concept-task id=sourcing-out-of-band-text-tracks:concept-task-7>task</a> must use the <a href=#dom-manipulation-task-source id=sourcing-out-of-band-text-tracks:dom-manipulation-task-source-2>DOM manipulation task source</a>. </p>

   <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>.<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>.<li><p>Jump to the step labeled <i>top</i>.</ol>

  <p>Whenever a <code id=sourcing-out-of-band-text-tracks:the-track-element-23><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>

  


  

  <h6 id=guidelines-for-exposing-cues-in-various-formats-as-text-track-cues><span class=secno>4.8.12.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>
   <dd>
    <p>Should be set to the empty string if the format has no obvious analogue to a per-cue
    identifier.</p>
   <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>
   <dd>
    <p>Should be set to false.</p>
   </dl>

  


  <h6 id=text-track-api><span class=secno>4.8.12.11.5</span> Text track API<a href=#text-track-api class=self-link></a></h6>

  <pre><code class='idl'>[<c- g>Exposed</c->=<c- n>Window</c->]
<c- b>interface</c-> <dfn id='texttracklist'><c- g>TextTrackList</c-></dfn> : <a href='https://dom.spec.whatwg.org/#interface-eventtarget' data-x-internal='eventtarget' id='text-track-api: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><var>media</var> . <code id=dom-media-texttracks-dev><a href=#dom-media-texttracks>textTracks</a></code> . <code>length</code><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>
   <dt><var>media</var> . <code id=text-track-api:dom-media-texttracks><a href=#dom-media-texttracks>textTracks[</a></code> <var>n</var> <code>]</code><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>
   <dt><var>textTrack</var> = <var>media</var> . <code id=text-track-api:dom-media-texttracks-2><a href=#dom-media-texttracks>textTracks</a></code> . <code id=dom-texttracklist-gettrackbyid-dev><a href=#dom-texttracklist-gettrackbyid>getTrackById</a></code>( <var>id</var> )<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>

   </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>

  <p>The <dfn id=dom-media-texttracks><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>

  <p>The <dfn id=dom-texttracklist-length><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>

  <p>The <a id=text-track-api:supported-property-indices href=https://heycam.github.io/webidl/#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://heycam.github.io/webidl/#dfn-supported-property-indices data-x-internal=supported-property-indices>supported property
  indices</a>.</p>

  <p id=dom-texttracklist-item>To <a id=text-track-api:determine-the-value-of-an-indexed-property href=https://heycam.github.io/webidl/#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>

  <p>The <dfn id=dom-texttracklist-gettrackbyid><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>

  

  <hr>

  <pre><code class='idl'><c- b>enum</c-> <dfn id='texttrackmode'><c- g>TextTrackMode</c-></dfn> { <c- s>&quot;</c-><a href='#dom-texttrack-disabled' id='text-track-api:dom-texttrack-disabled'><c- s>disabled</c-></a><c- s>&quot;</c->,  <c- s>&quot;</c-><a href='#dom-texttrack-hidden' id='text-track-api:dom-texttrack-hidden'><c- s>hidden</c-></a><c- s>&quot;</c->,  <c- s>&quot;</c-><a href='#dom-texttrack-showing' id='text-track-api:dom-texttrack-showing'><c- s>showing</c-></a><c- s>&quot;</c-> };
<c- b>enum</c-> <dfn id='texttrackkind'><c- g>TextTrackKind</c-></dfn> { <c- s>&quot;</c-><a href='#dom-texttrack-kind-subtitles' id='text-track-api:dom-texttrack-kind-subtitles'><c- s>subtitles</c-></a><c- s>&quot;</c->,  <c- s>&quot;</c-><a href='#dom-texttrack-kind-captions' id='text-track-api:dom-texttrack-kind-captions'><c- s>captions</c-></a><c- s>&quot;</c->,  <c- s>&quot;</c-><a href='#dom-texttrack-kind-descriptions' id='text-track-api:dom-texttrack-kind-descriptions'><c- s>descriptions</c-></a><c- s>&quot;</c->,  <c- s>&quot;</c-><a href='#dom-texttrack-kind-chapters' id='text-track-api:dom-texttrack-kind-chapters'><c- s>chapters</c-></a><c- s>&quot;</c->,  <c- s>&quot;</c-><a href='#dom-texttrack-kind-metadata' id='text-track-api:dom-texttrack-kind-metadata'><c- s>metadata</c-></a><c- s>&quot;</c-> };

[<c- g>Exposed</c->=<c- n>Window</c->]
<c- b>interface</c-> <dfn id='texttrack'><c- g>TextTrack</c-></dfn> : <a href='https://dom.spec.whatwg.org/#interface-eventtarget' data-x-internal='eventtarget' id='text-track-api:eventtarget-2'><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>void</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>void</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><var>textTrack</var> = <var>media</var> . <code id=dom-media-addtexttrack-dev><a href=#dom-media-addtexttrack>addTextTrack</a></code>( <var>kind</var> [, <var>label</var> [, <var>language</var> ] ] )<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>

   <dt><var>textTrack</var> . <code id=dom-texttrack-kind-dev><a href=#dom-texttrack-kind>kind</a></code><dd>

    <p>Returns the <a href=#text-track-kind id=text-track-api:text-track-kind>text track kind</a> string.</p>

   <dt><var>textTrack</var> . <code id=dom-texttrack-label-dev><a href=#dom-texttrack-label>label</a></code><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>

   <dt><var>textTrack</var> . <code id=dom-texttrack-language-dev><a href=#dom-texttrack-language>language</a></code><dd>
    <p>Returns the <a href=#text-track-language id=text-track-api:text-track-language>text track language</a> string.</p>
   <dt><var>textTrack</var> . <code id=dom-texttrack-id-dev><a href=#dom-texttrack-id>id</a></code><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>

   <dt><var>textTrack</var> . <code id=dom-texttrack-inbandmetadatatrackdispatchtype-dev><a href=#dom-texttrack-inbandmetadatatrackdispatchtype>inBandMetadataTrackDispatchType</a></code><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>

   <dt><var>textTrack</var> . <code id=dom-texttrack-mode-dev><a href=#dom-texttrack-mode>mode</a></code> [ = <var>value</var> ]<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>"<dd>
      <p>The <a href=#text-track-disabled id=text-track-api:text-track-disabled>text track disabled</a> mode.</p>
     <dt>"<code id=text-track-api:dom-texttrack-hidden-2><a href=#dom-texttrack-hidden>hidden</a></code>"<dd>
      <p>The <a href=#text-track-hidden id=text-track-api:text-track-hidden>text track hidden</a> mode.</p>
     <dt>"<code id=text-track-api:dom-texttrack-showing-2><a href=#dom-texttrack-showing>showing</a></code>"<dd>
      <p>The <a href=#text-track-showing id=text-track-api:text-track-showing>text track showing</a> mode.</p>
     </dl>

    <p>Can be set, to change the mode.</p>

   <dt><var>textTrack</var> . <code id=dom-texttrack-cues-dev><a href=#dom-texttrack-cues>cues</a></code><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>
   <dt><var>textTrack</var> . <code id=dom-texttrack-activecues-dev><a href=#dom-texttrack-activecues>activeCues</a></code><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>

   <dt><var>textTrack</var> . <code id=dom-texttrack-addcue-dev><a href=#dom-texttrack-addcue>addCue</a></code>( <var>cue</var> )<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>
   <dt><var>textTrack</var> . <code id=dom-texttrack-removecue-dev><a href=#dom-texttrack-removecue>removeCue</a></code>( <var>cue</var> )<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>
   </dl>

  

  <p>The <dfn id=dom-media-addtexttrack><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>

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

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

    <p><a href=#queue-a-task id=text-track-api:queue-a-task>Queue a task</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-9>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>

    <p>Return the new <code id=text-track-api:texttrack-11><a href=#texttrack>TextTrack</a></code> object.</p>

   </ol>

  <hr>

  <p>The <dfn id=dom-texttrack-kind><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>

  <p>The <dfn id=dom-texttrack-label><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>

  <p>The <dfn id=dom-texttrack-language><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>

  <p>The <dfn id=dom-texttrack-id><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>

  <p>The <dfn id=dom-texttrack-inbandmetadatatrackdispatchtype><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>

  <p>The <dfn id=dom-texttrack-mode><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 id=dom-texttrack-disabled><code>disabled</code></dfn>"<dd>The <a href=#text-track-disabled id=text-track-api:text-track-disabled-2>text track disabled</a> mode.<dt>"<dfn id=dom-texttrack-hidden><code>hidden</code></dfn>"<dd>The <a href=#text-track-hidden id=text-track-api:text-track-hidden-3>text track hidden</a> mode.<dt>"<dfn id=dom-texttrack-showing><code>showing</code></dfn>"<dd>The <a href=#text-track-showing id=text-track-api:text-track-showing-2>text track showing</a> mode.</dl>

  <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>"<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>

   <dt>If the new value is "<code id=text-track-api:dom-texttrack-hidden-3><a href=#dom-texttrack-hidden>hidden</a></code>"<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>

   <dt>If the new value is "<code id=text-track-api:dom-texttrack-showing-3><a href=#dom-texttrack-showing>showing</a></code>"<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>

   </dl>

  <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 id=dom-texttrack-cues><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>

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

  <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 id=dom-texttrack-activecues><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>

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

  <hr>

  <p>The <dfn id=dom-texttrack-addcue><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><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://heycam.github.io/webidl/#invalidstateerror data-x-internal=invalidstateerror>"<code>InvalidStateError</code>"</a>
   <code id=text-track-api:domexception><a data-x-internal=domexception href=https://heycam.github.io/webidl/#dfn-DOMException>DOMException</a></code>.</p>

   <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>.<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>.</ol>

  <p>The <dfn id=dom-texttrack-removecue><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://heycam.github.io/webidl/#notfounderror data-x-internal=notfounderror>"<code>NotFoundError</code>"</a> <code id=text-track-api:domexception-2><a data-x-internal=domexception href=https://heycam.github.io/webidl/#dfn-DOMException>DOMException</a></code>.<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>.</ol>

  

  <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>&apos;sfx.wav&apos;</c-><c- p>);</c->
<c- a>var</c-> sounds <c- o>=</c-> sfx<c- p>.</c->addTextTrack<c- p>(</c-><c- t>&apos;metadata&apos;</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>&apos;&apos;</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>&apos;dog bark&apos;</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>&apos;kitten mew&apos;</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>&apos;dog bark&apos;</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>&apos;kitten mew&apos;</c-><c- p>);</c->
  e<c- p>.</c->preventDefault<c- p>();</c->
<c- p>}</c-></code></pre>

  </div>

  <hr>

  <pre><code class='idl'>[<c- g>Exposed</c->=<c- n>Window</c->]
<c- b>interface</c-> <dfn id='texttrackcuelist'><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><var>cuelist</var> . <code id=dom-texttrackcuelist-length-dev><a href=#dom-texttrackcuelist-length>length</a></code><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>
   <dt><var>cuelist</var>[<var>index</var>]<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>
   <dt><var>cuelist</var> . <code id=dom-texttrackcuelist-getcuebyid-dev><a href=#dom-texttrackcuelist-getcuebyid>getCueById</a></code>( <var>id</var> )<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>
   </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>

  <p>The <dfn id=dom-texttrackcuelist-length><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>

  <p>The <a id=text-track-api:supported-property-indices-3 href=https://heycam.github.io/webidl/#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://heycam.github.io/webidl/#dfn-supported-property-indices data-x-internal=supported-property-indices>supported property
  indices</a>.</p>

  <p id=dom-texttrackcuelist-item>To <a id=text-track-api:determine-the-value-of-an-indexed-property-2 href=https://heycam.github.io/webidl/#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>

  <p>The <dfn id=dom-texttrackcuelist-getcuebyid><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>

  

  <hr>

  <pre><code class='idl'>[<c- g>Exposed</c->=<c- n>Window</c->]
<c- b>interface</c-> <dfn id='texttrackcue'><c- g>TextTrackCue</c-></dfn> : <a href='https://dom.spec.whatwg.org/#interface-eventtarget' data-x-internal='eventtarget' id='text-track-api:eventtarget-3'><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>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><var>cue</var> . <a href=#dom-texttrackcue-track id=dom-texttrackcue-track-dev>track</a><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>
   <dt><var>cue</var> . <a href=#dom-texttrackcue-id id=dom-texttrackcue-id-dev>id</a> [ = <var>value</var> ]<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>
   <dt><var>cue</var> . <a href=#dom-texttrackcue-starttime id=dom-texttrackcue-starttime-dev>startTime</a> [ = <var>value</var> ]<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>
   <dt><var>cue</var> . <a href=#dom-texttrackcue-endtime id=dom-texttrackcue-endtime-dev>endTime</a> [ = <var>value</var> ]<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>Can be set.</p>
   <dt><var>cue</var> . <a href=#dom-texttrackcue-pauseonexit id=dom-texttrackcue-pauseonexit-dev>pauseOnExit</a> [ = <var>value</var> ]<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>
   </dl>

  

  <p>The <dfn id=dom-texttrackcue-track><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>

  <p>The <dfn id=dom-texttrackcue-id><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>

  <p>The <dfn id=dom-texttrackcue-starttime><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-10>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-11>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-12>media element</a>.</p>

  <p>The <dfn id=dom-texttrackcue-endtime><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. On setting, 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, interpreted in seconds; 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-13>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-14>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-15>media element</a>.</p>

  <p>The <dfn id=dom-texttrackcue-pauseonexit><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>


  <h6 id=cue-events><span class=secno>4.8.12.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><a href=#event-handler-event-type id=cue-events:event-handler-event-type-2>Event handler event type</a>
   <tbody><tr><td><dfn id=handler-texttracklist-onchange><code>onchange</code></dfn> <td> <code id=cue-events:event-media-change><a href=#event-media-change>change</a></code>
    <tr><td><dfn id=handler-texttracklist-onaddtrack><code>onaddtrack</code></dfn> <td> <code id=cue-events:event-media-addtrack><a href=#event-media-addtrack>addtrack</a></code>
    <tr><td><dfn id=handler-texttracklist-onremovetrack><code>onremovetrack</code></dfn> <td> <code id=cue-events:event-media-removetrack><a href=#event-media-removetrack>removetrack</a></code>
  </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><a href=#event-handler-event-type id=cue-events:event-handler-event-type-4>Event handler event type</a>
   <tbody><tr><td><dfn id=handler-texttrack-oncuechange><code>oncuechange</code></dfn> <td> <code id=cue-events:event-media-cuechange><a href=#event-media-cuechange>cuechange</a></code>
  </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><a href=#event-handler-event-type id=cue-events:event-handler-event-type-6>Event handler event type</a>
   <tbody><tr><td><dfn id=handler-texttrackcue-onenter><code>onenter</code></dfn> <td> <code id=cue-events:event-media-enter><a href=#event-media-enter>enter</a></code>
    <tr><td><dfn id=handler-texttrackcue-onexit><code>onexit</code></dfn> <td> <code id=cue-events:event-media-exit><a href=#event-media-exit>exit</a></code>
  </table>

  



  <h6 id=best-practices-for-metadata-text-tracks><span class=secno>4.8.12.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 overlayed 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>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 --> 05:12:15.000
matchtype:qual
matchnumber:37

...

05:11:02.251 --> 05:11:17.198
red:78

05:11:03.672 --> 05:11:54.198
blue:66

05:11:17.198 --> 05:11:25.912
red:80

05:11:25.912 --> 05:11:26.522
red:83

05:11:26.522 --> 05:11:26.982
red:86

05:11:26.982 --> 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.12.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:dom-audiotrack-kind><a href=#dom-audiotrack-kind>AudioTrack.kind</a></code> or <code id=identifying-a-track-kind-through-a-url:dom-videotrack-kind><a href=#dom-videotrack-kind>VideoTrack.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.12.13</span> User interface<a href=#user-interface class=self-link></a></h5>

  <p>The <dfn id=attr-media-controls><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>

  <p>The <dfn id=dom-media-controls><code>controls</code></dfn> IDL attribute must
  <a href=#reflect id=user-interface:reflect>reflect</a> the content attribute of the same name.</p>

  <hr>

  

  <dl class=domintro><dt><var>media</var> . <code id=dom-media-volume-dev><a href=#dom-media-volume>volume</a></code> [ = <var>value</var> ]<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://heycam.github.io/webidl/#indexsizeerror data-x-internal=indexsizeerror>"<code>IndexSizeError</code>"</a> <code id=user-interface:domexception><a data-x-internal=domexception href=https://heycam.github.io/webidl/#dfn-DOMException>DOMException</a></code> if the new
    value is not in the range 0.0 .. 1.0.</p>

   <dt><var>media</var> . <code id=dom-media-muted-dev><a href=#dom-media-muted>muted</a></code> [ = <var>value</var> ]<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>

   </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>

  <p>The <dfn id=dom-media-volume><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://heycam.github.io/webidl/#indexsizeerror data-x-internal=indexsizeerror>"<code>IndexSizeError</code>"</a> <code id=user-interface:domexception-2><a data-x-internal=domexception href=https://heycam.github.io/webidl/#dfn-DOMException>DOMException</a></code> must be thrown
  instead.</p>

  <p>A <a href=#media-element id=user-interface:media-element-8>media element</a> can also be <dfn id=concept-media-muted>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>

  <p>The <dfn id=dom-media-muted><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>

  <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-task id=user-interface:queue-a-task>queue a task</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-11>media element</a>. Then, if
  the <a href=#media-element id=user-interface:media-element-12>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-13>media element</a>.</p>

  <p>An element's <dfn id=effective-media-volume>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.<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.<li><p>Let <var>volume</var> be the <a href=#concept-media-volume id=user-interface:concept-media-volume-3>playback
   volume</a> of the audio portions of the <a href=#media-element id=user-interface:media-element-14>media element</a>, in range 0.0 (silent) to
   1.0 (loudest).<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.</ol>

  

  <p>The <dfn id=attr-media-muted><code>muted</code></dfn> content attribute on <a href=#media-element id=user-interface:media-element-15>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>The <dfn id=dom-media-defaultmuted><code>defaultMuted</code></dfn> IDL attribute must
  <a href=#reflect id=user-interface:reflect-2>reflect</a> the <code id=user-interface:attr-media-muted-2><a href=#attr-media-muted>muted</a></code> content attribute.</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>&quot;adverts.cgi?kind=video&quot;</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.12.14</span> Time ranges<a href=#time-ranges class=self-link></a></h5>

  <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'><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><var>media</var> . <code id=dom-timeranges-length-dev><a href=#dom-timeranges-length>length</a></code><dd>

    <p>Returns the number of ranges in the object.</p>

   <dt><var>time</var> = <var>media</var> . <code id=dom-timeranges-start-dev><a href=#dom-timeranges-start>start</a></code>(<var>index</var>)<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://heycam.github.io/webidl/#indexsizeerror data-x-internal=indexsizeerror>"<code>IndexSizeError</code>"</a> <code id=time-ranges:domexception><a data-x-internal=domexception href=https://heycam.github.io/webidl/#dfn-DOMException>DOMException</a></code> if the index
    is out of range.</p>

   <dt><var>time</var> = <var>media</var> . <code id=dom-timeranges-end-dev><a href=#dom-timeranges-end>end</a></code>(<var>index</var>)<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://heycam.github.io/webidl/#indexsizeerror data-x-internal=indexsizeerror>"<code>IndexSizeError</code>"</a> <code id=time-ranges:domexception-2><a data-x-internal=domexception href=https://heycam.github.io/webidl/#dfn-DOMException>DOMException</a></code> if the index
    is out of range.</p>

   </dl>

  

  <p>The <dfn id=dom-timeranges-length><code>length</code></dfn> IDL attribute must return the
  number of ranges represented by the object.</p>

  <p>The <dfn id=dom-timeranges-start><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>

  <p>The <dfn id=dom-timeranges-end><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>

  <p>These methods must throw <a id=time-ranges:indexsizeerror-3 href=https://heycam.github.io/webidl/#indexsizeerror data-x-internal=indexsizeerror>"<code>IndexSizeError</code>"</a> <code id=time-ranges:domexception-3><a data-x-internal=domexception href=https://heycam.github.io/webidl/#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>

  <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>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>The start of a range must be less than or equal to the end of that same range.</ul>

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

  <pre><code class='idl'>[<c- g>Exposed</c->=<c- n>Window</c->,
 <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>interface</c-> <dfn id='trackevent'><c- g>TrackEvent</c-></dfn> : <a href='https://dom.spec.whatwg.org/#interface-event' data-x-internal='event' id='the-trackevent-interface:event'><c- n>Event</c-></a> {
  <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'><c- g>TrackEventInit</c-></dfn> : <a href='https://dom.spec.whatwg.org/#dictdef-eventinit' data-x-internal='eventinit' id='the-trackevent-interface: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><var>event</var> . <code id=dom-trackevent-track-dev><a href=#dom-trackevent-track>track</a></code><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>

   </dl>

  

  <p>The <dfn id=dom-trackevent-track><code>track</code></dfn> attribute must return the value
  it was initialized to. It represents the context information for the event.</p>

  



  <h5 id=mediaevents><span class=secno>4.8.12.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>Interface
     <th>Fired when...
     <th>Preconditions

   <tbody><tr><td><dfn id=event-media-loadstart><code>loadstart</code></dfn>

     <td><code id=mediaevents:event><a data-x-internal=event href=https://dom.spec.whatwg.org/#interface-event>Event</a></code>

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

    <tr><td><dfn id=event-media-progress><code>progress</code></dfn>

     <td><code id=mediaevents:event-2><a data-x-internal=event href=https://dom.spec.whatwg.org/#interface-event>Event</a></code>

     <td>The user agent is fetching <a href=#media-data id=mediaevents:media-data-2>media data</a>.

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

    <tr><td><dfn id=event-media-suspend><code>suspend</code></dfn>

     <td><code id=mediaevents:event-3><a data-x-internal=event href=https://dom.spec.whatwg.org/#interface-event>Event</a></code>

     <td>The user agent is intentionally not currently fetching <a href=#media-data id=mediaevents:media-data-3>media data</a>.

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

    <tr><td><dfn id=event-media-abort><code>abort</code></dfn>

     <td><code id=mediaevents:event-4><a data-x-internal=event href=https://dom.spec.whatwg.org/#interface-event>Event</a></code>

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

    <tr><td><dfn id=event-media-error><code>error</code></dfn>

     <td><code id=mediaevents:event-5><a data-x-internal=event href=https://dom.spec.whatwg.org/#interface-event>Event</a></code>

     <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 supported media format.

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

    <tr><td><dfn id=event-media-emptied><code>emptied</code></dfn>

     <td><code id=mediaevents:event-6><a data-x-internal=event href=https://dom.spec.whatwg.org/#interface-event>Event</a></code>

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

    <tr><td><dfn id=event-media-stalled><code>stalled</code></dfn>

     <td><code id=mediaevents:event-7><a data-x-internal=event href=https://dom.spec.whatwg.org/#interface-event>Event</a></code>

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

   <tbody><tr><td><dfn id=event-media-loadedmetadata><code>loadedmetadata</code></dfn>

     <td><code id=mediaevents:event-8><a data-x-internal=event href=https://dom.spec.whatwg.org/#interface-event>Event</a></code>

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

    <tr><td><dfn id=event-media-loadeddata><code>loadeddata</code></dfn>

     <td><code id=mediaevents:event-9><a data-x-internal=event href=https://dom.spec.whatwg.org/#interface-event>Event</a></code>

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

    <tr><td><dfn id=event-media-canplay><code>canplay</code></dfn>

     <td><code id=mediaevents:event-10><a data-x-internal=event href=https://dom.spec.whatwg.org/#interface-event>Event</a></code>

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

    <tr><td><dfn id=event-media-canplaythrough><code>canplaythrough</code></dfn>

     <td><code id=mediaevents:event-11><a data-x-internal=event href=https://dom.spec.whatwg.org/#interface-event>Event</a></code>

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

    <tr><td><dfn id=event-media-playing><code>playing</code></dfn>

     <td><code id=mediaevents:event-12><a data-x-internal=event href=https://dom.spec.whatwg.org/#interface-event>Event</a></code>

     <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><code id=mediaevents:dom-media-readystate-5><a href=#dom-media-readystate>readyState</a></code> is newly equal to or greater than
     <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 equal to or greater than <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>.

    <tr><td><dfn id=event-media-waiting><code>waiting</code></dfn>

     <td><code id=mediaevents:event-13><a data-x-internal=event href=https://dom.spec.whatwg.org/#interface-event>Event</a></code>

     <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><code id=mediaevents:dom-media-readystate-7><a href=#dom-media-readystate>readyState</a></code> is equal to or less than <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>.

   <tbody><tr><td><dfn id=event-media-seeking><code>seeking</code></dfn>

     <td><code id=mediaevents:event-14><a data-x-internal=event href=https://dom.spec.whatwg.org/#interface-event>Event</a></code>

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

    <tr><td><dfn id=event-media-seeked><code>seeked</code></dfn>

     <td><code id=mediaevents:event-15><a data-x-internal=event href=https://dom.spec.whatwg.org/#interface-event>Event</a></code>

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

    <tr><td><dfn id=event-media-ended><code>ended</code></dfn>

     <td><code id=mediaevents:event-16><a data-x-internal=event href=https://dom.spec.whatwg.org/#interface-event>Event</a></code>

     <td>Playback has stopped because the end of the <a href=#media-resource id=mediaevents:media-resource-4>media resource</a> was reached.

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

   <tbody><tr><td><dfn id=event-media-durationchange><code>durationchange</code></dfn>

     <td><code id=mediaevents:event-17><a data-x-internal=event href=https://dom.spec.whatwg.org/#interface-event>Event</a></code>

     <td>The <code id=mediaevents:dom-media-duration><a href=#dom-media-duration>duration</a></code> attribute has just been updated.

     <td>

    <tr><td><dfn id=event-media-timeupdate><code>timeupdate</code></dfn>

     <td><code id=mediaevents:event-18><a data-x-internal=event href=https://dom.spec.whatwg.org/#interface-event>Event</a></code>

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

    <tr><td><dfn id=event-media-play><code>play</code></dfn>

     <td><code id=mediaevents:event-19><a data-x-internal=event href=https://dom.spec.whatwg.org/#interface-event>Event</a></code>

     <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><code id=mediaevents:dom-media-paused-5><a href=#dom-media-paused>paused</a></code> is newly false.

    <tr><td><dfn id=event-media-pause><code>pause</code></dfn>

     <td><code id=mediaevents:event-20><a data-x-internal=event href=https://dom.spec.whatwg.org/#interface-event>Event</a></code>

     <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><code id=mediaevents:dom-media-paused-6><a href=#dom-media-paused>paused</a></code> is newly true.

    <tr><td><dfn id=event-media-ratechange><code>ratechange</code></dfn>

     <td><code id=mediaevents:event-21><a data-x-internal=event href=https://dom.spec.whatwg.org/#interface-event>Event</a></code>

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

   <tbody><tr><td><dfn id=event-media-resize><code>resize</code></dfn>

     <td><code id=mediaevents:event-22><a data-x-internal=event href=https://dom.spec.whatwg.org/#interface-event>Event</a></code>

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

    <tr><td><dfn id=event-media-volumechange><code>volumechange</code></dfn>

     <td><code id=mediaevents:event-23><a data-x-internal=event href=https://dom.spec.whatwg.org/#interface-event>Event</a></code>

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

  </table>


  <p>The following event fires on <code id=mediaevents:the-source-element><a href=#the-source-element>source</a></code> element:</p>

  <table><thead><tr><th>Event name

     <th>Interface

     <th>Fired when...

   <tbody><tr><td><dfn id=event-source-error><code>error</code></dfn>

     <td><code id=mediaevents:event-24><a data-x-internal=event href=https://dom.spec.whatwg.org/#interface-event>Event</a></code>

     <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 supported media format.

  </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>Interface

     <th>Fired when...

   <tbody><tr><td><dfn id=event-media-change><code>change</code></dfn>

     <td><code id=mediaevents:event-25><a data-x-internal=event href=https://dom.spec.whatwg.org/#interface-event>Event</a></code>

     <td>One or more tracks in the track list have been enabled or disabled.

    <tr><td><dfn id=event-media-addtrack><code>addtrack</code></dfn>

     <td><code id=mediaevents:trackevent><a href=#trackevent>TrackEvent</a></code>

     <td>A track has been added to the track list.

    <tr><td><dfn id=event-media-removetrack><code>removetrack</code></dfn>

     <td><code id=mediaevents:trackevent-2><a href=#trackevent>TrackEvent</a></code>

     <td>A track has been removed from the track list.

  </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>Interface

     <th>Fired when...

   <tbody><tr><td><dfn id=event-media-cuechange><code>cuechange</code></dfn>

     <td><code id=mediaevents:event-26><a data-x-internal=event href=https://dom.spec.whatwg.org/#interface-event>Event</a></code>

     <td>One or more cues in the track have become active or stopped being active.

  </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>Interface

     <th>Fired when...

   <tbody><tr><td><dfn id=event-track-error><code>error</code></dfn>

     <td><code id=mediaevents:event-27><a data-x-internal=event href=https://dom.spec.whatwg.org/#interface-event>Event</a></code>

     <td>An error occurs while fetching the track data or the type of the resource is not supported text track format.

    <tr><td><dfn id=event-track-load><code>load</code></dfn>

     <td><code id=mediaevents:event-28><a data-x-internal=event href=https://dom.spec.whatwg.org/#interface-event>Event</a></code>

     <td>A track data has been fetched and successfully processed.
  </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>Interface

     <th>Fired when...

   <tbody><tr><td><dfn id=event-media-enter><code>enter</code></dfn>

     <td><code id=mediaevents:event-29><a data-x-internal=event href=https://dom.spec.whatwg.org/#interface-event>Event</a></code>

     <td>The cue has become active.

    <tr><td><dfn id=event-media-exit><code>exit</code></dfn>

     <td><code id=mediaevents:event-30><a data-x-internal=event href=https://dom.spec.whatwg.org/#interface-event>Event</a></code>

     <td>The cue has stopped being active.

  </table>



  

  <h5 id=security-and-privacy-considerations><span class=secno>4.8.12.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-browsing-context id=security-and-privacy-considerations:top-level-browsing-context>top-level browsing context</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 browsing context
  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.12.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 removing the element's <code id=best-practices-for-authors-using-media-elements:attr-media-src><a href=#attr-media-src>src</a></code>
  attribute and any <code id=best-practices-for-authors-using-media-elements:the-source-element><a href=#the-source-element>source</a></code> element descendants, and invoking the element's <code id=best-practices-for-authors-using-media-elements:dom-media-load><a href=#dom-media-load>load()</a></code> method.</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.12.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.13</span> The <dfn><code>map</code></dfn> element<a href=#the-map-element class=self-link></a></h4>

  <dl class=element><dt><a href=#concept-element-categories id=the-map-element:concept-element-categories>Categories</a>:<dd><a href=#flow-content-2 id=the-map-element:flow-content-2>Flow content</a>.<dd><a href=#phrasing-content-2 id=the-map-element:phrasing-content-2>Phrasing content</a>.<dd><a href=#palpable-content-2 id=the-map-element:palpable-content-2>Palpable content</a>.<dt><a href=#concept-element-contexts id=the-map-element:concept-element-contexts>Contexts in which this element can be used</a>:<dd>Where <a href=#phrasing-content-2 id=the-map-element:phrasing-content-2-2>phrasing content</a> is expected.<dt><a href=#concept-element-content-model id=the-map-element:concept-element-content-model>Content model</a>:<dd><a href=#transparent id=the-map-element:transparent>Transparent</a>.<dt><a href=#concept-element-tag-omission id=the-map-element:concept-element-tag-omission>Tag omission in text/html</a>:<dd>Neither tag is omissible.<dt><a href=#concept-element-attributes id=the-map-element:concept-element-attributes>Content attributes</a>:<dd><a href=#global-attributes id=the-map-element:global-attributes>Global attributes</a><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<dt><a href=#concept-element-dom id=the-map-element:concept-element-dom>DOM interface</a>:<dd>
    <pre><code class='idl'>[<c- g>Exposed</c->=<c- n>Window</c->,
 <a href='#htmlconstructor' id='the-map-element:htmlconstructor'><c- g>HTMLConstructor</c-></a>]
<c- b>interface</c-> <dfn id='htmlmapelement'><c- g>HTMLMapElement</c-></dfn> : <a href='#htmlelement' id='the-map-element:htmlelement'><c- n>HTMLElement</c-></a> {
  [<a href='#cereactions' id='the-map-element:cereactions'><c- g>CEReactions</c-></a>] <c- b>attribute</c-> <c- b>DOMString</c-> <a href='#dom-map-name' id='the-map-element:dom-map-name'><c- g>name</c-></a>;
  [<c- g>SameObject</c->] <c- b>readonly</c-> <c- b>attribute</c-> <a href='https://dom.spec.whatwg.org/#interface-htmlcollection' data-x-internal='htmlcollection' id='the-map-element: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>
   </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 id=attr-map-name><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><var>map</var> . <code id=dom-map-areas-dev><a href=#dom-map-areas>areas</a></code><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>

   </dl>

  

  <p>The <dfn id=dom-map-areas><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>

  <p>The IDL attribute <dfn id=dom-map-name><code>name</code></dfn> must <a href=#reflect id=the-map-element:reflect>reflect</a>
  the content attribute of the same name.</p>

  

  <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>&quot;EN&quot;</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>&quot;/images/menu.gif&quot;</c->
      <c- e>ALT</c-><c- o>=</c-><c- s>&quot;Babies™ navigation menu. Select a department to go to its page.&quot;</c->
      <c- e>USEMAP</c-><c- o>=</c-><c- s>&quot;#NAV&quot;</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>&quot;NAV&quot;</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>&quot;/clothes/&quot;</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>&quot;Clothes&quot;</c-> <c- e>COORDS</c-><c- o>=</c-><c- s>&quot;0,0,100,50&quot;</c-> <c- e>HREF</c-><c- o>=</c-><c- s>&quot;/clothes/&quot;</c-><c- p>&gt;</c-> |
   <c- p>&lt;</c-><c- f>A</c-> <c- e>HREF</c-><c- o>=</c-><c- s>&quot;/toys/&quot;</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>&quot;Toys&quot;</c-> <c- e>COORDS</c-><c- o>=</c-><c- s>&quot;100,0,200,50&quot;</c-> <c- e>HREF</c-><c- o>=</c-><c- s>&quot;/toys/&quot;</c-><c- p>&gt;</c-> |
   <c- p>&lt;</c-><c- f>A</c-> <c- e>HREF</c-><c- o>=</c-><c- s>&quot;/food/&quot;</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>&quot;Food&quot;</c-> <c- e>COORDS</c-><c- o>=</c-><c- s>&quot;200,0,300,50&quot;</c-> <c- e>HREF</c-><c- o>=</c-><c- s>&quot;/food/&quot;</c-><c- p>&gt;</c-> |
   <c- p>&lt;</c-><c- f>A</c-> <c- e>HREF</c-><c- o>=</c-><c- s>&quot;/books/&quot;</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>&quot;Books&quot;</c-> <c- e>COORDS</c-><c- o>=</c-><c- s>&quot;300,0,400,50&quot;</c-> <c- e>HREF</c-><c- o>=</c-><c- s>&quot;/books/&quot;</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.14</span> The <dfn><code>area</code></dfn> element<a href=#the-area-element class=self-link></a></h4>

  <dl class=element><dt><a href=#concept-element-categories id=the-area-element:concept-element-categories>Categories</a>:<dd><a href=#flow-content-2 id=the-area-element:flow-content-2>Flow content</a>.<dd><a href=#phrasing-content-2 id=the-area-element:phrasing-content-2>Phrasing content</a>.<dt><a href=#concept-element-contexts id=the-area-element:concept-element-contexts>Contexts in which this element can be used</a>:<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.<dt><a href=#concept-element-content-model id=the-area-element:concept-element-content-model>Content model</a>:<dd><a href=#concept-content-nothing id=the-area-element:concept-content-nothing>Nothing</a>.<dt><a href=#concept-element-tag-omission id=the-area-element:concept-element-tag-omission>Tag omission in text/html</a>:<dd>No <a href=#syntax-end-tag id=the-area-element:syntax-end-tag>end tag</a>.<dt><a href=#concept-element-attributes id=the-area-element:concept-element-attributes>Content attributes</a>:<dd><a href=#global-attributes id=the-area-element:global-attributes>Global attributes</a><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><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><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><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><code id=the-area-element:attr-hyperlink-target><a href=#attr-hyperlink-target>target</a></code> — <a href=#browsing-context id=the-area-element:browsing-context>Browsing context</a> for <a href=#hyperlink id=the-area-element:hyperlink-2>hyperlink</a> <a href=#navigate id=the-area-element:navigate>navigation</a><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 file name if so<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><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><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<dt><a href=#concept-element-dom id=the-area-element:concept-element-dom>DOM interface</a>:<dd>
    <pre><code class='idl'>[<c- g>Exposed</c->=<c- n>Window</c->,
 <a href='#htmlconstructor' id='the-area-element:htmlconstructor'><c- g>HTMLConstructor</c-></a>]
<c- b>interface</c-> <dfn id='htmlareaelement'><c- g>HTMLAreaElement</c-></dfn> : <a href='#htmlelement' id='the-area-element:htmlelement'><c- n>HTMLElement</c-></a> {
  [<a href='#cereactions' id='the-area-element:cereactions'><c- g>CEReactions</c-></a>] <c- b>attribute</c-> <c- b>DOMString</c-> <a href='#dom-area-alt' id='the-area-element:dom-area-alt'><c- g>alt</c-></a>;
  [<a href='#cereactions' id='the-area-element:cereactions-2'><c- g>CEReactions</c-></a>] <c- b>attribute</c-> <c- b>DOMString</c-> <a href='#dom-area-coords' id='the-area-element:dom-area-coords'><c- g>coords</c-></a>;
  [<a href='#cereactions' id='the-area-element:cereactions-3'><c- g>CEReactions</c-></a>] <c- b>attribute</c-> <c- b>DOMString</c-> <a href='#dom-area-shape' id='the-area-element:dom-area-shape'><c- g>shape</c-></a>;
  [<a href='#cereactions' id='the-area-element:cereactions-4'><c- g>CEReactions</c-></a>] <c- b>attribute</c-> <c- b>DOMString</c-> <a href='#dom-area-target' id='the-area-element:dom-area-target'><c- g>target</c-></a>;
  [<a href='#cereactions' id='the-area-element:cereactions-5'><c- g>CEReactions</c-></a>] <c- b>attribute</c-> <c- b>DOMString</c-> <a href='#dom-area-download' id='the-area-element:dom-area-download'><c- g>download</c-></a>;
  [<a href='#cereactions' id='the-area-element:cereactions-6'><c- g>CEReactions</c-></a>] <c- b>attribute</c-> <c- b>USVString</c-> <a href='#dom-area-ping' id='the-area-element:dom-area-ping'><c- g>ping</c-></a>;
  [<a href='#cereactions' id='the-area-element:cereactions-7'><c- g>CEReactions</c-></a>] <c- b>attribute</c-> <c- b>DOMString</c-> <a href='#dom-area-rel' id='the-area-element:dom-area-rel'><c- g>rel</c-></a>;
  [<c- g>SameObject</c->, <c- g>PutForwards</c->=<a href='https://dom.spec.whatwg.org/#dom-domtokenlist-value' data-x-internal='dom-domtokenlist-value' id='the-area-element:dom-domtokenlist-value'><c- n>value</c-></a>] <c- b>readonly</c-> <c- b>attribute</c-> <a href='https://dom.spec.whatwg.org/#interface-domtokenlist' data-x-internal='domtokenlist' id='the-area-element:domtokenlist'><c- n>DOMTokenList</c-></a> <a href='#dom-area-rellist' id='the-area-element:dom-area-rellist'><c- g>relList</c-></a>;
  [<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' 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>
   </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-2><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 id=attr-area-alt><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-3><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 id=attr-area-shape><code>shape</code></dfn> attribute is an <a href=#enumerated-attribute id=the-area-element:enumerated-attribute>enumerated
  attribute</a>. The following table lists the keywords defined for this attribute. The states
  given in the first cell of the rows with keywords give the states to which those keywords map.
  Some of the keywords are non-conforming, as noted in the last
  column.</p>

  <table><thead><tr><th>State
     <th>Keywords
     <th>Notes
   <tbody><tr><td rowspan=2><a href=#attr-area-shape-circle id=the-area-element:attr-area-shape-circle>Circle state</a>
     <td><dfn id=attr-area-shape-keyword-circle><code>circle</code></dfn>
     <td>
    <tr><td><dfn id=attr-area-shape-keyword-circ><code>circ</code></dfn>
     <td>Non-conforming
    <tr><td><a href=#attr-area-shape-default id=the-area-element:attr-area-shape-default>Default state</a>
     <td><dfn id=attr-area-shape-keyword-default><code>default</code></dfn>
     <td>
    <tr><td rowspan=2><a href=#attr-area-shape-poly id=the-area-element:attr-area-shape-poly>Polygon state</a>
     <td><dfn id=attr-area-shape-keyword-poly><code>poly</code></dfn>
     <td>
    <tr><td><dfn id=attr-area-shape-keyword-polygon><code>polygon</code></dfn>
     <td>Non-conforming
    <tr><td rowspan=2><a href=#attr-area-shape-rect id=the-area-element:attr-area-shape-rect>Rectangle state</a>
     <td><dfn id=attr-area-shape-keyword-rect><code>rect</code></dfn>
     <td>
    <tr><td><dfn id=attr-area-shape-keyword-rectangle><code>rectangle</code></dfn>
     <td>Non-conforming
  </table>

  <p>The attribute may be omitted. The <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 the <a href=#attr-area-shape-rect id=the-area-element:attr-area-shape-rect-2>rectangle</a> state.</p>

  <p>The <dfn id=attr-area-coords><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 id=attr-area-shape-circle>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-3><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 id=attr-area-shape-default>default state</dfn> state, <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-4><a href=#attr-area-coords>coords</a></code> attribute. (The area is the
  whole image.)</p>

  <p>In the <dfn id=attr-area-shape-poly>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-5><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 id=attr-area-shape-rect>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-6><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, as described in the next section, the <code id=the-area-element:attr-hyperlink-href-4><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-2><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-3><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-5><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-6><a href=#attr-hyperlink-href>href</a></code> attribute must
  also be specified.</p>

  

  
  <p>The <a id=the-area-element:activation-behaviour href=https://dom.spec.whatwg.org/#eventtarget-activation-behavior data-x-internal=activation-behaviour>activation behavior</a> of <code id=the-area-element:the-area-element-13><a href=#the-area-element>area</a></code> elements is to <a href=#following-hyperlinks-2 id=the-area-element:following-hyperlinks-2-2>follow the hyperlink</a> or <a href=#downloading-hyperlinks id=the-area-element:downloading-hyperlinks-2>download the hyperlink</a> created by the <code id=the-area-element:the-area-element-14><a href=#the-area-element>area</a></code> element, if any, and as
  determined by the <code id=the-area-element:attr-hyperlink-download-4><a href=#attr-hyperlink-download>download</a></code> attribute and any
  expressed user preference.</p>

  <p>The IDL attributes <dfn id=dom-area-alt><code>alt</code></dfn>, <dfn id=dom-area-coords><code>coords</code></dfn>, <dfn id=dom-area-target><code>target</code></dfn>, <dfn id=dom-area-download><code>download</code></dfn>, <dfn id=dom-area-ping><code>ping</code></dfn>, and <dfn id=dom-area-rel><code>rel</code></dfn>,
  each must <a href=#reflect id=the-area-element:reflect>reflect</a> the respective content attributes of the same name.</p>

  <p>The IDL attribute <dfn id=dom-area-shape><code>shape</code></dfn> must
  <a href=#reflect id=the-area-element:reflect-2>reflect</a> the <code id=the-area-element:attr-area-shape-4><a href=#attr-area-shape>shape</a></code> content attribute.</p>

  <p>The IDL attribute <dfn id=dom-area-rellist><code>relList</code></dfn> must
  <a href=#reflect id=the-area-element:reflect-3>reflect</a> the <code id=the-area-element:attr-hyperlink-rel-4><a href=#attr-hyperlink-rel>rel</a></code> content attribute.</p>

  <p>The IDL attribute <dfn id=dom-area-referrerpolicy><code>referrerPolicy</code></dfn> must
  <a href=#reflect id=the-area-element:reflect-4>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>

  



  <h4 id=image-maps><span class=secno>4.8.15</span> Image maps<a href=#image-maps class=self-link></a></h4>

  

  

  <h5 id=authoring><span class=secno>4.8.15.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 or an <code id=authoring:the-object-element><a href=#the-object-element>object</a></code> element
  representing an image, 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 id=attr-hyperlink-usemap><code>usemap</code></dfn> attribute on
  the <code id=authoring:the-img-element-2><a href=#the-img-element>img</a></code> or <code id=authoring:the-object-element-2><a href=#the-object-element>object</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>&quot;shapes.png&quot;</c-> <c- e>usemap</c-><c- o>=</c-><c- s>&quot;#shapes&quot;</c->
      <c- e>alt</c-><c- o>=</c-><c- s>&quot;Four shapes are available: a red hollow box, a green circle, a blue triangle, and a yellow four-pointed star.&quot;</c-><c- p>&gt;</c->
 <c- p>&lt;</c-><c- f>map</c-> <c- e>name</c-><c- o>=</c-><c- s>&quot;shapes&quot;</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>&quot;50,50,100,100&quot;</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>&quot;25,25,125,125&quot;</c-> <c- e>href</c-><c- o>=</c-><c- s>&quot;red.html&quot;</c-> <c- e>alt</c-><c- o>=</c-><c- s>&quot;Red box.&quot;</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>&quot;200,75,50&quot;</c-> <c- e>href</c-><c- o>=</c-><c- s>&quot;green.html&quot;</c-> <c- e>alt</c-><c- o>=</c-><c- s>&quot;Green circle.&quot;</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>&quot;325,25,262,125,388,125&quot;</c-> <c- e>href</c-><c- o>=</c-><c- s>&quot;blue.html&quot;</c-> <c- e>alt</c-><c- o>=</c-><c- s>&quot;Blue triangle.&quot;</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>&quot;450,25,435,60,400,75,435,90,450,125,465,90,500,75,465,60&quot;</c->
        <c- e>href</c-><c- o>=</c-><c- s>&quot;yellow.html&quot;</c-> <c- e>alt</c-><c- o>=</c-><c- s>&quot;Yellow star.&quot;</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.15.2</span> <span id=processing-model></span>Processing model<a href=#image-map-processing-model class=self-link></a></h5>

  <p>If an <code id=image-map-processing-model:the-img-element><a href=#the-img-element>img</a></code> element or an <code id=image-map-processing-model:the-object-element><a href=#the-object-element>object</a></code> element representing an image 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.<li><p>If that returned null, then return. The image is not associated with an image
   map after all.<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 those be the <var>areas</var>.</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>

  <p class=note>In user agents that do not support images, or that have images disabled,
  <code id=image-map-processing-model:the-object-element-2><a href=#the-object-element>object</a></code> elements cannot represent images, and thus this section never applies (the
  <a href=#fallback-content id=image-map-processing-model:fallback-content>fallback content</a> is shown instead). The following steps therefore only apply to
  <code id=image-map-processing-model:the-img-element-3><a href=#the-img-element>img</a></code> elements.</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.<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.<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-4><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-5><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 a user-agent-defined fashion
   intended to indicate the lack of suitable author-provided text.</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>

  <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.<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
   result be the <var>coords</var> list. If the attribute is absent, let the <var>coords</var> list
   be the empty list.<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>Minimum number of items
     <tbody><tr><td><a href=#attr-area-shape-circle id=image-map-processing-model:attr-area-shape-circle>Circle state</a>
       <td>3
      <tr><td><a href=#attr-area-shape-default id=image-map-processing-model:attr-area-shape-default>Default state</a>
       <td>0
      <tr><td><a href=#attr-area-shape-poly id=image-map-processing-model:attr-area-shape-poly>Polygon state</a>
       <td>6
      <tr><td><a href=#attr-area-shape-rect id=image-map-processing-model:attr-area-shape-rect>Rectangle state</a>
       <td>4
    </table>

   <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><dd>Drop any items in the list beyond the third.<dt><a href=#attr-area-shape-default id=image-map-processing-model:attr-area-shape-default-2>Default state</a><dd>Drop all items in the list.<dt><a href=#attr-area-shape-poly id=image-map-processing-model:attr-area-shape-poly-2>Polygon state</a><dd>Drop the last item if there's an odd number of items.<dt><a href=#attr-area-shape-rect id=image-map-processing-model:attr-area-shape-rect-2>Rectangle state</a><dd>Drop any items in the list beyond the fourth.</dl>

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

     <dt><a href=#attr-area-shape-default id=image-map-processing-model:attr-area-shape-default-3>Default state</a><dd>

      <p>The shape is a rectangle that exactly covers the entire image.</p>

     <dt><a href=#attr-area-shape-poly id=image-map-processing-model:attr-area-shape-poly-3>Polygon state</a><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>

      

     <dt><a href=#attr-area-shape-rect id=image-map-processing-model:attr-area-shape-rect-5>Rectangle state</a><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>

     </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/visudet.html#the-width-property data-x-internal="'width'">'width'</a> and
    <a id="image-map-processing-model:'height'" href=https://drafts.csswg.org/css2/visudet.html#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>

   </ol>

  <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-6><a href=#the-img-element>img</a></code> and <code id=image-map-processing-model:the-object-element-3><a href=#the-object-element>object</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.16</span> MathML<a href=#mathml class=self-link></a></h4>

  <p>The <a id=mathml:mathml-math href=https://www.w3.org/Math/draft-spec/chapter2.html#interf.toplevel 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://www.w3.org/Math/draft-spec/chapter5.html#mixing.elements.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://www.w3.org/Math/draft-spec/chapter3.html#presm.mi>mi</a></code>, <code id=mathml:mathml-mo><a data-x-internal=mathml-mo href=https://www.w3.org/Math/draft-spec/chapter3.html#presm.mo>mo</a></code>, <code id=mathml:mathml-mn><a data-x-internal=mathml-mn href=https://www.w3.org/Math/draft-spec/chapter3.html#presm.mn>mn</a></code>, <code id=mathml:mathml-ms><a data-x-internal=mathml-ms href=https://www.w3.org/Math/draft-spec/chapter3.html#presm.ms>ms</a></code>, and <code id=mathml:mathml-mtext><a data-x-internal=mathml-mtext href=https://www.w3.org/Math/draft-spec/chapter3.html#presm.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://www.w3.org/Math/draft-spec/chapter3.html#presm.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://www.w3.org/Math/draft-spec/chapter3.html#presm.merror data-x-internal=mathml-merror>MathML
  <code>merror</code></a> element containing some appropriate error message.</p>

  <p>To enable authors to use MathML tools that only accept MathML in its XML form, interactive HTML
  user agents are encouraged to provide a way to export any MathML fragment as an XML
  namespace-well-formed XML fragment.</p>

  

  <p>The semantics of MathML elements are defined by the MathML specification 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>&quot;en&quot;</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>&quot;prefix&quot;</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.17</span> SVG<a href=#svg-0 class=self-link></a></h4><div class=status><input onclick=toggleStatus(this) value=⋰ type=button><p class=support><strong>Support:</strong> svg-html5<span class="and_chr yes"><span>Chrome for Android</span> <span>67+</span></span><span class="chrome yes"><span>Chrome</span> <span>7+</span></span><span class="ios_saf yes"><span>iOS Safari</span> <span>5.0+</span></span><span class="and_uc yes"><span>UC Browser for Android</span> <span>11.8+</span></span><span class="firefox yes"><span>Firefox</span> <span>4+</span></span><span class="ie yes"><span>IE</span> <span>9+</span></span><span class="op_mini yes"><span>Opera Mini</span> <span>all+</span></span><span class="safari yes"><span>Safari</span> <span>5.1+</span></span><span class="edge yes"><span>Edge</span> <span>12+</span></span><span class="samsung yes"><span>Samsung Internet</span> <span>4+</span></span><span class="opera yes"><span>Opera</span> <span>11.6+</span></span><span class="android yes"><span>Android Browser</span> <span>3+</span></span><p class=caniuse>Source: <a href="https://caniuse.com/#feat=svg-html5">caniuse.com</a></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>To enable authors to use SVG tools that only accept SVG in its XML form, interactive HTML user
  agents are encouraged to provide a way to export any SVG fragment as an XML namespace-well-formed
  XML fragment.</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 the SVG specification.)</p>

  <p>The semantics of SVG elements are defined by the SVG specification 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><var>doc</var> = <var>iframe</var> . <code id=dom-media-getsvgdocument-dev><a href=#dom-media-getsvgdocument>getSVGDocument</a></code>()<dt><var>doc</var> = <var>embed</var> . <code id=svg-0:dom-media-getsvgdocument><a href=#dom-media-getsvgdocument>getSVGDocument</a></code>()<dt><var>doc</var> = <var>object</var> . <code id=svg-0:dom-media-getsvgdocument-2><a href=#dom-media-getsvgdocument>getSVGDocument</a></code>()<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 images.</p>

   </dl>

  

  <p>The <dfn id=dom-media-getsvgdocument><code>getSVGDocument()</code></dfn> method must run
  the following steps:</p>

  <ol><li><p>If the element's <a href=#nested-browsing-context id=svg-0:nested-browsing-context>nested browsing context</a> is null, then return null.<li><p>If the <a href=#concept-origin id=svg-0:concept-origin>origin</a> of the <a href=#active-document id=svg-0:active-document>active document</a> of the <a href=#nested-browsing-context id=svg-0:nested-browsing-context-2>nested
   browsing context</a> is not <a href=#same-origin-domain id=svg-0:same-origin-domain>same origin-domain</a> with the element's <a id=svg-0:node-document href=https://dom.spec.whatwg.org/#concept-node-document data-x-internal=node-document>node
   document</a>'s <a href=#concept-origin id=svg-0:concept-origin-2>origin</a>, then return null.<li><p>If the <a href=#nested-browsing-context id=svg-0:nested-browsing-context-3>nested browsing context</a>'s <a href=#active-document id=svg-0:active-document-2>active document</a> 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 that
   <code id=svg-0:document-2><a href=#document>Document</a></code> object.<li><p>Otherwise, return null.</ol>

  




  <h4 id=dimension-attributes><span class=secno>4.8.18</span> <dfn>Dimension attributes</dfn><a href=#dimension-attributes class=self-link></a></h4>

  <p><strong>Author requirements</strong>: The <dfn id=attr-dim-width><code>width</code></dfn> and <dfn id=attr-dim-height><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>, 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>

  <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><var>specified height</var> - 0.5 ≤
             <var>specified width</var> / <var>target ratio</var> ≤
             <var>specified height</var> + 0.5<li><var>specified height</var> = <var>specified width</var> = 0</ul>

  <p>The <var>target ratio</var> is the ratio of the <a href=#intrinsic-width id=dimension-attributes:intrinsic-width>intrinsic width</a> to the
  <a href=#intrinsic-height id=dimension-attributes:intrinsic-height>intrinsic 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>

  <p>The two attributes must be omitted if the resource in question does not have both an
  <a href=#intrinsic-width id=dimension-attributes:intrinsic-width-2>intrinsic width</a> and an <a href=#intrinsic-height id=dimension-attributes:intrinsic-height-2>intrinsic height</a>.</p>

  <p>If the two attributes are both zero, 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>The <dfn id=dom-dim-width><code>width</code></dfn> and <dfn id=dom-dim-height><code>height</code></dfn> IDL attributes on the <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>, <code id=dimension-attributes:the-object-element-2><a href=#the-object-element>object</a></code>, and <code id=dimension-attributes:the-video-element-2><a href=#the-video-element>video</a></code> elements must <a href=#reflect id=dimension-attributes:reflect>reflect</a>
  the respective content attributes of the same name.</p>

  <p class=note>For <code id=dimension-attributes:the-iframe-element-3><a href=#the-iframe-element>iframe</a></code>, <code id=dimension-attributes:the-embed-element-3><a href=#the-embed-element>embed</a></code>, and <code id=dimension-attributes:the-object-element-3><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://heycam.github.io/webidl/#idl-DOMString>DOMString</a></code>; for <code id=dimension-attributes:the-video-element-3><a href=#the-video-element>video</a></code> the IDL attributes are <code id=dimension-attributes:idl-unsigned-long><a data-x-internal=idl-unsigned-long href=https://heycam.github.io/webidl/#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><code>table</code></dfn> element<a href=#the-table-element class=self-link></a></h4>

  <dl class=element><dt><a href=#concept-element-categories id=the-table-element:concept-element-categories>Categories</a>:<dd><a href=#flow-content-2 id=the-table-element:flow-content-2>Flow content</a>.<dd><a href=#palpable-content-2 id=the-table-element:palpable-content-2>Palpable content</a>.<dt><a href=#concept-element-contexts id=the-table-element:concept-element-contexts>Contexts in which this element can be used</a>:<dd>Where <a href=#flow-content-2 id=the-table-element:flow-content-2-2>flow content</a> is expected.<dt><a href=#concept-element-content-model id=the-table-element:concept-element-content-model>Content model</a>:<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>.<dt><a href=#concept-element-tag-omission id=the-table-element:concept-element-tag-omission>Tag omission in text/html</a>:<dd>Neither tag is omissible.<dt><a href=#concept-element-attributes id=the-table-element:concept-element-attributes>Content attributes</a>:<dd><a href=#global-attributes id=the-table-element:global-attributes>Global attributes</a><dt><a href=#concept-element-dom id=the-table-element:concept-element-dom>DOM interface</a>:<dd>
    <pre><code class='idl'>[<c- g>Exposed</c->=<c- n>Window</c->,
 <a href='#htmlconstructor' id='the-table-element:htmlconstructor'><c- g>HTMLConstructor</c-></a>]
<c- b>interface</c-> <dfn id='htmltableelement'><c- g>HTMLTableElement</c-></dfn> : <a href='#htmlelement' id='the-table-element:htmlelement'><c- n>HTMLElement</c-></a> {
  [<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>void</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>void</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>void</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 href='https://dom.spec.whatwg.org/#interface-htmlcollection' data-x-internal='htmlcollection' id='the-table-element: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 href='https://dom.spec.whatwg.org/#interface-htmlcollection' data-x-internal='htmlcollection' id='the-table-element:htmlcollection-2'><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>void</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->);
};</code></pre>
   </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, primarily
  using 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>Indication
   <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/aria/aria.html#presentation>presentation</a></code>
     <td>Probably a layout table
    <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>Probably a layout table
    <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>Probably a layout table
   <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>Probably a non-layout table
    <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>Probably a non-layout table
    <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>Probably a non-layout table
    <tr><td>Explicit visible borders set using CSS
     <td>Probably a non-layout table
   <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>Not a good indicator (both layout and non-layout tables have historically been given this attribute)
  </table>

  <p class=note>It is quite possible that the above suggestions are wrong. Implementors 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><var>table</var> . <code id=dom-table-caption-dev><a href=#dom-table-caption>caption</a></code> [ = <var>value</var> ]<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>

   <dt><var>caption</var> = <var>table</var> . <code id=dom-table-createcaption-dev><a href=#dom-table-createcaption>createCaption</a></code>()<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>

   <dt><var>table</var> . <code id=dom-table-deletecaption-dev><a href=#dom-table-deletecaption>deleteCaption</a></code>()<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>

   <dt><var>table</var> . <code id=dom-table-thead-dev><a href=#dom-table-thead>tHead</a></code> [ = <var>value</var> ]<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://heycam.github.io/webidl/#hierarchyrequesterror data-x-internal=hierarchyrequesterror>"<code>HierarchyRequestError</code>"</a>
    <code id=the-table-element:domexception><a data-x-internal=domexception href=https://heycam.github.io/webidl/#dfn-DOMException>DOMException</a></code>.</p>

   <dt><var>thead</var> = <var>table</var> . <code id=dom-table-createthead-dev><a href=#dom-table-createthead>createTHead</a></code>()<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>

   <dt><var>table</var> . <code id=dom-table-deletethead-dev><a href=#dom-table-deletethead>deleteTHead</a></code>()<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>

   <dt><var>table</var> . <code id=dom-table-tfoot-dev><a href=#dom-table-tfoot>tFoot</a></code> [ = <var>value</var> ]<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://heycam.github.io/webidl/#hierarchyrequesterror data-x-internal=hierarchyrequesterror>"<code>HierarchyRequestError</code>"</a>
    <code id=the-table-element:domexception-2><a data-x-internal=domexception href=https://heycam.github.io/webidl/#dfn-DOMException>DOMException</a></code>.</p>

   <dt><var>tfoot</var> = <var>table</var> . <code id=dom-table-createtfoot-dev><a href=#dom-table-createtfoot>createTFoot</a></code>()<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>

   <dt><var>table</var> . <code id=dom-table-deletetfoot-dev><a href=#dom-table-deletetfoot>deleteTFoot</a></code>()<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>

   <dt><var>table</var> . <code id=dom-table-tbodies-dev><a href=#dom-table-tbodies>tBodies</a></code><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>

   <dt><var>tbody</var> = <var>table</var> . <code id=dom-table-createtbody-dev><a href=#dom-table-createtbody>createTBody</a></code>()<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>

   <dt><var>table</var> . <code id=dom-table-rows-dev><a href=#dom-table-rows>rows</a></code><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>

   <dt><var>tr</var> = <var>table</var> . <code id=dom-table-insertrow-dev><a href=#dom-table-insertrow>insertRow</a></code>( [ <var>index</var> ] )<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://heycam.github.io/webidl/#indexsizeerror data-x-internal=indexsizeerror>"<code>IndexSizeError</code>"</a> <code id=the-table-element:domexception-3><a data-x-internal=domexception href=https://heycam.github.io/webidl/#dfn-DOMException>DOMException</a></code>.</p>

   <dt><var>table</var> . <code id=dom-table-deleterow-dev><a href=#dom-table-deleterow>deleteRow</a></code>(<var>index</var>)<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://heycam.github.io/webidl/#indexsizeerror data-x-internal=indexsizeerror>"<code>IndexSizeError</code>"</a>
    <code id=the-table-element:domexception-4><a data-x-internal=domexception href=https://heycam.github.io/webidl/#dfn-DOMException>DOMException</a></code>.</p>

   </dl>

  

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

  <p>The <dfn id=dom-table-caption><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>

  <p>The <dfn id=dom-table-createcaption><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>

  <p>The <dfn id=dom-table-deletecaption><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>

  <p>The <dfn id=dom-table-thead><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://heycam.github.io/webidl/#hierarchyrequesterror data-x-internal=hierarchyrequesterror>"<code>HierarchyRequestError</code>"</a> <code id=the-table-element:domexception-5><a data-x-internal=domexception href=https://heycam.github.io/webidl/#dfn-DOMException>DOMException</a></code> must be thrown
  instead.</p>

  <p>The <dfn id=dom-table-createthead><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>

  <p>The <dfn id=dom-table-deletethead><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>

  <p>The <dfn id=dom-table-tfoot><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://heycam.github.io/webidl/#hierarchyrequesterror data-x-internal=hierarchyrequesterror>"<code>HierarchyRequestError</code>"</a>
  <code id=the-table-element:domexception-6><a data-x-internal=domexception href=https://heycam.github.io/webidl/#dfn-DOMException>DOMException</a></code> must be thrown instead.</p>

  <p>The <dfn id=dom-table-createtfoot><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>

  <p>The <dfn id=dom-table-deletetfoot><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>

  <p>The <dfn id=dom-table-tbodies><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>

  <p>The <dfn id=dom-table-createtbody><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>

  <p>The <dfn id=dom-table-rows><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>

  <p>The behavior of the <dfn id=dom-table-insertrow><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:<dd>The method must throw an <a id=the-table-element:indexsizeerror-3 href=https://heycam.github.io/webidl/#indexsizeerror data-x-internal=indexsizeerror>"<code>IndexSizeError</code>"</a>
   <code id=the-table-element:domexception-7><a data-x-internal=domexception href=https://heycam.github.io/webidl/#dfn-DOMException>DOMException</a></code>.<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:<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.<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:<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.<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:<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.<dt>Otherwise:<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.</dl>

  <p>When the <dfn id=dom-table-deleterow><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://heycam.github.io/webidl/#indexsizeerror data-x-internal=indexsizeerror>"<code>IndexSizeError</code>"</a> <code id=the-table-element:domexception-8><a data-x-internal=domexception href=https://heycam.github.io/webidl/#dfn-DOMException>DOMException</a></code>.<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.<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.</ol>

  

  <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&apos;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>&quot;sudoku&quot;</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> Characteristic
     <th> Positive
   <tbody><tr><td headers="n r1"> Sad
     <th id=r1> Mood
     <td> Happy
    <tr><td headers="n r2"> Failing
     <th id=r2> Grade
     <td> Passing
  </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<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>&quot;n&quot;</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>&quot;n r1&quot;</c-><c- p>&gt;</c-> Sad
   <c- p>&lt;</c-><c- f>th</c-> <c- e>id</c-><c- o>=</c-><c- s>&quot;r1&quot;</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>&quot;n r2&quot;</c-><c- p>&gt;</c-> Failing
   <c- p>&lt;</c-><c- f>th</c-> <c- e>id</c-><c- o>=</c-><c- s>&quot;r2&quot;</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>
   <dt>In the table's <code id=table-descriptions-techniques:the-caption-element><a href=#the-caption-element>caption</a></code><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>&quot;n&quot;</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>&quot;n r1&quot;</c-><c- p>&gt;</c-> Sad
   <c- p>&lt;</c-><c- f>th</c-> <c- e>id</c-><c- o>=</c-><c- s>&quot;r1&quot;</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>&quot;n r2&quot;</c-><c- p>&gt;</c-> Failing
   <c- p>&lt;</c-><c- f>th</c-> <c- e>id</c-><c- o>=</c-><c- s>&quot;r2&quot;</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>
   <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<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>&quot;n&quot;</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>&quot;n r1&quot;</c-><c- p>&gt;</c-> Sad
   <c- p>&lt;</c-><c- f>th</c-> <c- e>id</c-><c- o>=</c-><c- s>&quot;r1&quot;</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>&quot;n r2&quot;</c-><c- p>&gt;</c-> Failing
   <c- p>&lt;</c-><c- f>th</c-> <c- e>id</c-><c- o>=</c-><c- s>&quot;r2&quot;</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>
   <dt>Next to the table, in the same <code id=table-descriptions-techniques:the-figure-element><a href=#the-figure-element>figure</a></code><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>&quot;n&quot;</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>&quot;n r1&quot;</c-><c- p>&gt;</c-> Sad
    <c- p>&lt;</c-><c- f>th</c-> <c- e>id</c-><c- o>=</c-><c- s>&quot;r1&quot;</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>&quot;n r2&quot;</c-><c- p>&gt;</c-> Failing
    <c- p>&lt;</c-><c- f>th</c-> <c- e>id</c-><c- o>=</c-><c- s>&quot;r2&quot;</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>
   <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><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>&quot;n&quot;</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>&quot;n r1&quot;</c-><c- p>&gt;</c-> Sad
    <c- p>&lt;</c-><c- f>th</c-> <c- e>id</c-><c- o>=</c-><c- s>&quot;r1&quot;</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>&quot;n r2&quot;</c-><c- p>&gt;</c-> Failing
    <c- p>&lt;</c-><c- f>th</c-> <c- e>id</c-><c- o>=</c-><c- s>&quot;r2&quot;</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>
   </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><code>caption</code></dfn> element<a href=#the-caption-element class=self-link></a></h4>

  <dl class=element><dt><a href=#concept-element-categories id=the-caption-element:concept-element-categories>Categories</a>:<dd>None.<dt><a href=#concept-element-contexts id=the-caption-element:concept-element-contexts>Contexts in which this element can be used</a>:<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.<dt><a href=#concept-element-content-model id=the-caption-element:concept-element-content-model>Content model</a>:<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.<dt><a href=#concept-element-tag-omission id=the-caption-element:concept-element-tag-omission>Tag omission in text/html</a>:<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>.<dt><a href=#concept-element-attributes id=the-caption-element:concept-element-attributes>Content attributes</a>:<dd><a href=#global-attributes id=the-caption-element:global-attributes>Global attributes</a><dt><a href=#concept-element-dom id=the-caption-element:concept-element-dom>DOM interface</a>:<dd>
    <pre><code class='idl'>[<c- g>Exposed</c->=<c- n>Window</c->,
 <a href='#htmlconstructor' id='the-caption-element:htmlconstructor'><c- g>HTMLConstructor</c-></a>]
<c- b>interface</c-> <dfn id='htmltablecaptionelement'><c- g>HTMLTableCaptionElement</c-></dfn> : <a href='#htmlelement' id='the-caption-element:htmlelement'><c- n>HTMLElement</c-></a> {};</code></pre>
   </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><tr><th>   <th> 1 <th> 2 <th> 3 <th> 4 <th> 5 <th> 6
    <tr><th> 1 <td> 2 <td> 3 <td> 4 <td> 5 <td> 6 <td> 7
    <tr><th> 2 <td> 3 <td> 4 <td> 5 <td> 6 <td> 7 <td> 8
    <tr><th> 3 <td> 4 <td> 5 <td> 6 <td> 7 <td> 8 <td> 9
    <tr><th> 4 <td> 5 <td> 6 <td> 7 <td> 8 <td> 9 <td> 10
    <tr><th> 5 <td> 6 <td> 7 <td> 8 <td> 9 <td> 10 <td> 11
    <tr><th> 6 <td> 7 <td> 8 <td> 9 <td> 10 <td> 11 <td> 12
   </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>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.
    </caption><tr><th>   <th> 1 <th> 2 <th> 3 <th> 4 <th> 5 <th> 6
    <tr><th> 1 <td> 2 <td> 3 <td> 4 <td> 5 <td> 6 <td> 7
    <tr><th> 2 <td> 3 <td> 4 <td> 5 <td> 6 <td> 7 <td> 8
    <tr><th> 3 <td> 4 <td> 5 <td> 6 <td> 7 <td> 8 <td> 9
    <tr><th> 4 <td> 5 <td> 6 <td> 7 <td> 8 <td> 9 <td> 10
    <tr><th> 5 <td> 6 <td> 7 <td> 8 <td> 9 <td> 10 <td> 11
    <tr><th> 6 <td> 7 <td> 8 <td> 9 <td> 10 <td> 11 <td> 12
   </table>

  </div>




  <h4 id=the-colgroup-element><span class=secno>4.9.3</span> The <dfn><code>colgroup</code></dfn> element<a href=#the-colgroup-element class=self-link></a></h4>

  <dl class=element><dt><a href=#concept-element-categories id=the-colgroup-element:concept-element-categories>Categories</a>:<dd>None.<dt><a href=#concept-element-contexts id=the-colgroup-element:concept-element-contexts>Contexts in which this element can be used</a>:<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.<dt><a href=#concept-element-content-model id=the-colgroup-element:concept-element-content-model>Content model</a>:<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>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.<dt><a href=#concept-element-tag-omission id=the-colgroup-element:concept-element-tag-omission>Tag omission in text/html</a>:<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>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>.<dt><a href=#concept-element-attributes id=the-colgroup-element:concept-element-attributes>Content attributes</a>:<dd><a href=#global-attributes id=the-colgroup-element:global-attributes>Global attributes</a><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<dt><a href=#concept-element-dom id=the-colgroup-element:concept-element-dom>DOM interface</a>:<dd>
    <pre><code class='idl'>[<c- g>Exposed</c->=<c- n>Window</c->,
 <a href='#htmlconstructor' id='the-colgroup-element:htmlconstructor'><c- g>HTMLConstructor</c-></a>]
<c- b>interface</c-> <dfn id='htmltablecolelement'><c- g>HTMLTableColElement</c-></dfn> : <a href='#htmlelement' id='the-colgroup-element:htmlelement'><c- n>HTMLElement</c-></a> {
  [<a href='#cereactions' id='the-colgroup-element:cereactions'><c- g>CEReactions</c-></a>] <c- b>attribute</c-> <c- b>unsigned</c-> <c- b>long</c-> <a href='#dom-colgroup-span' id='the-colgroup-element:dom-colgroup-span'><c- g>span</c-></a>;
};</code></pre>
   </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 id=attr-colgroup-span><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>

  <p>The <dfn id=dom-colgroup-span><code>span</code></dfn> IDL attribute must
  <a href=#reflect id=the-colgroup-element:reflect>reflect</a> the content attribute of the same name. It is <a href=#clamped-to-the-range id=the-colgroup-element:clamped-to-the-range>clamped to the
  range</a> [1, 1000], and its default value is 1.</p>

  


  <h4 id=the-col-element><span class=secno>4.9.4</span> The <dfn><code>col</code></dfn> element<a href=#the-col-element class=self-link></a></h4>

  <dl class=element><dt><a href=#concept-element-categories id=the-col-element:concept-element-categories>Categories</a>:<dd>None.<dt><a href=#concept-element-contexts id=the-col-element:concept-element-contexts>Contexts in which this element can be used</a>:<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.<dt><a href=#concept-element-content-model id=the-col-element:concept-element-content-model>Content model</a>:<dd><a href=#concept-content-nothing id=the-col-element:concept-content-nothing>Nothing</a>.<dt><a href=#concept-element-tag-omission id=the-col-element:concept-element-tag-omission>Tag omission in text/html</a>:<dd>No <a href=#syntax-end-tag id=the-col-element:syntax-end-tag>end tag</a>.<dt><a href=#concept-element-attributes id=the-col-element:concept-element-attributes>Content attributes</a>:<dd><a href=#global-attributes id=the-col-element:global-attributes>Global attributes</a><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<dt><a href=#concept-element-dom id=the-col-element:concept-element-dom>DOM interface</a>:<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.</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 id=attr-col-span><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>

  <p>The <dfn id=dom-col-span><code>span</code></dfn> IDL attribute must <a href=#reflect id=the-col-element:reflect>reflect</a>
  the content attribute of the same name. It is <a href=#clamped-to-the-range id=the-col-element:clamped-to-the-range>clamped to the range</a> [1, 1000], and
  its default value is 1.</p>

  


  <h4 id=the-tbody-element><span class=secno>4.9.5</span> The <dfn><code>tbody</code></dfn> element<a href=#the-tbody-element class=self-link></a></h4>

  <dl class=element><dt><a href=#concept-element-categories id=the-tbody-element:concept-element-categories>Categories</a>:<dd>None.<dt><a href=#concept-element-contexts id=the-tbody-element:concept-element-contexts>Contexts in which this element can be used</a>:<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.<dt><a href=#concept-element-content-model id=the-tbody-element:concept-element-content-model>Content model</a>:<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.<dt><a href=#concept-element-tag-omission id=the-tbody-element:concept-element-tag-omission>Tag omission in text/html</a>:<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>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.<dt><a href=#concept-element-attributes id=the-tbody-element:concept-element-attributes>Content attributes</a>:<dd><a href=#global-attributes id=the-tbody-element:global-attributes>Global attributes</a><dt><a href=#concept-element-dom id=the-tbody-element:concept-element-dom>DOM interface</a>:<dd>
    <pre><code class='idl'>[<c- g>Exposed</c->=<c- n>Window</c->,
 <a href='#htmlconstructor' id='the-tbody-element:htmlconstructor'><c- g>HTMLConstructor</c-></a>]
<c- b>interface</c-> <dfn id='htmltablesectionelement'><c- g>HTMLTableSectionElement</c-></dfn> : <a href='#htmlelement' id='the-tbody-element:htmlelement'><c- n>HTMLElement</c-></a> {
  [<c- g>SameObject</c->] <c- b>readonly</c-> <c- b>attribute</c-> <a href='https://dom.spec.whatwg.org/#interface-htmlcollection' data-x-internal='htmlcollection' id='the-tbody-element: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>void</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->);
};</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>
   </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><var>tbody</var> . <code id=dom-tbody-rows-dev><a href=#dom-tbody-rows>rows</a></code><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>

   <dt><var>tr</var> = <var>tbody</var> . <code id=dom-tbody-insertrow-dev><a href=#dom-tbody-insertrow>insertRow</a></code>( [ <var>index</var> ] )<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://heycam.github.io/webidl/#indexsizeerror data-x-internal=indexsizeerror>"<code>IndexSizeError</code>"</a> <code id=the-tbody-element:domexception><a data-x-internal=domexception href=https://heycam.github.io/webidl/#dfn-DOMException>DOMException</a></code>.</p>

   <dt><var>tbody</var> . <code id=dom-tbody-deleterow-dev><a href=#dom-tbody-deleterow>deleteRow</a></code>(<var>index</var>)<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://heycam.github.io/webidl/#indexsizeerror data-x-internal=indexsizeerror>"<code>IndexSizeError</code>"</a>
    <code id=the-tbody-element:domexception-2><a data-x-internal=domexception href=https://heycam.github.io/webidl/#dfn-DOMException>DOMException</a></code>.</p>

   </dl>

  

  <p>The <dfn id=dom-tbody-rows><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>

  <p>The <dfn id=dom-tbody-insertrow><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://heycam.github.io/webidl/#indexsizeerror data-x-internal=indexsizeerror>"<code>IndexSizeError</code>"</a> <code id=the-tbody-element:domexception-3><a data-x-internal=domexception href=https://heycam.github.io/webidl/#dfn-DOMException>DOMException</a></code>.<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 id=the-tbody-element:the-tr-element-9><a href=#the-tr-element>tr</a></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>.<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.<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-10><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.<li><p>Return <var>table row</var>.</ol>

  <p>The <dfn id=dom-tbody-deleterow><code>deleteRow(<var>index</var>)</code></dfn> method
  must, when invoked, act as follows:

  <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://heycam.github.io/webidl/#indexsizeerror data-x-internal=indexsizeerror>"<code>IndexSizeError</code>"</a> <code id=the-tbody-element:domexception-4><a data-x-internal=domexception href=https://heycam.github.io/webidl/#dfn-DOMException>DOMException</a></code>.<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.<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.</ol>

  


  <h4 id=the-thead-element><span class=secno>4.9.6</span> The <dfn><code>thead</code></dfn> element<a href=#the-thead-element class=self-link></a></h4>

  <dl class=element><dt><a href=#concept-element-categories id=the-thead-element:concept-element-categories>Categories</a>:<dd>None.<dt><a href=#concept-element-contexts id=the-thead-element:concept-element-contexts>Contexts in which this element can be used</a>:<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.<dt><a href=#concept-element-content-model id=the-thead-element:concept-element-content-model>Content model</a>:<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.<dt><a href=#concept-element-tag-omission id=the-thead-element:concept-element-tag-omission>Tag omission in text/html</a>:<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.<dt><a href=#concept-element-attributes id=the-thead-element:concept-element-attributes>Content attributes</a>:<dd><a href=#global-attributes id=the-thead-element:global-attributes>Global attributes</a><dt><a href=#concept-element-dom id=the-thead-element:concept-element-dom>DOM interface</a>:<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.</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) 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>&quot;https://example.com/mydoughnuts.png&quot;</c-> <c- e>title</c-><c- o>=</c-><c- s>&quot;Doughnuts from Ms Danus&quot;</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>&quot;/auction.cgi&quot;</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>&quot;Submit&quot;</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><code>tfoot</code></dfn> element<a href=#the-tfoot-element class=self-link></a></h4>

  <dl class=element><dt><a href=#concept-element-categories id=the-tfoot-element:concept-element-categories>Categories</a>:<dd>None.<dt><a href=#concept-element-contexts id=the-tfoot-element:concept-element-contexts>Contexts in which this element can be used</a>:<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.<dt><a href=#concept-element-content-model id=the-tfoot-element:concept-element-content-model>Content model</a>:<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.<dt><a href=#concept-element-tag-omission id=the-tfoot-element:concept-element-tag-omission>Tag omission in text/html</a>:<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.<dt><a href=#concept-element-attributes id=the-tfoot-element:concept-element-attributes>Content attributes</a>:<dd><a href=#global-attributes id=the-tfoot-element:global-attributes>Global attributes</a><dt><a href=#concept-element-dom id=the-tfoot-element:concept-element-dom>DOM interface</a>:<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.</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><code>tr</code></dfn> element<a href=#the-tr-element class=self-link></a></h4>

  <dl class=element><dt><a href=#concept-element-categories id=the-tr-element:concept-element-categories>Categories</a>:<dd>None.<dt><a href=#concept-element-contexts id=the-tr-element:concept-element-contexts>Contexts in which this element can be used</a>:<dd>As a child of a <code id=the-tr-element:the-thead-element><a href=#the-thead-element>thead</a></code> element.<dd>As a child of a <code id=the-tr-element:the-tbody-element><a href=#the-tbody-element>tbody</a></code> element.<dd>As a child of a <code id=the-tr-element:the-tfoot-element><a href=#the-tfoot-element>tfoot</a></code> element.<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.<dt><a href=#concept-element-content-model id=the-tr-element:concept-element-content-model>Content model</a>:<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.<dt><a href=#concept-element-tag-omission id=the-tr-element:concept-element-tag-omission>Tag omission in text/html</a>:<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.<dt><a href=#concept-element-attributes id=the-tr-element:concept-element-attributes>Content attributes</a>:<dd><a href=#global-attributes id=the-tr-element:global-attributes>Global attributes</a><dt><a href=#concept-element-dom id=the-tr-element:concept-element-dom>DOM interface</a>:<dd>
    <pre><code class='idl'>[<c- g>Exposed</c->=<c- n>Window</c->,
 <a href='#htmlconstructor' id='the-tr-element:htmlconstructor'><c- g>HTMLConstructor</c-></a>]
<c- b>interface</c-> <dfn id='htmltablerowelement'><c- g>HTMLTableRowElement</c-></dfn> : <a href='#htmlelement' id='the-tr-element:htmlelement'><c- n>HTMLElement</c-></a> {
  <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 href='https://dom.spec.whatwg.org/#interface-htmlcollection' data-x-internal='htmlcollection' id='the-tr-element: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>void</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->);
};</code></pre>
   </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><var>tr</var> . <code id=dom-tr-rowindex-dev><a href=#dom-tr-rowindex>rowIndex</a></code><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>

   <dt><var>tr</var> . <code id=dom-tr-sectionrowindex-dev><a href=#dom-tr-sectionrowindex>sectionRowIndex</a></code><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>

   <dt><var>tr</var> . <code id=dom-tr-cells-dev><a href=#dom-tr-cells>cells</a></code><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>

   <dt><var>cell</var> = <var>tr</var> . <code id=dom-tr-insertcell-dev><a href=#dom-tr-insertcell>insertCell</a></code>( [ <var>index</var> ] )<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://heycam.github.io/webidl/#indexsizeerror data-x-internal=indexsizeerror>"<code>IndexSizeError</code>"</a> <code id=the-tr-element:domexception><a data-x-internal=domexception href=https://heycam.github.io/webidl/#dfn-DOMException>DOMException</a></code>.</p>

   <dt><var>tr</var> . <code id=dom-tr-deletecell-dev><a href=#dom-tr-deletecell>deleteCell</a></code>(<var>index</var>)<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://heycam.github.io/webidl/#indexsizeerror data-x-internal=indexsizeerror>"<code>IndexSizeError</code>"</a>
    <code id=the-tr-element:domexception-2><a data-x-internal=domexception href=https://heycam.github.io/webidl/#dfn-DOMException>DOMException</a></code>.</p>

   </dl>

  

  <p>The <dfn id=dom-tr-rowindex><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>

  <p>The <dfn id=dom-tr-sectionrowindex><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>

  <p>The <dfn id=dom-tr-cells><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>

  <p>The <dfn id=dom-tr-insertcell><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://heycam.github.io/webidl/#indexsizeerror data-x-internal=indexsizeerror>"<code>IndexSizeError</code>"</a> <code id=the-tr-element:domexception-3><a data-x-internal=domexception href=https://heycam.github.io/webidl/#dfn-DOMException>DOMException</a></code>.<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 id=the-tr-element:the-td-element-7><a href=#the-td-element>td</a></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>.<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.<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-8><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.<li><p>Return <var>table cell</var>.</ol>

  <p>The <dfn id=dom-tr-deletecell><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://heycam.github.io/webidl/#indexsizeerror data-x-internal=indexsizeerror>"<code>IndexSizeError</code>"</a> <code id=the-tr-element:domexception-4><a data-x-internal=domexception href=https://heycam.github.io/webidl/#dfn-DOMException>DOMException</a></code>.<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.<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.</ol>

  


  <h4 id=the-td-element><span class=secno>4.9.9</span> The <dfn><code>td</code></dfn> element<a href=#the-td-element class=self-link></a></h4>

  <dl class=element><dt><a href=#concept-element-categories id=the-td-element:concept-element-categories>Categories</a>:<dd><a href=#sectioning-root id=the-td-element:sectioning-root>Sectioning root</a>.<dt><a href=#concept-element-contexts id=the-td-element:concept-element-contexts>Contexts in which this element can be used</a>:<dd>As a child of a <code id=the-td-element:the-tr-element><a href=#the-tr-element>tr</a></code> element.<dt><a href=#concept-element-content-model id=the-td-element:concept-element-content-model>Content model</a>:<dd><a href=#flow-content-2 id=the-td-element:flow-content-2>Flow content</a>.<dt><a href=#concept-element-tag-omission id=the-td-element:concept-element-tag-omission>Tag omission in text/html</a>:<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.<dt><a href=#concept-element-attributes id=the-td-element:concept-element-attributes>Content attributes</a>:<dd><a href=#global-attributes id=the-td-element:global-attributes>Global attributes</a><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><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><code id=the-td-element:attr-tdth-headers><a href=#attr-tdth-headers>headers</a></code> — The header cells for this cell<dt><a href=#concept-element-dom id=the-td-element:concept-element-dom>DOM interface</a>:<dd>
    <pre><code class='idl'>[<c- g>Exposed</c->=<c- n>Window</c->,
 <a href='#htmlconstructor' id='the-td-element:htmlconstructor'><c- g>HTMLConstructor</c-></a>]
<c- b>interface</c-> <dfn id='htmltablecellelement'><c- g>HTMLTableCellElement</c-></dfn> : <a href='#htmlelement' id='the-td-element:htmlelement'><c- n>HTMLElement</c-></a> {
  [<a href='#cereactions' id='the-td-element:cereactions'><c- g>CEReactions</c-></a>] <c- b>attribute</c-> <c- b>unsigned</c-> <c- b>long</c-> <a href='#dom-tdth-colspan' id='the-td-element:dom-tdth-colspan'><c- g>colSpan</c-></a>;
  [<a href='#cereactions' id='the-td-element:cereactions-2'><c- g>CEReactions</c-></a>] <c- b>attribute</c-> <c- b>unsigned</c-> <c- b>long</c-> <a href='#dom-tdth-rowspan' id='the-td-element:dom-tdth-rowspan'><c- g>rowSpan</c-></a>;
  [<a href='#cereactions' id='the-td-element:cereactions-3'><c- g>CEReactions</c-></a>] <c- b>attribute</c-> <c- b>DOMString</c-> <a href='#dom-tdth-headers' id='the-td-element:dom-tdth-headers'><c- g>headers</c-></a>;
  <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>] <c- b>attribute</c-> <c- b>DOMString</c-> <a href='#dom-th-abbr' id='the-td-element:dom-th-abbr'><c- g>abbr</c-></a>;  // only conforming for th elements
};</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>
   </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>&quot;Name&quot;</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>&quot;Paid ($)&quot;</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>&quot;Jeff&quot;</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>&quot;14&quot;</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>&quot;Britta&quot;</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>&quot;9&quot;</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>&quot;Abed&quot;</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>&quot;25&quot;</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>&quot;Shirley&quot;</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>&quot;2&quot;</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>&quot;Annie&quot;</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>&quot;5&quot;</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>&quot;Troy&quot;</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>&quot;5&quot;</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>&quot;Pierce&quot;</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>&quot;1000&quot;</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>&quot;Total&quot;</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>&quot;1060&quot;</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><code>th</code></dfn> element<a href=#the-th-element class=self-link></a></h4>

  <dl class=element><dt><a href=#concept-element-categories id=the-th-element:concept-element-categories>Categories</a>:<dd>None.<dt><a href=#concept-element-contexts id=the-th-element:concept-element-contexts>Contexts in which this element can be used</a>:<dd>As a child of a <code id=the-th-element:the-tr-element><a href=#the-tr-element>tr</a></code> element.<dt><a href=#concept-element-content-model id=the-th-element:concept-element-content-model>Content model</a>:<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.<dt><a href=#concept-element-tag-omission id=the-th-element:concept-element-tag-omission>Tag omission in text/html</a>:<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.<dt><a href=#concept-element-attributes id=the-th-element:concept-element-attributes>Content attributes</a>:<dd><a href=#global-attributes id=the-th-element:global-attributes>Global attributes</a><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><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><code id=the-th-element:attr-tdth-headers><a href=#attr-tdth-headers>headers</a></code> — The header cells for this cell<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><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<dt><a href=#concept-element-dom id=the-th-element:concept-element-dom>DOM interface</a>:<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.</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 id=attr-th-scope><code>scope</code></dfn>
  content attribute specified. 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 five states, four of which have explicit keywords:</p>

  <dl><dt>The <dfn id=attr-th-scope-row><code>row</code></dfn> keyword, which maps to the
   <i>row</i> state<dd>The <i>row</i> state means the header cell applies to some of the subsequent cells in the
   same row(s).<dt>The <dfn id=attr-th-scope-col><code>col</code></dfn> keyword, which maps to the
   <i>column</i> state<dd>The <i>column</i> state means the header cell applies to some of the subsequent cells in the
   same column(s).<dt>The <dfn id=attr-th-scope-rowgroup><code>rowgroup</code></dfn> keyword, which maps to
   the <i>row group</i> state<dd>The <i>row group</i> state means the header cell applies to all the remaining cells in the
   row group. 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 id=the-th-element:attr-th-scope-rowgroup>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>.<dt>The <dfn id=attr-th-scope-colgroup><code>colgroup</code></dfn> keyword, which maps to
   the <i>column group</i> state<dd>The <i>column group</i> state means the header cell applies to all the remaining cells in the
   column group. A <code id=the-th-element:the-th-element-7><a href=#the-th-element>th</a></code> element's <code id=the-th-element:attr-th-scope-4><a href=#attr-th-scope>scope</a></code> attribute must
   not be in the <a href=#attr-th-scope-colgroup id=the-th-element:attr-th-scope-colgroup>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>.<dt>The <dfn id=attr-th-scope-auto>auto</dfn> state<dd>The <i>auto</i> state makes the header cell apply to a set of cells selected based on
   context.</dl>

  <p>The <code id=the-th-element:attr-th-scope-5><a href=#attr-th-scope>scope</a></code> 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 the <i>auto</i> state.</p>

  <p>The <code id=the-th-element:the-th-element-8><a href=#the-th-element>th</a></code> element may have an <dfn id=attr-th-abbr><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-9><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-6><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-7><a href=#attr-th-scope>scope</a></code> attribute's <code id=the-th-element:attr-th-scope-rowgroup-2><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- e>scope</c-><c- o>=</c-><c- s>row</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- e>scope</c-><c- o>=</c-><c- s>row</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- e>scope</c-><c- o>=</c-><c- s>row</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- e>scope</c-><c- o>=</c-><c- s>row</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> Measurement <th> Average <th> Maximum
    <tbody><tr><td> <th scope=rowgroup> Cats <td> <td>
     <tr><td> 93 <th scope=row> Legs <td> 3.5 <td> 4
     <tr><td> 10 <th scope=row> Tails <td> 1 <td> 1
    <tbody><tr><td> <th scope=rowgroup> English speakers <td> <td>
     <tr><td> 32 <th scope=row> Legs <td> 2.67 <td> 4
     <tr><td> 35 <th scope=row> Tails <td> 0.33 <td> 1
   </table>

   <p>The headers in the first row all apply directly down to the rows in their column.</p>

   <p>The headers with the explicit <code id=the-th-element:attr-th-scope-8><a href=#attr-th-scope>scope</a></code> attributes 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 id=attr-tdth-colspan><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 id=attr-tdth-rowspan><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 id=attr-tdth-headers><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> that are
  <a href=#case-sensitive id=attributes-common-to-td-and-th-elements:case-sensitive>case-sensitive</a>, 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>

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

  <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><var>cell</var> . <code id=dom-tdth-cellindex-dev><a href=#dom-tdth-cellindex>cellIndex</a></code><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>

   </dl>

  

  

  

  <p>The <dfn id=dom-tdth-colspan><code>colSpan</code></dfn> IDL attribute must
  <a href=#reflect id=attributes-common-to-td-and-th-elements:reflect>reflect</a> the <code id=attributes-common-to-td-and-th-elements:attr-tdth-colspan-2><a href=#attr-tdth-colspan>colspan</a></code> content attribute. It is
  <a href=#clamped-to-the-range id=attributes-common-to-td-and-th-elements:clamped-to-the-range>clamped to the range</a> [1, 1000], and its default value is 1.</p>

  <p>The <dfn id=dom-tdth-rowspan><code>rowSpan</code></dfn> IDL attribute must
  <a href=#reflect id=attributes-common-to-td-and-th-elements:reflect-2>reflect</a> the <code id=attributes-common-to-td-and-th-elements:attr-tdth-rowspan-2><a href=#attr-tdth-rowspan>rowspan</a></code> content attribute. It is
  <a href=#clamped-to-the-range id=attributes-common-to-td-and-th-elements:clamped-to-the-range-2>clamped to the range</a> [0, 65534], and its default value is 1.</p>

  <p>The <dfn id=dom-tdth-headers><code>headers</code></dfn> IDL attribute must
  <a href=#reflect id=attributes-common-to-td-and-th-elements:reflect-3>reflect</a> the content attribute of the same name.</p>

  <p>The <dfn id=dom-tdth-cellindex><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>

  <p>The <dfn id=dom-th-scope><code>scope</code></dfn> IDL attribute must <a href=#reflect id=attributes-common-to-td-and-th-elements:reflect-4>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>

  <p>The <dfn id=dom-th-abbr><code>abbr</code></dfn> IDL attribute must <a href=#reflect id=attributes-common-to-td-and-th-elements:reflect-5>reflect</a>
  the content attribute of the same name.</p>

  


  

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

  <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 ≤ <var>x</var> &lt; <var>x<sub>width</sub></var></span>, and the <var>y</var> coordinates are always in the
  range <span>0 ≤ <var>y</var> &lt; <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> ≤ <var>x</var> &lt; <var>cell<sub>x</sub></var>+<var>width</var></span> and <var>cell<sub>y</sub></var> ≤ <var>y</var> &lt; <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 ≤ <var>x</var> &lt; <var>x<sub>width</sub></var></span> and <var>group<sub>y</sub></var> ≤ <var>y</var> &lt; <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> ≤ <var>x</var> &lt; <var>group<sub>x</sub></var>+<var>width</var></span> and <span>0 ≤ <var>y</var> &lt; <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>

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

  <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 zero.</p>
   <li>
    <p>Let <var>y<sub>height</sub></var> be zero.</p>
   <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>

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

    

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

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

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

    <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><code id=forming-a-table:the-thead-element><a href=#the-thead-element>thead</a></code><li><code id=forming-a-table:the-tbody-element><a href=#the-tbody-element>tbody</a></code><li><code id=forming-a-table:the-tfoot-element-3><a href=#the-tfoot-element>tfoot</a></code><li><code id=forming-a-table:the-tr-element><a href=#the-tr-element>tr</a></code></ul>

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

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

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

          <p>Increase <var>x<sub>width</sub></var> by <var>span</var>.</p>

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

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

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

         </ol>

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

          <p>Increase <var>x<sub>width</sub></var> by <var>span</var>.</p>

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

         </ol>

       </dl>

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

      <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><code id=forming-a-table:the-thead-element-2><a href=#the-thead-element>thead</a></code><li><code id=forming-a-table:the-tbody-element-2><a href=#the-tbody-element>tbody</a></code><li><code id=forming-a-table:the-tfoot-element-4><a href=#the-tfoot-element>tfoot</a></code><li><code id=forming-a-table:the-tr-element-2><a href=#the-tr-element>tr</a></code></ul>

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

     </ol>

   <li>

    <p>Let <var>y<sub>current</sub></var> be zero.</p>

   <li>

    <p>Let the <var>list of downward-growing cells</var> be an empty list.</p>

   <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><code id=forming-a-table:the-tbody-element-3><a href=#the-tbody-element>tbody</a></code><li><code id=forming-a-table:the-tfoot-element-5><a href=#the-tfoot-element>tfoot</a></code><li><code id=forming-a-table:the-tr-element-3><a href=#the-tr-element>tr</a></code></ul>

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

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

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

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

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

    <p>Return to the step labeled <i>rows</i>.</p>

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

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

    <p>Return <var>the table</var>.</p>

   </ol>

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

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

    
    <p>If <var>y<sub>height</sub></var> > <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>

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

   </ol>

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

      <p>Increase <var>y<sub>current</sub></var> by 1.</p>

     </ol>

   <li>

    <p>Empty the <var>list of downward-growing cells</var>.</p>

   </ol>


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

    <p>Let <var>x<sub>current</sub></var> be 0.</p>

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

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

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

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

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

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

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

    <p>If <var>rowspan</var> is zero and the <code id=forming-a-table:the-table-element-13><a href=#the-table-element>table</a></code> element's
    <a id=forming-a-table:node-document href=https://dom.spec.whatwg.org/#concept-node-document data-x-internal=node-document>node document</a> is not set to <a id=forming-a-table:quirks-mode href=https://dom.spec.whatwg.org/#concept-document-quirks data-x-internal=quirks-mode>quirks mode</a>, then let <var>cell grows
    downward</var> be true, and set <var>rowspan</var> to 1. Otherwise, let <var>cell grows downward</var> be false.</p>

   <li>

    <p>If <var>x<sub>width</sub></var> &lt; <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>

    <p>If <var>y<sub>height</sub></var> &lt; <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>

    <p>Let the slots with coordinates (<var>x</var>, <var>y</var>) such that <span><var>x<sub>current</sub></var> ≤ <var>x</var> &lt; <var>x<sub>current</sub></var>+<var>colspan</var></span> and <var>y<sub>current</sub></var> ≤ <var>y</var> &lt; <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>

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

    <p>Increase <var>x<sub>current</sub></var> by <var>colspan</var>.</p>

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

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

    <p>Return to the step labeled <i>cells</i>.</p>

   </ol>


  <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> ≤ <var>x</var> &lt; <var>cell<sub>x</sub></var>+<var>width</var></span>.</p>




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

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

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

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

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

       </ol>

     <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<dd>

      <ol><li>

        <p>Let <var>principal<sub>width</sub></var> be the width of the <var>principal cell</var>.</p>

       <li>

        <p>Let <var>principal<sub>height</sub></var> be the height of the <var>principal cell</var>.</p>

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

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

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

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

        

       </ol>

     </dl>

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

    <p>Remove any duplicates from the <var>header list</var>.</p>

   <li>

    <p>Remove <var>principal cell</var> from the <var>header list</var> if it is
    there.</p> 

   <li>

    <p>Assign the headers in the <var>header list</var> to the <var>principal
    cell</var>.</p>

   </ol>

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

    <p>Let <var>y</var> equal <var>initial<sub>y</sub></var>.</p>

   <li>

    <p>Let <var>opaque headers</var> be an empty list of cells.</p>

   <li>

    <dl class=switch><dt>If <var>principal cell</var> is a header cell<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>.<dt>Otherwise<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>

    </dl>

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

    <p>If either <var>x</var> or <var>y</var> are less than 0, then abort this
    internal algorithm.</p>

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

    <p>Let <var>current cell</var> be the cell covering slot (<var>x</var>, <var>y</var>).</p>

   <li>

    <dl class=switch><dt>If <var>current cell</var> is a header cell<dd>

      <ol><li><p>Set <var>in header block</var> to true.<li><p>Add <var>current cell</var> to <var>headers from current header
       block</var>.<li><p>Let <var>blocked</var> be false.<li>

        <dl class=switch><dt>If Δ<var>x</var> is 0<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>

         <dt>If Δ<var>y</var> is 0<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>

         </dl>

       <li><p>If <var>blocked</var> is false, then add the <var>current cell</var>
       to the <var>headers list</var>.</ol>

     <dt>If <var>current cell</var> is a data cell and <var>in header block</var> is true<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>

    </dl>

   <li>

    <p>Return to the step labeled <i>loop</i>.</p>

   </ol>

  <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 conditions are true:</p>

  <ul><li>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-col id=header-and-data-cell-semantics:attr-th-scope-col>column</a> state, or<li>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 id=header-and-data-cell-semantics:attr-th-scope-auto>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>.</ul>

  <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 conditions are true:</p>

  <ul><li>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 id=header-and-data-cell-semantics:attr-th-scope-row>row</a> state, or<li>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 id=header-and-data-cell-semantics:attr-th-scope-auto-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.</ul>

  <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 id=header-and-data-cell-semantics:attr-th-scope-colgroup>column
  group</a> state.</p>

  <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 id=header-and-data-cell-semantics:attr-th-scope-rowgroup>row
  group</a> state.</p>

  <p>A cell is said to be an <dfn id=empty-cell>empty cell</dfn> if it contains no elements and its text content,
  if any, consists only of <a href=#white_space id=header-and-data-cell-semantics:white_space>White_Space</a> characters.</p>

  

  <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 might one 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.8mm or 2 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 rowspan=2>Yield Point.<th colspan=2>Ultimate tensile strength<th rowspan=2>Per cent elong. 50.8 mm or 2 in.<th rowspan=2>Per cent reduct. area.<tr><th>kg/mm<sup>2</sup><th>lb/in<sup>2</sup><tbody><tr><td>Hard<td>0.45 ultimate<td>56.2<td>80,000<td>15<td>20<tr><td>Medium<td>0.45 ultimate<td>49.2<td>70,000<td>18<td>25<tr><td>Soft<td>0.45 ultimate<td>42.2<td>60,000<td>22<td>30</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>2008
     <th>2007
     <th>2006
   <tbody><tr><th>Net sales
     <td>$ 32,479
     <td>$ 24,006
     <td>$ 19,315
    <tr><th>Cost of sales
     <td>  21,334
     <td>  15,852
     <td>  13,717
   <tbody><tr><th>Gross margin
     <td>$ 11,145
     <td>$  8,154
     <td>$  5,598
   <tfoot><tr><th>Gross margin percentage
     <td>34.3%
     <td>34.0%
     <td>29.0%
  </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>2008 <th>2007 <th>2006
   <tbody><tr><th scope=rowgroup> Research and development
         <td> $ 1,109 <td> $ 782 <td> $ 712
    <tr><th scope=row> Percentage of net sales
         <td> 3.4% <td> 3.3% <td> 3.7%
   <tbody><tr><th scope=rowgroup> Selling, general, and administrative
         <td> $ 3,761 <td> $ 2,963 <td> $ 2,433
    <tr><th scope=row> Percentage of net sales
         <td> 11.6% <td> 12.3% <td> 12.6%
  </table>



  <h3 id=forms><span class=secno>4.10</span> Forms<a href=#forms class=self-link></a></h3><div class=status><input onclick=toggleStatus(this) value=⋰ type=button><p class=support><strong>Support:</strong> forms<span class="and_chr yes"><span>Chrome for Android</span> <span>67+</span></span><span class="chrome yes"><span>Chrome</span> <span>61+</span></span><span class="ios_saf partial"><span>iOS Safari (limited)</span> <span>4.0+</span></span><span class="and_uc yes"><span>UC Browser for Android</span> <span>11.8+</span></span><span class="firefox partial"><span>Firefox (limited)</span> <span>4+</span></span><span class="ie partial"><span>IE (limited)</span> <span>10+</span></span><span class="op_mini no"><span>Opera Mini</span> <span>None</span></span><span class="safari partial"><span>Safari (limited)</span> <span>4+</span></span><span class="edge yes"><span>Edge</span> <span>16+</span></span><span class="samsung partial"><span>Samsung Internet (limited)</span> <span>4+</span></span><span class="opera yes"><span>Opera</span> <span>52+</span></span><span class="android yes"><span>Android Browser</span> <span>67+</span></span><p class=caniuse>Source: <a href="https://caniuse.com/#feat=forms">caniuse.com</a></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 e-mail 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:e-mail-state-(type=email)"><a href="#e-mail-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->E-mail 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->E-mail 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>&quot;11:00&quot;</c-> <c- e>max</c-><c- o>=</c-><c- s>&quot;21:00&quot;</c-> <c- e>step</c-><c- o>=</c-><c- s>&quot;900&quot;</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->E-mail 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>&quot;11:00&quot;</c-> <c- e>max</c-><c- o>=</c-><c- s>&quot;21:00&quot;</c-> <c- e>step</c-><c- o>=</c-><c- s>&quot;900&quot;</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->E-mail 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>&quot;11:00&quot;</c-> <c- e>max</c-><c- o>=</c-><c- s>&quot;21:00&quot;</c-> <c- e>step</c-><c- o>=</c-><c- s>&quot;900&quot;</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><dd>Customer's name<dt><code>custtel</code><dd>Customer's telephone number<dt><code>custemail</code><dd>Customer's e-mail address<dt><code>size</code><dd>The pizza size, either <code>small</code>, <code>medium</code>, or <code>large</code><dt><code>topping</code><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><dt><code>delivery</code><dd>The requested delivery time<dt><code>comments</code><dd>The delivery instructions</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>&quot;post&quot;</c->
      <c- e>enctype</c-><c- o>=</c-><c- s>&quot;application/x-www-form-urlencoded&quot;</c->
      <c- e>action</c-><c- o>=</c-><c- s>&quot;https://pizza.example.com/order.cgi&quot;</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>&quot;custname&quot;</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>&quot;custtel&quot;</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->E-mail 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>&quot;custemail&quot;</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>&quot;small&quot;</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>&quot;medium&quot;</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>&quot;large&quot;</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>&quot;topping&quot;</c-> <c- e>value</c-><c- o>=</c-><c- s>&quot;bacon&quot;</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>&quot;topping&quot;</c-> <c- e>value</c-><c- o>=</c-><c- s>&quot;cheese&quot;</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>&quot;topping&quot;</c-> <c- e>value</c-><c- o>=</c-><c- s>&quot;onion&quot;</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>&quot;topping&quot;</c-> <c- e>value</c-><c- o>=</c-><c- s>&quot;mushroom&quot;</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>&quot;11:00&quot;</c-> <c- e>max</c-><c- o>=</c-><c- s>&quot;21:00&quot;</c-> <c- e>step</c-><c- o>=</c-><c- s>&quot;900&quot;</c-><strong> <c- e>name</c-><c- o>=</c-><c- s>&quot;delivery&quot;</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>&quot;comments&quot;</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 e-mail 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=status><input onclick=toggleStatus(this) value=⋰ type=button><p class=support><strong>Support:</strong> form-validation<span class="and_chr yes"><span>Chrome for Android</span> <span>67+</span></span><span class="chrome yes"><span>Chrome</span> <span>10+</span></span><span class="ios_saf yes"><span>iOS Safari</span> <span>10.3+</span></span><span class="and_uc yes"><span>UC Browser for Android</span> <span>11.8+</span></span><span class="firefox yes"><span>Firefox</span> <span>4+</span></span><span class="ie yes"><span>IE</span> <span>10+</span></span><span class="op_mini partial"><span>Opera Mini (limited)</span> <span>all+</span></span><span class="safari yes"><span>Safari</span> <span>10.1+</span></span><span class="edge yes"><span>Edge</span> <span>12+</span></span><span class="samsung yes"><span>Samsung Internet</span> <span>4+</span></span><span class="opera yes"><span>Opera</span> <span>10.0+</span></span><span class="android yes"><span>Android Browser</span> <span>4.4.3+</span></span><p class=caniuse>Source: <a href="https://caniuse.com/#feat=form-validation">caniuse.com</a></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>&quot;post&quot;</c->
      <c- e>enctype</c-><c- o>=</c-><c- s>&quot;application/x-www-form-urlencoded&quot;</c->
      <c- e>action</c-><c- o>=</c-><c- s>&quot;https://pizza.example.com/order.cgi&quot;</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>&quot;custname&quot;</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>&quot;custtel&quot;</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->E-mail 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>&quot;custemail&quot;</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>&quot;small&quot;</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>&quot;medium&quot;</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>&quot;large&quot;</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>&quot;topping&quot;</c-> <c- e>value</c-><c- o>=</c-><c- s>&quot;bacon&quot;</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>&quot;topping&quot;</c-> <c- e>value</c-><c- o>=</c-><c- s>&quot;cheese&quot;</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>&quot;topping&quot;</c-> <c- e>value</c-><c- o>=</c-><c- s>&quot;onion&quot;</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>&quot;topping&quot;</c-> <c- e>value</c-><c- o>=</c-><c- s>&quot;mushroom&quot;</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>&quot;11:00&quot;</c-> <c- e>max</c-><c- o>=</c-><c- s>&quot;21:00&quot;</c-> <c- e>step</c-><c- o>=</c-><c- s>&quot;900&quot;</c-> <c- e>name</c-><c- o>=</c-><c- s>&quot;delivery&quot;</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>&quot;comments&quot;</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>&quot;post&quot;</c->
      <c- e>enctype</c-><c- o>=</c-><c- s>&quot;application/x-www-form-urlencoded&quot;</c->
      <c- e>action</c-><c- o>=</c-><c- s>&quot;https://pizza.example.com/order.cgi&quot;</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>&quot;custname&quot;</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>&quot;custtel&quot;</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->E-mail 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>&quot;custemail&quot;</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>&quot;small&quot;</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>&quot;medium&quot;</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>&quot;large&quot;</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>&quot;topping&quot;</c-> <c- e>value</c-><c- o>=</c-><c- s>&quot;bacon&quot;</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>&quot;topping&quot;</c-> <c- e>value</c-><c- o>=</c-><c- s>&quot;cheese&quot;</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>&quot;topping&quot;</c-> <c- e>value</c-><c- o>=</c-><c- s>&quot;onion&quot;</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>&quot;topping&quot;</c-> <c- e>value</c-><c- o>=</c-><c- s>&quot;mushroom&quot;</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>&quot;11:00&quot;</c-> <c- e>max</c-><c- o>=</c-><c- s>&quot;21:00&quot;</c-> <c- e>step</c-><c- o>=</c-><c- s>&quot;900&quot;</c-> <c- e>name</c-><c- o>=</c-><c- s>&quot;delivery&quot;</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>&quot;comments&quot;</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, and then at the <code id=client-side-form-validation:the-form-element><a href=#the-form-element>form</a></code> element itself. 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>&quot;post&quot;</c->
      <c- e>enctype</c-><c- o>=</c-><c- s>&quot;application/x-www-form-urlencoded&quot;</c->
      <c- e>action</c-><c- o>=</c-><c- s>&quot;https://pizza.example.com/order.cgi&quot;</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>&quot;custname&quot;</c-> <c- e>required</c-> <strong><c- e>autocomplete</c-><c- o>=</c-><c- s>&quot;shipping name&quot;</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>&quot;custtel&quot;</c-> <strong><c- e>autocomplete</c-><c- o>=</c-><c- s>&quot;shipping tel&quot;</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->E-mail 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>&quot;custemail&quot;</c-> <strong><c- e>autocomplete</c-><c- o>=</c-><c- s>&quot;shipping email&quot;</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>&quot;small&quot;</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>&quot;medium&quot;</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>&quot;large&quot;</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>&quot;topping&quot;</c-> <c- e>value</c-><c- o>=</c-><c- s>&quot;bacon&quot;</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>&quot;topping&quot;</c-> <c- e>value</c-><c- o>=</c-><c- s>&quot;cheese&quot;</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>&quot;topping&quot;</c-> <c- e>value</c-><c- o>=</c-><c- s>&quot;onion&quot;</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>&quot;topping&quot;</c-> <c- e>value</c-><c- o>=</c-><c- s>&quot;mushroom&quot;</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>&quot;11:00&quot;</c-> <c- e>max</c-><c- o>=</c-><c- s>&quot;21:00&quot;</c-> <c- e>step</c-><c- o>=</c-><c- s>&quot;900&quot;</c-> <c- e>name</c-><c- o>=</c-><c- s>&quot;delivery&quot;</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>&quot;comments&quot;</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>&quot;post&quot;</c->
      <c- e>enctype</c-><c- o>=</c-><c- s>&quot;application/x-www-form-urlencoded&quot;</c->
      <c- e>action</c-><c- o>=</c-><c- s>&quot;https://pizza.example.com/order.cgi&quot;</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>&quot;custname&quot;</c-> <c- e>required</c-> <c- e>autocomplete</c-><c- o>=</c-><c- s>&quot;shipping name&quot;</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>&quot;custtel&quot;</c-> <c- e>autocomplete</c-><c- o>=</c-><c- s>&quot;shipping tel&quot;</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>&quot;custbuzz&quot;</c-> <strong><c- e>inputmode</c-><c- o>=</c-><c- s>&quot;number&quot;</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->E-mail 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>&quot;custemail&quot;</c-> <c- e>autocomplete</c-><c- o>=</c-><c- s>&quot;shipping email&quot;</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>&quot;small&quot;</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>&quot;medium&quot;</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>&quot;large&quot;</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>&quot;topping&quot;</c-> <c- e>value</c-><c- o>=</c-><c- s>&quot;bacon&quot;</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>&quot;topping&quot;</c-> <c- e>value</c-><c- o>=</c-><c- s>&quot;cheese&quot;</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>&quot;topping&quot;</c-> <c- e>value</c-><c- o>=</c-><c- s>&quot;onion&quot;</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>&quot;topping&quot;</c-> <c- e>value</c-><c- o>=</c-><c- s>&quot;mushroom&quot;</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>&quot;11:00&quot;</c-> <c- e>max</c-><c- o>=</c-><c- s>&quot;21:00&quot;</c-> <c- e>step</c-><c- o>=</c-><c- s>&quot;900&quot;</c-> <c- e>name</c-><c- o>=</c-><c- s>&quot;delivery&quot;</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>&quot;comments&quot;</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></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>&quot;billing tel&quot;</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&apos;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>&quot;shipping tel&quot;</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 &quot;+1 555 123 4567&quot;.</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>&quot;billing tel-national&quot;</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&apos;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>&quot;shipping tel-national&quot;</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 &quot;(01632) 960 123&quot;.</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></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></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></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></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>.

  <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>&quot;j&quot;</c-> <c- e>type</c-><c- o>=</c-><c- s>&quot;text&quot;</c-> <c- e>autocomplete</c-><c- o>=</c-><c- s>&quot;section-jp name&quot;</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>&quot;e&quot;</c-> <c- e>type</c-><c- o>=</c-><c- s>&quot;text&quot;</c-> <c- e>autocomplete</c-><c- o>=</c-><c- s>&quot;section-en name&quot;</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></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></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>&quot;cc&quot;</c-> <c- e>type</c-><c- o>=</c-><c- s>&quot;text&quot;</c-> <c- e>inputmode</c-><c- o>=</c-><c- s>&quot;numeric&quot;</c-> <c- e>pattern</c-><c- o>=</c-><c- s>&quot;[0-9]{8,19}&quot;</c-> <c- e>autocomplete</c-><c- o>=</c-><c- s>&quot;cc-number&quot;</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". Users are not expected to ever see
  this format.</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>.

  
  <ul class="brief category-list"><li><code id=categories:the-button-element><a href=#the-button-element>button</a></code><li><code id=categories:the-fieldset-element><a href=#the-fieldset-element>fieldset</a></code><li><code id=categories:the-input-element><a href=#the-input-element>input</a></code><li><code id=categories:the-object-element><a href=#the-object-element>object</a></code><li><code id=categories:the-output-element><a href=#the-output-element>output</a></code><li><code id=categories:the-select-element><a href=#the-select-element>select</a></code><li><code id=categories:the-textarea-element><a href=#the-textarea-element>textarea</a></code><li><code id=categories:the-img-element><a href=#the-img-element>img</a></code></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><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><code id=categories:the-fieldset-element-2><a href=#the-fieldset-element>fieldset</a></code><li><code id=categories:the-input-element-2><a href=#the-input-element>input</a></code><li><code id=categories:the-object-element-2><a href=#the-object-element>object</a></code><li><code id=categories:the-output-element-2><a href=#the-output-element>output</a></code><li><code id=categories:the-select-element-2><a href=#the-select-element>select</a></code><li><code id=categories:the-textarea-element-2><a href=#the-textarea-element>textarea</a></code></ul>

   <dt><dfn id=category-submit>Submittable elements</dfn><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><code id=categories:the-input-element-3><a href=#the-input-element>input</a></code><li><code id=categories:the-object-element-3><a href=#the-object-element>object</a></code><li><code id=categories:the-select-element-3><a href=#the-select-element>select</a></code><li><code id=categories:the-textarea-element-3><a href=#the-textarea-element>textarea</a></code></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>submit
    buttons</dfn>.</p>

   <dt><dfn id=category-reset>Resettable elements</dfn><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><code id=categories:the-output-element-3><a href=#the-output-element>output</a></code><li><code id=categories:the-select-element-4><a href=#the-select-element>select</a></code><li><code id=categories:the-textarea-element-4><a href=#the-textarea-element>textarea</a></code></ul>

   <dt><dfn id=category-autocapitalize>Autocapitalize-inheriting elements</dfn><dd>

    <p>Denotes elements that inherit the <code id=categories:attr-autocapitalize><a href=#attr-autocapitalize>autocapitalize</a></code>
    attribute 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><code id=categories:the-fieldset-element-3><a href=#the-fieldset-element>fieldset</a></code><li><code id=categories:the-input-element-5><a href=#the-input-element>input</a></code><li><code id=categories:the-output-element-4><a href=#the-output-element>output</a></code><li><code id=categories:the-select-element-5><a href=#the-select-element>select</a></code><li><code id=categories:the-textarea-element-5><a href=#the-textarea-element>textarea</a></code></ul>

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

  
  <ul class="brief category-list"><li><code id=categories:the-button-element-5><a href=#the-button-element>button</a></code><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><code id=categories:the-meter-element><a href=#the-meter-element>meter</a></code><li><code id=categories:the-output-element-5><a href=#the-output-element>output</a></code><li><code id=categories:the-progress-element><a href=#the-progress-element>progress</a></code><li><code id=categories:the-select-element-6><a href=#the-select-element>select</a></code><li><code id=categories:the-textarea-element-6><a href=#the-textarea-element>textarea</a></code></ul>


  <h4 id=the-form-element data-dfn-type=element data-lt=form><span class=secno>4.10.3</span> The <dfn><code>form</code></dfn> element<a href=#the-form-element class=self-link></a></h4>

  <dl class=element><dt><a href=#concept-element-categories id=the-form-element:concept-element-categories>Categories</a>:<dd><a href=#flow-content-2 id=the-form-element:flow-content-2>Flow content</a>.<dd><a href=#palpable-content-2 id=the-form-element:palpable-content-2>Palpable content</a>.<dt><a href=#concept-element-contexts id=the-form-element:concept-element-contexts>Contexts in which this element can be used</a>:<dd>Where <a href=#flow-content-2 id=the-form-element:flow-content-2-2>flow content</a> is expected.<dt><a href=#concept-element-content-model id=the-form-element:concept-element-content-model>Content model</a>:<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.<dt><a href=#concept-element-tag-omission id=the-form-element:concept-element-tag-omission>Tag omission in text/html</a>:<dd>Neither tag is omissible.<dt><a href=#concept-element-attributes id=the-form-element:concept-element-attributes>Content attributes</a>:<dd><a href=#global-attributes id=the-form-element:global-attributes>Global attributes</a><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><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><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><code id=the-form-element:attr-fs-enctype><a href=#attr-fs-enctype>enctype</a></code> — Entry list encoding type to use for <a href=#form-submission-2 id=the-form-element:form-submission-2-3>form submission</a><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><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><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><code id=the-form-element:attr-fs-target><a href=#attr-fs-target>target</a></code> — <a href=#browsing-context id=the-form-element:browsing-context>Browsing context</a> for <a href=#form-submission-2 id=the-form-element:form-submission-2-6>form submission</a><dt><a href=#concept-element-dom id=the-form-element:concept-element-dom>DOM interface</a>:<dd>
    <pre><code class='idl'>[<c- g>Exposed</c->=<c- n>Window</c->,
 <c- g>OverrideBuiltins</c->,
 <c- g>LegacyUnenumerableNamedProperties</c->,
 <a href='#htmlconstructor' id='the-form-element:htmlconstructor'><c- g>HTMLConstructor</c-></a>]
<c- b>interface</c-> <dfn id='htmlformelement'><c- g>HTMLFormElement</c-></dfn> : <a href='#htmlelement' id='the-form-element:htmlelement'><c- n>HTMLElement</c-></a> {
  [<a href='#cereactions' id='the-form-element:cereactions'><c- g>CEReactions</c-></a>] <c- b>attribute</c-> <c- b>DOMString</c-> <a href='#dom-form-acceptcharset' id='the-form-element:dom-form-acceptcharset'><c- g>acceptCharset</c-></a>;
  [<a href='#cereactions' id='the-form-element:cereactions-2'><c- g>CEReactions</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>] <c- b>attribute</c-> <c- b>DOMString</c-> <a href='#dom-form-name' id='the-form-element:dom-form-name'><c- g>name</c-></a>;
  [<a href='#cereactions' id='the-form-element:cereactions-8'><c- g>CEReactions</c-></a>] <c- b>attribute</c-> <c- b>boolean</c-> <a href='#dom-fs-novalidate' id='the-form-element:dom-fs-novalidate'><c- g>noValidate</c-></a>;
  [<a href='#cereactions' id='the-form-element:cereactions-9'><c- g>CEReactions</c-></a>] <c- b>attribute</c-> <c- b>DOMString</c-> <a href='#dom-fs-target' id='the-form-element:dom-fs-target'><c- g>target</c-></a>;

  [<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 href='https://dom.spec.whatwg.org/#interface-element' data-x-internal='element' id='the-form-element: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 href='https://dom.spec.whatwg.org/#interface-element' data-x-internal='element' id='the-form-element:element-2'><c- n>Element</c-></a>) (<c- b>DOMString</c-> <c- g>name</c->);

  <c- b>void</c-> <a href='#dom-form-submit' id='the-form-element:dom-form-submit'><c- g>submit</c-></a>();
  [<a href='#cereactions' id='the-form-element:cereactions-10'><c- g>CEReactions</c-></a>] <c- b>void</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>
   </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 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 id=attr-form-accept-charset><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 href=#ordered-set-of-unique-space-separated-tokens id=the-form-element:ordered-set-of-unique-space-separated-tokens>ordered set of unique space-separated tokens</a> that are <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>, and each token must be an <a id=the-form-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
  one of the <a href=https://encoding.spec.whatwg.org/#label id=the-form-element:encoding-label data-x-internal=encoding-label>labels</a> of an <a href=#ascii-compatible-encoding id=the-form-element:ascii-compatible-encoding>ASCII-compatible
  encoding</a>. <a href=#refsENCODING>[ENCODING]</a></p>

  <p>The <dfn id=attr-form-name><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 id=attr-form-autocomplete><code>autocomplete</code></dfn> attribute is an
  <a href=#enumerated-attribute id=the-form-element:enumerated-attribute>enumerated attribute</a>. The attribute has two states. The <dfn id=attr-form-autocomplete-on><code>on</code></dfn> keyword maps to the <dfn id=attr-form-autocomplete-on-state>on</dfn> state, and the <dfn id=attr-form-autocomplete-off><code>off</code></dfn> keyword maps to the <dfn id=attr-form-autocomplete-off-state>off</dfn> state. The attribute may also be omitted. The
  <i id=the-form-element:missing-value-default><a href=#missing-value-default>missing value default</a></i> and the <i id=the-form-element:invalid-value-default><a href=#invalid-value-default>invalid value default</a></i> are the <a href=#attr-form-autocomplete-on-state id=the-form-element:attr-form-autocomplete-on-state>on</a> state. The <a href=#attr-form-autocomplete-off-state id=the-form-element:attr-form-autocomplete-off-state>off</a> state indicates that by default, form
  controls in the form 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-off><a href=#attr-fe-autocomplete-off>off</a></code>"; the <a href=#attr-form-autocomplete-on-state id=the-form-element:attr-form-autocomplete-on-state-2>on</a> state indicates that by default, form controls
  in the form 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-on><a href=#attr-fe-autocomplete-on>on</a></code>".</p>

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

  <dl class=domintro><dt><var>form</var> . <code id=dom-form-elements-dev><a href=#dom-form-elements>elements</a></code><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>

   <dt><var>form</var> . <code id=dom-form-length-dev><a href=#dom-form-length>length</a></code><dd>

    <p>Returns the number of form controls in the form (excluding image buttons for historical
    reasons).</p>

   <dt><var>form</var>[<var>index</var>]<dd>

    <p>Returns the <var>index</var>th element in the form (excluding image buttons for
    historical reasons).</p>

   <dt><var>form</var>[<var>name</var>]<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>

   <dt><var>form</var> . <code id=dom-form-submit-dev><a href=#dom-form-submit>submit</a></code>()<dd>

    <p>Submits the form.</p>

   <dt><var>form</var> . <code id=dom-form-reset-dev><a href=#dom-form-reset>reset</a></code>()<dd>

    <p>Resets the form.</p>

   <dt><var>form</var> . <code id=dom-form-checkvalidity-dev><a href=#dom-form-checkvalidity>checkValidity</a></code>()<dd>

    <p>Returns true if the form's controls are all valid; otherwise, returns false.</p>

   <dt><var>form</var> . <code id=dom-form-reportvalidity-dev><a href=#dom-form-reportvalidity>reportValidity</a></code>()<dd>

    <p>Returns true if the form's controls are all valid; otherwise, returns false and informs the user.</p>

   </dl>

  

  <p>The <dfn id=dom-form-autocomplete><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>

  <p>The <dfn id=dom-form-name><code>name</code></dfn> IDL attribute must <a href=#reflect id=the-form-element:reflect-2>reflect</a>
  the content attribute of the same name.</p>

  <p>The <dfn id=dom-form-acceptcharset><code>acceptCharset</code></dfn> IDL attribute must
  <a href=#reflect id=the-form-element:reflect-3>reflect</a> the <code id=the-form-element:attr-form-accept-charset-2><a href=#attr-form-accept-charset>accept-charset</a></code> content
  attribute.</p>

  <hr>

  <p>The <dfn id=dom-form-elements><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-5><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-6><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>

  <p>The <dfn id=dom-form-length><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>

  <p>The <a id=the-form-element:supported-property-indices href=https://heycam.github.io/webidl/#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>

  <p id=dom-form-item>To <a id=the-form-element:determine-the-value-of-an-indexed-property href=https://heycam.github.io/webidl/#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-7><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>

  <hr>

  

  <p>Each <code id=the-form-element:the-form-element-8><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>

  <p>The <a id=the-form-element:supported-property-names href=https://heycam.github.io/webidl/#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.<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-9><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.<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.</ol>

   <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-10><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.<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.</ol>

   <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><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.<li><p>Remove any entries in <var>sourced names</var> that have the empty string as
   their name.<li><p>Remove any entries in <var>sourced names</var> that have the same name as an
   earlier entry in the map.<li><p>Return the list of names from <var>sourced names</var>, maintaining their
   relative order.</ol>

  <p id=dom-form-nameditem>To <a id=the-form-element:determine-the-value-of-a-named-property href=https://heycam.github.io/webidl/#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-11><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-12><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>.<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-13><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>.<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-14><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.<li><p>If <var>candidates</var> contains more than one node, return <var>candidates</var>.<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-15><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.<li><p>Return the node in <var>candidates</var>.</ol>

  <p>If an element listed in a <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-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>

  <p>The <dfn id=dom-form-submit><code>submit()</code></dfn> method, when invoked, must <a href=#concept-form-submit id=the-form-element:concept-form-submit>submit</a> the <code id=the-form-element:the-form-element-17><a href=#the-form-element>form</a></code> element from the <code id=the-form-element:the-form-element-18><a href=#the-form-element>form</a></code>
  element itself, with the <var>submitted from <code id=the-form-element:dom-form-submit-2><a href=#dom-form-submit>submit()</a></code> method</var> flag set.</p>

  <p>The <dfn id=dom-form-reset><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-19><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.<li><p>Mark the <code id=the-form-element:the-form-element-20><a href=#the-form-element>form</a></code> element as <dfn id=locked-for-reset>locked for reset</dfn>.<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-21><a href=#the-form-element>form</a></code> element.<li><p>Unmark the <code id=the-form-element:the-form-element-22><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>.</ol>

  <p>If the <dfn id=dom-form-checkvalidity><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-23><a href=#the-form-element>form</a></code> element, and return true if the constraint validation return a <i>positive</i>
  result, and false if it returned a <i>negative</i> result.</p>

  <p>If the <dfn id=dom-form-reportvalidity><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>interactively validate the constraints</a> of the
  <code id=the-form-element:the-form-element-24><a href=#the-form-element>form</a></code> element, and return true if the constraint validation return a <i>positive</i>
  result, and false if it returned a <i>negative</i> result.</p>

  

  <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>&quot;https://www.google.com/search&quot;</c-> <c- e>method</c-><c- o>=</c-><c- s>&quot;get&quot;</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>&quot;search&quot;</c-> <c- e>name</c-><c- o>=</c-><c- s>&quot;q&quot;</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>&quot;submit&quot;</c-> <c- e>value</c-><c- o>=</c-><c- s>&quot;Search...&quot;</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>&quot;https://www.bing.com/search&quot;</c-> <c- e>method</c-><c- o>=</c-><c- s>&quot;get&quot;</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>&quot;search&quot;</c-> <c- e>name</c-><c- o>=</c-><c- s>&quot;q&quot;</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>&quot;submit&quot;</c-> <c- e>value</c-><c- o>=</c-><c- s>&quot;Search...&quot;</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><code>label</code></dfn> element<a href=#the-label-element class=self-link></a></h4>

  <dl class=element><dt><a href=#concept-element-categories id=the-label-element:concept-element-categories>Categories</a>:<dd><a href=#flow-content-2 id=the-label-element:flow-content-2>Flow content</a>.<dd><a href=#phrasing-content-2 id=the-label-element:phrasing-content-2>Phrasing content</a>.<dd><a href=#interactive-content-2 id=the-label-element:interactive-content-2>Interactive content</a>.<dd><a href=#palpable-content-2 id=the-label-element:palpable-content-2>Palpable content</a>.<dt><a href=#concept-element-contexts id=the-label-element:concept-element-contexts>Contexts in which this element can be used</a>:<dd>Where <a href=#phrasing-content-2 id=the-label-element:phrasing-content-2-2>phrasing content</a> is expected.<dt><a href=#concept-element-content-model id=the-label-element:concept-element-content-model>Content model</a>:<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.<dt><a href=#concept-element-tag-omission id=the-label-element:concept-element-tag-omission>Tag omission in text/html</a>:<dd>Neither tag is omissible.<dt><a href=#concept-element-attributes id=the-label-element:concept-element-attributes>Content attributes</a>:<dd><a href=#global-attributes id=the-label-element:global-attributes>Global attributes</a><dd><code id=the-label-element:attr-label-for><a href=#attr-label-for>for</a></code> — Associate the label with form control<dt><a href=#concept-element-dom id=the-label-element:concept-element-dom>DOM interface</a>:<dd>
    <pre><code class='idl'>[<c- g>Exposed</c->=<c- n>Window</c->,
 <a href='#htmlconstructor' id='the-label-element:htmlconstructor'><c- g>HTMLConstructor</c-></a>]
<c- b>interface</c-> <dfn id='htmllabelelement'><c- g>HTMLLabelElement</c-></dfn> : <a href='#htmlelement' id='the-label-element:htmlelement'><c- n>HTMLElement</c-></a> {
  <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>] <c- b>attribute</c-> <c- b>DOMString</c-> <a href='#dom-label-htmlfor' id='the-label-element:dom-label-htmlfor'><c- g>htmlFor</c-></a>;
  <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>
   </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-2><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>

  

  <p>The <dfn id=attr-label-for><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-3><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>

  

  <p>If the <code id=the-label-element:attr-label-for-4><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>

  <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 class=example>

   <p>For example, on platforms where clicking a checkbox label checks the checkbox, clicking the
   <code id=the-label-element:the-label-element-13><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>On other platforms, the behavior might be just to focus the control, or 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><var>label</var> . <code id=dom-label-control-dev><a href=#dom-label-control>control</a></code><dd>

    <p>Returns the form control that is associated with this element.</p>

   <dt><var>label</var> . <code id=dom-label-form-dev><a href=#dom-label-form>form</a></code><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>

   </dl>

  

  <p>The <dfn id=dom-label-htmlfor><code>htmlFor</code></dfn> IDL attribute must
  <a href=#reflect id=the-label-element:reflect>reflect</a> the <code id=the-label-element:attr-label-for-5><a href=#attr-label-for>for</a></code> content attribute.</p>

  <p>The <dfn id=dom-label-control><code>control</code></dfn> IDL attribute must return the
  <code id=the-label-element:the-label-element-14><a href=#the-label-element>label</a></code> element's <a href=#labeled-control id=the-label-element:labeled-control-5>labeled control</a>, if any, or null if there isn't one.</p>

  <p>The <dfn id=dom-label-form><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-15><a href=#the-label-element>label</a></code> element has no <a href=#labeled-control id=the-label-element:labeled-control-6>labeled control</a>, then return
   null.<li><p>If the <code id=the-label-element:the-label-element-16><a href=#the-label-element>label</a></code> element's <a href=#labeled-control id=the-label-element:labeled-control-7>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.<li><p>Return 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>'s <a href=#form-owner id=the-label-element:form-owner-2>form
   owner</a> (which can still be null).</ol>

  

  <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-18><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-19><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><var>control</var> . <code id=dom-lfe-labels-dev><a href=#dom-lfe-labels>labels</a></code><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-20><a href=#the-label-element>label</a></code> elements that the form control
    is associated with.</p>

   </dl>

  

  <p><a href=#category-label id=the-label-element:category-label-5>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-21><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-9>labeled
  control</a> is the element in question. The <dfn id=dom-lfe-labels><code>labels</code></dfn> IDL attribute of <a href=#category-label id=the-label-element:category-label-6>labelable elements</a> and <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 class=example>
   <p>This (non-conforming) example shows what happens to the <code id=the-label-element:nodelist-4><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><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- kr>const</c-> input <c- o>=</c-> document<c- p>.</c->querySelector<c- p>(</c-><c- t>&apos;input&apos;</c-><c- p>);</c->
 <c- kr>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- mi>1</c-><c- p>);</c->

 input<c- p>.</c->type <c- o>=</c-> <c- t>&apos;hidden&apos;</c-><c- p>;</c->
 console<c- p>.</c->assert<c- p>(</c->labels<c- p>.</c->length <c- o>===</c-> <c- mi>0</c-><c- p>);</c-> <c- c1>// the input is no longer the label&apos;s </c-><a href='#labeled-control' id='the-label-element:labeled-control-10'><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>&apos;checkbox&apos;</c-><c- p>;</c->
 console<c- p>.</c->assert<c- p>(</c->labels<c- p>.</c->length <c- o>===</c-> <c- mi>1</c-><c- p>);</c-> <c- c1>// the input is once again the label&apos;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-> 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 data-dfn-type=element data-lt=input><span class=secno>4.10.5</span> The
  <dfn><code>input</code></dfn> element<a href=#the-input-element class=self-link></a></h4>

  <dl class=element><dt><a href=#concept-element-categories id=the-input-element:concept-element-categories>Categories</a>:<dd><a href=#flow-content-2 id=the-input-element:flow-content-2>Flow content</a>.<dd><a href=#phrasing-content-2 id=the-input-element:phrasing-content-2>Phrasing content</a>.<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>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-inheriting</a> <a href=#form-associated-element id=the-input-element:form-associated-element>form-associated element</a>.<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-inheriting</a> <a href=#form-associated-element id=the-input-element:form-associated-element-2>form-associated element</a>.<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>.<dt><a href=#concept-element-contexts id=the-input-element:concept-element-contexts>Contexts in which this element can be used</a>:<dd>Where <a href=#phrasing-content-2 id=the-input-element:phrasing-content-2-2>phrasing content</a> is expected.<dt><a href=#concept-element-content-model id=the-input-element:concept-element-content-model>Content model</a>:<dd><a href=#concept-content-nothing id=the-input-element:concept-content-nothing>Nothing</a>.<dt><a href=#concept-element-tag-omission id=the-input-element:concept-element-tag-omission>Tag omission in text/html</a>:<dd>No <a href=#syntax-end-tag id=the-input-element:syntax-end-tag>end tag</a>.<dt><a href=#concept-element-attributes id=the-input-element:concept-element-attributes>Content attributes</a>:<dd><a href=#global-attributes id=the-input-element:global-attributes>Global attributes</a><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><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><code id=the-input-element:attr-fe-autocomplete><a href=#attr-fe-autocomplete>autocomplete</a></code> — Hint for form autofill feature<dd><code id=the-input-element:attr-fe-autofocus><a href=#attr-fe-autofocus>autofocus</a></code> — Automatically focus the form control when the page is loaded<dd><code id=the-input-element:attr-input-checked><a href=#attr-input-checked>checked</a></code> — Whether the control is checked<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><code id=the-input-element:attr-fe-disabled><a href=#attr-fe-disabled>disabled</a></code> — Whether the form control is disabled<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><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><code id=the-input-element:attr-fs-formenctype><a href=#attr-fs-formenctype>formenctype</a></code> — Entry list encoding type to use for <a href=#form-submission-2 id=the-input-element:form-submission-2-3>form submission</a><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><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><code id=the-input-element:attr-fs-formtarget><a href=#attr-fs-formtarget>formtarget</a></code> — <a href=#browsing-context id=the-input-element:browsing-context>Browsing context</a> for <a href=#form-submission-2 id=the-input-element:form-submission-2-6>form submission</a><dd><code id=the-input-element:attr-dim-height><a href=#attr-dim-height>height</a></code> — Vertical dimension<dd><code id=the-input-element:attr-input-list><a href=#attr-input-list>list</a></code> — List of autocomplete options<dd><code id=the-input-element:attr-input-max><a href=#attr-input-max>max</a></code> — Maximum value<dd><code id=the-input-element:attr-input-maxlength><a href=#attr-input-maxlength>maxlength</a></code> — Maximum length of value<dd><code id=the-input-element:attr-input-min><a href=#attr-input-min>min</a></code> — Minimum value<dd><code id=the-input-element:attr-input-minlength><a href=#attr-input-minlength>minlength</a></code> — Minimum length of value<dd><code id=the-input-element:attr-input-multiple><a href=#attr-input-multiple>multiple</a></code> — Whether to allow multiple values<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><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><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><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><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><code id=the-input-element:attr-input-size><a href=#attr-input-size>size</a></code> — Size of the control<dd><code id=the-input-element:attr-input-src><a href=#attr-input-src>src</a></code> — Address of the resource<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><code id=the-input-element:attr-input-type-5><a href=#attr-input-type>type</a></code> — Type of form control<dd><code id=the-input-element:attr-input-value><a href=#attr-input-value>value</a></code> — Value of the form control<dd><code id=the-input-element:attr-dim-width><a href=#attr-dim-width>width</a></code> — Horizontal dimension<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).<dt><a href=#concept-element-dom id=the-input-element:concept-element-dom>DOM interface</a>:<dd>
    <pre><code class='idl'>[<c- g>Exposed</c->=<c- n>Window</c->,
 <a href='#htmlconstructor' id='the-input-element:htmlconstructor'><c- g>HTMLConstructor</c-></a>]
<c- b>interface</c-> <dfn id='htmlinputelement'><c- g>HTMLInputElement</c-></dfn> : <a href='#htmlelement' id='the-input-element:htmlelement'><c- n>HTMLElement</c-></a> {
  [<a href='#cereactions' id='the-input-element:cereactions'><c- g>CEReactions</c-></a>] <c- b>attribute</c-> <c- b>DOMString</c-> <a href='#dom-input-accept' id='the-input-element:dom-input-accept'><c- g>accept</c-></a>;
  [<a href='#cereactions' id='the-input-element:cereactions-2'><c- g>CEReactions</c-></a>] <c- b>attribute</c-> <c- b>DOMString</c-> <a href='#dom-input-alt' id='the-input-element:dom-input-alt'><c- g>alt</c-></a>;
  [<a href='#cereactions' id='the-input-element:cereactions-3'><c- g>CEReactions</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-4'><c- g>CEReactions</c-></a>] <c- b>attribute</c-> <c- b>boolean</c-> <a href='#dom-fe-autofocus' id='the-input-element:dom-fe-autofocus'><c- g>autofocus</c-></a>;
  [<a href='#cereactions' id='the-input-element:cereactions-5'><c- g>CEReactions</c-></a>] <c- b>attribute</c-> <c- b>boolean</c-> <a href='#dom-input-defaultchecked' id='the-input-element:dom-input-defaultchecked'><c- g>defaultChecked</c-></a>;
  <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-dirname' id='the-input-element:dom-input-dirname'><c- g>dirName</c-></a>;
  [<a href='#cereactions' id='the-input-element:cereactions-7'><c- g>CEReactions</c-></a>] <c- b>attribute</c-> <c- b>boolean</c-> <a href='#dom-fe-disabled' id='the-input-element:dom-fe-disabled'><c- g>disabled</c-></a>;
  <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 href='https://w3c.github.io/FileAPI/#filelist-section' data-x-internal='filelist' id='the-input-element: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-8'><c- g>CEReactions</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-9'><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-10'><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-11'><c- g>CEReactions</c-></a>] <c- b>attribute</c-> <c- b>boolean</c-> <a href='#dom-fs-formnovalidate' id='the-input-element:dom-fs-formnovalidate'><c- g>formNoValidate</c-></a>;
  [<a href='#cereactions' id='the-input-element:cereactions-12'><c- g>CEReactions</c-></a>] <c- b>attribute</c-> <c- b>DOMString</c-> <a href='#dom-fs-formtarget' id='the-input-element:dom-fs-formtarget'><c- g>formTarget</c-></a>;
  [<a href='#cereactions' id='the-input-element:cereactions-13'><c- g>CEReactions</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='#htmlelement' id='the-input-element:htmlelement-2'><c- n>HTMLElement</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-14'><c- g>CEReactions</c-></a>] <c- b>attribute</c-> <c- b>DOMString</c-> <a href='#dom-input-max' id='the-input-element:dom-input-max'><c- g>max</c-></a>;
  [<a href='#cereactions' id='the-input-element:cereactions-15'><c- g>CEReactions</c-></a>] <c- b>attribute</c-> <c- b>long</c-> <a href='#dom-input-maxlength' id='the-input-element:dom-input-maxlength'><c- g>maxLength</c-></a>;
  [<a href='#cereactions' id='the-input-element:cereactions-16'><c- g>CEReactions</c-></a>] <c- b>attribute</c-> <c- b>DOMString</c-> <a href='#dom-input-min' id='the-input-element:dom-input-min'><c- g>min</c-></a>;
  [<a href='#cereactions' id='the-input-element:cereactions-17'><c- g>CEReactions</c-></a>] <c- b>attribute</c-> <c- b>long</c-> <a href='#dom-input-minlength' id='the-input-element:dom-input-minlength'><c- g>minLength</c-></a>;
  [<a href='#cereactions' id='the-input-element:cereactions-18'><c- g>CEReactions</c-></a>] <c- b>attribute</c-> <c- b>boolean</c-> <a href='#dom-input-multiple' id='the-input-element:dom-input-multiple'><c- g>multiple</c-></a>;
  [<a href='#cereactions' id='the-input-element:cereactions-19'><c- g>CEReactions</c-></a>] <c- b>attribute</c-> <c- b>DOMString</c-> <a href='#dom-fe-name' id='the-input-element:dom-fe-name'><c- g>name</c-></a>;
  [<a href='#cereactions' id='the-input-element:cereactions-20'><c- g>CEReactions</c-></a>] <c- b>attribute</c-> <c- b>DOMString</c-> <a href='#dom-input-pattern' id='the-input-element:dom-input-pattern'><c- g>pattern</c-></a>;
  [<a href='#cereactions' id='the-input-element:cereactions-21'><c- g>CEReactions</c-></a>] <c- b>attribute</c-> <c- b>DOMString</c-> <a href='#dom-input-placeholder' id='the-input-element:dom-input-placeholder'><c- g>placeholder</c-></a>;
  [<a href='#cereactions' id='the-input-element:cereactions-22'><c- g>CEReactions</c-></a>] <c- b>attribute</c-> <c- b>boolean</c-> <a href='#dom-input-readonly' id='the-input-element:dom-input-readonly'><c- g>readOnly</c-></a>;
  [<a href='#cereactions' id='the-input-element:cereactions-23'><c- g>CEReactions</c-></a>] <c- b>attribute</c-> <c- b>boolean</c-> <a href='#dom-input-required' id='the-input-element:dom-input-required'><c- g>required</c-></a>;
  [<a href='#cereactions' id='the-input-element:cereactions-24'><c- g>CEReactions</c-></a>] <c- b>attribute</c-> <c- b>unsigned</c-> <c- b>long</c-> <a href='#dom-input-size' id='the-input-element:dom-input-size'><c- g>size</c-></a>;
  [<a href='#cereactions' id='the-input-element:cereactions-25'><c- g>CEReactions</c-></a>] <c- b>attribute</c-> <c- b>USVString</c-> <a href='#dom-input-src' id='the-input-element:dom-input-src'><c- g>src</c-></a>;
  [<a href='#cereactions' id='the-input-element:cereactions-26'><c- g>CEReactions</c-></a>] <c- b>attribute</c-> <c- b>DOMString</c-> <a href='#dom-input-step' id='the-input-element:dom-input-step'><c- g>step</c-></a>;
  [<a href='#cereactions' id='the-input-element:cereactions-27'><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-28'><c- g>CEReactions</c-></a>] <c- b>attribute</c-> <c- b>DOMString</c-> <a href='#dom-input-defaultvalue' id='the-input-element:dom-input-defaultvalue'><c- g>defaultValue</c-></a>;
  [<a href='#cereactions' id='the-input-element:cereactions-29'><c- g>CEReactions</c-></a>] <c- b>attribute</c-> [<c- g>TreatNullAs</c->=<c- n>EmptyString</c->] <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://heycam.github.io/webidl/#idl-object' data-x-internal='idl-object' id='the-input-element: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-30'><c- g>CEReactions</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>void</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>void</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>void</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 href='https://dom.spec.whatwg.org/#interface-nodelist' data-x-internal='nodelist' id='the-input-element: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>void</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>void</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>void</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-> = &quot;preserve&quot;);
  <c- b>void</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->);
};</code></pre>
   </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 id=attr-input-type><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>. The following
  table lists the keywords and states for the attribute — the keywords in the left column map
  to the states in the cell in the second column on the same row as the keyword.</p>

  <table id=attr-input-type-keywords><thead><tr><th> Keyword
     <th> State
     <th> Data type
     <th> Control type
   <tbody><tr><td> <dfn id=attr-input-type-hidden-keyword><code>hidden</code></dfn>
     <td> <a href="#hidden-state-(type=hidden)" id="the-input-element:hidden-state-(type=hidden)-5">Hidden</a>
     <td> An arbitrary string
     <td> n/a
    <tr><td> <dfn id=attr-input-type-text-keyword><code>text</code></dfn>
     <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)">Text</a>
     <td> Text with no line breaks
     <td> A text control
    <tr><td> <dfn id=attr-input-type-search-keyword><code>search</code></dfn>
     <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)-2">Search</a>
     <td> Text with no line breaks
     <td> Search control
    <tr><td> <dfn id=attr-input-type-tel-keyword><code>tel</code></dfn>
     <td> <a href="#telephone-state-(type=tel)" id="the-input-element:telephone-state-(type=tel)">Telephone</a>
     <td> Text with no line breaks
     <td> A text control
    <tr><td> <dfn id=attr-input-type-url-keyword><code>url</code></dfn>
     <td> <a href="#url-state-(type=url)" id="the-input-element:url-state-(type=url)">URL</a>
     <td> An absolute URL
     <td> A text control
    <tr><td> <dfn id=attr-input-type-email-keyword><code>email</code></dfn>
     <td> <a href="#e-mail-state-(type=email)" id="the-input-element:e-mail-state-(type=email)">E-mail</a>
     <td> An e-mail address or list of e-mail addresses
     <td> A text control
    <tr><td> <dfn id=attr-input-type-password-keyword><code>password</code></dfn>
     <td> <a href="#password-state-(type=password)" id="the-input-element:password-state-(type=password)">Password</a>
     <td> Text with no line breaks (sensitive information)
     <td> A text control that obscures data entry
    <tr><td> <dfn id=attr-input-type-date-keyword><code>date</code></dfn>
     <td> <a href="#date-state-(type=date)" id="the-input-element:date-state-(type=date)">Date</a>
     <td> A date (year, month, day) with no time zone
     <td> A date control
    <tr><td> <dfn id=attr-input-type-month-keyword><code>month</code></dfn>
     <td> <a href="#month-state-(type=month)" id="the-input-element:month-state-(type=month)">Month</a>
     <td> A date consisting of a year and a month with no time zone
     <td> A month control
    <tr><td> <dfn id=attr-input-type-week-keyword><code>week</code></dfn>
     <td> <a href="#week-state-(type=week)" id="the-input-element:week-state-(type=week)">Week</a>
     <td> A date consisting of a week-year number and a week number with no time zone
     <td> A week control
    <tr><td> <dfn id=attr-input-type-time-keyword><code>time</code></dfn>
     <td> <a href="#time-state-(type=time)" id="the-input-element:time-state-(type=time)">Time</a>
     <td> A time (hour, minute, seconds, fractional seconds) with no time zone
     <td> A time control
    <tr><td> <dfn id=attr-input-type-datetime-local-keyword><code>datetime-local</code></dfn>
     <td> <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>
     <td> A date and time (year, month, day, hour, minute, second, fraction of a second) with no time zone
     <td> A date and time control
    <tr><td> <dfn id=attr-input-type-number-keyword><code>number</code></dfn>
     <td> <a href="#number-state-(type=number)" id="the-input-element:number-state-(type=number)">Number</a>
     <td> A numerical value
     <td> A text control or spinner control
    <tr><td> <dfn id=attr-input-type-range-keyword><code>range</code></dfn>
     <td> <a href="#range-state-(type=range)" id="the-input-element:range-state-(type=range)">Range</a>
     <td> A numerical value, with the extra semantic that the exact value is not important
     <td> A slider control or similar
    <tr><td> <dfn id=attr-input-type-color-keyword><code>color</code></dfn>
     <td> <a href="#color-state-(type=color)" id="the-input-element:color-state-(type=color)">Color</a>
     <td> An sRGB color with 8-bit red, green, and blue components
     <td> A color picker
    <tr><td> <dfn id=attr-input-type-checkbox-keyword><code>checkbox</code></dfn>
     <td> <a href="#checkbox-state-(type=checkbox)" id="the-input-element:checkbox-state-(type=checkbox)">Checkbox</a>
     <td> A set of zero or more values from a predefined list
     <td> A checkbox
    <tr><td> <dfn id=attr-input-type-radio-keyword><code>radio</code></dfn>
     <td> <a href="#radio-button-state-(type=radio)" id="the-input-element:radio-button-state-(type=radio)">Radio Button</a>
     <td> An enumerated value
     <td> A radio button
    <tr><td> <dfn id=attr-input-type-file-keyword><code>file</code></dfn>
     <td> <a href="#file-upload-state-(type=file)" id="the-input-element:file-upload-state-(type=file)-2">File Upload</a>
     <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 file name
     <td> A label and a button
    <tr><td> <dfn id=attr-input-type-submit-keyword><code>submit</code></dfn>
     <td> <a href="#submit-button-state-(type=submit)" id="the-input-element:submit-button-state-(type=submit)">Submit Button</a>
     <td> An enumerated value, with the extra semantic that it must be the last value selected and initiates form submission
     <td> A button
    <tr><td> <dfn id=attr-input-type-image-keyword><code>image</code></dfn>
     <td> <a href="#image-button-state-(type=image)" id="the-input-element:image-button-state-(type=image)">Image Button</a>
     <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> Either a clickable image, or a button
    <tr><td> <dfn id=attr-input-type-reset-keyword><code>reset</code></dfn>
     <td> <a href="#reset-button-state-(type=reset)" id="the-input-element:reset-button-state-(type=reset)">Reset Button</a>
     <td> n/a
     <td> A button
    <tr><td> <dfn id=attr-input-type-button-keyword><code>button</code></dfn>
     <td> <a href="#button-state-(type=button)" id="the-input-element:button-state-(type=button)">Button</a>
     <td> n/a
     <td> A button
  </table>

  <p>The <i id=the-input-element:missing-value-default><a href=#missing-value-default>missing value default</a></i> and the <i id=the-input-element:invalid-value-default><a href=#invalid-value-default>invalid value default</a></i> are 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)-3">Text</a> state.</p>

  <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-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-2><a href=#attr-input-checked>checked</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 href=#event-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-6><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> <span><a href="#hidden-state-(type=hidden)" id="the-input-element:hidden-state-(type=hidden)-6">Hidden</a></span>
     <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)-4">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)-5">Search</a></span>
     <th> <span><a href="#url-state-(type=url)" id="the-input-element:url-state-(type=url)-2">URL</a>,</span>
          <span><a href="#telephone-state-(type=tel)" id="the-input-element:telephone-state-(type=tel)-2">Telephone</a></span>
     <th> <span><a href="#e-mail-state-(type=email)" id="the-input-element:e-mail-state-(type=email)-2">E-mail</a></span>
     <th> <span><a href="#password-state-(type=password)" id="the-input-element:password-state-(type=password)-2">Password</a></span>
     <th> <span><a href="#date-state-(type=date)" id="the-input-element:date-state-(type=date)-2">Date</a>,</span>
          <span><a href="#month-state-(type=month)" id="the-input-element:month-state-(type=month)-2">Month</a>,</span>
          <span><a href="#week-state-(type=week)" id="the-input-element:week-state-(type=week)-2">Week</a>,</span>
          <span><a href="#time-state-(type=time)" id="the-input-element:time-state-(type=time)-2">Time</a></span>
     <th> <span><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></span>
     <th> <span><a href="#number-state-(type=number)" id="the-input-element:number-state-(type=number)-2">Number</a></span>
     <th> <span><a href="#range-state-(type=range)" id="the-input-element:range-state-(type=range)-2">Range</a></span>
     <th> <span><a href="#color-state-(type=color)" id="the-input-element:color-state-(type=color)-2">Color</a></span>
     <th> <span><a href="#checkbox-state-(type=checkbox)" id="the-input-element:checkbox-state-(type=checkbox)-2">Checkbox</a>,</span>
          <span><a href="#radio-button-state-(type=radio)" id="the-input-element:radio-button-state-(type=radio)-2">Radio Button</a></span>
     <th> <span><a href="#file-upload-state-(type=file)" id="the-input-element:file-upload-state-(type=file)-3">File Upload</a></span>
     <th> <span><a href="#submit-button-state-(type=submit)" id="the-input-element:submit-button-state-(type=submit)-2">Submit Button</a></span>
     <th> <span><a href="#image-button-state-(type=image)" id="the-input-element:image-button-state-(type=image)-2">Image Button</a></span>
     <th> <span><a href="#reset-button-state-(type=reset)" id="the-input-element:reset-button-state-(type=reset)-2">Reset Button</a>,</span>
          <span><a href="#button-state-(type=button)" id="the-input-element:button-state-(type=button)-2">Button</a></span>

   <tbody><tr><th colspan=16 scope=rowgroup>Content attributes

    <tr><th> <code id=the-input-element:attr-input-accept-3><a href=#attr-input-accept>accept</a></code>
     <td class=no> · 
     <td class=no> · 

     <td class=no> · 
     <td class=no> · 
     <td class=no> · 
     <td class=no> · 



     <td class=no> · 
     <td class=no> · 
     <td class=no> · 
     <td class=no> · 
     <td class=no> · 

     <td class=yes> Yes     
     <td class=no> · 
     <td class=no> · 
     <td class=no> · 


    <tr><th> <code id=the-input-element:attr-input-alt-3><a href=#attr-input-alt>alt</a></code>
     <td class=no> · 
     <td class=no> · 

     <td class=no> · 
     <td class=no> · 
     <td class=no> · 
     <td class=no> · 



     <td class=no> · 
     <td class=no> · 
     <td class=no> · 
     <td class=no> · 
     <td class=no> · 

     <td class=no> · 
     <td class=no> · 
     <td class=yes> Yes     
     <td class=no> · 


    <tr><th> <code id=the-input-element:attr-fe-autocomplete-3><a href=#attr-fe-autocomplete>autocomplete</a></code>
     <td class=yes> Yes     
     <td class=yes> Yes     

     <td class=yes> Yes     
     <td class=yes> Yes     
     <td class=yes> Yes     
     <td class=yes> Yes     



     <td class=yes> Yes     
     <td class=yes> Yes     
     <td class=yes> Yes     
     <td class=yes> Yes     
     <td class=no> · 

     <td class=no> · 
     <td class=no> · 
     <td class=no> · 
     <td class=no> · 


    <tr><th> <code id=the-input-element:attr-input-checked-3><a href=#attr-input-checked>checked</a></code>
     <td class=no> · 
     <td class=no> · 

     <td class=no> · 
     <td class=no> · 
     <td class=no> · 
     <td class=no> · 



     <td class=no> · 
     <td class=no> · 
     <td class=no> · 
     <td class=no> · 
     <td class=yes> Yes     

     <td class=no> · 
     <td class=no> · 
     <td class=no> · 
     <td class=no> · 


    <tr><th> <code id=the-input-element:attr-fe-dirname-3><a href=#attr-fe-dirname>dirname</a></code>
     <td class=no> · 
     <td class=yes> Yes     

     <td class=no> · 
     <td class=no> · 
     <td class=no> · 
     <td class=no> · 



     <td class=no> · 
     <td class=no> · 
     <td class=no> · 
     <td class=no> · 
     <td class=no> · 

     <td class=no> · 
     <td class=no> · 
     <td class=no> · 
     <td class=no> · 


    <tr><th> <code id=the-input-element:attr-fs-formaction-3><a href=#attr-fs-formaction>formaction</a></code>
     <td class=no> · 
     <td class=no> · 

     <td class=no> · 
     <td class=no> · 
     <td class=no> · 
     <td class=no> · 



     <td class=no> · 
     <td class=no> · 
     <td class=no> · 
     <td class=no> · 
     <td class=no> · 

     <td class=no> · 
     <td class=yes> Yes     
     <td class=yes> Yes     
     <td class=no> · 


    <tr><th> <code id=the-input-element:attr-fs-formenctype-3><a href=#attr-fs-formenctype>formenctype</a></code>
     <td class=no> · 
     <td class=no> · 

     <td class=no> · 
     <td class=no> · 
     <td class=no> · 
     <td class=no> · 



     <td class=no> · 
     <td class=no> · 
     <td class=no> · 
     <td class=no> · 
     <td class=no> · 

     <td class=no> · 
     <td class=yes> Yes     
     <td class=yes> Yes     
     <td class=no> · 


    <tr><th> <code id=the-input-element:attr-fs-formmethod-3><a href=#attr-fs-formmethod>formmethod</a></code>
     <td class=no> · 
     <td class=no> · 

     <td class=no> · 
     <td class=no> · 
     <td class=no> · 
     <td class=no> · 



     <td class=no> · 
     <td class=no> · 
     <td class=no> · 
     <td class=no> · 
     <td class=no> · 

     <td class=no> · 
     <td class=yes> Yes     
     <td class=yes> Yes     
     <td class=no> · 


    <tr><th> <code id=the-input-element:attr-fs-formnovalidate-3><a href=#attr-fs-formnovalidate>formnovalidate</a></code>
     <td class=no> · 
     <td class=no> · 

     <td class=no> · 
     <td class=no> · 
     <td class=no> · 
     <td class=no> · 



     <td class=no> · 
     <td class=no> · 
     <td class=no> · 
     <td class=no> · 
     <td class=no> · 

     <td class=no> · 
     <td class=yes> Yes     
     <td class=yes> Yes     
     <td class=no> · 


    <tr><th> <code id=the-input-element:attr-fs-formtarget-3><a href=#attr-fs-formtarget>formtarget</a></code>
     <td class=no> · 
     <td class=no> · 

     <td class=no> · 
     <td class=no> · 
     <td class=no> · 
     <td class=no> · 



     <td class=no> · 
     <td class=no> · 
     <td class=no> · 
     <td class=no> · 
     <td class=no> · 

     <td class=no> · 
     <td class=yes> Yes     
     <td class=yes> Yes     
     <td class=no> · 


    <tr><th> <code id=the-input-element:attr-dim-height-3><a href=#attr-dim-height>height</a></code>
     <td class=no> · 
     <td class=no> · 

     <td class=no> · 
     <td class=no> · 
     <td class=no> · 
     <td class=no> · 



     <td class=no> · 
     <td class=no> · 
     <td class=no> · 
     <td class=no> · 
     <td class=no> · 

     <td class=no> · 
     <td class=no> · 
     <td class=yes> Yes     
     <td class=no> · 


    <tr><th> <code id=the-input-element:attr-input-list-3><a href=#attr-input-list>list</a></code>
     <td class=no> · 
     <td class=yes> Yes     

     <td class=yes> Yes     
     <td class=yes> Yes     
     <td class=no> · 
     <td class=yes> Yes     



     <td class=yes> Yes     
     <td class=yes> Yes     
     <td class=yes> Yes     
     <td class=yes> Yes     
     <td class=no> · 

     <td class=no> · 
     <td class=no> · 
     <td class=no> · 
     <td class=no> · 


    <tr><th> <code id=the-input-element:attr-input-max-3><a href=#attr-input-max>max</a></code>
     <td class=no> · 
     <td class=no> · 

     <td class=no> · 
     <td class=no> · 
     <td class=no> · 
     <td class=yes> Yes     



     <td class=yes> Yes     
     <td class=yes> Yes     
     <td class=yes> Yes     
     <td class=no> · 
     <td class=no> · 

     <td class=no> · 
     <td class=no> · 
     <td class=no> · 
     <td class=no> · 


    <tr><th> <code id=the-input-element:attr-input-maxlength-3><a href=#attr-input-maxlength>maxlength</a></code>
     <td class=no> · 
     <td class=yes> Yes     

     <td class=yes> Yes     
     <td class=yes> Yes     
     <td class=yes> Yes     
     <td class=no> · 



     <td class=no> · 
     <td class=no> · 
     <td class=no> · 
     <td class=no> · 
     <td class=no> · 

     <td class=no> · 
     <td class=no> · 
     <td class=no> · 
     <td class=no> · 


    <tr><th> <code id=the-input-element:attr-input-min-3><a href=#attr-input-min>min</a></code>
     <td class=no> · 
     <td class=no> · 

     <td class=no> · 
     <td class=no> · 
     <td class=no> · 
     <td class=yes> Yes     



     <td class=yes> Yes     
     <td class=yes> Yes     
     <td class=yes> Yes     
     <td class=no> · 
     <td class=no> · 

     <td class=no> · 
     <td class=no> · 
     <td class=no> · 
     <td class=no> · 


    <tr><th> <code id=the-input-element:attr-input-minlength-3><a href=#attr-input-minlength>minlength</a></code>
     <td class=no> · 
     <td class=yes> Yes     

     <td class=yes> Yes     
     <td class=yes> Yes     
     <td class=yes> Yes     
     <td class=no> · 



     <td class=no> · 
     <td class=no> · 
     <td class=no> · 
     <td class=no> · 
     <td class=no> · 

     <td class=no> · 
     <td class=no> · 
     <td class=no> · 
     <td class=no> · 


    <tr><th> <code id=the-input-element:attr-input-multiple-3><a href=#attr-input-multiple>multiple</a></code>
     <td class=no> · 
     <td class=no> · 

     <td class=no> ·  
     <td class=yes> Yes     
     <td class=no> · 
     <td class=no> · 



     <td class=no> · 
     <td class=no> · 
     <td class=no> · 
     <td class=no> · 
     <td class=no> · 

     <td class=yes> Yes     
     <td class=no> · 
     <td class=no> · 
     <td class=no> · 


    <tr><th> <code id=the-input-element:attr-input-pattern-4><a href=#attr-input-pattern>pattern</a></code>
     <td class=no> · 
     <td class=yes> Yes     

     <td class=yes> Yes     
     <td class=yes> Yes     
     <td class=yes> Yes     
     <td class=no> · 



     <td class=no> · 
     <td class=no> · 
     <td class=no> · 
     <td class=no> · 
     <td class=no> · 

     <td class=no> · 
     <td class=no> · 
     <td class=no> · 
     <td class=no> · 


    <tr><th> <code id=the-input-element:attr-input-placeholder-3><a href=#attr-input-placeholder>placeholder</a></code>
     <td class=no> · 
     <td class=yes> Yes     

     <td class=yes> Yes     
     <td class=yes> Yes     
     <td class=yes> Yes     
     <td class=no> · 



     <td class=no> · 
     <td class=yes> Yes     
     <td class=no> · 
     <td class=no> · 
     <td class=no> · 

     <td class=no> · 
     <td class=no> · 
     <td class=no> · 
     <td class=no> · 


    <tr><th> <code id=the-input-element:attr-input-readonly-3><a href=#attr-input-readonly>readonly</a></code>
     <td class=no> · 
     <td class=yes> Yes     

     <td class=yes> Yes     
     <td class=yes> Yes     
     <td class=yes> Yes     
     <td class=yes> Yes     



     <td class=yes> Yes     
     <td class=yes> Yes     
     <td class=no> · 
     <td class=no> · 
     <td class=no> · 

     <td class=no> · 
     <td class=no> · 
     <td class=no> · 
     <td class=no> · 


    <tr><th> <code id=the-input-element:attr-input-required-3><a href=#attr-input-required>required</a></code>
     <td class=no> · 
     <td class=yes> Yes     

     <td class=yes> Yes     
     <td class=yes> Yes     
     <td class=yes> Yes     
     <td class=yes> Yes     



     <td class=yes> Yes     
     <td class=yes> Yes     
     <td class=no> · 
     <td class=no> · 
     <td class=yes> Yes     

     <td class=yes> Yes     
     <td class=no> · 
     <td class=no> · 
     <td class=no> · 


    <tr><th> <code id=the-input-element:attr-input-size-3><a href=#attr-input-size>size</a></code>
     <td class=no> · 
     <td class=yes> Yes     

     <td class=yes> Yes     
     <td class=yes> Yes     
     <td class=yes> Yes     
     <td class=no> · 



     <td class=no> · 
     <td class=no> · 
     <td class=no> · 
     <td class=no> · 
     <td class=no> · 

     <td class=no> · 
     <td class=no> · 
     <td class=no> · 
     <td class=no> · 


    <tr><th> <code id=the-input-element:attr-input-src-3><a href=#attr-input-src>src</a></code>
     <td class=no> · 
     <td class=no> · 

     <td class=no> · 
     <td class=no> · 
     <td class=no> · 
     <td class=no> · 



     <td class=no> · 
     <td class=no> · 
     <td class=no> · 
     <td class=no> · 
     <td class=no> · 

     <td class=no> · 
     <td class=no> · 
     <td class=yes> Yes     
     <td class=no> · 


    <tr><th> <code id=the-input-element:attr-input-step-3><a href=#attr-input-step>step</a></code>
     <td class=no> · 
     <td class=no> · 

     <td class=no> · 
     <td class=no> · 
     <td class=no> · 
     <td class=yes> Yes     



     <td class=yes> Yes     
     <td class=yes> Yes     
     <td class=yes> Yes     
     <td class=no> · 
     <td class=no> · 

     <td class=no> · 
     <td class=no> · 
     <td class=no> · 
     <td class=no> · 


    <tr><th> <code id=the-input-element:attr-dim-width-3><a href=#attr-dim-width>width</a></code>
     <td class=no> · 
     <td class=no> · 

     <td class=no> · 
     <td class=no> · 
     <td class=no> · 
     <td class=no> · 



     <td class=no> · 
     <td class=no> · 
     <td class=no> · 
     <td class=no> · 
     <td class=no> · 

     <td class=no> · 
     <td class=no> · 
     <td class=yes> Yes     
     <td class=no> · 


   <tbody><tr><th colspan=16 scope=rowgroup>IDL attributes and methods

    <tr><th> <code id=the-input-element:dom-input-checked-3><a href=#dom-input-checked>checked</a></code>
     <td class=no> · 
     <td class=no> · 

     <td class=no> · 
     <td class=no> · 
     <td class=no> · 
     <td class=no> · 



     <td class=no> · 
     <td class=no> · 
     <td class=no> · 
     <td class=no> · 
     <td class=yes> Yes     

     <td class=no> · 
     <td class=no> · 
     <td class=no> · 
     <td class=no> · 


    <tr><th> <code id=the-input-element:dom-input-files-3><a href=#dom-input-files>files</a></code>
     <td class=no> · 
     <td class=no> · 

     <td class=no> · 
     <td class=no> · 
     <td class=no> · 
     <td class=no> · 



     <td class=no> · 
     <td class=no> · 
     <td class=no> · 
     <td class=no> · 
     <td class=no> · 

     <td class=yes> Yes     
     <td class=no> · 
     <td class=no> · 
     <td class=no> · 


    <tr><th> <code id=the-input-element:dom-input-value-2><a href=#dom-input-value>value</a></code>
     <td class=yes> <a href=#dom-input-value-default id=the-input-element:dom-input-value-default>default</a> 
     <td class=yes> <a href=#dom-input-value-value id=the-input-element:dom-input-value-value>value</a> 

     <td class=yes> <a href=#dom-input-value-value id=the-input-element:dom-input-value-value-2>value</a> 
     <td class=yes> <a href=#dom-input-value-value id=the-input-element:dom-input-value-value-3>value</a> 
     <td class=yes> <a href=#dom-input-value-value id=the-input-element:dom-input-value-value-4>value</a> 
     <td class=yes> <a href=#dom-input-value-value id=the-input-element:dom-input-value-value-5>value</a> 



     <td class=yes> <a href=#dom-input-value-value id=the-input-element:dom-input-value-value-6>value</a> 
     <td class=yes> <a href=#dom-input-value-value id=the-input-element:dom-input-value-value-7>value</a> 
     <td class=yes> <a href=#dom-input-value-value id=the-input-element:dom-input-value-value-8>value</a> 
     <td class=yes> <a href=#dom-input-value-value id=the-input-element:dom-input-value-value-9>value</a> 
     <td class=yes> <a href=#dom-input-value-default-on id=the-input-element:dom-input-value-default-on>default/on</a> 

     <td class=yes> <a href=#dom-input-value-filename id=the-input-element:dom-input-value-filename>filename</a> 
     <td class=yes> <a href=#dom-input-value-default id=the-input-element:dom-input-value-default-2>default</a> 
     <td class=yes> <a href=#dom-input-value-default id=the-input-element:dom-input-value-default-3>default</a> 
     <td class=yes> <a href=#dom-input-value-default id=the-input-element:dom-input-value-default-4>default</a> 


    <tr><th> <code id=the-input-element:dom-input-valueasdate-3><a href=#dom-input-valueasdate>valueAsDate</a></code>
     <td class=no> · 
     <td class=no> · 

     <td class=no> · 
     <td class=no> · 
     <td class=no> · 
     <td class=yes> Yes     



     <td class=no> · 
     <td class=no> · 
     <td class=no> · 
     <td class=no> · 
     <td class=no> · 

     <td class=no> · 
     <td class=no> · 
     <td class=no> · 
     <td class=no> · 


    <tr><th> <code id=the-input-element:dom-input-valueasnumber-3><a href=#dom-input-valueasnumber>valueAsNumber</a></code>
     <td class=no> · 
     <td class=no> · 

     <td class=no> · 
     <td class=no> · 
     <td class=no> · 
     <td class=yes> Yes     



     <td class=yes> Yes     
     <td class=yes> Yes     
     <td class=yes> Yes     
     <td class=no> · 
     <td class=no> · 

     <td class=no> · 
     <td class=no> · 
     <td class=no> · 
     <td class=no> · 


    <tr><th> <code id=the-input-element:dom-input-list-3><a href=#dom-input-list>list</a></code>
     <td class=no> · 
     <td class=yes> Yes     

     <td class=yes> Yes     
     <td class=yes> Yes     
     <td class=no> · 
     <td class=yes> Yes     



     <td class=yes> Yes     
     <td class=yes> Yes     
     <td class=yes> Yes     
     <td class=yes> Yes     
     <td class=no> · 

     <td class=no> · 
     <td class=no> · 
     <td class=no> · 
     <td class=no> · 


    <tr><th> <code id=the-input-element:dom-textarea/input-select-3><a href=#dom-textarea/input-select>select()</a></code>
     <td class=no> ·     
     <td class=yes> Yes         

     <td class=yes> Yes         
     <td class=yes> Yes† 
     <td class=yes> Yes         
     <td class=yes> Yes† 



     <td class=yes> Yes† 
     <td class=yes> Yes† 
     <td class=no> ·     
     <td class=yes> Yes† 
     <td class=no> ·     

     <td class=yes> Yes† 
     <td class=no> ·     
     <td class=no> ·     
     <td class=no> ·     


    <tr><th> <code id=the-input-element:dom-textarea/input-selectionstart-3><a href=#dom-textarea/input-selectionstart>selectionStart</a></code>
     <td class=no> · 
     <td class=yes> Yes     

     <td class=yes> Yes     
     <td class=no> · 
     <td class=yes> Yes     
     <td class=no> · 



     <td class=no> · 
     <td class=no> · 
     <td class=no> · 
     <td class=no> · 
     <td class=no> · 

     <td class=no> · 
     <td class=no> · 
     <td class=no> · 
     <td class=no> · 


    <tr><th> <code id=the-input-element:dom-textarea/input-selectionend-3><a href=#dom-textarea/input-selectionend>selectionEnd</a></code>
     <td class=no> · 
     <td class=yes> Yes     

     <td class=yes> Yes     
     <td class=no> · 
     <td class=yes> Yes     
     <td class=no> · 



     <td class=no> · 
     <td class=no> · 
     <td class=no> · 
     <td class=no> · 
     <td class=no> · 

     <td class=no> · 
     <td class=no> · 
     <td class=no> · 
     <td class=no> · 


    <tr><th> <code id=the-input-element:dom-textarea/input-selectiondirection-3><a href=#dom-textarea/input-selectiondirection>selectionDirection</a></code>
     <td class=no> · 
     <td class=yes> Yes     

     <td class=yes> Yes     
     <td class=no> · 
     <td class=yes> Yes     
     <td class=no> · 



     <td class=no> · 
     <td class=no> · 
     <td class=no> · 
     <td class=no> · 
     <td class=no> · 

     <td class=no> · 
     <td class=no> · 
     <td class=no> · 
     <td class=no> · 


    <tr><th> <code id=the-input-element:dom-textarea/input-setrangetext-4><a href=#dom-textarea/input-setrangetext>setRangeText()</a></code>
     <td class=no> · 
     <td class=yes> Yes     

     <td class=yes> Yes     
     <td class=no> · 
     <td class=yes> Yes     
     <td class=no> · 



     <td class=no> · 
     <td class=no> · 
     <td class=no> · 
     <td class=no> · 
     <td class=no> · 

     <td class=no> · 
     <td class=no> · 
     <td class=no> · 
     <td class=no> · 


    <tr><th> <code id=the-input-element:dom-textarea/input-setselectionrange-3><a href=#dom-textarea/input-setselectionrange>setSelectionRange()</a></code>
     <td class=no> · 
     <td class=yes> Yes     

     <td class=yes> Yes     
     <td class=no> · 
     <td class=yes> Yes     
     <td class=no> · 



     <td class=no> · 
     <td class=no> · 
     <td class=no> · 
     <td class=no> · 
     <td class=no> · 

     <td class=no> · 
     <td class=no> · 
     <td class=no> · 
     <td class=no> · 


    <tr><th> <code id=the-input-element:dom-input-stepdown-3><a href=#dom-input-stepdown>stepDown()</a></code>
     <td class=no> · 
     <td class=no> · 

     <td class=no> · 
     <td class=no> · 
     <td class=no> · 
     <td class=yes> Yes     



     <td class=yes> Yes     
     <td class=yes> Yes     
     <td class=yes> Yes     
     <td class=no> · 
     <td class=no> · 

     <td class=no> · 
     <td class=no> · 
     <td class=no> · 
     <td class=no> · 


    <tr><th> <code id=the-input-element:dom-input-stepup-3><a href=#dom-input-stepup>stepUp()</a></code>
     <td class=no> · 
     <td class=no> · 

     <td class=no> · 
     <td class=no> · 
     <td class=no> · 
     <td class=yes> Yes     



     <td class=yes> Yes     
     <td class=yes> Yes     
     <td class=yes> Yes     
     <td class=no> · 
     <td class=no> · 

     <td class=no> · 
     <td class=no> · 
     <td class=no> · 
     <td class=no> · 


   <tbody><tr><th colspan=16 scope=rowgroup>Events

    <tr><th> <span><code id=the-input-element:event-input-2><a href=#event-input>input</a></code> event</span>
     <td class=no> · 
     <td class=yes> Yes     

     <td class=yes> Yes     
     <td class=yes> Yes     
     <td class=yes> Yes     
     <td class=yes> Yes     



     <td class=yes> Yes     
     <td class=yes> Yes     
     <td class=yes> Yes     
     <td class=yes> Yes     
     <td class=yes> Yes     

     <td class=yes> Yes     
     <td class=no> · 
     <td class=no> · 
     <td class=no> · 


    <tr><th> <span><code id=the-input-element:event-change-2><a href=#event-change>change</a></code> event</span>
     <td class=no> · 
     <td class=yes> Yes     

     <td class=yes> Yes     
     <td class=yes> Yes     
     <td class=yes> Yes     
     <td class=yes> Yes     



     <td class=yes> Yes     
     <td class=yes> Yes     
     <td class=yes> Yes     
     <td class=yes> Yes     
     <td class=yes> Yes     

     <td class=yes> Yes     
     <td class=no> · 
     <td class=no> · 
     <td class=no> · 


  </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://heycam.github.io/webidl/#invalidstateerror data-x-internal=invalidstateerror>"<code>InvalidStateError</code>"</a> <code id=the-input-element:domexception><a data-x-internal=domexception href=https://heycam.github.io/webidl/#dfn-DOMException>DOMException</a></code>.</small></p>

  

  <p>Some states of the <code id=the-input-element:attr-input-type-7><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>

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

  

  <p>The <dfn id=attr-input-value><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-2><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-3><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>

  

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

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

  

  <p>The <dfn id=attr-input-checked><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-4><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-5><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>

  

  <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 the <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-4><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-6><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-8><a href=#attr-input-type>type</a></code> attribute's current state defines one.</p>

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

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

  <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)-3">Date</a> state, but not the <a href="#checkbox-state-(type=checkbox)" id="the-input-element:checkbox-state-(type=checkbox)-3">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 <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-14><a href=#the-input-element>input</a></code> elements
  must 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 the node being cloned
  to the copy.</p>

  <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-15><a href=#the-input-element>input</a></code> elements are these steps:</p>

  <ol><li><p>If this element is not <i id=the-input-element:concept-fe-mutable-5><a href=#concept-fe-mutable>mutable</a></i>, then return.<li><p>Run this element's <dfn id=input-activation-behavior>input activation behavior</dfn>, if any, and do nothing
   otherwise.</ol>

  <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-16><a href=#the-input-element>input</a></code> elements are these
  steps:</p>

  <ol><li><p>If this element is not <i id=the-input-element:concept-fe-mutable-6><a href=#concept-fe-mutable>mutable</a></i>, then return.<li><p>If this element's <code id=the-input-element:attr-input-type-9><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)-4">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.<li><p>If this element's <code id=the-input-element:attr-input-type-10><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)-3">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.</ol>

  <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-17><a href=#the-input-element>input</a></code> elements are these
  steps:</p>

  <ol><li><p>If the element is not <i id=the-input-element:concept-fe-mutable-7><a href=#concept-fe-mutable>mutable</a></i>, then return.<li><p>If the element's <code id=the-input-element:attr-input-type-11><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)-5">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.<li><p>If this element's <code id=the-input-element:attr-input-type-12><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)-4">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,
   setting 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>, setting this
   element's <a href=#concept-fe-checked id=the-input-element:concept-fe-checked-14>checkedness</a> to false.
  </ol>

  

  <hr>

  <p>When an <code id=the-input-element:the-input-element-18><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-13><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-14><a href=#attr-input-type>type</a></code> attribute's state, must be invoked.</p>

  

  <div id=input-type-change>

  <p>When an <code id=the-input-element:the-input-element-19><a href=#the-input-element>input</a></code> element's <code id=the-input-element:attr-input-type-15><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-16><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-17><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-5><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>.<li><p>Otherwise, if the previous state of the element's <code id=the-input-element:attr-input-type-18><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-19><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-6><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.<li><p>Otherwise, if the previous state of the element's <code id=the-input-element:attr-input-type-20><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-21><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.<li><p>Update the element's rendering and behavior to the new state's.<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)-5">Radio Button</a> state uses this, in particular.)<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-22><a href=#attr-input-type>type</a></code> attribute's new state.<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.<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.<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>".</ol>

  </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-20><a href=#the-input-element>input</a></code> element with its <a href=#form-owner id=the-input-element:form-owner>form owner</a>.
  The <code id=the-input-element:attr-fe-autofocus-2><a href=#attr-fe-autofocus>autofocus</a></code> attribute controls focus.
  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>

  

  <p>The <dfn id=dom-input-indeterminate><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)-6">checkbox</a> controls.<div class=status><input onclick=toggleStatus(this) value=⋰ type=button><p class=support><strong>Support:</strong> indeterminate-checkbox<span class="and_chr yes"><span>Chrome for Android</span> <span>67+</span></span><span class="chrome yes"><span>Chrome</span> <span>28+</span></span><span class="ios_saf yes"><span>iOS Safari</span> <span>12+</span></span><span class="and_uc no"><span>UC Browser for Android</span> <span>None</span></span><span class="firefox yes"><span>Firefox</span> <span>3.6+</span></span><span class="ie yes"><span>IE</span> <span>6+</span></span><span class="op_mini no"><span>Opera Mini</span> <span>None</span></span><span class="safari yes"><span>Safari</span> <span>6+</span></span><span class="edge yes"><span>Edge</span> <span>12+</span></span><span class="samsung yes"><span>Samsung Internet</span> <span>4+</span></span><span class="opera yes"><span>Opera</span> <span>11.6+</span></span><span class="android yes"><span>Android Browser</span> <span>4.4+</span></span><p class=caniuse>Source: <a href="https://caniuse.com/#feat=indeterminate-checkbox">caniuse.com</a></div>

  <p>The <dfn id=dom-input-accept><code>accept</code></dfn>, <dfn id=dom-input-alt><code>alt</code></dfn>, <dfn id=dom-input-max><code>max</code></dfn>,
  <dfn id=dom-input-min><code>min</code></dfn>, <dfn id=dom-input-multiple><code>multiple</code></dfn>, <dfn id=dom-input-pattern><code>pattern</code></dfn>, <dfn id=dom-input-placeholder><code>placeholder</code></dfn>, <dfn id=dom-input-required><code>required</code></dfn>, <dfn id=dom-input-size><code>size</code></dfn>, <dfn id=dom-input-src><code>src</code></dfn>,
  and <dfn id=dom-input-step><code>step</code></dfn> IDL attributes must <a href=#reflect id=the-input-element:reflect>reflect</a>
  the respective content attributes of the same name. The <dfn id=dom-input-dirname><code>dirName</code></dfn> IDL attribute must <a href=#reflect id=the-input-element:reflect-2>reflect</a> the
  <code id=the-input-element:attr-fe-dirname-5><a href=#attr-fe-dirname>dirname</a></code> content attribute. The <dfn id=dom-input-readonly><code>readOnly</code></dfn> IDL attribute must <a href=#reflect id=the-input-element:reflect-3>reflect</a> the
  <code id=the-input-element:attr-input-readonly-5><a href=#attr-input-readonly>readonly</a></code> content attribute. The <dfn id=dom-input-defaultchecked><code>defaultChecked</code></dfn> IDL attribute must
  <a href=#reflect id=the-input-element:reflect-4>reflect</a> the <code id=the-input-element:attr-input-checked-7><a href=#attr-input-checked>checked</a></code> content attribute. The
  <dfn id=dom-input-defaultvalue><code>defaultValue</code></dfn> IDL attribute must
  <a href=#reflect id=the-input-element:reflect-5>reflect</a> the <code id=the-input-element:attr-input-value-7><a href=#attr-input-value>value</a></code> content attribute.</p>

  <p>The <dfn id=dom-input-type><code>type</code></dfn> IDL attribute must
  <a href=#reflect id=the-input-element:reflect-6>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>limited to only
  known values</a>. The <dfn id=dom-input-maxlength><code>maxLength</code></dfn> IDL
  attribute must <a href=#reflect id=the-input-element:reflect-7>reflect</a> the <code id=the-input-element:attr-input-maxlength-4><a href=#attr-input-maxlength>maxlength</a></code>
  content attribute, <a href=#limited-to-only-non-negative-numbers id=the-input-element:limited-to-only-non-negative-numbers>limited to only non-negative numbers</a>.
  The <dfn id=dom-input-minlength><code>minLength</code></dfn> IDL attribute must
  <a href=#reflect id=the-input-element:reflect-8>reflect</a> the <code id=the-input-element:attr-input-minlength-4><a href=#attr-input-minlength>minlength</a></code> content attribute,
  <a href=#limited-to-only-non-negative-numbers id=the-input-element:limited-to-only-non-negative-numbers-2>limited to only non-negative numbers</a>.</p>

  <p>The IDL attributes <dfn id=dom-input-width><code>width</code></dfn> and <dfn id=dom-input-height><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>, and
  is being rendered to a visual medium; or else the <a href=https://drafts.csswg.org/css2/conform.html#intrinsic id=the-input-element:intrinsic-dimensions data-x-internal=intrinsic-dimensions>intrinsic
  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 being rendered to a visual medium; 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-21><a href=#the-input-element>input</a></code>
  element's <code id=the-input-element:attr-input-type-23><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)-3">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>

  <p>On setting, they must act as if they <a href=#reflect id=the-input-element:reflect-9>reflected</a> the respective
  content attributes of the same name.</p>

  <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-autofocus-2><a href=#dom-fe-autofocus>autofocus</a></code>, <code id=the-input-element:dom-fe-disabled-2><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-2><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>Hidden</dfn> state (<code>type=hidden</code>)<a href="#hidden-state-(type=hidden)" class=self-link></a></h6>

  

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

  

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

  

  <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 a
  <a href=#case-sensitive id="hidden-state-(type=hidden):case-sensitive">case-sensitive</a> match for the string "<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>
   content attribute <a href=#concept-input-apply id="hidden-state-(type=hidden):concept-input-apply">applies</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" class=no-backref><a href=#attr-input-accept>accept</a></code>,
   <code id="hidden-state-(type=hidden):attr-input-alt" class=no-backref><a href=#attr-input-alt>alt</a></code>,
   <code id="hidden-state-(type=hidden):attr-input-checked" class=no-backref><a href=#attr-input-checked>checked</a></code>,
   <code id="hidden-state-(type=hidden):attr-fe-dirname" class=no-backref><a href=#attr-fe-dirname>dirname</a></code>,
   <code id="hidden-state-(type=hidden):attr-fs-formaction" class=no-backref><a href=#attr-fs-formaction>formaction</a></code>,
   <code id="hidden-state-(type=hidden):attr-fs-formenctype" class=no-backref><a href=#attr-fs-formenctype>formenctype</a></code>,
   <code id="hidden-state-(type=hidden):attr-fs-formmethod" class=no-backref><a href=#attr-fs-formmethod>formmethod</a></code>,
   <code id="hidden-state-(type=hidden):attr-fs-formnovalidate" class=no-backref><a href=#attr-fs-formnovalidate>formnovalidate</a></code>,
   <code id="hidden-state-(type=hidden):attr-fs-formtarget" class=no-backref><a href=#attr-fs-formtarget>formtarget</a></code>,
   <code id="hidden-state-(type=hidden):attr-dim-height" class=no-backref><a href=#attr-dim-height>height</a></code>,
   <code id="hidden-state-(type=hidden):attr-input-list" class=no-backref><a href=#attr-input-list>list</a></code>,
   <code id="hidden-state-(type=hidden):attr-input-max" class=no-backref><a href=#attr-input-max>max</a></code>,
   <code id="hidden-state-(type=hidden):attr-input-maxlength" class=no-backref><a href=#attr-input-maxlength>maxlength</a></code>,
   <code id="hidden-state-(type=hidden):attr-input-min" class=no-backref><a href=#attr-input-min>min</a></code>,
   <code id="hidden-state-(type=hidden):attr-input-minlength" class=no-backref><a href=#attr-input-minlength>minlength</a></code>,
   <code id="hidden-state-(type=hidden):attr-input-multiple" class=no-backref><a href=#attr-input-multiple>multiple</a></code>,
   <code id="hidden-state-(type=hidden):attr-input-pattern" class=no-backref><a href=#attr-input-pattern>pattern</a></code>,
   <code id="hidden-state-(type=hidden):attr-input-placeholder" class=no-backref><a href=#attr-input-placeholder>placeholder</a></code>,
   <code id="hidden-state-(type=hidden):attr-input-readonly" class=no-backref><a href=#attr-input-readonly>readonly</a></code>,
   <code id="hidden-state-(type=hidden):attr-input-required" class=no-backref><a href=#attr-input-required>required</a></code>,
   <code id="hidden-state-(type=hidden):attr-input-size" class=no-backref><a href=#attr-input-size>size</a></code>,
   <code id="hidden-state-(type=hidden):attr-input-src" class=no-backref><a href=#attr-input-src>src</a></code>,
   <code id="hidden-state-(type=hidden):attr-input-step" class=no-backref><a href=#attr-input-step>step</a></code>, and
   <code id="hidden-state-(type=hidden):attr-dim-width" class=no-backref><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" class=no-backref><a href=#dom-input-checked>checked</a></code>,
   <code id="hidden-state-(type=hidden):dom-input-files" class=no-backref><a href=#dom-input-files>files</a></code>,
   <code id="hidden-state-(type=hidden):dom-input-list" class=no-backref><a href=#dom-input-list>list</a></code>,
   <code id="hidden-state-(type=hidden):dom-textarea/input-selectionstart" class=no-backref><a href=#dom-textarea/input-selectionstart>selectionStart</a></code>,
   <code id="hidden-state-(type=hidden):dom-textarea/input-selectionend" class=no-backref><a href=#dom-textarea/input-selectionend>selectionEnd</a></code>,
   <code id="hidden-state-(type=hidden):dom-textarea/input-selectiondirection" class=no-backref><a href=#dom-textarea/input-selectiondirection>selectionDirection</a></code>,
   <code id="hidden-state-(type=hidden):dom-input-valueasdate" class=no-backref><a href=#dom-input-valueasdate>valueAsDate</a></code>, and
   <code id="hidden-state-(type=hidden):dom-input-valueasnumber" class=no-backref><a href=#dom-input-valueasnumber>valueAsNumber</a></code> IDL attributes;
   <code id="hidden-state-(type=hidden):dom-textarea/input-select" class=no-backref><a href=#dom-textarea/input-select>select()</a></code>,
   <code id="hidden-state-(type=hidden):dom-textarea/input-setrangetext" class=no-backref><a href=#dom-textarea/input-setrangetext>setRangeText()</a></code>,
   <code id="hidden-state-(type=hidden):dom-textarea/input-setselectionrange" class=no-backref><a href=#dom-textarea/input-setselectionrange>setSelectionRange()</a></code>,
   <code id="hidden-state-(type=hidden):dom-input-stepdown" class=no-backref><a href=#dom-input-stepdown>stepDown()</a></code>, and
   <code id="hidden-state-(type=hidden):dom-input-stepup" class=no-backref><a href=#dom-input-stepup>stepUp()</a></code> methods.</p>

   <p>The <code id="hidden-state-(type=hidden):event-input" class=no-backref><a href=#event-input>input</a></code> and <code id="hidden-state-(type=hidden):event-change" class=no-backref><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>Text</dfn> (<code>type=text</code>) state and <dfn>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=status><input onclick=toggleStatus(this) value=⋰ type=button><p class=support><strong>Support:</strong> input-search<span class="and_chr yes"><span>Chrome for Android</span> <span>67+</span></span><span class="chrome yes"><span>Chrome</span> <span>15+</span></span><span class="ios_saf yes"><span>iOS Safari</span> <span>5.0+</span></span><span class="and_uc yes"><span>UC Browser for Android</span> <span>11.8+</span></span><span class="firefox yes"><span>Firefox</span> <span>4+</span></span><span class="ie yes"><span>IE</span> <span>10+</span></span><span class="op_mini yes"><span>Opera Mini</span> <span>all+</span></span><span class="safari yes"><span>Safari</span> <span>5.1+</span></span><span class="edge yes"><span>Edge</span> <span>12+</span></span><span class="samsung yes"><span>Samsung Internet</span> <span>4+</span></span><span class="opera yes"><span>Opera</span> <span>11.6+</span></span><span class="android yes"><span>Android Browser</span> <span>2.3+</span></span><p class=caniuse>Source: <a href="https://caniuse.com/#feat=input-search">caniuse.com</a></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>

  
  
  <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):the-dir-attribute"><a href=#the-dir-attribute>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.<li><p><a href=#queue-a-task id="text-(type=text)-state-and-search-state-(type=search):queue-a-task">Queue a task</a> 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 href=#event-input>input</a></code> at the <code id="text-(type=text)-state-and-search-state-(type=search):the-input-element-3"><a href=#the-input-element>input</a></code> 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> attribute initialized to true.</ol>

  

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

  

  <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 class=bookkeeping>

   <p>The following common <code id="text-(type=text)-state-and-search-state-(type=search):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="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 href=#event-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" class=no-backref><a href=#attr-input-accept>accept</a></code>,
   <code id="text-(type=text)-state-and-search-state-(type=search):attr-input-alt" class=no-backref><a href=#attr-input-alt>alt</a></code>,
   <code id="text-(type=text)-state-and-search-state-(type=search):attr-input-checked" class=no-backref><a href=#attr-input-checked>checked</a></code>,
   <code id="text-(type=text)-state-and-search-state-(type=search):attr-fs-formaction" class=no-backref><a href=#attr-fs-formaction>formaction</a></code>,
   <code id="text-(type=text)-state-and-search-state-(type=search):attr-fs-formenctype" class=no-backref><a href=#attr-fs-formenctype>formenctype</a></code>,
   <code id="text-(type=text)-state-and-search-state-(type=search):attr-fs-formmethod" class=no-backref><a href=#attr-fs-formmethod>formmethod</a></code>,
   <code id="text-(type=text)-state-and-search-state-(type=search):attr-fs-formnovalidate" class=no-backref><a href=#attr-fs-formnovalidate>formnovalidate</a></code>,
   <code id="text-(type=text)-state-and-search-state-(type=search):attr-fs-formtarget" class=no-backref><a href=#attr-fs-formtarget>formtarget</a></code>,
   <code id="text-(type=text)-state-and-search-state-(type=search):attr-dim-height" class=no-backref><a href=#attr-dim-height>height</a></code>,
   <code id="text-(type=text)-state-and-search-state-(type=search):attr-input-max" class=no-backref><a href=#attr-input-max>max</a></code>,
   <code id="text-(type=text)-state-and-search-state-(type=search):attr-input-min" class=no-backref><a href=#attr-input-min>min</a></code>,
   <code id="text-(type=text)-state-and-search-state-(type=search):attr-input-multiple" class=no-backref><a href=#attr-input-multiple>multiple</a></code>,
   <code id="text-(type=text)-state-and-search-state-(type=search):attr-input-src" class=no-backref><a href=#attr-input-src>src</a></code>,
   <code id="text-(type=text)-state-and-search-state-(type=search):attr-input-step" class=no-backref><a href=#attr-input-step>step</a></code>, and
   <code id="text-(type=text)-state-and-search-state-(type=search):attr-dim-width" class=no-backref><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" class=no-backref><a href=#dom-input-checked>checked</a></code>,
   <code id="text-(type=text)-state-and-search-state-(type=search):dom-input-files" class=no-backref><a href=#dom-input-files>files</a></code>,
   <code id="text-(type=text)-state-and-search-state-(type=search):dom-input-valueasdate" class=no-backref><a href=#dom-input-valueasdate>valueAsDate</a></code>, and
   <code id="text-(type=text)-state-and-search-state-(type=search):dom-input-valueasnumber" class=no-backref><a href=#dom-input-valueasnumber>valueAsNumber</a></code> IDL attributes;
   <code id="text-(type=text)-state-and-search-state-(type=search):dom-input-stepdown" class=no-backref><a href=#dom-input-stepdown>stepDown()</a></code> and
   <code id="text-(type=text)-state-and-search-state-(type=search):dom-input-stepup" class=no-backref><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>Telephone</dfn> state (<code>type=tel</code>)<a href="#telephone-state-(type=tel)" class=self-link></a></h6><div class=status><input onclick=toggleStatus(this) value=⋰ type=button><p class=support><strong>Support:</strong> input-email-tel-url<span class="and_chr yes"><span>Chrome for Android</span> <span>67+</span></span><span class="chrome yes"><span>Chrome</span> <span>5+</span></span><span class="ios_saf yes"><span>iOS Safari</span> <span>3.2+</span></span><span class="and_uc yes"><span>UC Browser for Android</span> <span>11.8+</span></span><span class="firefox yes"><span>Firefox</span> <span>4+</span></span><span class="ie yes"><span>IE</span> <span>10+</span></span><span class="op_mini no"><span>Opera Mini</span> <span>None</span></span><span class="safari yes"><span>Safari</span> <span>5+</span></span><span class="edge yes"><span>Edge</span> <span>12+</span></span><span class="samsung yes"><span>Samsung Internet</span> <span>4+</span></span><span class="opera yes"><span>Opera</span> <span>9.5+</span></span><span class="android yes"><span>Android Browser</span> <span>3+</span></span><p class=caniuse>Source: <a href="https://caniuse.com/#feat=input-email-tel-url">caniuse.com</a></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>

  

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

  

  <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="#e-mail-state-(type=email)" id="telephone-state-(type=tel):e-mail-state-(type=email)">E-mail</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-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 href=#event-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" class=no-backref><a href=#attr-input-accept>accept</a></code>,
   <code id="telephone-state-(type=tel):attr-input-alt" class=no-backref><a href=#attr-input-alt>alt</a></code>,
   <code id="telephone-state-(type=tel):attr-input-checked" class=no-backref><a href=#attr-input-checked>checked</a></code>,
   <code id="telephone-state-(type=tel):attr-fe-dirname" class=no-backref><a href=#attr-fe-dirname>dirname</a></code>,
   <code id="telephone-state-(type=tel):attr-fs-formaction" class=no-backref><a href=#attr-fs-formaction>formaction</a></code>,
   <code id="telephone-state-(type=tel):attr-fs-formenctype" class=no-backref><a href=#attr-fs-formenctype>formenctype</a></code>,
   <code id="telephone-state-(type=tel):attr-fs-formmethod" class=no-backref><a href=#attr-fs-formmethod>formmethod</a></code>,
   <code id="telephone-state-(type=tel):attr-fs-formnovalidate" class=no-backref><a href=#attr-fs-formnovalidate>formnovalidate</a></code>,
   <code id="telephone-state-(type=tel):attr-fs-formtarget" class=no-backref><a href=#attr-fs-formtarget>formtarget</a></code>,
   <code id="telephone-state-(type=tel):attr-dim-height" class=no-backref><a href=#attr-dim-height>height</a></code>,
   <code id="telephone-state-(type=tel):attr-input-max" class=no-backref><a href=#attr-input-max>max</a></code>,
   <code id="telephone-state-(type=tel):attr-input-min" class=no-backref><a href=#attr-input-min>min</a></code>,
   <code id="telephone-state-(type=tel):attr-input-multiple" class=no-backref><a href=#attr-input-multiple>multiple</a></code>,
   <code id="telephone-state-(type=tel):attr-input-src" class=no-backref><a href=#attr-input-src>src</a></code>,
   <code id="telephone-state-(type=tel):attr-input-step" class=no-backref><a href=#attr-input-step>step</a></code>, and
   <code id="telephone-state-(type=tel):attr-dim-width" class=no-backref><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" class=no-backref><a href=#dom-input-checked>checked</a></code>,
   <code id="telephone-state-(type=tel):dom-input-files" class=no-backref><a href=#dom-input-files>files</a></code>,
   <code id="telephone-state-(type=tel):dom-input-valueasdate" class=no-backref><a href=#dom-input-valueasdate>valueAsDate</a></code>, and
   <code id="telephone-state-(type=tel):dom-input-valueasnumber" class=no-backref><a href=#dom-input-valueasnumber>valueAsNumber</a></code> IDL attributes;
   <code id="telephone-state-(type=tel):dom-input-stepdown" class=no-backref><a href=#dom-input-stepdown>stepDown()</a></code> and
   <code id="telephone-state-(type=tel):dom-input-stepup" class=no-backref><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>URL</dfn> state (<code>type=url</code>)<a href="#url-state-(type=url)" class=self-link></a></h6>

  

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

  

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

  <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 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-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 href=#event-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" class=no-backref><a href=#attr-input-accept>accept</a></code>,
   <code id="url-state-(type=url):attr-input-alt" class=no-backref><a href=#attr-input-alt>alt</a></code>,
   <code id="url-state-(type=url):attr-input-checked" class=no-backref><a href=#attr-input-checked>checked</a></code>,
   <code id="url-state-(type=url):attr-fe-dirname" class=no-backref><a href=#attr-fe-dirname>dirname</a></code>,
   <code id="url-state-(type=url):attr-fs-formaction" class=no-backref><a href=#attr-fs-formaction>formaction</a></code>,
   <code id="url-state-(type=url):attr-fs-formenctype" class=no-backref><a href=#attr-fs-formenctype>formenctype</a></code>,
   <code id="url-state-(type=url):attr-fs-formmethod" class=no-backref><a href=#attr-fs-formmethod>formmethod</a></code>,
   <code id="url-state-(type=url):attr-fs-formnovalidate" class=no-backref><a href=#attr-fs-formnovalidate>formnovalidate</a></code>,
   <code id="url-state-(type=url):attr-fs-formtarget" class=no-backref><a href=#attr-fs-formtarget>formtarget</a></code>,
   <code id="url-state-(type=url):attr-dim-height" class=no-backref><a href=#attr-dim-height>height</a></code>,
   <code id="url-state-(type=url):attr-input-max" class=no-backref><a href=#attr-input-max>max</a></code>,
   <code id="url-state-(type=url):attr-input-min" class=no-backref><a href=#attr-input-min>min</a></code>,
   <code id="url-state-(type=url):attr-input-multiple" class=no-backref><a href=#attr-input-multiple>multiple</a></code>,
   <code id="url-state-(type=url):attr-input-src" class=no-backref><a href=#attr-input-src>src</a></code>,
   <code id="url-state-(type=url):attr-input-step" class=no-backref><a href=#attr-input-step>step</a></code>, and
   <code id="url-state-(type=url):attr-dim-width" class=no-backref><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" class=no-backref><a href=#dom-input-checked>checked</a></code>,
   <code id="url-state-(type=url):dom-input-files" class=no-backref><a href=#dom-input-files>files</a></code>,
   <code id="url-state-(type=url):dom-input-valueasdate" class=no-backref><a href=#dom-input-valueasdate>valueAsDate</a></code>, and
   <code id="url-state-(type=url):dom-input-valueasnumber" class=no-backref><a href=#dom-input-valueasnumber>valueAsNumber</a></code> IDL attributes;
   <code id="url-state-(type=url):dom-input-stepdown" class=no-backref><a href=#dom-input-stepdown>stepDown()</a></code> and
   <code id="url-state-(type=url):dom-input-stepup" class=no-backref><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>&quot;url&quot;</c-> <c- e>name</c-><c- o>=</c-><c- s>&quot;location&quot;</c-> <c- e>list</c-><c- o>=</c-><c- s>&quot;urls&quot;</c-><c- p>&gt;</c->
<c- p>&lt;</c-><c- f>datalist</c-> <c- e>id</c-><c- o>=</c-><c- s>&quot;urls&quot;</c-><c- p>&gt;</c->
 <c- p>&lt;</c-><c- f>option</c-> <c- e>label</c-><c- o>=</c-><c- s>&quot;MIME: Format of Internet Message Bodies&quot;</c-> <c- e>value</c-><c- o>=</c-><c- s>&quot;https://tools.ietf.org/html/rfc2045&quot;</c-><c- p>&gt;</c->
 <c- p>&lt;</c-><c- f>option</c-> <c- e>label</c-><c- o>=</c-><c- s>&quot;HTML&quot;</c-> <c- e>value</c-><c- o>=</c-><c- s>&quot;https://html.spec.whatwg.org/&quot;</c-><c- p>&gt;</c->
 <c- p>&lt;</c-><c- f>option</c-> <c- e>label</c-><c- o>=</c-><c- s>&quot;DOM&quot;</c-> <c- e>value</c-><c- o>=</c-><c- s>&quot;https://dom.spec.whatwg.org/&quot;</c-><c- p>&gt;</c->
 <c- p>&lt;</c-><c- f>option</c-> <c- e>label</c-><c- o>=</c-><c- s>&quot;Fullscreen&quot;</c-> <c- e>value</c-><c- o>=</c-><c- s>&quot;https://fullscreen.spec.whatwg.org/&quot;</c-><c- p>&gt;</c->
 <c- p>&lt;</c-><c- f>option</c-> <c- e>label</c-><c- o>=</c-><c- s>&quot;Media Session&quot;</c-> <c- e>value</c-><c- o>=</c-><c- s>&quot;https://mediasession.spec.whatwg.org/&quot;</c-><c- p>&gt;</c->
 <c- p>&lt;</c-><c- f>option</c-> <c- e>label</c-><c- o>=</c-><c- s>&quot;The Single UNIX Specification, Version 3&quot;</c-> <c- e>value</c-><c- o>=</c-><c- s>&quot;http://www.unix.org/version3/&quot;</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 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 scroll bar 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 UA-defined 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="e-mail-state-(type=email)"><span class=secno>4.10.5.1.5</span> <dfn>E-mail</dfn> state (<code>type=email</code>)<a href="#e-mail-state-(type=email)" class=self-link></a></h6>

  

  <p>When an <code id="e-mail-state-(type=email):the-input-element"><a href=#the-input-element>input</a></code> element's <code id="e-mail-state-(type=email):attr-input-type"><a href=#attr-input-type>type</a></code> attribute is in
  the <a href="#e-mail-state-(type=email)" id="e-mail-state-(type=email):e-mail-state-(type=email)">E-mail</a> state, the rules in this section apply.</p>

  

  <p>How the <a href="#e-mail-state-(type=email)" id="e-mail-state-(type=email):e-mail-state-(type=email)-2">E-mail</a> state operates depends on whether the
  <code id="e-mail-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="e-mail-state-(type=email):attr-input-multiple-2"><a href=#attr-input-multiple>multiple</a></code> attribute is not specified on the
   element<dd>

    <p>The <code id="e-mail-state-(type=email):the-input-element-2"><a href=#the-input-element>input</a></code> element <a href=#represents id="e-mail-state-(type=email):represents">represents</a> a control for editing an e-mail
    address given in the element's <a href=#concept-fe-value id="e-mail-state-(type=email):concept-fe-value">value</a>.</p>

    

    <p>If the element is <i id="e-mail-state-(type=email):concept-fe-mutable"><a href=#concept-fe-mutable>mutable</a></i>, the user agent should allow the
    user to change the e-mail address represented by its <a href=#concept-fe-value id="e-mail-state-(type=email):concept-fe-value-2">value</a>. User agents may allow the user to set the <a href=#concept-fe-value id="e-mail-state-(type=email):concept-fe-value-3">value</a> to a string that is not a <a href=#valid-e-mail-address id="e-mail-state-(type=email):valid-e-mail-address">valid e-mail
    address</a>. The user agent should act in a manner consistent with expecting the user to
    provide a single e-mail address. User agents should allow the user to set the <a href=#concept-fe-value id="e-mail-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="e-mail-state-(type=email):concept-fe-value-5">value</a>. User agents may transform the <a href=#concept-fe-value id="e-mail-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="e-mail-state-(type=email):concept-fe-value-7">value</a> to IDN in the display and
    vice versa.</p>

    <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="e-mail-state-(type=email):suffering-from-bad-input">suffering from bad
    input</a>.</p>

    

    <p>The <code id="e-mail-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="e-mail-state-(type=email):valid-e-mail-address-2">valid e-mail address</a>.</p>

    

    <p><strong>The <a href=#value-sanitization-algorithm id="e-mail-state-(type=email):value-sanitization-algorithm">value sanitization algorithm</a> is as follows</strong>: <a id="e-mail-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="e-mail-state-(type=email):concept-fe-value-8">value</a>, then <a id="e-mail-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="e-mail-state-(type=email):concept-fe-value-9">value</a>.</p>

    <p><strong>Constraint validation</strong>: While the <a href=#concept-fe-value id="e-mail-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="e-mail-state-(type=email):valid-e-mail-address-3">valid e-mail address</a>, the
    element is <a href=#suffering-from-a-type-mismatch id="e-mail-state-(type=email):suffering-from-a-type-mismatch">suffering from a type mismatch</a>.</p>

    

   <dt>When the <code id="e-mail-state-(type=email):attr-input-multiple-3"><a href=#attr-input-multiple>multiple</a></code> attribute <em>is</em> specified on
   the element<dd>

    <p>The <code id="e-mail-state-(type=email):the-input-element-3"><a href=#the-input-element>input</a></code> element <a href=#represents id="e-mail-state-(type=email):represents-2">represents</a> a control for adding, removing, and
    editing the e-mail addresses given in the element's <a href=#concept-fe-values id="e-mail-state-(type=email):concept-fe-values">value<em>s</em></a>.</p>

    

    <p>If the element is <i id="e-mail-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 e-mail addresses represented by its <a href=#concept-fe-values id="e-mail-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="e-mail-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="e-mail-state-(type=email):valid-e-mail-address-4">valid e-mail 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="e-mail-state-(type=email):concept-fe-values-3">values</a>. User agents may
    transform the <a href=#concept-fe-values id="e-mail-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="e-mail-state-(type=email):concept-fe-value-12">value</a> to IDN in the display and vice versa.</p>

    <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="e-mail-state-(type=email):suffering-from-bad-input-2">suffering from bad input</a>.</p>

    <p>Whenever the user changes the element's <a href=#concept-fe-value id="e-mail-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="e-mail-state-(type=email):concept-fe-value-14">value<em>s</em></a>.<li><p><a id="e-mail-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>.<li><p>Let the element's <a href=#concept-fe-value id="e-mail-state-(type=email):concept-fe-value-15">value</a> be 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.</ol>

    

    <p>The <code id="e-mail-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="e-mail-state-(type=email):valid-e-mail-address-list">valid e-mail address list</a>.</p>

    

    <p><strong>The <a href=#value-sanitization-algorithm id="e-mail-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="e-mail-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="e-mail-state-(type=email):concept-fe-value-16">value</a>, <a id="e-mail-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="e-mail-state-(type=email):concept-fe-values-5">values</a> be the (possibly empty) resulting list of
     (possibly empty) tokens, maintaining the original order.<li><p>Let the element's <a href=#concept-fe-value id="e-mail-state-(type=email):concept-fe-value-17">value</a> be the result of
     concatenating the element's <a href=#concept-fe-values id="e-mail-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.</ol>

    <p><strong>Constraint validation</strong>: While the <a href=#concept-fe-value id="e-mail-state-(type=email):concept-fe-value-18">value</a>
    of the element is not a <a href=#valid-e-mail-address-list id="e-mail-state-(type=email):valid-e-mail-address-list-2">valid e-mail address list</a>, the element is <a href=#suffering-from-a-type-mismatch id="e-mail-state-(type=email):suffering-from-a-type-mismatch-2">suffering
    from a type mismatch</a>.</p>

    

   </dl>

  <p>When the <code id="e-mail-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="e-mail-state-(type=email):value-sanitization-algorithm-3">value sanitization algorithm</a>.</p>

  <p>A <dfn id=valid-e-mail-address>valid e-mail 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>&quot;.&quot;</c-> <c- p>)</c-> <c- l>&quot;@&quot;</c-> <c- nc>label</c-> <c- o>*</c-><c- p>(</c-> <c- l>&quot;.&quot;</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://tools.ietf.org/html/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://tools.ietf.org/html/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://tools.ietf.org/html/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://tools.ietf.org/html/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>

  

  <p class=note>This requirement is a <a href=#willful-violation id="e-mail-state-(type=email):willful-violation">willful violation</a> of RFC 5322, which defines a
  syntax for e-mail 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>

  <p>A <dfn id=valid-e-mail-address-list>valid e-mail address list</dfn> is a <a href=#set-of-comma-separated-tokens id="e-mail-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="e-mail-state-(type=email):valid-e-mail-address-5">valid e-mail address</a>. To obtain the list of
  tokens from a <a href=#valid-e-mail-address-list id="e-mail-state-(type=email):valid-e-mail-address-list-3">valid e-mail address list</a>, an implementation must <a href=https://infra.spec.whatwg.org/#split-on-commas id="e-mail-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 class=bookkeeping>

   <p>The following common <code id="e-mail-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="e-mail-state-(type=email):concept-input-apply">apply</a> to the element:
   <code id="e-mail-state-(type=email):attr-fe-autocomplete"><a href=#attr-fe-autocomplete>autocomplete</a></code>,
   <code id="e-mail-state-(type=email):attr-input-list"><a href=#attr-input-list>list</a></code>,
   <code id="e-mail-state-(type=email):attr-input-maxlength"><a href=#attr-input-maxlength>maxlength</a></code>,
   <code id="e-mail-state-(type=email):attr-input-minlength"><a href=#attr-input-minlength>minlength</a></code>,
   <code id="e-mail-state-(type=email):attr-input-multiple-5"><a href=#attr-input-multiple>multiple</a></code>,
   <code id="e-mail-state-(type=email):attr-input-pattern"><a href=#attr-input-pattern>pattern</a></code>,
   <code id="e-mail-state-(type=email):attr-input-placeholder"><a href=#attr-input-placeholder>placeholder</a></code>,
   <code id="e-mail-state-(type=email):attr-input-readonly"><a href=#attr-input-readonly>readonly</a></code>,
   <code id="e-mail-state-(type=email):attr-input-required"><a href=#attr-input-required>required</a></code>, and
   <code id="e-mail-state-(type=email):attr-input-size"><a href=#attr-input-size>size</a></code> content attributes;
   <code id="e-mail-state-(type=email):dom-input-list"><a href=#dom-input-list>list</a></code> and
   <code id="e-mail-state-(type=email):dom-input-value"><a href=#dom-input-value>value</a></code> IDL attributes;
   <code id="e-mail-state-(type=email):dom-textarea/input-select"><a href=#dom-textarea/input-select>select()</a></code> method.</p>



   <p>The <code id="e-mail-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="e-mail-state-(type=email):dom-input-value-value">value</a>.</p>

   <p>The <code id="e-mail-state-(type=email):event-input"><a href=#event-input>input</a></code> and <code id="e-mail-state-(type=email):event-change"><a href=#event-change>change</a></code> events <a href=#concept-input-apply id="e-mail-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="e-mail-state-(type=email):do-not-apply">do not
   apply</a> to the element:
   <code id="e-mail-state-(type=email):attr-input-accept" class=no-backref><a href=#attr-input-accept>accept</a></code>,
   <code id="e-mail-state-(type=email):attr-input-alt" class=no-backref><a href=#attr-input-alt>alt</a></code>,
   <code id="e-mail-state-(type=email):attr-input-checked" class=no-backref><a href=#attr-input-checked>checked</a></code>,
   <code id="e-mail-state-(type=email):attr-fe-dirname" class=no-backref><a href=#attr-fe-dirname>dirname</a></code>,
   <code id="e-mail-state-(type=email):attr-fs-formaction" class=no-backref><a href=#attr-fs-formaction>formaction</a></code>,
   <code id="e-mail-state-(type=email):attr-fs-formenctype" class=no-backref><a href=#attr-fs-formenctype>formenctype</a></code>,
   <code id="e-mail-state-(type=email):attr-fs-formmethod" class=no-backref><a href=#attr-fs-formmethod>formmethod</a></code>,
   <code id="e-mail-state-(type=email):attr-fs-formnovalidate" class=no-backref><a href=#attr-fs-formnovalidate>formnovalidate</a></code>,
   <code id="e-mail-state-(type=email):attr-fs-formtarget" class=no-backref><a href=#attr-fs-formtarget>formtarget</a></code>,
   <code id="e-mail-state-(type=email):attr-dim-height" class=no-backref><a href=#attr-dim-height>height</a></code>,
   <code id="e-mail-state-(type=email):attr-input-max" class=no-backref><a href=#attr-input-max>max</a></code>,
   <code id="e-mail-state-(type=email):attr-input-min" class=no-backref><a href=#attr-input-min>min</a></code>,
   <code id="e-mail-state-(type=email):attr-input-src" class=no-backref><a href=#attr-input-src>src</a></code>,
   <code id="e-mail-state-(type=email):attr-input-step" class=no-backref><a href=#attr-input-step>step</a></code>, and
   <code id="e-mail-state-(type=email):attr-dim-width" class=no-backref><a href=#attr-dim-width>width</a></code>.</p>

   <p>The following IDL attributes and methods <a href=#do-not-apply id="e-mail-state-(type=email):do-not-apply-2">do not apply</a> to the
   element:
   <code id="e-mail-state-(type=email):dom-input-checked" class=no-backref><a href=#dom-input-checked>checked</a></code>,
   <code id="e-mail-state-(type=email):dom-input-files" class=no-backref><a href=#dom-input-files>files</a></code>,
   <code id="e-mail-state-(type=email):dom-textarea/input-selectionstart" class=no-backref><a href=#dom-textarea/input-selectionstart>selectionStart</a></code>,
   <code id="e-mail-state-(type=email):dom-textarea/input-selectionend" class=no-backref><a href=#dom-textarea/input-selectionend>selectionEnd</a></code>,
   <code id="e-mail-state-(type=email):dom-textarea/input-selectiondirection" class=no-backref><a href=#dom-textarea/input-selectiondirection>selectionDirection</a></code>,
   <code id="e-mail-state-(type=email):dom-input-valueasdate" class=no-backref><a href=#dom-input-valueasdate>valueAsDate</a></code>, and
   <code id="e-mail-state-(type=email):dom-input-valueasnumber" class=no-backref><a href=#dom-input-valueasnumber>valueAsNumber</a></code> IDL attributes;
   <code id="e-mail-state-(type=email):dom-textarea/input-setrangetext" class=no-backref><a href=#dom-textarea/input-setrangetext>setRangeText()</a></code>,
   <code id="e-mail-state-(type=email):dom-textarea/input-setselectionrange" class=no-backref><a href=#dom-textarea/input-setselectionrange>setSelectionRange()</a></code>,
   <code id="e-mail-state-(type=email):dom-input-stepdown" class=no-backref><a href=#dom-input-stepdown>stepDown()</a></code> and
   <code id="e-mail-state-(type=email):dom-input-stepup" class=no-backref><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>Password</dfn> state (<code>type=password</code>)<a href="#password-state-(type=password)" class=self-link></a></h6>

  

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

  

  <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 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-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 href=#event-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" class=no-backref><a href=#attr-input-accept>accept</a></code>,
   <code id="password-state-(type=password):attr-input-alt" class=no-backref><a href=#attr-input-alt>alt</a></code>,
   <code id="password-state-(type=password):attr-input-checked" class=no-backref><a href=#attr-input-checked>checked</a></code>,
   <code id="password-state-(type=password):attr-fe-dirname" class=no-backref><a href=#attr-fe-dirname>dirname</a></code>,
   <code id="password-state-(type=password):attr-fs-formaction" class=no-backref><a href=#attr-fs-formaction>formaction</a></code>,
   <code id="password-state-(type=password):attr-fs-formenctype" class=no-backref><a href=#attr-fs-formenctype>formenctype</a></code>,
   <code id="password-state-(type=password):attr-fs-formmethod" class=no-backref><a href=#attr-fs-formmethod>formmethod</a></code>,
   <code id="password-state-(type=password):attr-fs-formnovalidate" class=no-backref><a href=#attr-fs-formnovalidate>formnovalidate</a></code>,
   <code id="password-state-(type=password):attr-fs-formtarget" class=no-backref><a href=#attr-fs-formtarget>formtarget</a></code>,
   <code id="password-state-(type=password):attr-dim-height" class=no-backref><a href=#attr-dim-height>height</a></code>,
   <code id="password-state-(type=password):attr-input-list" class=no-backref><a href=#attr-input-list>list</a></code>,
   <code id="password-state-(type=password):attr-input-max" class=no-backref><a href=#attr-input-max>max</a></code>,
   <code id="password-state-(type=password):attr-input-min" class=no-backref><a href=#attr-input-min>min</a></code>,
   <code id="password-state-(type=password):attr-input-multiple" class=no-backref><a href=#attr-input-multiple>multiple</a></code>,
   <code id="password-state-(type=password):attr-input-src" class=no-backref><a href=#attr-input-src>src</a></code>,
   <code id="password-state-(type=password):attr-input-step" class=no-backref><a href=#attr-input-step>step</a></code>, and
   <code id="password-state-(type=password):attr-dim-width" class=no-backref><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" class=no-backref><a href=#dom-input-checked>checked</a></code>,
   <code id="password-state-(type=password):dom-input-files" class=no-backref><a href=#dom-input-files>files</a></code>,
   <code id="password-state-(type=password):dom-input-list" class=no-backref><a href=#dom-input-list>list</a></code>,
   <code id="password-state-(type=password):dom-input-valueasdate" class=no-backref><a href=#dom-input-valueasdate>valueAsDate</a></code>, and
   <code id="password-state-(type=password):dom-input-valueasnumber" class=no-backref><a href=#dom-input-valueasnumber>valueAsNumber</a></code> IDL attributes;
   <code id="password-state-(type=password):dom-input-stepdown" class=no-backref><a href=#dom-input-stepdown>stepDown()</a></code> and
   <code id="password-state-(type=password):dom-input-stepup" class=no-backref><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>Date</dfn> state (<code>type=date</code>)<a href="#date-state-(type=date)" class=self-link></a></h6><div class=status><input onclick=toggleStatus(this) value=⋰ type=button><p class=support><strong>Support:</strong> input-datetime<span class="and_chr yes"><span>Chrome for Android</span> <span>67+</span></span><span class="chrome yes"><span>Chrome</span> <span>25+</span></span><span class="ios_saf partial"><span>iOS Safari (limited)</span> <span>5.0+</span></span><span class="and_uc yes"><span>UC Browser for Android</span> <span>11.8+</span></span><span class="firefox partial"><span>Firefox (limited)</span> <span>57+</span></span><span class="ie no"><span>IE</span> <span>None</span></span><span class="op_mini no"><span>Opera Mini</span> <span>None</span></span><span class="safari no"><span>Safari</span> <span>None</span></span><span class="edge yes"><span>Edge</span> <span>13+</span></span><span class="samsung yes"><span>Samsung Internet</span> <span>4+</span></span><span class="opera yes"><span>Opera</span> <span>9+</span></span><span class="android yes"><span>Android Browser</span> <span>4.4+</span></span><p class=caniuse>Source: <a href="https://caniuse.com/#feat=input-datetime">caniuse.com</a></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>

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

  

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

  

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

  

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

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

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

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

  <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.github.io/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 id=only-contemporary-times class=note>

   <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 href=#event-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" class=no-backref><a href=#attr-input-accept>accept</a></code>,
   <code id="date-state-(type=date):attr-input-alt" class=no-backref><a href=#attr-input-alt>alt</a></code>,
   <code id="date-state-(type=date):attr-input-checked" class=no-backref><a href=#attr-input-checked>checked</a></code>,
   <code id="date-state-(type=date):attr-fe-dirname" class=no-backref><a href=#attr-fe-dirname>dirname</a></code>,
   <code id="date-state-(type=date):attr-fs-formaction" class=no-backref><a href=#attr-fs-formaction>formaction</a></code>,
   <code id="date-state-(type=date):attr-fs-formenctype" class=no-backref><a href=#attr-fs-formenctype>formenctype</a></code>,
   <code id="date-state-(type=date):attr-fs-formmethod" class=no-backref><a href=#attr-fs-formmethod>formmethod</a></code>,
   <code id="date-state-(type=date):attr-fs-formnovalidate" class=no-backref><a href=#attr-fs-formnovalidate>formnovalidate</a></code>,
   <code id="date-state-(type=date):attr-fs-formtarget" class=no-backref><a href=#attr-fs-formtarget>formtarget</a></code>,
   <code id="date-state-(type=date):attr-dim-height" class=no-backref><a href=#attr-dim-height>height</a></code>,
   <code id="date-state-(type=date):attr-input-maxlength" class=no-backref><a href=#attr-input-maxlength>maxlength</a></code>,
   <code id="date-state-(type=date):attr-input-minlength" class=no-backref><a href=#attr-input-minlength>minlength</a></code>,
   <code id="date-state-(type=date):attr-input-multiple" class=no-backref><a href=#attr-input-multiple>multiple</a></code>,
   <code id="date-state-(type=date):attr-input-pattern" class=no-backref><a href=#attr-input-pattern>pattern</a></code>,
   <code id="date-state-(type=date):attr-input-placeholder" class=no-backref><a href=#attr-input-placeholder>placeholder</a></code>,
   <code id="date-state-(type=date):attr-input-size" class=no-backref><a href=#attr-input-size>size</a></code>,
   <code id="date-state-(type=date):attr-input-src" class=no-backref><a href=#attr-input-src>src</a></code>, and
   <code id="date-state-(type=date):attr-dim-width" class=no-backref><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" class=no-backref><a href=#dom-input-checked>checked</a></code>,
   <code id="date-state-(type=date):dom-textarea/input-selectionstart" class=no-backref><a href=#dom-textarea/input-selectionstart>selectionStart</a></code>,
   <code id="date-state-(type=date):dom-textarea/input-selectionend" class=no-backref><a href=#dom-textarea/input-selectionend>selectionEnd</a></code>, and
   <code id="date-state-(type=date):dom-textarea/input-selectiondirection" class=no-backref><a href=#dom-textarea/input-selectiondirection>selectionDirection</a></code> IDL attributes;
   <code id="date-state-(type=date):dom-textarea/input-setrangetext" class=no-backref><a href=#dom-textarea/input-setrangetext>setRangeText()</a></code>, and
   <code id="date-state-(type=date):dom-textarea/input-setselectionrange" class=no-backref><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>Month</dfn> state (<code>type=month</code>)<a href="#month-state-(type=month)" class=self-link></a></h6>

  

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

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

  

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

  

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

  

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

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

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

  

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

  <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.github.io/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 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 href=#event-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" class=no-backref><a href=#attr-input-accept>accept</a></code>,
   <code id="month-state-(type=month):attr-input-alt" class=no-backref><a href=#attr-input-alt>alt</a></code>,
   <code id="month-state-(type=month):attr-input-checked" class=no-backref><a href=#attr-input-checked>checked</a></code>,
   <code id="month-state-(type=month):attr-fe-dirname" class=no-backref><a href=#attr-fe-dirname>dirname</a></code>,
   <code id="month-state-(type=month):attr-fs-formaction" class=no-backref><a href=#attr-fs-formaction>formaction</a></code>,
   <code id="month-state-(type=month):attr-fs-formenctype" class=no-backref><a href=#attr-fs-formenctype>formenctype</a></code>,
   <code id="month-state-(type=month):attr-fs-formmethod" class=no-backref><a href=#attr-fs-formmethod>formmethod</a></code>,
   <code id="month-state-(type=month):attr-fs-formnovalidate" class=no-backref><a href=#attr-fs-formnovalidate>formnovalidate</a></code>,
   <code id="month-state-(type=month):attr-fs-formtarget" class=no-backref><a href=#attr-fs-formtarget>formtarget</a></code>,
   <code id="month-state-(type=month):attr-dim-height" class=no-backref><a href=#attr-dim-height>height</a></code>,
   <code id="month-state-(type=month):attr-input-maxlength" class=no-backref><a href=#attr-input-maxlength>maxlength</a></code>,
   <code id="month-state-(type=month):attr-input-minlength" class=no-backref><a href=#attr-input-minlength>minlength</a></code>,
   <code id="month-state-(type=month):attr-input-multiple" class=no-backref><a href=#attr-input-multiple>multiple</a></code>,
   <code id="month-state-(type=month):attr-input-pattern" class=no-backref><a href=#attr-input-pattern>pattern</a></code>,
   <code id="month-state-(type=month):attr-input-placeholder" class=no-backref><a href=#attr-input-placeholder>placeholder</a></code>,
   <code id="month-state-(type=month):attr-input-size" class=no-backref><a href=#attr-input-size>size</a></code>,
   <code id="month-state-(type=month):attr-input-src" class=no-backref><a href=#attr-input-src>src</a></code>, and
   <code id="month-state-(type=month):attr-dim-width" class=no-backref><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" class=no-backref><a href=#dom-input-checked>checked</a></code>,
   <code id="month-state-(type=month):dom-input-files" class=no-backref><a href=#dom-input-files>files</a></code>,
   <code id="month-state-(type=month):dom-textarea/input-selectionstart" class=no-backref><a href=#dom-textarea/input-selectionstart>selectionStart</a></code>,
   <code id="month-state-(type=month):dom-textarea/input-selectionend" class=no-backref><a href=#dom-textarea/input-selectionend>selectionEnd</a></code>, and
   <code id="month-state-(type=month):dom-textarea/input-selectiondirection" class=no-backref><a href=#dom-textarea/input-selectiondirection>selectionDirection</a></code> IDL attributes;
   <code id="month-state-(type=month):dom-textarea/input-setrangetext" class=no-backref><a href=#dom-textarea/input-setrangetext>setRangeText()</a></code>, and
   <code id="month-state-(type=month):dom-textarea/input-setselectionrange" class=no-backref><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>Week</dfn> state (<code>type=week</code>)<a href="#week-state-(type=week)" class=self-link></a></h6>

  

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

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

  

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

  

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

  

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

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

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

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

  <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.github.io/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 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 href=#event-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" class=no-backref><a href=#attr-input-accept>accept</a></code>,
   <code id="week-state-(type=week):attr-input-alt" class=no-backref><a href=#attr-input-alt>alt</a></code>,
   <code id="week-state-(type=week):attr-input-checked" class=no-backref><a href=#attr-input-checked>checked</a></code>,
   <code id="week-state-(type=week):attr-fe-dirname" class=no-backref><a href=#attr-fe-dirname>dirname</a></code>,
   <code id="week-state-(type=week):attr-fs-formaction" class=no-backref><a href=#attr-fs-formaction>formaction</a></code>,
   <code id="week-state-(type=week):attr-fs-formenctype" class=no-backref><a href=#attr-fs-formenctype>formenctype</a></code>,
   <code id="week-state-(type=week):attr-fs-formmethod" class=no-backref><a href=#attr-fs-formmethod>formmethod</a></code>,
   <code id="week-state-(type=week):attr-fs-formnovalidate" class=no-backref><a href=#attr-fs-formnovalidate>formnovalidate</a></code>,
   <code id="week-state-(type=week):attr-fs-formtarget" class=no-backref><a href=#attr-fs-formtarget>formtarget</a></code>,
   <code id="week-state-(type=week):attr-dim-height" class=no-backref><a href=#attr-dim-height>height</a></code>,
   <code id="week-state-(type=week):attr-input-maxlength" class=no-backref><a href=#attr-input-maxlength>maxlength</a></code>,
   <code id="week-state-(type=week):attr-input-minlength" class=no-backref><a href=#attr-input-minlength>minlength</a></code>,
   <code id="week-state-(type=week):attr-input-multiple" class=no-backref><a href=#attr-input-multiple>multiple</a></code>,
   <code id="week-state-(type=week):attr-input-pattern" class=no-backref><a href=#attr-input-pattern>pattern</a></code>,
   <code id="week-state-(type=week):attr-input-placeholder" class=no-backref><a href=#attr-input-placeholder>placeholder</a></code>,
   <code id="week-state-(type=week):attr-input-size" class=no-backref><a href=#attr-input-size>size</a></code>,
   <code id="week-state-(type=week):attr-input-src" class=no-backref><a href=#attr-input-src>src</a></code>, and
   <code id="week-state-(type=week):attr-dim-width" class=no-backref><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" class=no-backref><a href=#dom-input-checked>checked</a></code>,
   <code id="week-state-(type=week):dom-input-files" class=no-backref><a href=#dom-input-files>files</a></code>,
   <code id="week-state-(type=week):dom-textarea/input-selectionstart" class=no-backref><a href=#dom-textarea/input-selectionstart>selectionStart</a></code>,
   <code id="week-state-(type=week):dom-textarea/input-selectionend" class=no-backref><a href=#dom-textarea/input-selectionend>selectionEnd</a></code>, and
   <code id="week-state-(type=week):dom-textarea/input-selectiondirection" class=no-backref><a href=#dom-textarea/input-selectiondirection>selectionDirection</a></code> IDL attributes;
   <code id="week-state-(type=week):dom-textarea/input-setrangetext" class=no-backref><a href=#dom-textarea/input-setrangetext>setRangeText()</a></code>, and
   <code id="week-state-(type=week):dom-textarea/input-setselectionrange" class=no-backref><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>Time</dfn> state (<code>type=time</code>)<a href="#time-state-(type=time)" class=self-link></a></h6>

  

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

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

  

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

  

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

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

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

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

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

  <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.github.io/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 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 href=#event-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" class=no-backref><a href=#attr-input-accept>accept</a></code>,
   <code id="time-state-(type=time):attr-input-alt" class=no-backref><a href=#attr-input-alt>alt</a></code>,
   <code id="time-state-(type=time):attr-input-checked" class=no-backref><a href=#attr-input-checked>checked</a></code>,
   <code id="time-state-(type=time):attr-fe-dirname" class=no-backref><a href=#attr-fe-dirname>dirname</a></code>,
   <code id="time-state-(type=time):attr-fs-formaction" class=no-backref><a href=#attr-fs-formaction>formaction</a></code>,
   <code id="time-state-(type=time):attr-fs-formenctype" class=no-backref><a href=#attr-fs-formenctype>formenctype</a></code>,
   <code id="time-state-(type=time):attr-fs-formmethod" class=no-backref><a href=#attr-fs-formmethod>formmethod</a></code>,
   <code id="time-state-(type=time):attr-fs-formnovalidate" class=no-backref><a href=#attr-fs-formnovalidate>formnovalidate</a></code>,
   <code id="time-state-(type=time):attr-fs-formtarget" class=no-backref><a href=#attr-fs-formtarget>formtarget</a></code>,
   <code id="time-state-(type=time):attr-dim-height" class=no-backref><a href=#attr-dim-height>height</a></code>,
   <code id="time-state-(type=time):attr-input-maxlength" class=no-backref><a href=#attr-input-maxlength>maxlength</a></code>,
   <code id="time-state-(type=time):attr-input-minlength" class=no-backref><a href=#attr-input-minlength>minlength</a></code>,
   <code id="time-state-(type=time):attr-input-multiple" class=no-backref><a href=#attr-input-multiple>multiple</a></code>,
   <code id="time-state-(type=time):attr-input-pattern" class=no-backref><a href=#attr-input-pattern>pattern</a></code>,
   <code id="time-state-(type=time):attr-input-placeholder" class=no-backref><a href=#attr-input-placeholder>placeholder</a></code>,
   <code id="time-state-(type=time):attr-input-size" class=no-backref><a href=#attr-input-size>size</a></code>,
   <code id="time-state-(type=time):attr-input-src" class=no-backref><a href=#attr-input-src>src</a></code>, and
   <code id="time-state-(type=time):attr-dim-width" class=no-backref><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" class=no-backref><a href=#dom-input-checked>checked</a></code>,
   <code id="time-state-(type=time):dom-input-files" class=no-backref><a href=#dom-input-files>files</a></code>,
   <code id="time-state-(type=time):dom-textarea/input-selectionstart" class=no-backref><a href=#dom-textarea/input-selectionstart>selectionStart</a></code>,
   <code id="time-state-(type=time):dom-textarea/input-selectionend" class=no-backref><a href=#dom-textarea/input-selectionend>selectionEnd</a></code>, and
   <code id="time-state-(type=time):dom-textarea/input-selectiondirection" class=no-backref><a href=#dom-textarea/input-selectiondirection>selectionDirection</a></code> IDL attributes;
   <code id="time-state-(type=time):dom-textarea/input-setrangetext" class=no-backref><a href=#dom-textarea/input-setrangetext>setRangeText()</a></code>, and
   <code id="time-state-(type=time):dom-textarea/input-setselectionrange" class=no-backref><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>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>

  

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

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

  

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

  

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

  

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

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

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

  

  <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 href=#event-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" class=no-backref><a href=#attr-input-accept>accept</a></code>,
   <code id="local-date-and-time-state-(type=datetime-local):attr-input-alt" class=no-backref><a href=#attr-input-alt>alt</a></code>,
   <code id="local-date-and-time-state-(type=datetime-local):attr-input-checked" class=no-backref><a href=#attr-input-checked>checked</a></code>,
   <code id="local-date-and-time-state-(type=datetime-local):attr-fe-dirname" class=no-backref><a href=#attr-fe-dirname>dirname</a></code>,
   <code id="local-date-and-time-state-(type=datetime-local):attr-fs-formaction" class=no-backref><a href=#attr-fs-formaction>formaction</a></code>,
   <code id="local-date-and-time-state-(type=datetime-local):attr-fs-formenctype" class=no-backref><a href=#attr-fs-formenctype>formenctype</a></code>,
   <code id="local-date-and-time-state-(type=datetime-local):attr-fs-formmethod" class=no-backref><a href=#attr-fs-formmethod>formmethod</a></code>,
   <code id="local-date-and-time-state-(type=datetime-local):attr-fs-formnovalidate" class=no-backref><a href=#attr-fs-formnovalidate>formnovalidate</a></code>,
   <code id="local-date-and-time-state-(type=datetime-local):attr-fs-formtarget" class=no-backref><a href=#attr-fs-formtarget>formtarget</a></code>,
   <code id="local-date-and-time-state-(type=datetime-local):attr-dim-height" class=no-backref><a href=#attr-dim-height>height</a></code>,
   <code id="local-date-and-time-state-(type=datetime-local):attr-input-maxlength" class=no-backref><a href=#attr-input-maxlength>maxlength</a></code>,
   <code id="local-date-and-time-state-(type=datetime-local):attr-input-minlength" class=no-backref><a href=#attr-input-minlength>minlength</a></code>,
   <code id="local-date-and-time-state-(type=datetime-local):attr-input-multiple" class=no-backref><a href=#attr-input-multiple>multiple</a></code>,
   <code id="local-date-and-time-state-(type=datetime-local):attr-input-pattern" class=no-backref><a href=#attr-input-pattern>pattern</a></code>,
   <code id="local-date-and-time-state-(type=datetime-local):attr-input-placeholder" class=no-backref><a href=#attr-input-placeholder>placeholder</a></code>,
   <code id="local-date-and-time-state-(type=datetime-local):attr-input-size" class=no-backref><a href=#attr-input-size>size</a></code>,
   <code id="local-date-and-time-state-(type=datetime-local):attr-input-src" class=no-backref><a href=#attr-input-src>src</a></code>, and
   <code id="local-date-and-time-state-(type=datetime-local):attr-dim-width" class=no-backref><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" class=no-backref><a href=#dom-input-checked>checked</a></code>,
   <code id="local-date-and-time-state-(type=datetime-local):dom-input-files" class=no-backref><a href=#dom-input-files>files</a></code>,
   <code id="local-date-and-time-state-(type=datetime-local):dom-textarea/input-selectionstart" class=no-backref><a href=#dom-textarea/input-selectionstart>selectionStart</a></code>,
   <code id="local-date-and-time-state-(type=datetime-local):dom-textarea/input-selectionend" class=no-backref><a href=#dom-textarea/input-selectionend>selectionEnd</a></code>,
   <code id="local-date-and-time-state-(type=datetime-local):dom-textarea/input-selectiondirection" class=no-backref><a href=#dom-textarea/input-selectiondirection>selectionDirection</a></code>, and
   <code id="local-date-and-time-state-(type=datetime-local):dom-input-valueasdate" class=no-backref><a href=#dom-input-valueasdate>valueAsDate</a></code> IDL attributes;
   <code id="local-date-and-time-state-(type=datetime-local):dom-textarea/input-setrangetext" class=no-backref><a href=#dom-textarea/input-setrangetext>setRangeText()</a></code>, and
   <code id="local-date-and-time-state-(type=datetime-local):dom-textarea/input-setselectionrange" class=no-backref><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>&quot;Atlanta&quot;</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>&quot;Memphis&quot;</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>&quot;London Heathrow&quot;</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>&quot;Los Angeles&quot;</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>&quot;Frankfurt&quot;</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 id=number-state>Number</dfn> state (<code>type=number</code>)<a href="#number-state-(type=number)" class=self-link></a></h6><div class=status><input onclick=toggleStatus(this) value=⋰ type=button><p class=support><strong>Support:</strong> input-number<span class="and_chr partial"><span>Chrome for Android (limited)</span> <span>67+</span></span><span class="chrome yes"><span>Chrome</span> <span>6+</span></span><span class="ios_saf partial"><span>iOS Safari (limited)</span> <span>3.2+</span></span><span class="and_uc partial"><span>UC Browser for Android (limited)</span> <span>11.8+</span></span><span class="firefox yes"><span>Firefox</span> <span>29+</span></span><span class="ie yes"><span>IE</span> <span>10+</span></span><span class="op_mini no"><span>Opera Mini</span> <span>None</span></span><span class="safari yes"><span>Safari</span> <span>5+</span></span><span class="edge yes"><span>Edge</span> <span>12+</span></span><span class="samsung partial"><span>Samsung Internet (limited)</span> <span>4+</span></span><span class="opera yes"><span>Opera</span> <span>9+</span></span><span class="android partial"><span>Android Browser (limited)</span> <span>4+</span></span><p class=caniuse>Source: <a href="https://caniuse.com/#feat=input-number">caniuse.com</a></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>

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

  

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

  

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

  

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

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

  <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 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 href=#event-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" class=no-backref><a href=#attr-input-accept>accept</a></code>,
   <code id="number-state-(type=number):attr-input-alt" class=no-backref><a href=#attr-input-alt>alt</a></code>,
   <code id="number-state-(type=number):attr-input-checked" class=no-backref><a href=#attr-input-checked>checked</a></code>,
   <code id="number-state-(type=number):attr-fe-dirname" class=no-backref><a href=#attr-fe-dirname>dirname</a></code>,
   <code id="number-state-(type=number):attr-fs-formaction" class=no-backref><a href=#attr-fs-formaction>formaction</a></code>,
   <code id="number-state-(type=number):attr-fs-formenctype" class=no-backref><a href=#attr-fs-formenctype>formenctype</a></code>,
   <code id="number-state-(type=number):attr-fs-formmethod" class=no-backref><a href=#attr-fs-formmethod>formmethod</a></code>,
   <code id="number-state-(type=number):attr-fs-formnovalidate" class=no-backref><a href=#attr-fs-formnovalidate>formnovalidate</a></code>,
   <code id="number-state-(type=number):attr-fs-formtarget" class=no-backref><a href=#attr-fs-formtarget>formtarget</a></code>,
   <code id="number-state-(type=number):attr-dim-height" class=no-backref><a href=#attr-dim-height>height</a></code>,
   <code id="number-state-(type=number):attr-input-maxlength" class=no-backref><a href=#attr-input-maxlength>maxlength</a></code>,
   <code id="number-state-(type=number):attr-input-minlength" class=no-backref><a href=#attr-input-minlength>minlength</a></code>,
   <code id="number-state-(type=number):attr-input-multiple" class=no-backref><a href=#attr-input-multiple>multiple</a></code>,
   <code id="number-state-(type=number):attr-input-pattern" class=no-backref><a href=#attr-input-pattern>pattern</a></code>,
   <code id="number-state-(type=number):attr-input-size" class=no-backref><a href=#attr-input-size>size</a></code>,
   <code id="number-state-(type=number):attr-input-src" class=no-backref><a href=#attr-input-src>src</a></code>, and
   <code id="number-state-(type=number):attr-dim-width" class=no-backref><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" class=no-backref><a href=#dom-input-checked>checked</a></code>,
   <code id="number-state-(type=number):dom-input-files" class=no-backref><a href=#dom-input-files>files</a></code>,
   <code id="number-state-(type=number):dom-textarea/input-selectionstart" class=no-backref><a href=#dom-textarea/input-selectionstart>selectionStart</a></code>,
   <code id="number-state-(type=number):dom-textarea/input-selectionend" class=no-backref><a href=#dom-textarea/input-selectionend>selectionEnd</a></code>,
   <code id="number-state-(type=number):dom-textarea/input-selectiondirection" class=no-backref><a href=#dom-textarea/input-selectiondirection>selectionDirection</a></code>, and
   <code id="number-state-(type=number):dom-input-valueasdate" class=no-backref><a href=#dom-input-valueasdate>valueAsDate</a></code> IDL attributes;
   <code id="number-state-(type=number):dom-textarea/input-setrangetext" class=no-backref><a href=#dom-textarea/input-setrangetext>setRangeText()</a></code>, and
   <code id="number-state-(type=number):dom-textarea/input-setselectionrange" class=no-backref><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>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 a <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>Range</dfn> state (<code>type=range</code>)<a href="#range-state-(type=range)" class=self-link></a></h6><div class=status><input onclick=toggleStatus(this) value=⋰ type=button><p class=support><strong>Support:</strong> input-range<span class="and_chr yes"><span>Chrome for Android</span> <span>67+</span></span><span class="chrome yes"><span>Chrome</span> <span>4+</span></span><span class="ios_saf yes"><span>iOS Safari</span> <span>5.0+</span></span><span class="and_uc yes"><span>UC Browser for Android</span> <span>11.8+</span></span><span class="firefox yes"><span>Firefox</span> <span>23+</span></span><span class="ie yes"><span>IE</span> <span>10+</span></span><span class="op_mini no"><span>Opera Mini</span> <span>None</span></span><span class="safari yes"><span>Safari</span> <span>3.1+</span></span><span class="edge yes"><span>Edge</span> <span>12+</span></span><span class="samsung yes"><span>Samsung Internet</span> <span>4+</span></span><span class="opera yes"><span>Opera</span> <span>9+</span></span><span class="android yes"><span>Android Browser</span> <span>4.2+</span></span><p class=caniuse>Source: <a href="https://caniuse.com/#feat=input-range">caniuse.com</a></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>

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

  

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

  

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

  

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

  

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

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

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

  <p class=example>For example, the markup
  <code>&lt;input type="range" min=0 max=100 step=20 value=50></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>&quot;range&quot;</c-> <c- e>min</c-><c- o>=</c-><c- s>&quot;-100&quot;</c-> <c- e>max</c-><c- o>=</c-><c- s>&quot;100&quot;</c-> <c- e>value</c-><c- o>=</c-><c- s>&quot;0&quot;</c-> <c- e>step</c-><c- o>=</c-><c- s>&quot;10&quot;</c-> <c- e>name</c-><c- o>=</c-><c- s>&quot;power&quot;</c-> <c- e>list</c-><c- o>=</c-><c- s>&quot;powers&quot;</c-><c- p>&gt;</c->
<c- p>&lt;</c-><c- f>datalist</c-> <c- e>id</c-><c- o>=</c-><c- s>&quot;powers&quot;</c-><c- p>&gt;</c->
<c- p>&lt;</c-><c- f>option</c-> <c- e>value</c-><c- o>=</c-><c- s>&quot;0&quot;</c-><c- p>&gt;</c->
<c- p>&lt;</c-><c- f>option</c-> <c- e>value</c-><c- o>=</c-><c- s>&quot;-30&quot;</c-><c- p>&gt;</c->
<c- p>&lt;</c-><c- f>option</c-> <c- e>value</c-><c- o>=</c-><c- s>&quot;30&quot;</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>&quot;++50&quot;</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>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>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 completely 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>&quot;range&quot;</c-> <c- e>name</c-><c- o>=</c-><c- s>&quot;a&quot;</c-> <c- e>list</c-><c- o>=</c-><c- s>&quot;a-values&quot;</c-><c- p>&gt;</c->
<c- p>&lt;</c-><c- f>datalist</c-> <c- e>id</c-><c- o>=</c-><c- s>&quot;a-values&quot;</c-><c- p>&gt;</c->
<c- p>&lt;</c-><c- f>option</c-> <c- e>value</c-><c- o>=</c-><c- s>&quot;10&quot;</c-> <c- e>label</c-><c- o>=</c-><c- s>&quot;Low&quot;</c-><c- p>&gt;</c->
<c- p>&lt;</c-><c- f>option</c-> <c- e>value</c-><c- o>=</c-><c- s>&quot;90&quot;</c-> <c- e>label</c-><c- o>=</c-><c- s>&quot;High&quot;</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>

  </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>

  

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

  <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 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 href=#event-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" class=no-backref><a href=#attr-input-accept>accept</a></code>,
   <code id="range-state-(type=range):attr-input-alt" class=no-backref><a href=#attr-input-alt>alt</a></code>,
   <code id="range-state-(type=range):attr-input-checked" class=no-backref><a href=#attr-input-checked>checked</a></code>,
   <code id="range-state-(type=range):attr-fe-dirname" class=no-backref><a href=#attr-fe-dirname>dirname</a></code>,
   <code id="range-state-(type=range):attr-fs-formaction" class=no-backref><a href=#attr-fs-formaction>formaction</a></code>,
   <code id="range-state-(type=range):attr-fs-formenctype" class=no-backref><a href=#attr-fs-formenctype>formenctype</a></code>,
   <code id="range-state-(type=range):attr-fs-formmethod" class=no-backref><a href=#attr-fs-formmethod>formmethod</a></code>,
   <code id="range-state-(type=range):attr-fs-formnovalidate" class=no-backref><a href=#attr-fs-formnovalidate>formnovalidate</a></code>,
   <code id="range-state-(type=range):attr-fs-formtarget" class=no-backref><a href=#attr-fs-formtarget>formtarget</a></code>,
   <code id="range-state-(type=range):attr-dim-height" class=no-backref><a href=#attr-dim-height>height</a></code>,
   <code id="range-state-(type=range):attr-input-maxlength" class=no-backref><a href=#attr-input-maxlength>maxlength</a></code>,
   <code id="range-state-(type=range):attr-input-minlength" class=no-backref><a href=#attr-input-minlength>minlength</a></code>,
   <code id="range-state-(type=range):attr-input-multiple" class=no-backref><a href=#attr-input-multiple>multiple</a></code>,
   <code id="range-state-(type=range):attr-input-pattern" class=no-backref><a href=#attr-input-pattern>pattern</a></code>,
   <code id="range-state-(type=range):attr-input-placeholder" class=no-backref><a href=#attr-input-placeholder>placeholder</a></code>,
   <code id="range-state-(type=range):attr-input-readonly" class=no-backref><a href=#attr-input-readonly>readonly</a></code>,
   <code id="range-state-(type=range):attr-input-required" class=no-backref><a href=#attr-input-required>required</a></code>,
   <code id="range-state-(type=range):attr-input-size" class=no-backref><a href=#attr-input-size>size</a></code>,
   <code id="range-state-(type=range):attr-input-src" class=no-backref><a href=#attr-input-src>src</a></code>, and
   <code id="range-state-(type=range):attr-dim-width" class=no-backref><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" class=no-backref><a href=#dom-input-checked>checked</a></code>,
   <code id="range-state-(type=range):dom-input-files" class=no-backref><a href=#dom-input-files>files</a></code>,
   <code id="range-state-(type=range):dom-textarea/input-selectionstart" class=no-backref><a href=#dom-textarea/input-selectionstart>selectionStart</a></code>,
   <code id="range-state-(type=range):dom-textarea/input-selectionend" class=no-backref><a href=#dom-textarea/input-selectionend>selectionEnd</a></code>,
   <code id="range-state-(type=range):dom-textarea/input-selectiondirection" class=no-backref><a href=#dom-textarea/input-selectiondirection>selectionDirection</a></code>, and
   <code id="range-state-(type=range):dom-input-valueasdate" class=no-backref><a href=#dom-input-valueasdate>valueAsDate</a></code> IDL attributes;
   <code id="range-state-(type=range):dom-textarea/input-select" class=no-backref><a href=#dom-textarea/input-select>select()</a></code>,
   <code id="range-state-(type=range):dom-textarea/input-setrangetext" class=no-backref><a href=#dom-textarea/input-setrangetext>setRangeText()</a></code>, and
   <code id="range-state-(type=range):dom-textarea/input-setselectionrange" class=no-backref><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>Color</dfn> state (<code>type=color</code>)<a href="#color-state-(type=color)" class=self-link></a></h6><div class=status><input onclick=toggleStatus(this) value=⋰ type=button><p class=support><strong>Support:</strong> input-color<span class="and_chr yes"><span>Chrome for Android</span> <span>67+</span></span><span class="chrome yes"><span>Chrome</span> <span>20+</span></span><span class="ios_saf no"><span>iOS Safari</span> <span>None</span></span><span class="and_uc yes"><span>UC Browser for Android</span> <span>11.8+</span></span><span class="firefox yes"><span>Firefox</span> <span>29+</span></span><span class="ie no"><span>IE</span> <span>None</span></span><span class="op_mini no"><span>Opera Mini</span> <span>None</span></span><span class="safari no"><span>Safari</span> <span>None</span></span><span class="edge yes"><span>Edge</span> <span>14+</span></span><span class="samsung yes"><span>Samsung Internet</span> <span>4+</span></span><span class="opera yes"><span>Opera</span> <span>17+</span></span><span class="android yes"><span>Android Browser</span> <span>4.4+</span></span><p class=caniuse>Source: <a href="https://caniuse.com/#feat=input-color">caniuse.com</a></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 a <a href=#simple-colour id="color-state-(type=color):simple-colour">simple
  color</a>.</p>

  

  <p class=note>In this state, there is always a color picked, and there is no way to set the
  value to the empty string.</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 applying the <a href=#rules-for-parsing-simple-colour-values id="color-state-(type=color):rules-for-parsing-simple-colour-values">rules for parsing simple color values</a> to 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 is
  not a <a href=#valid-lowercase-simple-colour id="color-state-(type=color):valid-lowercase-simple-colour">valid lowercase simple color</a>. If the user agent provides a user interface for
  selecting a 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 using the <a href=#rules-for-serialising-simple-colour-values id="color-state-(type=color):rules-for-serialising-simple-colour-values">rules for serializing simple color values</a> to the user's selection. User
  agents must not allow the user to set the <a href=#concept-fe-value id="color-state-(type=color):concept-fe-value-5">value</a> to the empty
  string.</p>

  <p><strong>Constraint validation</strong>: While the user interface describes input that the user
  agent cannot convert to a <a href=#valid-lowercase-simple-colour id="color-state-(type=color):valid-lowercase-simple-colour-2">valid lowercase simple color</a>, the control is
  <a href=#suffering-from-bad-input id="color-state-(type=color):suffering-from-bad-input">suffering from bad input</a>.</p>

  

  <p>The <code id="color-state-(type=color):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-simple-colour id="color-state-(type=color):valid-simple-colour">valid simple color</a>.</p>

  

  <p><strong>The <a href=#value-sanitization-algorithm id="color-state-(type=color):value-sanitization-algorithm">value sanitization algorithm</a> is as follows</strong>: If the <a href=#concept-fe-value id="color-state-(type=color):concept-fe-value-6">value</a> of the element is a <a href=#valid-simple-colour id="color-state-(type=color):valid-simple-colour-2">valid simple color</a>, then
  set it to the <a href=#concept-fe-value id="color-state-(type=color):concept-fe-value-7">value</a> of the element <a id="color-state-(type=color):converted-to-ascii-lowercase" href=https://infra.spec.whatwg.org/#ascii-lowercase data-x-internal=converted-to-ascii-lowercase>converted to ASCII
  lowercase</a>; otherwise, set it to the string "<code>#000000</code>".</p>

  

  <div class=bookkeeping>

   <p>The following common <code id="color-state-(type=color):the-input-element-3"><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-fe-autocomplete"><a href=#attr-fe-autocomplete>autocomplete</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 href=#event-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" class=no-backref><a href=#attr-input-accept>accept</a></code>,
   <code id="color-state-(type=color):attr-input-alt" class=no-backref><a href=#attr-input-alt>alt</a></code>,
   <code id="color-state-(type=color):attr-input-checked" class=no-backref><a href=#attr-input-checked>checked</a></code>,
   <code id="color-state-(type=color):attr-fe-dirname" class=no-backref><a href=#attr-fe-dirname>dirname</a></code>,
   <code id="color-state-(type=color):attr-fs-formaction" class=no-backref><a href=#attr-fs-formaction>formaction</a></code>,
   <code id="color-state-(type=color):attr-fs-formenctype" class=no-backref><a href=#attr-fs-formenctype>formenctype</a></code>,
   <code id="color-state-(type=color):attr-fs-formmethod" class=no-backref><a href=#attr-fs-formmethod>formmethod</a></code>,
   <code id="color-state-(type=color):attr-fs-formnovalidate" class=no-backref><a href=#attr-fs-formnovalidate>formnovalidate</a></code>,
   <code id="color-state-(type=color):attr-fs-formtarget" class=no-backref><a href=#attr-fs-formtarget>formtarget</a></code>,
   <code id="color-state-(type=color):attr-dim-height" class=no-backref><a href=#attr-dim-height>height</a></code>,
   <code id="color-state-(type=color):attr-input-max" class=no-backref><a href=#attr-input-max>max</a></code>,
   <code id="color-state-(type=color):attr-input-maxlength" class=no-backref><a href=#attr-input-maxlength>maxlength</a></code>,
   <code id="color-state-(type=color):attr-input-min" class=no-backref><a href=#attr-input-min>min</a></code>,
   <code id="color-state-(type=color):attr-input-minlength" class=no-backref><a href=#attr-input-minlength>minlength</a></code>,
   <code id="color-state-(type=color):attr-input-multiple" class=no-backref><a href=#attr-input-multiple>multiple</a></code>,
   <code id="color-state-(type=color):attr-input-pattern" class=no-backref><a href=#attr-input-pattern>pattern</a></code>,
   <code id="color-state-(type=color):attr-input-placeholder" class=no-backref><a href=#attr-input-placeholder>placeholder</a></code>,
   <code id="color-state-(type=color):attr-input-readonly" class=no-backref><a href=#attr-input-readonly>readonly</a></code>,
   <code id="color-state-(type=color):attr-input-required" class=no-backref><a href=#attr-input-required>required</a></code>,
   <code id="color-state-(type=color):attr-input-size" class=no-backref><a href=#attr-input-size>size</a></code>,
   <code id="color-state-(type=color):attr-input-src" class=no-backref><a href=#attr-input-src>src</a></code>,
   <code id="color-state-(type=color):attr-input-step" class=no-backref><a href=#attr-input-step>step</a></code>, and
   <code id="color-state-(type=color):attr-dim-width" class=no-backref><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" class=no-backref><a href=#dom-input-checked>checked</a></code>,
   <code id="color-state-(type=color):dom-input-files" class=no-backref><a href=#dom-input-files>files</a></code>,
   <code id="color-state-(type=color):dom-textarea/input-selectionstart" class=no-backref><a href=#dom-textarea/input-selectionstart>selectionStart</a></code>,
   <code id="color-state-(type=color):dom-textarea/input-selectionend" class=no-backref><a href=#dom-textarea/input-selectionend>selectionEnd</a></code>,
   <code id="color-state-(type=color):dom-textarea/input-selectiondirection" class=no-backref><a href=#dom-textarea/input-selectiondirection>selectionDirection</a></code>,
   <code id="color-state-(type=color):dom-input-valueasdate" class=no-backref><a href=#dom-input-valueasdate>valueAsDate</a></code> and,
   <code id="color-state-(type=color):dom-input-valueasnumber" class=no-backref><a href=#dom-input-valueasnumber>valueAsNumber</a></code> IDL attributes;
   <code id="color-state-(type=color):dom-textarea/input-setrangetext" class=no-backref><a href=#dom-textarea/input-setrangetext>setRangeText()</a></code>,
   <code id="color-state-(type=color):dom-textarea/input-setselectionrange" class=no-backref><a href=#dom-textarea/input-setselectionrange>setSelectionRange()</a></code>,
   <code id="color-state-(type=color):dom-input-stepdown" class=no-backref><a href=#dom-input-stepdown>stepDown()</a></code>, and
   <code id="color-state-(type=color):dom-input-stepup" class=no-backref><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>Checkbox</dfn> state (<code>type=checkbox</code>)<a href="#checkbox-state-(type=checkbox)" class=self-link></a></h6>

  

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

  

  <p>The <a href=#input-activation-behavior id="checkbox-state-(type=checkbox):input-activation-behavior">input activation behavior</a> is to <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 href=#event-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> attribute initialized to true, and then <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>
  

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

  

  <dl class=domintro><dt><var>input</var> . <code id=dom-input-indeterminate-dev><a href=#dom-input-indeterminate>indeterminate</a></code> [ = <var>value</var> ]<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>

   </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 href=#event-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" class=no-backref><a href=#attr-input-accept>accept</a></code>,
   <code id="checkbox-state-(type=checkbox):attr-input-alt" class=no-backref><a href=#attr-input-alt>alt</a></code>,
   <code id="checkbox-state-(type=checkbox):attr-fe-autocomplete" class=no-backref><a href=#attr-fe-autocomplete>autocomplete</a></code>,
   <code id="checkbox-state-(type=checkbox):attr-fe-dirname" class=no-backref><a href=#attr-fe-dirname>dirname</a></code>,
   <code id="checkbox-state-(type=checkbox):attr-fs-formaction" class=no-backref><a href=#attr-fs-formaction>formaction</a></code>,
   <code id="checkbox-state-(type=checkbox):attr-fs-formenctype" class=no-backref><a href=#attr-fs-formenctype>formenctype</a></code>,
   <code id="checkbox-state-(type=checkbox):attr-fs-formmethod" class=no-backref><a href=#attr-fs-formmethod>formmethod</a></code>,
   <code id="checkbox-state-(type=checkbox):attr-fs-formnovalidate" class=no-backref><a href=#attr-fs-formnovalidate>formnovalidate</a></code>,
   <code id="checkbox-state-(type=checkbox):attr-fs-formtarget" class=no-backref><a href=#attr-fs-formtarget>formtarget</a></code>,
   <code id="checkbox-state-(type=checkbox):attr-dim-height" class=no-backref><a href=#attr-dim-height>height</a></code>,
   <code id="checkbox-state-(type=checkbox):attr-input-list" class=no-backref><a href=#attr-input-list>list</a></code>,
   <code id="checkbox-state-(type=checkbox):attr-input-max" class=no-backref><a href=#attr-input-max>max</a></code>,
   <code id="checkbox-state-(type=checkbox):attr-input-maxlength" class=no-backref><a href=#attr-input-maxlength>maxlength</a></code>,
   <code id="checkbox-state-(type=checkbox):attr-input-min" class=no-backref><a href=#attr-input-min>min</a></code>,
   <code id="checkbox-state-(type=checkbox):attr-input-minlength" class=no-backref><a href=#attr-input-minlength>minlength</a></code>,
   <code id="checkbox-state-(type=checkbox):attr-input-multiple" class=no-backref><a href=#attr-input-multiple>multiple</a></code>,
   <code id="checkbox-state-(type=checkbox):attr-input-pattern" class=no-backref><a href=#attr-input-pattern>pattern</a></code>,
   <code id="checkbox-state-(type=checkbox):attr-input-placeholder" class=no-backref><a href=#attr-input-placeholder>placeholder</a></code>,
   <code id="checkbox-state-(type=checkbox):attr-input-readonly" class=no-backref><a href=#attr-input-readonly>readonly</a></code>,
   <code id="checkbox-state-(type=checkbox):attr-input-size" class=no-backref><a href=#attr-input-size>size</a></code>,
   <code id="checkbox-state-(type=checkbox):attr-input-src" class=no-backref><a href=#attr-input-src>src</a></code>,
   <code id="checkbox-state-(type=checkbox):attr-input-step" class=no-backref><a href=#attr-input-step>step</a></code>, and
   <code id="checkbox-state-(type=checkbox):attr-dim-width" class=no-backref><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" class=no-backref><a href=#dom-input-files>files</a></code>,
   <code id="checkbox-state-(type=checkbox):dom-input-list" class=no-backref><a href=#dom-input-list>list</a></code>,
   <code id="checkbox-state-(type=checkbox):dom-textarea/input-selectionstart" class=no-backref><a href=#dom-textarea/input-selectionstart>selectionStart</a></code>,
   <code id="checkbox-state-(type=checkbox):dom-textarea/input-selectionend" class=no-backref><a href=#dom-textarea/input-selectionend>selectionEnd</a></code>,
   <code id="checkbox-state-(type=checkbox):dom-textarea/input-selectiondirection" class=no-backref><a href=#dom-textarea/input-selectiondirection>selectionDirection</a></code>,
   <code id="checkbox-state-(type=checkbox):dom-input-valueasdate" class=no-backref><a href=#dom-input-valueasdate>valueAsDate</a></code>, and
   <code id="checkbox-state-(type=checkbox):dom-input-valueasnumber" class=no-backref><a href=#dom-input-valueasnumber>valueAsNumber</a></code> IDL attributes;
   <code id="checkbox-state-(type=checkbox):dom-textarea/input-select" class=no-backref><a href=#dom-textarea/input-select>select()</a></code>,
   <code id="checkbox-state-(type=checkbox):dom-textarea/input-setrangetext" class=no-backref><a href=#dom-textarea/input-setrangetext>setRangeText()</a></code>,
   <code id="checkbox-state-(type=checkbox):dom-textarea/input-setselectionrange" class=no-backref><a href=#dom-textarea/input-setselectionrange>setSelectionRange()</a></code>,
   <code id="checkbox-state-(type=checkbox):dom-input-stepdown" class=no-backref><a href=#dom-input-stepdown>stepDown()</a></code>, and
   <code id="checkbox-state-(type=checkbox):dom-input-stepup" class=no-backref><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>Radio Button</dfn> state (<code>type=radio</code>)<a href="#radio-button-state-(type=radio)" class=self-link></a></h6>

  

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

  <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>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>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>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.</ul>

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

  

  <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>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>The element's <a href=#form-owner id="radio-button-state-(type=radio):form-owner-3">form owner</a> changes.<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.</ul>

  <p>The <a href=#input-activation-behavior id="radio-button-state-(type=radio):input-activation-behavior">input activation behavior</a> is to <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 href=#event-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> attribute initialized to true, and then <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>
  

  <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 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>&quot;radio&quot;</c-> <c- e>name</c-><c- o>=</c-><c- s>&quot;dog-type&quot;</c-> <c- e>value</c-><c- o>=</c-><c- s>&quot;pupper&quot;</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>&quot;radio&quot;</c-> <c- e>name</c-><c- o>=</c-><c- s>&quot;dog-type&quot;</c-> <c- e>value</c-><c- o>=</c-><c- s>&quot;doggo&quot;</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 href=#event-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" class=no-backref><a href=#attr-input-accept>accept</a></code>,
   <code id="radio-button-state-(type=radio):attr-input-alt" class=no-backref><a href=#attr-input-alt>alt</a></code>,
   <code id="radio-button-state-(type=radio):attr-fe-autocomplete" class=no-backref><a href=#attr-fe-autocomplete>autocomplete</a></code>,
   <code id="radio-button-state-(type=radio):attr-fe-dirname" class=no-backref><a href=#attr-fe-dirname>dirname</a></code>,
   <code id="radio-button-state-(type=radio):attr-fs-formaction" class=no-backref><a href=#attr-fs-formaction>formaction</a></code>,
   <code id="radio-button-state-(type=radio):attr-fs-formenctype" class=no-backref><a href=#attr-fs-formenctype>formenctype</a></code>,
   <code id="radio-button-state-(type=radio):attr-fs-formmethod" class=no-backref><a href=#attr-fs-formmethod>formmethod</a></code>,
   <code id="radio-button-state-(type=radio):attr-fs-formnovalidate" class=no-backref><a href=#attr-fs-formnovalidate>formnovalidate</a></code>,
   <code id="radio-button-state-(type=radio):attr-fs-formtarget" class=no-backref><a href=#attr-fs-formtarget>formtarget</a></code>,
   <code id="radio-button-state-(type=radio):attr-dim-height" class=no-backref><a href=#attr-dim-height>height</a></code>,
   <code id="radio-button-state-(type=radio):attr-input-list" class=no-backref><a href=#attr-input-list>list</a></code>,
   <code id="radio-button-state-(type=radio):attr-input-max" class=no-backref><a href=#attr-input-max>max</a></code>,
   <code id="radio-button-state-(type=radio):attr-input-maxlength" class=no-backref><a href=#attr-input-maxlength>maxlength</a></code>,
   <code id="radio-button-state-(type=radio):attr-input-min" class=no-backref><a href=#attr-input-min>min</a></code>,
   <code id="radio-button-state-(type=radio):attr-input-minlength" class=no-backref><a href=#attr-input-minlength>minlength</a></code>,
   <code id="radio-button-state-(type=radio):attr-input-multiple" class=no-backref><a href=#attr-input-multiple>multiple</a></code>,
   <code id="radio-button-state-(type=radio):attr-input-pattern" class=no-backref><a href=#attr-input-pattern>pattern</a></code>,
   <code id="radio-button-state-(type=radio):attr-input-placeholder" class=no-backref><a href=#attr-input-placeholder>placeholder</a></code>,
   <code id="radio-button-state-(type=radio):attr-input-readonly" class=no-backref><a href=#attr-input-readonly>readonly</a></code>,
   <code id="radio-button-state-(type=radio):attr-input-size" class=no-backref><a href=#attr-input-size>size</a></code>,
   <code id="radio-button-state-(type=radio):attr-input-src" class=no-backref><a href=#attr-input-src>src</a></code>,
   <code id="radio-button-state-(type=radio):attr-input-step" class=no-backref><a href=#attr-input-step>step</a></code>, and
   <code id="radio-button-state-(type=radio):attr-dim-width" class=no-backref><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" class=no-backref><a href=#dom-input-files>files</a></code>,
   <code id="radio-button-state-(type=radio):dom-input-list" class=no-backref><a href=#dom-input-list>list</a></code>,
   <code id="radio-button-state-(type=radio):dom-textarea/input-selectionstart" class=no-backref><a href=#dom-textarea/input-selectionstart>selectionStart</a></code>,
   <code id="radio-button-state-(type=radio):dom-textarea/input-selectionend" class=no-backref><a href=#dom-textarea/input-selectionend>selectionEnd</a></code>,
   <code id="radio-button-state-(type=radio):dom-textarea/input-selectiondirection" class=no-backref><a href=#dom-textarea/input-selectiondirection>selectionDirection</a></code>,
   <code id="radio-button-state-(type=radio):dom-input-valueasdate" class=no-backref><a href=#dom-input-valueasdate>valueAsDate</a></code>, and
   <code id="radio-button-state-(type=radio):dom-input-valueasnumber" class=no-backref><a href=#dom-input-valueasnumber>valueAsNumber</a></code> IDL attributes;
   <code id="radio-button-state-(type=radio):dom-textarea/input-select" class=no-backref><a href=#dom-textarea/input-select>select()</a></code>,
   <code id="radio-button-state-(type=radio):dom-textarea/input-setrangetext" class=no-backref><a href=#dom-textarea/input-setrangetext>setRangeText()</a></code>,
   <code id="radio-button-state-(type=radio):dom-textarea/input-setselectionrange" class=no-backref><a href=#dom-textarea/input-setselectionrange>setSelectionRange()</a></code>,
   <code id="radio-button-state-(type=radio):dom-input-stepdown" class=no-backref><a href=#dom-input-stepdown>stepDown()</a></code>, and
   <code id="radio-button-state-(type=radio):dom-input-stepup" class=no-backref><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>File Upload</dfn> state (<code>type=file</code>)<a href="#file-upload-state-(type=file)" class=self-link></a></h6>

  

  

  <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 file
  name, a file type, and a file body (the contents of the file).</p>

  

  <p>File names 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 file names 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>

  <p>The element's <a href=#input-activation-behavior id="file-upload-state-(type=file):input-activation-behavior">input activation behavior</a> is to run the following steps:</p>

  <ol><li><p>If the algorithm is not <a href=#triggered-by-user-activation id="file-upload-state-(type=file):triggered-by-user-activation">triggered by user activation</a>, then return
   without doing anything else.<li>
    <p>Run these steps <a href=#in-parallel id="file-upload-state-(type=file):in-parallel">in parallel</a>:</p>

    <ol><li><p>Optionally, wait until any prior execution of this algorithm has terminated.<li><p>Display a prompt to the user requesting that the user specify some files. If the <code id="file-upload-state-(type=file):attr-input-multiple-2"><a href=#attr-input-multiple>multiple</a></code> attribute is not set, 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.<li><p>Wait for the user to have made their selection.<li><p><a href=#queue-a-task id="file-upload-state-(type=file):queue-a-task">Queue a task</a> to first update the element'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, then <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 href=#event-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> attribute initialized to true, and finally <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.</ol>
   </ol>

  <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=#queue-a-task id="file-upload-state-(type=file):queue-a-task-2">queue a task</a> to first
  update the element's <a href=#concept-input-type-file-selected id="file-upload-state-(type=file):concept-input-type-file-selected-3">selected files</a> so that
  it represents the user's new selection, then <a href=https://dom.spec.whatwg.org/#concept-event-fire id="file-upload-state-(type=file):concept-event-fire-3" data-x-internal=concept-event-fire>fire an
  event</a> named <code id="file-upload-state-(type=file):event-input-2"><a href=#event-input>input</a></code> at the <code id="file-upload-state-(type=file):the-input-element-5"><a href=#the-input-element>input</a></code> element, with
  the <code id="file-upload-state-(type=file):dom-event-bubbles-3"><a data-x-internal=dom-event-bubbles href=https://dom.spec.whatwg.org/#dom-event-bubbles>bubbles</a></code> attribute initialized to true, and finally
  <a href=https://dom.spec.whatwg.org/#concept-event-fire id="file-upload-state-(type=file):concept-event-fire-4" data-x-internal=concept-event-fire>fire an event</a> named <code id="file-upload-state-(type=file):event-change-2"><a href=#event-change>change</a></code> at the <code id="file-upload-state-(type=file):the-input-element-6"><a href=#the-input-element>input</a></code> element, with the <code id="file-upload-state-(type=file):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>

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

  <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-4">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>

  

  <hr>

  <p>The <dfn id=attr-input-accept><code>accept</code></dfn> attribute may be specified to
  provide user agents with a hint of what file types will be accepted.<div class=status><input onclick=toggleStatus(this) value=⋰ type=button><p class=support><strong>Support:</strong> input-file-accept<span class="and_chr partial"><span>Chrome for Android (limited)</span> <span>67+</span></span><span class="chrome yes"><span>Chrome</span> <span>26+</span></span><span class="ios_saf partial"><span>iOS Safari (limited)</span> <span>8+</span></span><span class="and_uc no"><span>UC Browser for Android</span> <span>None</span></span><span class="firefox yes"><span>Firefox</span> <span>37+</span></span><span class="ie yes"><span>IE</span> <span>10+</span></span><span class="op_mini no"><span>Opera Mini</span> <span>None</span></span><span class="safari yes"><span>Safari</span> <span>11.1+</span></span><span class="edge no"><span>Edge</span> <span>None</span></span><span class="samsung partial"><span>Samsung Internet (limited)</span> <span>4+</span></span><span class="opera yes"><span>Opera</span> <span>15+</span></span><span class="android no"><span>Android Browser</span> <span>None</span></span><p class=caniuse>Source: <a href="https://caniuse.com/#feat=input-file-accept">caniuse.com</a></div>

  <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>"<dd>Indicates that sound files are accepted.<dt>The string "<code>video/*</code>"<dd>Indicates that video files are accepted.<dt>The string "<code>image/*</code>"<dd>Indicates that image files are accepted.<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><dd>Indicates that files of the specified type are accepted.<dt>A string whose first character is a U+002E FULL STOP character (.)<dd>Indicates that files with the specified file extension are accepted.</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>&quot;file&quot;</c-> <c- e>accept</c-><c- o>=</c-><c- s>&quot;.doc,.docx,.xml,application/msword,application/vnd.openxmlformats-officedocument.wordprocessingml.document&quot;</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 file names 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 id=fakepath-srsly class=example>

   <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 file name 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 file name 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 file name 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- mi>0</c-><c- p>,</c-> <c- mi>12</c-><c- p>)</c-> <c- o>==</c-> <c- u>&quot;C:\\fakepath\\&quot;</c-><c- p>)</c->
    <c- k>return</c-> path<c- p>.</c->substr<c- p>(</c-><c- mi>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>&apos;/&apos;</c-><c- p>);</c->
  <c- k>if</c-> <c- p>(</c->x <c- o>&gt;=</c-> <c- mi>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- mi>1</c-><c- p>);</c->
  x <c- o>=</c-> path<c- p>.</c->lastIndexOf<c- p>(</c-><c- t>&apos;\\&apos;</c-><c- p>);</c->
  <c- k>if</c-> <c- p>(</c->x <c- o>&gt;=</c-> <c- mi>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- mi>1</c-><c- p>);</c->
  <c- k>return</c-> path<c- p>;</c-> <c- c1>// just the file name</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>&quot;updateFilename(this.value)&quot;</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>&quot;filename&quot;</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>&apos;filename&apos;</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-7"><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-3"><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-3"><a href=#event-input>input</a></code> and <code id="file-upload-state-(type=file):event-change-3"><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-alt" class=no-backref><a href=#attr-input-alt>alt</a></code>,
   <code id="file-upload-state-(type=file):attr-fe-autocomplete" class=no-backref><a href=#attr-fe-autocomplete>autocomplete</a></code>,
   <code id="file-upload-state-(type=file):attr-input-checked" class=no-backref><a href=#attr-input-checked>checked</a></code>,
   <code id="file-upload-state-(type=file):attr-fe-dirname" class=no-backref><a href=#attr-fe-dirname>dirname</a></code>,
   <code id="file-upload-state-(type=file):attr-fs-formaction" class=no-backref><a href=#attr-fs-formaction>formaction</a></code>,
   <code id="file-upload-state-(type=file):attr-fs-formenctype" class=no-backref><a href=#attr-fs-formenctype>formenctype</a></code>,
   <code id="file-upload-state-(type=file):attr-fs-formmethod" class=no-backref><a href=#attr-fs-formmethod>formmethod</a></code>,
   <code id="file-upload-state-(type=file):attr-fs-formnovalidate" class=no-backref><a href=#attr-fs-formnovalidate>formnovalidate</a></code>,
   <code id="file-upload-state-(type=file):attr-fs-formtarget" class=no-backref><a href=#attr-fs-formtarget>formtarget</a></code>,
   <code id="file-upload-state-(type=file):attr-dim-height" class=no-backref><a href=#attr-dim-height>height</a></code>,
   <code id="file-upload-state-(type=file):attr-input-list" class=no-backref><a href=#attr-input-list>list</a></code>,
   <code id="file-upload-state-(type=file):attr-input-max" class=no-backref><a href=#attr-input-max>max</a></code>,
   <code id="file-upload-state-(type=file):attr-input-maxlength" class=no-backref><a href=#attr-input-maxlength>maxlength</a></code>,
   <code id="file-upload-state-(type=file):attr-input-min" class=no-backref><a href=#attr-input-min>min</a></code>,
   <code id="file-upload-state-(type=file):attr-input-minlength" class=no-backref><a href=#attr-input-minlength>minlength</a></code>,
   <code id="file-upload-state-(type=file):attr-input-pattern" class=no-backref><a href=#attr-input-pattern>pattern</a></code>,
   <code id="file-upload-state-(type=file):attr-input-placeholder" class=no-backref><a href=#attr-input-placeholder>placeholder</a></code>,
   <code id="file-upload-state-(type=file):attr-input-readonly" class=no-backref><a href=#attr-input-readonly>readonly</a></code>,
   <code id="file-upload-state-(type=file):attr-input-size" class=no-backref><a href=#attr-input-size>size</a></code>,
   <code id="file-upload-state-(type=file):attr-input-src" class=no-backref><a href=#attr-input-src>src</a></code>,
   <code id="file-upload-state-(type=file):attr-input-step" class=no-backref><a href=#attr-input-step>step</a></code>, and
   <code id="file-upload-state-(type=file):attr-dim-width" class=no-backref><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" class=no-backref><a href=#dom-input-checked>checked</a></code>,
   <code id="file-upload-state-(type=file):dom-input-list" class=no-backref><a href=#dom-input-list>list</a></code>,
   <code id="file-upload-state-(type=file):dom-textarea/input-selectionstart" class=no-backref><a href=#dom-textarea/input-selectionstart>selectionStart</a></code>,
   <code id="file-upload-state-(type=file):dom-textarea/input-selectionend" class=no-backref><a href=#dom-textarea/input-selectionend>selectionEnd</a></code>,
   <code id="file-upload-state-(type=file):dom-textarea/input-selectiondirection" class=no-backref><a href=#dom-textarea/input-selectiondirection>selectionDirection</a></code>,
   <code id="file-upload-state-(type=file):dom-input-valueasdate" class=no-backref><a href=#dom-input-valueasdate>valueAsDate</a></code>, and
   <code id="file-upload-state-(type=file):dom-input-valueasnumber" class=no-backref><a href=#dom-input-valueasnumber>valueAsNumber</a></code> IDL attributes;
   <code id="file-upload-state-(type=file):dom-textarea/input-setrangetext" class=no-backref><a href=#dom-textarea/input-setrangetext>setRangeText()</a></code>,
   <code id="file-upload-state-(type=file):dom-textarea/input-setselectionrange" class=no-backref><a href=#dom-textarea/input-setselectionrange>setSelectionRange()</a></code>,
   <code id="file-upload-state-(type=file):dom-input-stepdown" class=no-backref><a href=#dom-input-stepdown>stepDown()</a></code>, and
   <code id="file-upload-state-(type=file):dom-input-stepup" class=no-backref><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>Submit Button</dfn> state (<code>type=submit</code>)<a href="#submit-button-state-(type=submit)" class=self-link></a></h6>

  

  <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>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
  implementation-defined 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>.
  <a href=#fingerprinting-vector id="submit-button-state-(type=submit):fingerprinting-vector" class=fingerprint title="There is a potential fingerprinting vector here."><img alt="(This is a fingerprinting vector.)" src=/images/fingerprint.png width=46 height=64></a>
  </p>

  <p class=note>Since the default label is implementation-defined, 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>

  

  <p>The element's <a href=#input-activation-behavior id="submit-button-state-(type=submit):input-activation-behavior">input activation behavior</a> is as follows: if the element has a
  <a href=#form-owner id="submit-button-state-(type=submit):form-owner">form owner</a>, and 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 <a href=#fully-active id="submit-button-state-(type=submit):fully-active">fully
  active</a>, <a href=#concept-form-submit id="submit-button-state-(type=submit):concept-form-submit">submit</a> the <a href=#form-owner id="submit-button-state-(type=submit):form-owner-2">form owner</a> from
  the <code id="submit-button-state-(type=submit):the-input-element-3"><a href=#the-input-element>input</a></code> element; otherwise, do nothing.</p>

  

  <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-4"><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-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>, and
   <code id="submit-button-state-(type=submit):attr-fs-formtarget-2"><a href=#attr-fs-formtarget>formtarget</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" class=no-backref><a href=#attr-input-accept>accept</a></code>,
   <code id="submit-button-state-(type=submit):attr-input-alt" class=no-backref><a href=#attr-input-alt>alt</a></code>,
   <code id="submit-button-state-(type=submit):attr-fe-autocomplete" class=no-backref><a href=#attr-fe-autocomplete>autocomplete</a></code>,
   <code id="submit-button-state-(type=submit):attr-input-checked" class=no-backref><a href=#attr-input-checked>checked</a></code>,
   <code id="submit-button-state-(type=submit):attr-fe-dirname" class=no-backref><a href=#attr-fe-dirname>dirname</a></code>,
   <code id="submit-button-state-(type=submit):attr-dim-height" class=no-backref><a href=#attr-dim-height>height</a></code>,
   <code id="submit-button-state-(type=submit):attr-input-list" class=no-backref><a href=#attr-input-list>list</a></code>,
   <code id="submit-button-state-(type=submit):attr-input-max" class=no-backref><a href=#attr-input-max>max</a></code>,
   <code id="submit-button-state-(type=submit):attr-input-maxlength" class=no-backref><a href=#attr-input-maxlength>maxlength</a></code>,
   <code id="submit-button-state-(type=submit):attr-input-min" class=no-backref><a href=#attr-input-min>min</a></code>,
   <code id="submit-button-state-(type=submit):attr-input-minlength" class=no-backref><a href=#attr-input-minlength>minlength</a></code>,
   <code id="submit-button-state-(type=submit):attr-input-multiple" class=no-backref><a href=#attr-input-multiple>multiple</a></code>,
   <code id="submit-button-state-(type=submit):attr-input-pattern" class=no-backref><a href=#attr-input-pattern>pattern</a></code>,
   <code id="submit-button-state-(type=submit):attr-input-placeholder" class=no-backref><a href=#attr-input-placeholder>placeholder</a></code>,
   <code id="submit-button-state-(type=submit):attr-input-readonly" class=no-backref><a href=#attr-input-readonly>readonly</a></code>,
   <code id="submit-button-state-(type=submit):attr-input-required" class=no-backref><a href=#attr-input-required>required</a></code>,
   <code id="submit-button-state-(type=submit):attr-input-size" class=no-backref><a href=#attr-input-size>size</a></code>,
   <code id="submit-button-state-(type=submit):attr-input-src" class=no-backref><a href=#attr-input-src>src</a></code>,
   <code id="submit-button-state-(type=submit):attr-input-step" class=no-backref><a href=#attr-input-step>step</a></code>, and
   <code id="submit-button-state-(type=submit):attr-dim-width" class=no-backref><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" class=no-backref><a href=#dom-input-checked>checked</a></code>,
   <code id="submit-button-state-(type=submit):dom-input-files" class=no-backref><a href=#dom-input-files>files</a></code>,
   <code id="submit-button-state-(type=submit):dom-input-list" class=no-backref><a href=#dom-input-list>list</a></code>,
   <code id="submit-button-state-(type=submit):dom-textarea/input-selectionstart" class=no-backref><a href=#dom-textarea/input-selectionstart>selectionStart</a></code>,
   <code id="submit-button-state-(type=submit):dom-textarea/input-selectionend" class=no-backref><a href=#dom-textarea/input-selectionend>selectionEnd</a></code>,
   <code id="submit-button-state-(type=submit):dom-textarea/input-selectiondirection" class=no-backref><a href=#dom-textarea/input-selectiondirection>selectionDirection</a></code>,
   <code id="submit-button-state-(type=submit):dom-input-valueasdate" class=no-backref><a href=#dom-input-valueasdate>valueAsDate</a></code>, and
   <code id="submit-button-state-(type=submit):dom-input-valueasnumber" class=no-backref><a href=#dom-input-valueasnumber>valueAsNumber</a></code> IDL attributes;
   <code id="submit-button-state-(type=submit):dom-textarea/input-select" class=no-backref><a href=#dom-textarea/input-select>select()</a></code>,
   <code id="submit-button-state-(type=submit):dom-textarea/input-setrangetext" class=no-backref><a href=#dom-textarea/input-setrangetext>setRangeText()</a></code>,
   <code id="submit-button-state-(type=submit):dom-textarea/input-setselectionrange" class=no-backref><a href=#dom-textarea/input-setselectionrange>setSelectionRange()</a></code>,
   <code id="submit-button-state-(type=submit):dom-input-stepdown" class=no-backref><a href=#dom-input-stepdown>stepDown()</a></code>, and
   <code id="submit-button-state-(type=submit):dom-input-stepup" class=no-backref><a href=#dom-input-stepup>stepUp()</a></code> methods.</p>

   <p>The <code id="submit-button-state-(type=submit):event-input" class=no-backref><a href=#event-input>input</a></code> and <code id="submit-button-state-(type=submit):event-change" class=no-backref><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>Image Button</dfn> state (<code>type=image</code>)<a href="#image-button-state-(type=image)" class=self-link></a></h6>

  

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

  <p>The image is given by the <dfn id=attr-input-src><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>

  

  <p>When any of the these events occur

  <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>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>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</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, the user agent must <a href=#parse-a-url id="image-button-state-(type=image):parse-a-url">parse</a> the value of the <code id="image-button-state-(type=image):attr-input-src-6"><a href=#attr-input-src>src</a></code>
  attribute 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>, and if that is successful,
  then:</p>

  <ol><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 the <a href=#resulting-url-record id="image-button-state-(type=image):resulting-url-record">resulting URL record</a>,
   <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/#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.<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>.</ol>

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

  <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-6"><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>

  <p>The <a href=#concept-task id="image-button-state-(type=image):concept-task-3">task</a> that is <a href=#queue-a-task id="image-button-state-(type=image):queue-a-task-3">queued</a>
  by the <a href=#networking-task-source id="image-button-state-(type=image):networking-task-source-3">networking task source</a> once the resource has been fetched, must, 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-a-task id="image-button-state-(type=image):queue-a-task-4">queue a task</a> 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; and 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, <a href=#queue-a-task id="image-button-state-(type=image):queue-a-task-5">queue a task</a> 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-8"><a href=#the-input-element>input</a></code> element.</p>

  <hr>

  

  <p>The <dfn id=attr-input-alt><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-9"><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>

  <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; 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>, and the element's <a href=#input-activation-behavior id="image-button-state-(type=image):input-activation-behavior">input
  activation behavior</a> is as follows: if the element has a <a href=#form-owner id="image-button-state-(type=image):form-owner">form owner</a>, and 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 <a href=#fully-active id="image-button-state-(type=image):fully-active">fully active</a>, take the user's selected <a href=#concept-input-type-image-coordinate id="image-button-state-(type=image):concept-input-type-image-coordinate-3">coordinate</a>, and <a href=#concept-form-submit id="image-button-state-(type=image):concept-form-submit">submit</a> the <code id="image-button-state-(type=image):the-input-element-10"><a href=#the-input-element>input</a></code> element's <a href=#form-owner id="image-button-state-(type=image):form-owner-2">form owner</a>
  from the <code id="image-button-state-(type=image):the-input-element-11"><a href=#the-input-element>input</a></code> element. If the user activates the control without explicitly
  selecting a coordinate, then the coordinate (0,0) must be assumed.</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; the element's <a href=#input-activation-behavior id="image-button-state-(type=image):input-activation-behavior-2">input
  activation behavior</a> is as follows: if the element has a <a href=#form-owner id="image-button-state-(type=image):form-owner-3">form owner</a>, and the
  element's <a id="image-button-state-(type=image):node-document-5" href=https://dom.spec.whatwg.org/#concept-node-document data-x-internal=node-document>node document</a> is <a href=#fully-active id="image-button-state-(type=image):fully-active-2">fully active</a>, set the <a href=#concept-input-type-image-coordinate id="image-button-state-(type=image):concept-input-type-image-coordinate-4">selected coordinate</a> to (0,0), and <a href=#concept-form-submit id="image-button-state-(type=image):concept-form-submit-2">submit</a> the <code id="image-button-state-(type=image):the-input-element-12"><a href=#the-input-element>input</a></code> element's <a href=#form-owner id="image-button-state-(type=image):form-owner-4">form
  owner</a> from the <code id="image-button-state-(type=image):the-input-element-13"><a href=#the-input-element>input</a></code> element.</p>

  <p>In either case, if the element has no <a href=#form-owner id="image-button-state-(type=image):form-owner-5">form owner</a> or the element's <a id="image-button-state-(type=image):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="image-button-state-(type=image):fully-active-3">fully active</a>, then its <a href=#input-activation-behavior id="image-button-state-(type=image):input-activation-behavior-3">input activation behavior</a>
  must be to do nothing..</p>

  <p>The <dfn id=concept-input-type-image-coordinate>selected coordinate</dfn> must consist of
  an <var>x</var>-component and a <var>y</var>-component. The coordinates
  represent the position relative to the edge of the 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>

  <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><var>image</var> . <code id=dom-input-width-dev><a href=#dom-input-width>width</a></code> [ = <var>value</var> ]<dt><var>image</var> . <code id=dom-input-height-dev><a href=#dom-input-height>height</a></code> [ = <var>value</var> ]<dd>

    <p>These attributes return the actual rendered dimensions of the image, or zero if the
    dimensions are not known.</p>

    <p>They can be set, to change the corresponding content attributes.</p>

   </dl>

  <div class=bookkeeping>

   <p>The following common <code id="image-button-state-(type=image):the-input-element-14"><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-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" class=no-backref><a href=#attr-input-accept>accept</a></code>,
   <code id="image-button-state-(type=image):attr-fe-autocomplete" class=no-backref><a href=#attr-fe-autocomplete>autocomplete</a></code>,
   <code id="image-button-state-(type=image):attr-input-checked" class=no-backref><a href=#attr-input-checked>checked</a></code>,
   <code id="image-button-state-(type=image):attr-fe-dirname" class=no-backref><a href=#attr-fe-dirname>dirname</a></code>,
   <code id="image-button-state-(type=image):attr-input-list" class=no-backref><a href=#attr-input-list>list</a></code>,
   <code id="image-button-state-(type=image):attr-input-max" class=no-backref><a href=#attr-input-max>max</a></code>,
   <code id="image-button-state-(type=image):attr-input-maxlength" class=no-backref><a href=#attr-input-maxlength>maxlength</a></code>,
   <code id="image-button-state-(type=image):attr-input-min" class=no-backref><a href=#attr-input-min>min</a></code>,
   <code id="image-button-state-(type=image):attr-input-minlength" class=no-backref><a href=#attr-input-minlength>minlength</a></code>,
   <code id="image-button-state-(type=image):attr-input-multiple" class=no-backref><a href=#attr-input-multiple>multiple</a></code>,
   <code id="image-button-state-(type=image):attr-input-pattern" class=no-backref><a href=#attr-input-pattern>pattern</a></code>,
   <code id="image-button-state-(type=image):attr-input-placeholder" class=no-backref><a href=#attr-input-placeholder>placeholder</a></code>,
   <code id="image-button-state-(type=image):attr-input-readonly" class=no-backref><a href=#attr-input-readonly>readonly</a></code>,
   <code id="image-button-state-(type=image):attr-input-required" class=no-backref><a href=#attr-input-required>required</a></code>,
   <code id="image-button-state-(type=image):attr-input-size" class=no-backref><a href=#attr-input-size>size</a></code>, and
   <code id="image-button-state-(type=image):attr-input-step" class=no-backref><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" class=no-backref><a href=#dom-input-checked>checked</a></code>,
   <code id="image-button-state-(type=image):dom-input-files" class=no-backref><a href=#dom-input-files>files</a></code>,
   <code id="image-button-state-(type=image):dom-input-list" class=no-backref><a href=#dom-input-list>list</a></code>,
   <code id="image-button-state-(type=image):dom-textarea/input-selectionstart" class=no-backref><a href=#dom-textarea/input-selectionstart>selectionStart</a></code>,
   <code id="image-button-state-(type=image):dom-textarea/input-selectionend" class=no-backref><a href=#dom-textarea/input-selectionend>selectionEnd</a></code>,
   <code id="image-button-state-(type=image):dom-textarea/input-selectiondirection" class=no-backref><a href=#dom-textarea/input-selectiondirection>selectionDirection</a></code>,
   <code id="image-button-state-(type=image):dom-input-valueasdate" class=no-backref><a href=#dom-input-valueasdate>valueAsDate</a></code>, and
   <code id="image-button-state-(type=image):dom-input-valueasnumber" class=no-backref><a href=#dom-input-valueasnumber>valueAsNumber</a></code> IDL attributes;
   <code id="image-button-state-(type=image):dom-textarea/input-select" class=no-backref><a href=#dom-textarea/input-select>select()</a></code>,
   <code id="image-button-state-(type=image):dom-textarea/input-setrangetext" class=no-backref><a href=#dom-textarea/input-setrangetext>setRangeText()</a></code>,
   <code id="image-button-state-(type=image):dom-textarea/input-setselectionrange" class=no-backref><a href=#dom-textarea/input-setselectionrange>setSelectionRange()</a></code>,
   <code id="image-button-state-(type=image):dom-input-stepdown" class=no-backref><a href=#dom-input-stepdown>stepDown()</a></code>, and
   <code id="image-button-state-(type=image):dom-input-stepup" class=no-backref><a href=#dom-input-stepup>stepUp()</a></code> methods.</p>

   <p>The <code id="image-button-state-(type=image):event-input" class=no-backref><a href=#event-input>input</a></code> and <code id="image-button-state-(type=image):event-change" class=no-backref><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>&quot;process.cgi&quot;</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>&quot;Show location list&quot;</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>Reset Button</dfn> state (<code>type=reset</code>)<a href="#reset-button-state-(type=reset)" class=self-link></a></h6>

  

  <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>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
  implementation-defined 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>.
  <a href=#fingerprinting-vector id="reset-button-state-(type=reset):fingerprinting-vector" class=fingerprint title="There is a potential fingerprinting vector here."><img alt="(This is a fingerprinting vector.)" src=/images/fingerprint.png width=46 height=64></a>
  </p>

  <p class=note>Since the default label is implementation-defined, 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>

  

  <p>The element's <a href=#input-activation-behavior id="reset-button-state-(type=reset):input-activation-behavior">input activation behavior</a>, if the element has a <a href=#form-owner id="reset-button-state-(type=reset):form-owner">form
  owner</a> and 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 <a href=#fully-active id="reset-button-state-(type=reset):fully-active">fully active</a>, is to
  <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>; otherwise, it is to do
  nothing.</p>

  <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 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 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" class=no-backref><a href=#attr-input-accept>accept</a></code>,
   <code id="reset-button-state-(type=reset):attr-input-alt" class=no-backref><a href=#attr-input-alt>alt</a></code>,
   <code id="reset-button-state-(type=reset):attr-fe-autocomplete" class=no-backref><a href=#attr-fe-autocomplete>autocomplete</a></code>,
   <code id="reset-button-state-(type=reset):attr-input-checked" class=no-backref><a href=#attr-input-checked>checked</a></code>,
   <code id="reset-button-state-(type=reset):attr-fe-dirname" class=no-backref><a href=#attr-fe-dirname>dirname</a></code>,
   <code id="reset-button-state-(type=reset):attr-fs-formaction" class=no-backref><a href=#attr-fs-formaction>formaction</a></code>,
   <code id="reset-button-state-(type=reset):attr-fs-formenctype" class=no-backref><a href=#attr-fs-formenctype>formenctype</a></code>,
   <code id="reset-button-state-(type=reset):attr-fs-formmethod" class=no-backref><a href=#attr-fs-formmethod>formmethod</a></code>,
   <code id="reset-button-state-(type=reset):attr-fs-formnovalidate" class=no-backref><a href=#attr-fs-formnovalidate>formnovalidate</a></code>,
   <code id="reset-button-state-(type=reset):attr-fs-formtarget" class=no-backref><a href=#attr-fs-formtarget>formtarget</a></code>,
   <code id="reset-button-state-(type=reset):attr-dim-height" class=no-backref><a href=#attr-dim-height>height</a></code>,
   <code id="reset-button-state-(type=reset):attr-input-list" class=no-backref><a href=#attr-input-list>list</a></code>,
   <code id="reset-button-state-(type=reset):attr-input-max" class=no-backref><a href=#attr-input-max>max</a></code>,
   <code id="reset-button-state-(type=reset):attr-input-maxlength" class=no-backref><a href=#attr-input-maxlength>maxlength</a></code>,
   <code id="reset-button-state-(type=reset):attr-input-min" class=no-backref><a href=#attr-input-min>min</a></code>,
   <code id="reset-button-state-(type=reset):attr-input-minlength" class=no-backref><a href=#attr-input-minlength>minlength</a></code>,
   <code id="reset-button-state-(type=reset):attr-input-multiple" class=no-backref><a href=#attr-input-multiple>multiple</a></code>,
   <code id="reset-button-state-(type=reset):attr-input-pattern" class=no-backref><a href=#attr-input-pattern>pattern</a></code>,
   <code id="reset-button-state-(type=reset):attr-input-placeholder" class=no-backref><a href=#attr-input-placeholder>placeholder</a></code>,
   <code id="reset-button-state-(type=reset):attr-input-readonly" class=no-backref><a href=#attr-input-readonly>readonly</a></code>,
   <code id="reset-button-state-(type=reset):attr-input-required" class=no-backref><a href=#attr-input-required>required</a></code>,
   <code id="reset-button-state-(type=reset):attr-input-size" class=no-backref><a href=#attr-input-size>size</a></code>,
   <code id="reset-button-state-(type=reset):attr-input-src" class=no-backref><a href=#attr-input-src>src</a></code>,
   <code id="reset-button-state-(type=reset):attr-input-step" class=no-backref><a href=#attr-input-step>step</a></code>, and
   <code id="reset-button-state-(type=reset):attr-dim-width" class=no-backref><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" class=no-backref><a href=#dom-input-checked>checked</a></code>,
   <code id="reset-button-state-(type=reset):dom-input-files" class=no-backref><a href=#dom-input-files>files</a></code>,
   <code id="reset-button-state-(type=reset):dom-input-list" class=no-backref><a href=#dom-input-list>list</a></code>,
   <code id="reset-button-state-(type=reset):dom-textarea/input-selectionstart" class=no-backref><a href=#dom-textarea/input-selectionstart>selectionStart</a></code>,
   <code id="reset-button-state-(type=reset):dom-textarea/input-selectionend" class=no-backref><a href=#dom-textarea/input-selectionend>selectionEnd</a></code>,
   <code id="reset-button-state-(type=reset):dom-textarea/input-selectiondirection" class=no-backref><a href=#dom-textarea/input-selectiondirection>selectionDirection</a></code>,
   <code id="reset-button-state-(type=reset):dom-input-valueasdate" class=no-backref><a href=#dom-input-valueasdate>valueAsDate</a></code>, and
   <code id="reset-button-state-(type=reset):dom-input-valueasnumber" class=no-backref><a href=#dom-input-valueasnumber>valueAsNumber</a></code> IDL attributes;
   <code id="reset-button-state-(type=reset):dom-textarea/input-select" class=no-backref><a href=#dom-textarea/input-select>select()</a></code>,
   <code id="reset-button-state-(type=reset):dom-textarea/input-setrangetext" class=no-backref><a href=#dom-textarea/input-setrangetext>setRangeText()</a></code>,
   <code id="reset-button-state-(type=reset):dom-textarea/input-setselectionrange" class=no-backref><a href=#dom-textarea/input-setselectionrange>setSelectionRange()</a></code>,
   <code id="reset-button-state-(type=reset):dom-input-stepdown" class=no-backref><a href=#dom-input-stepdown>stepDown()</a></code>, and
   <code id="reset-button-state-(type=reset):dom-input-stepup" class=no-backref><a href=#dom-input-stepup>stepUp()</a></code> methods.</p>

   <p>The <code id="reset-button-state-(type=reset):event-input" class=no-backref><a href=#event-input>input</a></code> and <code id="reset-button-state-(type=reset):event-change" class=no-backref><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>Button</dfn> state (<code>type=button</code>)<a href="#button-state-(type=button)" class=self-link></a></h6>

  

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

  <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 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 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" class=no-backref><a href=#attr-input-accept>accept</a></code>,
   <code id="button-state-(type=button):attr-input-alt" class=no-backref><a href=#attr-input-alt>alt</a></code>,
   <code id="button-state-(type=button):attr-fe-autocomplete" class=no-backref><a href=#attr-fe-autocomplete>autocomplete</a></code>,
   <code id="button-state-(type=button):attr-input-checked" class=no-backref><a href=#attr-input-checked>checked</a></code>,
   <code id="button-state-(type=button):attr-fe-dirname" class=no-backref><a href=#attr-fe-dirname>dirname</a></code>,
   <code id="button-state-(type=button):attr-fs-formaction" class=no-backref><a href=#attr-fs-formaction>formaction</a></code>,
   <code id="button-state-(type=button):attr-fs-formenctype" class=no-backref><a href=#attr-fs-formenctype>formenctype</a></code>,
   <code id="button-state-(type=button):attr-fs-formmethod" class=no-backref><a href=#attr-fs-formmethod>formmethod</a></code>,
   <code id="button-state-(type=button):attr-fs-formnovalidate" class=no-backref><a href=#attr-fs-formnovalidate>formnovalidate</a></code>,
   <code id="button-state-(type=button):attr-fs-formtarget" class=no-backref><a href=#attr-fs-formtarget>formtarget</a></code>,
   <code id="button-state-(type=button):attr-dim-height" class=no-backref><a href=#attr-dim-height>height</a></code>,
   <code id="button-state-(type=button):attr-input-list" class=no-backref><a href=#attr-input-list>list</a></code>,
   <code id="button-state-(type=button):attr-input-max" class=no-backref><a href=#attr-input-max>max</a></code>,
   <code id="button-state-(type=button):attr-input-maxlength" class=no-backref><a href=#attr-input-maxlength>maxlength</a></code>,
   <code id="button-state-(type=button):attr-input-min" class=no-backref><a href=#attr-input-min>min</a></code>,
   <code id="button-state-(type=button):attr-input-minlength" class=no-backref><a href=#attr-input-minlength>minlength</a></code>,
   <code id="button-state-(type=button):attr-input-multiple" class=no-backref><a href=#attr-input-multiple>multiple</a></code>,
   <code id="button-state-(type=button):attr-input-pattern" class=no-backref><a href=#attr-input-pattern>pattern</a></code>,
   <code id="button-state-(type=button):attr-input-placeholder" class=no-backref><a href=#attr-input-placeholder>placeholder</a></code>,
   <code id="button-state-(type=button):attr-input-readonly" class=no-backref><a href=#attr-input-readonly>readonly</a></code>,
   <code id="button-state-(type=button):attr-input-required" class=no-backref><a href=#attr-input-required>required</a></code>,
   <code id="button-state-(type=button):attr-input-size" class=no-backref><a href=#attr-input-size>size</a></code>,
   <code id="button-state-(type=button):attr-input-src" class=no-backref><a href=#attr-input-src>src</a></code>,
   <code id="button-state-(type=button):attr-input-step" class=no-backref><a href=#attr-input-step>step</a></code>, and
   <code id="button-state-(type=button):attr-dim-width" class=no-backref><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" class=no-backref><a href=#dom-input-checked>checked</a></code>,
   <code id="button-state-(type=button):dom-input-files" class=no-backref><a href=#dom-input-files>files</a></code>,
   <code id="button-state-(type=button):dom-input-list" class=no-backref><a href=#dom-input-list>list</a></code>,
   <code id="button-state-(type=button):dom-textarea/input-selectionstart" class=no-backref><a href=#dom-textarea/input-selectionstart>selectionStart</a></code>,
   <code id="button-state-(type=button):dom-textarea/input-selectionend" class=no-backref><a href=#dom-textarea/input-selectionend>selectionEnd</a></code>,
   <code id="button-state-(type=button):dom-textarea/input-selectiondirection" class=no-backref><a href=#dom-textarea/input-selectiondirection>selectionDirection</a></code>,
   <code id="button-state-(type=button):dom-input-valueasdate" class=no-backref><a href=#dom-input-valueasdate>valueAsDate</a></code>, and
   <code id="button-state-(type=button):dom-input-valueasnumber" class=no-backref><a href=#dom-input-valueasnumber>valueAsNumber</a></code> IDL attributes;
   <code id="button-state-(type=button):dom-textarea/input-select" class=no-backref><a href=#dom-textarea/input-select>select()</a></code>,
   <code id="button-state-(type=button):dom-textarea/input-setrangetext" class=no-backref><a href=#dom-textarea/input-setrangetext>setRangeText()</a></code>,
   <code id="button-state-(type=button):dom-textarea/input-setselectionrange" class=no-backref><a href=#dom-textarea/input-setselectionrange>setSelectionRange()</a></code>,
   <code id="button-state-(type=button):dom-input-stepdown" class=no-backref><a href=#dom-input-stepdown>stepDown()</a></code>, and
   <code id="button-state-(type=button):dom-input-stepup" class=no-backref><a href=#dom-input-stepup>stepUp()</a></code> methods.</p>

   <p>The <code id="button-state-(type=button):event-input" class=no-backref><a href=#event-input>input</a></code> and <code id="button-state-(type=button):event-change" class=no-backref><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 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=status><input onclick=toggleStatus(this) value=⋰ type=button><p class=support><strong>Support:</strong> input-minlength<span class="and_chr yes"><span>Chrome for Android</span> <span>67+</span></span><span class="chrome yes"><span>Chrome</span> <span>40+</span></span><span class="ios_saf yes"><span>iOS Safari</span> <span>10.3+</span></span><span class="and_uc yes"><span>UC Browser for Android</span> <span>11.8+</span></span><span class="firefox yes"><span>Firefox</span> <span>51+</span></span><span class="ie no"><span>IE</span> <span>None</span></span><span class="op_mini no"><span>Opera Mini</span> <span>None</span></span><span class="safari yes"><span>Safari</span> <span>10.1+</span></span><span class="edge yes"><span>Edge</span> <span>17+</span></span><span class="samsung yes"><span>Samsung Internet</span> <span>5+</span></span><span class="opera yes"><span>Opera</span> <span>27+</span></span><span class="android yes"><span>Android Browser</span> <span>67+</span></span><p class=caniuse>Source: <a href="https://caniuse.com/#feat=input-minlength">caniuse.com</a></div>

  <p>The <dfn id=attr-input-maxlength><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>.<div class=status><input onclick=toggleStatus(this) value=⋰ type=button><p class=support><strong>Support:</strong> maxlength<span class="and_chr yes"><span>Chrome for Android</span> <span>67+</span></span><span class="chrome yes"><span>Chrome</span> <span>4+</span></span><span class="ios_saf yes"><span>iOS Safari</span> <span>9.0+</span></span><span class="and_uc yes"><span>UC Browser for Android</span> <span>11.8+</span></span><span class="firefox yes"><span>Firefox</span> <span>4+</span></span><span class="ie yes"><span>IE</span> <span>10+</span></span><span class="op_mini partial"><span>Opera Mini (limited)</span> <span>all+</span></span><span class="safari yes"><span>Safari</span> <span>5.1+</span></span><span class="edge yes"><span>Edge</span> <span>12+</span></span><span class="samsung yes"><span>Samsung Internet</span> <span>4+</span></span><span class="opera yes"><span>Opera</span> <span>15+</span></span><span class="android yes"><span>Android Browser</span> <span>2.3+</span></span><p class=caniuse>Source: <a href="https://caniuse.com/#feat=maxlength">caniuse.com</a></div>

  <p>The <dfn id=attr-input-minlength><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:javascript-string-length href=https://infra.spec.whatwg.org/#javascript-string-length data-x-internal=javascript-string-length>JavaScript string 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 equal to or less than 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 id=attr-input-size><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
  non-negative numbers greater than zero</a> and has a default value 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>

  <p>The <dfn id=attr-input-readonly><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>.<div class=status><input onclick=toggleStatus(this) value=⋰ type=button><p class=support><strong>Support:</strong> readonly-attr<span class="and_chr yes"><span>Chrome for Android</span> <span>67+</span></span><span class="chrome yes"><span>Chrome</span> <span>26+</span></span><span class="ios_saf yes"><span>iOS Safari</span> <span>7.0+</span></span><span class="and_uc yes"><span>UC Browser for Android</span> <span>11.8+</span></span><span class="firefox yes"><span>Firefox</span> <span>4+</span></span><span class="ie yes"><span>IE</span> <span>6+</span></span><span class="op_mini yes"><span>Opera Mini</span> <span>all+</span></span><span class="safari yes"><span>Safari</span> <span>5.1+</span></span><span class="edge yes"><span>Edge</span> <span>12+</span></span><span class="samsung yes"><span>Samsung Internet</span> <span>4+</span></span><span class="opera yes"><span>Opera</span> <span>15+</span></span><span class="android yes"><span>Android Browser</span> <span>2.3+</span></span><p class=caniuse>Source: <a href="https://caniuse.com/#feat=readonly-attr">caniuse.com</a></div>

  

  <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 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>&quot;products.cgi&quot;</c-> <c- e>method</c-><c- o>=</c-><c- s>&quot;post&quot;</c-> <c- e>enctype</c-><c- o>=</c-><c- s>&quot;multipart/form-data&quot;</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>&quot;readonly&quot;</c-> <c- e>name</c-><c- o>=</c-><c- s>&quot;1.pid&quot;</c-> <c- e>value</c-><c- o>=</c-><c- s>&quot;H412&quot;</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>&quot;required&quot;</c-> <c- e>name</c-><c- o>=</c-><c- s>&quot;1.pname&quot;</c-> <c- e>value</c-><c- o>=</c-><c- s>&quot;Floor lamp Ulke&quot;</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>&quot;required&quot;</c-> <c- e>type</c-><c- o>=</c-><c- s>&quot;number&quot;</c-> <c- e>min</c-><c- o>=</c-><c- s>&quot;0&quot;</c-> <c- e>step</c-><c- o>=</c-><c- s>&quot;0.01&quot;</c-> <c- e>name</c-><c- o>=</c-><c- s>&quot;1.pprice&quot;</c-> <c- e>value</c-><c- o>=</c-><c- s>&quot;49.99&quot;</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>&quot;formnovalidate&quot;</c-> <c- e>name</c-><c- o>=</c-><c- s>&quot;action&quot;</c-> <c- e>value</c-><c- o>=</c-><c- s>&quot;delete:1&quot;</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>&quot;readonly&quot;</c-> <c- e>name</c-><c- o>=</c-><c- s>&quot;2.pid&quot;</c-> <c- e>value</c-><c- o>=</c-><c- s>&quot;FG28&quot;</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>&quot;required&quot;</c-> <c- e>name</c-><c- o>=</c-><c- s>&quot;2.pname&quot;</c-> <c- e>value</c-><c- o>=</c-><c- s>&quot;Table lamp Ulke&quot;</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>&quot;required&quot;</c-> <c- e>type</c-><c- o>=</c-><c- s>&quot;number&quot;</c-> <c- e>min</c-><c- o>=</c-><c- s>&quot;0&quot;</c-> <c- e>step</c-><c- o>=</c-><c- s>&quot;0.01&quot;</c-> <c- e>name</c-><c- o>=</c-><c- s>&quot;2.pprice&quot;</c-> <c- e>value</c-><c- o>=</c-><c- s>&quot;24.99&quot;</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>&quot;formnovalidate&quot;</c-> <c- e>name</c-><c- o>=</c-><c- s>&quot;action&quot;</c-> <c- e>value</c-><c- o>=</c-><c- s>&quot;delete:2&quot;</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>&quot;required&quot;</c-> <c- e>name</c-><c- o>=</c-><c- s>&quot;3.pid&quot;</c-> <c- e>value</c-><c- o>=</c-><c- s>&quot;&quot;</c-> <c- e>pattern</c-><c- o>=</c-><c- s>&quot;[A-Z0-9]+&quot;</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>&quot;required&quot;</c-> <c- e>name</c-><c- o>=</c-><c- s>&quot;3.pname&quot;</c-> <c- e>value</c-><c- o>=</c-><c- s>&quot;&quot;</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>&quot;required&quot;</c-> <c- e>type</c-><c- o>=</c-><c- s>&quot;number&quot;</c-> <c- e>min</c-><c- o>=</c-><c- s>&quot;0&quot;</c-> <c- e>step</c-><c- o>=</c-><c- s>&quot;0.01&quot;</c-> <c- e>name</c-><c- o>=</c-><c- s>&quot;3.pprice&quot;</c-> <c- e>value</c-><c- o>=</c-><c- s>&quot;&quot;</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>&quot;formnovalidate&quot;</c-> <c- e>name</c-><c- o>=</c-><c- s>&quot;action&quot;</c-> <c- e>value</c-><c- o>=</c-><c- s>&quot;delete:3&quot;</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>&quot;formnovalidate&quot;</c-> <c- e>name</c-><c- o>=</c-><c- s>&quot;action&quot;</c-> <c- e>value</c-><c- o>=</c-><c- s>&quot;add&quot;</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>&quot;action&quot;</c-> <c- e>value</c-><c- o>=</c-><c- s>&quot;update&quot;</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 id=attr-input-required><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>

  

  <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 class=example>

   <p>The following form has two required fields, one for an e-mail 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>&quot;/newaccount&quot;</c-> <c- e>method</c-><c- o>=</c-><c- s>post</c->
      <c- e>oninput</c-><c- o>=</c-><c- s>&quot;up2.setCustomValidity(up2.value != up.value ? &apos;Passwords do not match.&apos; : &apos;&apos;)&quot;</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>&quot;username&quot;</c-><c- p>&gt;</c->E-mail 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>&quot;username&quot;</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>&quot;password1&quot;</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>&quot;password1&quot;</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>&quot;password2&quot;</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>&quot;password2&quot;</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>&quot;Create account&quot;</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>&quot;radio&quot;</c-> <c- e>name</c-><c- o>=</c-><c- s>&quot;bechdel&quot;</c-> <c- e>value</c-><c- o>=</c-><c- s>&quot;no-characters&quot;</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>&quot;radio&quot;</c-> <c- e>name</c-><c- o>=</c-><c- s>&quot;bechdel&quot;</c-> <c- e>value</c-><c- o>=</c-><c- s>&quot;no-names&quot;</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>&quot;radio&quot;</c-> <c- e>name</c-><c- o>=</c-><c- s>&quot;bechdel&quot;</c-> <c- e>value</c-><c- o>=</c-><c- s>&quot;no-topic&quot;</c-><c- p>&gt;</c-> No, when female characters talk to each other it&apos;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>&quot;radio&quot;</c-> <c- e>name</c-><c- o>=</c-><c- s>&quot;bechdel&quot;</c-> <c- e>value</c-><c- o>=</c-><c- s>&quot;yes&quot;</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>&quot;radio&quot;</c-> <c- e>name</c-><c- o>=</c-><c- s>&quot;bechdel&quot;</c-> <c- e>value</c-><c- o>=</c-><c- s>&quot;unknown&quot;</c-><c- p>&gt;</c-> I don&apos;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>

  <p>The <dfn id=attr-input-multiple><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.<div class=status><input onclick=toggleStatus(this) value=⋰ type=button><p class=support><strong>Support:</strong> input-file-multiple<span class="and_chr partial"><span>Chrome for Android (limited)</span> <span>67+</span></span><span class="chrome yes"><span>Chrome</span> <span>5+</span></span><span class="ios_saf yes"><span>iOS Safari</span> <span>6.0+</span></span><span class="and_uc no"><span>UC Browser for Android</span> <span>None</span></span><span class="firefox yes"><span>Firefox</span> <span>3.6+</span></span><span class="ie yes"><span>IE</span> <span>10+</span></span><span class="op_mini no"><span>Opera Mini</span> <span>None</span></span><span class="safari yes"><span>Safari</span> <span>4+</span></span><span class="edge yes"><span>Edge</span> <span>12+</span></span><span class="samsung partial"><span>Samsung Internet (limited)</span> <span>5+</span></span><span class="opera yes"><span>Opera</span> <span>10.6+</span></span><span class="android no"><span>Android Browser</span> <span>None</span></span><p class=caniuse>Source: <a href="https://caniuse.com/#feat=input-file-multiple">caniuse.com</a></div>

  <div class=example>

   <p>The following extract shows how an e-mail client's "To" field could accept multiple e-mail
   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 e-mail addresses to the user.</p>

   
   <p><img 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>&quot;contacts&quot;</c-><c- p>&gt;</c->
 <c- p>&lt;</c-><c- f>option</c-> <c- e>value</c-><c- o>=</c-><c- s>&quot;hedral@damowmow.com&quot;</c-><c- p>&gt;</c->
 <c- p>&lt;</c-><c- f>option</c-> <c- e>value</c-><c- o>=</c-><c- s>&quot;pillar@example.com&quot;</c-><c- p>&gt;</c->
 <c- p>&lt;</c-><c- f>option</c-> <c- e>value</c-><c- o>=</c-><c- s>&quot;astrophy@cute.example&quot;</c-><c- p>&gt;</c->
 <c- p>&lt;</c-><c- f>option</c-> <c- e>value</c-><c- o>=</c-><c- s>&quot;astronomy@science.example.org&quot;</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 e-mail 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 src=/images/sample-email-2.svg width=330 alt="" height=140></p>

  </div>

  <div class=example>

   <p>The following extract shows how an e-mail 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=status><input onclick=toggleStatus(this) value=⋰ type=button><p class=support><strong>Support:</strong> input-pattern<span class="and_chr yes"><span>Chrome for Android</span> <span>67+</span></span><span class="chrome yes"><span>Chrome</span> <span>10+</span></span><span class="ios_saf yes"><span>iOS Safari</span> <span>10.3+</span></span><span class="and_uc yes"><span>UC Browser for Android</span> <span>11.8+</span></span><span class="firefox yes"><span>Firefox</span> <span>4+</span></span><span class="ie yes"><span>IE</span> <span>10+</span></span><span class="op_mini no"><span>Opera Mini</span> <span>None</span></span><span class="safari yes"><span>Safari</span> <span>10.1+</span></span><span class="edge yes"><span>Edge</span> <span>12+</span></span><span class="samsung yes"><span>Samsung Internet</span> <span>4+</span></span><span class="opera yes"><span>Opera</span> <span>9.5+</span></span><span class="android yes"><span>Android Browser</span> <span>4.4.3+</span></span><p class=caniuse>Source: <a href="https://caniuse.com/#feat=input-pattern">caniuse.com</a></div>

  

  <p>The <dfn id=attr-input-pattern><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.github.io/ecma262/#prod-Pattern>Pattern</a></i> production.</p>

  

  <p>If an <code id=the-pattern-attribute:the-input-element><a href=#the-input-element>input</a></code> element has a <code id=the-pattern-attribute:attr-input-pattern-2><a href=#attr-input-pattern>pattern</a></code>
  attribute specified, and the attribute's value, when compiled as a JavaScript regular expression
  with only the "<code>u</code>" flag specified, compiles successfully, then the resulting regular expression is the element's
  <dfn id=compiled-pattern-regular-expression>compiled pattern regular expression</dfn>. If the element has no such attribute, or if the
  value doesn't compile successfully, then the element has no <a href=#compiled-pattern-regular-expression id=the-pattern-attribute:compiled-pattern-regular-expression>compiled pattern regular
  expression</a>. <a href=#refsJAVASCRIPT>[JAVASCRIPT]</a></p>

  <p class=note>If the value doesn't compile successfully, user agents are encouraged to log this
  fact in a developer console, to aid debugging.</p>

  <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-2>compiled pattern regular expression</a> but that regular expression does not match the
  entirety of 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>

  <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-3>compiled pattern regular expression</a> but that regular expression does not match the
  entirety of 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>

  <p>The <a href=#compiled-pattern-regular-expression id=the-pattern-attribute:compiled-pattern-regular-expression-4>compiled pattern regular expression</a>, when matched against a string, must have
  its start anchored to the start of the string and its end anchored to the end of the string.</p>

  <p class=note>This implies that the regular expression language used for this attribute is the
  same as that used in JavaScript, except that the <code id=the-pattern-attribute:attr-input-pattern-3><a href=#attr-input-pattern>pattern</a></code>
  attribute is matched against the entire value, not just any subset (somewhat as if it implied a
  <code>^(?:</code> at the start of the pattern and a <code>)$</code> at the
  end).</p>

  

  <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-4><a href=#attr-input-pattern>pattern</a></code>
  attribute specified, authors should include a <dfn id=attr-input-title><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>&quot;[0-9][A-Z]{3}&quot;</c-> <c- e>name</c-><c- o>=</c-><c- s>&quot;part&quot;</c->
        <c- e>title</c-><c- o>=</c-><c- s>&quot;A part number is a digit followed by three uppercase letters.&quot;</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-5><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>

  

  <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 id=attr-input-min><code>min</code></dfn> and <dfn id=attr-input-max><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>

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

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

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

  

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

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

  

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

  

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

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

  <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 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>&quot;1979-12-31&quot;</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>&quot;&quot;</c-> <c- e>type</c-><c- o>=</c-><c- s>&quot;number&quot;</c-> <c- e>min</c-><c- o>=</c-><c- s>&quot;1&quot;</c-> <c- e>value</c-><c- o>=</c-><c- s>&quot;1&quot;</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>&quot;sleepStart&quot;</c-> <c- e>type</c-><c- o>=</c-><c- s>time</c-> <c- e>min</c-><c- o>=</c-><c- s>&quot;21:00&quot;</c-> <c- e>max</c-><c- o>=</c-><c- s>&quot;06:00&quot;</c-> <c- e>step</c-><c- o>=</c-><c- s>&quot;60&quot;</c-> <c- e>value</c-><c- o>=</c-><c- s>&quot;00:00&quot;</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>

  

  <p>The <dfn id=attr-input-step><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>

  

  <p>The attribute provides the <dfn id=concept-input-step>allowed value step</dfn> for the
  element, as follows:</p>

  <ol><li>If the attribute is absent, then the <a href=#concept-input-step id=the-step-attribute:concept-input-step>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>.<li>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-2>allowed
   value step</a>.<li>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-3>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>.<li>Otherwise, the <a href=#concept-input-step id=the-step-attribute:concept-input-step-4>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>.</ol>

  <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.<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.<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><p>Return zero.</ol>

  <p><strong>Constraint validation</strong>: When the element has an <a href=#concept-input-step id=the-step-attribute:concept-input-step-5>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-6>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 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>

  

  <p>The <dfn id=attr-input-list><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>

  

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

  <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 use substring matching against both the suggestions'
  <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>.</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>&quot;text&quot;</c-> <c- e>list</c-><c- o>=</c-><c- s>&quot;function-types&quot;</c-><c- p>&gt;</c->
<c- p>&lt;</c-><c- f>datalist</c-> <c- e>id</c-><c- o>=</c-><c- s>&quot;function-types&quot;</c-><c- p>&gt;</c->
  <c- p>&lt;</c-><c- f>option</c-> <c- e>value</c-><c- o>=</c-><c- s>&quot;function&quot;</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>&quot;async function&quot;</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>&quot;function*&quot;</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>&quot;=&gt;&quot;</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>&quot;async =&gt;&quot;</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>&quot;async function*&quot;</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 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>=></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>


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

   <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="#e-mail-state-(type=email)" id="the-list-attribute:e-mail-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<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 a user-agent-defined manner.</p>

   </dl>

  <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>&quot;https://www.google.com/&quot;</c-> <c- e>label</c-><c- o>=</c-><c- s>&quot;Google&quot;</c-><c- p>&gt;</c->
 <c- p>&lt;</c-><c- f>option</c-> <c- e>value</c-><c- o>=</c-><c- s>&quot;https://www.reddit.com/&quot;</c-> <c- e>label</c-><c- o>=</c-><c- s>&quot;Reddit&quot;</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>&quot;text&quot;</c-> <c- e>name</c-><c- o>=</c-><c- s>&quot;breed&quot;</c-> <c- e>list</c-><c- o>=</c-><c- s>&quot;breeds&quot;</c-><c- p>&gt;</c->
  <c- p>&lt;</c-><c- f>datalist</c-> <c- e>id</c-><c- o>=</c-><c- s>&quot;breeds&quot;</c-><c- p>&gt;</c->
   <c- p>&lt;</c-><c- f>option</c-> <c- e>value</c-><c- o>=</c-><c- s>&quot;Abyssinian&quot;</c-><c- p>&gt;</c->
   <c- p>&lt;</c-><c- f>option</c-> <c- e>value</c-><c- o>=</c-><c- s>&quot;Alpaca&quot;</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>&quot;text&quot;</c-> <c- e>name</c-><c- o>=</c-><c- s>&quot;breed&quot;</c-> <c- e>list</c-><c- o>=</c-><c- s>&quot;breeds&quot;</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>&quot;breeds&quot;</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>&quot;breed&quot;</c-><c- p>&gt;</c->
    <c- p>&lt;</c-><c- f>option</c-> <c- e>value</c-><c- o>=</c-><c- s>&quot;&quot;</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>), 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>

  

  <p>The <dfn id=attr-input-placeholder><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.<div class=status><input onclick=toggleStatus(this) value=⋰ type=button><p class=support><strong>Support:</strong> input-placeholder<span class="and_chr yes"><span>Chrome for Android</span> <span>67+</span></span><span class="chrome yes"><span>Chrome</span> <span>4+</span></span><span class="ios_saf yes"><span>iOS Safari</span> <span>3.2+</span></span><span class="and_uc yes"><span>UC Browser for Android</span> <span>11.8+</span></span><span class="firefox yes"><span>Firefox</span> <span>4+</span></span><span class="ie yes"><span>IE</span> <span>10+</span></span><span class="op_mini yes"><span>Opera Mini</span> <span>all+</span></span><span class="safari yes"><span>Safari</span> <span>5+</span></span><span class="edge yes"><span>Edge</span> <span>12+</span></span><span class="samsung yes"><span>Samsung Internet</span> <span>4+</span></span><span class="opera yes"><span>Opera</span> <span>11.5+</span></span><span class="android yes"><span>Android Browser</span> <span>4.2+</span></span><p class=caniuse>Source: <a href="https://caniuse.com/#feat=input-placeholder">caniuse.com</a></div>

  <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>&quot;text&quot;</c-> <c- e>name</c-><c- o>=</c-><c- s>&quot;fullname&quot;</c-> <c- e>placeholder</c-><c- o>=</c-><c- s>&quot;John Ratzenberger&quot;</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>&quot;email&quot;</c-> <c- e>name</c-><c- o>=</c-><c- s>&quot;address&quot;</c-> <c- e>placeholder</c-><c- o>=</c-><c- s>&quot;john@example.net&quot;</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>&quot;password&quot;</c-> <c- e>name</c-><c- o>=</c-><c- s>&quot;password&quot;</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>&quot;text&quot;</c-> <c- e>name</c-><c- o>=</c-><c- s>&quot;desc&quot;</c-> <c- e>placeholder</c-><c- o>=</c-><c- s>&quot;My Email Account&quot;</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>&quot;</c-><strong><c- s>&amp;#x202B;</c-></strong><c- s> </c-><bdo dir='rtl'><c- s>رقم الهاتف 1</c-></bdo><c- s> </c-><strong><c- s>&amp;#x202E;</c-></strong><c- s>&quot;</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>&quot;</c-><strong><c- s>&amp;#x202B;</c-></strong><c- s> </c-><bdo dir='rtl'><c- s>رقم الهاتف 2</c-></bdo><c- s> </c-><strong><c- s>&amp;#x202E;</c-></strong><c- s>&quot;</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>&quot;</c-><strong><c- s>&amp;#x202B;</c-></strong><c- s>&amp;#1585;&amp;#1602;&amp;#1605; &amp;#1575;&amp;#1604;&amp;#1607;&amp;#1575;&amp;#1578;&amp;#1601; 1</c-><strong><c- s>&amp;#x202E;</c-></strong><c- s>&quot;</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>&quot;</c-><strong><c- s>&amp;#x202B;</c-></strong><c- s>&amp;#1585;&amp;#1602;&amp;#1605; &amp;#1575;&amp;#1604;&amp;#1607;&amp;#1575;&amp;#1578;&amp;#1601; 2</c-><strong><c- s>&amp;#x202E;</c-></strong><c- s>&quot;</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><var>input</var> . <code id=dom-input-value-dev><a href=#dom-input-value>value</a></code> [ = <var>value</var> ]<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://heycam.github.io/webidl/#invalidstateerror data-x-internal=invalidstateerror>"<code>InvalidStateError</code>"</a> <code id=common-input-element-apis:domexception><a data-x-internal=domexception href=https://heycam.github.io/webidl/#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>

   <dt><var>input</var> . <code id=dom-input-checked-dev><a href=#dom-input-checked>checked</a></code> [ = <var>value</var> ]<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>

   <dt><var>input</var> . <code id=dom-input-files-dev><a href=#dom-input-files>files</a></code> [ = <var>files</var> ]<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>

   <dt><var>input</var> . <code id=dom-input-valueasdate-dev><a href=#dom-input-valueasdate>valueAsDate</a></code> [ = <var>value</var> ]<dd>

    <p>Returns a <code id=common-input-element-apis:date><a data-x-internal=date href=https://tc39.github.io/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://heycam.github.io/webidl/#invalidstateerror data-x-internal=invalidstateerror>"<code>InvalidStateError</code>"</a> <code id=common-input-element-apis:domexception-2><a data-x-internal=domexception href=https://heycam.github.io/webidl/#dfn-DOMException>DOMException</a></code> if the
    control isn't date- or time-based.</p>

   <dt><var>input</var> . <code id=dom-input-valueasnumber-dev><a href=#dom-input-valueasnumber>valueAsNumber</a></code> [ = <var>value</var> ]<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://heycam.github.io/webidl/#invalidstateerror data-x-internal=invalidstateerror>"<code>InvalidStateError</code>"</a> <code id=common-input-element-apis:domexception-3><a data-x-internal=domexception href=https://heycam.github.io/webidl/#dfn-DOMException>DOMException</a></code> if the
    control is neither date- or time-based nor numeric.</p>

   <dt><var>input</var> . <code id=dom-input-stepup-dev><a href=#dom-input-stepup>stepUp</a></code>( [ <var>n</var> ] )<dt><var>input</var> . <code id=dom-input-stepdown-dev><a href=#dom-input-stepdown>stepDown</a></code>( [ <var>n</var> ] )<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://heycam.github.io/webidl/#invalidstateerror data-x-internal=invalidstateerror>"<code>InvalidStateError</code>"</a> <code id=common-input-element-apis:domexception-4><a data-x-internal=domexception href=https://heycam.github.io/webidl/#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>

   <dt><var>input</var> . <code id=dom-input-list-dev><a href=#dom-input-list>list</a></code><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>

   </dl>

  

  <p>The <dfn id=dom-input-value><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>

   <dd>
    <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>

    <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>.<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.<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.<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.<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>".</ol>
   <dt><dfn id=dom-input-value-default>default</dfn>

   <dd>
    <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>

    <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>
   <dt><dfn id=dom-input-value-default-on>default/on</dfn>

   <dd>
    <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>

    <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>
   <dt><dfn id=dom-input-value-filename>filename</dfn>

   <dd id=fakepath-orly>

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

    <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-5 href=https://heycam.github.io/webidl/#invalidstateerror data-x-internal=invalidstateerror>"<code>InvalidStateError</code>"</a> <code id=common-input-element-apis:domexception-5><a data-x-internal=domexception href=https://heycam.github.io/webidl/#dfn-DOMException>DOMException</a></code>.</p>

    <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 file names 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>

   </dl>

  <hr>

  <p>The <dfn id=dom-input-checked><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>

  <hr>

  <p>The <dfn id=dom-input-files><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>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>

  <p>On setting, it must run these steps:

  <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.<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.</ol>

  <hr>

  <p>The <dfn id=dom-input-valueasdate><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>

  <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.github.io/ecma262/#sec-date-objects>Date</a></code> object, then
  return it, otherwise, return null.</p>

  <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-6 href=https://heycam.github.io/webidl/#invalidstateerror data-x-internal=invalidstateerror>"<code>InvalidStateError</code>"</a> <code id=common-input-element-apis:domexception-6><a data-x-internal=domexception href=https://heycam.github.io/webidl/#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.github.io/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.github.io/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.github.io/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>

  <hr>

  <p>The <dfn id=dom-input-valueasnumber><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>

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

  <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.github.io/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-7 href=https://heycam.github.io/webidl/#invalidstateerror data-x-internal=invalidstateerror>"<code>InvalidStateError</code>"</a> <code id=common-input-element-apis:domexception-7><a data-x-internal=domexception href=https://heycam.github.io/webidl/#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>

  <hr>

  <p>The <dfn id=dom-input-stepdown><code>stepDown(<var>n</var>)</code></dfn> and <dfn id=dom-input-stepup><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-8 href=https://heycam.github.io/webidl/#invalidstateerror data-x-internal=invalidstateerror>"<code>InvalidStateError</code>"</a> <code id=common-input-element-apis:domexception-8><a data-x-internal=domexception href=https://heycam.github.io/webidl/#dfn-DOMException>DOMException</a></code>.<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-9 href=https://heycam.github.io/webidl/#invalidstateerror data-x-internal=invalidstateerror>"<code>InvalidStateError</code>"</a> <code id=common-input-element-apis:domexception-9><a data-x-internal=domexception href=https://heycam.github.io/webidl/#dfn-DOMException>DOMException</a></code>.<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><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><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.<li><p>Let <var>valueBeforeStepping</var> be <var>value</var>.<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.<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>.<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>.<li><p>Let <var>value</var> be the result of adding <var>delta</var> to <var>value</var>.</ol>

   <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 <var>minimum</var>.<li><p>If the element has a <a href=#concept-input-min id=common-input-element-apis:concept-input-min-7>maximum</a>, and <var>value</var> is greater than that <a href=#concept-input-min id=common-input-element-apis:concept-input-min-8>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 <var>maximum</var>.<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><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>.<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>.</ol>

  <hr>

  <p>The <dfn id=dom-input-list><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>

  


  

  <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 href=#event-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 href=#event-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 href=#event-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>

  <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-a-task id=common-input-element-events:queue-a-task>queue a task</a> 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 href=#event-input>input</a></code> at the <code id=common-input-element-events:the-input-element-5><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> attribute initialized to true, and any time the user
  commits the change, the user agent must <a href=#queue-a-task id=common-input-element-events:queue-a-task-2>queue a task</a> to <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-6><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>

  <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 href=#event-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>

  <p>For <code id=common-input-element-events:the-input-element-7><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-a-task id=common-input-element-events:queue-a-task-3>queue a task</a> 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 href=#event-input>input</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-3><a data-x-internal=dom-event-bubbles href=https://dom.spec.whatwg.org/#dom-event-bubbles>bubbles</a></code> attribute 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-9><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>

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

  <p>For <code id=common-input-element-events:the-input-element-10><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-a-task id=common-input-element-events:queue-a-task-4>queue a task</a> 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 href=#event-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-5><a data-x-internal=dom-event-bubbles href=https://dom.spec.whatwg.org/#dom-event-bubbles>bubbles</a></code> attribute 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>

  <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 href=#event-input>input</a></code> event, user agents may wait for a suitable break in the
  user's interaction before <a href=#queue-a-task id=common-input-element-events:queue-a-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>When the user agent is to change an <code id=common-input-element-events:the-input-element-12><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-a-task id=common-input-element-events:queue-a-task-6>queue a task</a> 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 href=#event-input>input</a></code> at the <code id=common-input-element-events:the-input-element-13><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> attribute 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-14><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>

  <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>The <a href=#task-source id=common-input-element-events:task-source>task source</a> for these <a href=#concept-task id=common-input-element-events:concept-task-2>tasks</a> is the
  <a href=#user-interaction-task-source id=common-input-element-events:user-interaction-task-source>user interaction task source</a>.</p>

  



  <h4 id=the-button-element><span class=secno>4.10.6</span> The <dfn><code>button</code></dfn> element<a href=#the-button-element class=self-link></a></h4>

  <dl class=element><dt><a href=#concept-element-categories id=the-button-element:concept-element-categories>Categories</a>:<dd><a href=#flow-content-2 id=the-button-element:flow-content-2>Flow content</a>.<dd><a href=#phrasing-content-2 id=the-button-element:phrasing-content-2>Phrasing content</a>.<dd><a href=#interactive-content-2 id=the-button-element:interactive-content-2>Interactive content</a>.<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-inheriting</a> <a href=#form-associated-element id=the-button-element:form-associated-element>form-associated element</a>.<dd><a href=#palpable-content-2 id=the-button-element:palpable-content-2>Palpable content</a>.<dt><a href=#concept-element-contexts id=the-button-element:concept-element-contexts>Contexts in which this element can be used</a>:<dd>Where <a href=#phrasing-content-2 id=the-button-element:phrasing-content-2-2>phrasing content</a> is expected.<dt><a href=#concept-element-content-model id=the-button-element:concept-element-content-model>Content model</a>:<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.<dt><a href=#concept-element-tag-omission id=the-button-element:concept-element-tag-omission>Tag omission in text/html</a>:<dd>Neither tag is omissible.<dt><a href=#concept-element-attributes id=the-button-element:concept-element-attributes>Content attributes</a>:<dd><a href=#global-attributes id=the-button-element:global-attributes>Global attributes</a><dd><code id=the-button-element:attr-fe-autofocus><a href=#attr-fe-autofocus>autofocus</a></code> — Automatically focus the form control when the page is loaded<dd><code id=the-button-element:attr-fe-disabled><a href=#attr-fe-disabled>disabled</a></code> — Whether the form control is disabled<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><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><code id=the-button-element:attr-fs-formenctype><a href=#attr-fs-formenctype>formenctype</a></code> — Entry list encoding type to use for <a href=#form-submission-2 id=the-button-element:form-submission-2-2>form submission</a><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><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><code id=the-button-element:attr-fs-formtarget><a href=#attr-fs-formtarget>formtarget</a></code> — <a href=#browsing-context id=the-button-element:browsing-context>Browsing context</a> for <a href=#form-submission-2 id=the-button-element:form-submission-2-5>form submission</a><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><code id=the-button-element:attr-button-type><a href=#attr-button-type>type</a></code> — Type of button<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><dt><a href=#concept-element-dom id=the-button-element:concept-element-dom>DOM interface</a>:<dd>
    <pre><code class='idl'>[<c- g>Exposed</c->=<c- n>Window</c->,
 <a href='#htmlconstructor' id='the-button-element:htmlconstructor'><c- g>HTMLConstructor</c-></a>]
<c- b>interface</c-> <dfn id='htmlbuttonelement'><c- g>HTMLButtonElement</c-></dfn> : <a href='#htmlelement' id='the-button-element:htmlelement'><c- n>HTMLElement</c-></a> {
  [<a href='#cereactions' id='the-button-element:cereactions'><c- g>CEReactions</c-></a>] <c- b>attribute</c-> <c- b>boolean</c-> <a href='#dom-fe-autofocus' id='the-button-element:dom-fe-autofocus'><c- g>autofocus</c-></a>;
  [<a href='#cereactions' id='the-button-element:cereactions-2'><c- g>CEReactions</c-></a>] <c- b>attribute</c-> <c- b>boolean</c-> <a href='#dom-fe-disabled' id='the-button-element:dom-fe-disabled'><c- g>disabled</c-></a>;
  <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-3'><c- g>CEReactions</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-4'><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-5'><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-6'><c- g>CEReactions</c-></a>] <c- b>attribute</c-> <c- b>boolean</c-> <a href='#dom-fs-formnovalidate' id='the-button-element:dom-fs-formnovalidate'><c- g>formNoValidate</c-></a>;
  [<a href='#cereactions' id='the-button-element:cereactions-7'><c- g>CEReactions</c-></a>] <c- b>attribute</c-> <c- b>DOMString</c-> <a href='#dom-fs-formtarget' id='the-button-element:dom-fs-formtarget'><c- g>formTarget</c-></a>;
  [<a href='#cereactions' id='the-button-element:cereactions-8'><c- g>CEReactions</c-></a>] <c- b>attribute</c-> <c- b>DOMString</c-> <a href='#dom-fe-name' id='the-button-element:dom-fe-name'><c- g>name</c-></a>;
  [<a href='#cereactions' id='the-button-element:cereactions-9'><c- g>CEReactions</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-10'><c- g>CEReactions</c-></a>] <c- b>attribute</c-> <c- b>DOMString</c-> <a href='#dom-button-value' id='the-button-element:dom-button-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-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>void</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 href='https://dom.spec.whatwg.org/#interface-nodelist' data-x-internal='nodelist' id='the-button-element:nodelist'><c- n>NodeList</c-></a> <a href='#dom-lfe-labels' id='the-button-element:dom-lfe-labels'><c- g>labels</c-></a>;
};</code></pre>
   </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 id=attr-button-type><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>. The following table
  lists the keywords and states for the attribute — the keywords in the left column map to the
  states in the cell in the second column on the same row as the keyword.</p>

  <table><thead><tr><th> Keyword
     <th> State
     <th> Brief description
   <tbody><tr><td><dfn id=attr-button-type-submit><code>submit</code></dfn>
     <td><a href=#attr-button-type-submit-state id=the-button-element:attr-button-type-submit-state>Submit Button</a>
     <td>Submits the form.
    <tr><td><dfn id=attr-button-type-reset><code>reset</code></dfn>
     <td><a href=#attr-button-type-reset-state id=the-button-element:attr-button-type-reset-state>Reset Button</a>
     <td>Resets the form.
    <tr><td><dfn id=attr-button-type-button><code>button</code></dfn>
     <td><a href=#attr-button-type-button-state id=the-button-element:attr-button-type-button-state>Button</a>
     <td>Does nothing.
  </table>

  <p>The <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 the <a href=#attr-button-type-submit-state id=the-button-element:attr-button-type-submit-state-2>Submit Button</a> state.</p>

  <p>If 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-submit-state id=the-button-element:attr-button-type-submit-state-3>Submit Button</a> state, the element is specifically a
  <a href=#concept-submit-button id=the-button-element:concept-submit-button>submit button</a>.</p>

  

  <p><strong>Constraint validation</strong>: If 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-reset-state id=the-button-element:attr-button-type-reset-state-2>Reset Button</a> state or the
  <a href=#attr-button-type-button-state id=the-button-element:attr-button-type-button-state-2>Button</a> state, the element is <a href=#barred-from-constraint-validation id=the-button-element:barred-from-constraint-validation>barred from
  constraint validation</a>.</p>

  <p>A <code id=the-button-element:the-button-element-2><a href=#the-button-element>button</a></code> element'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> is to run the steps defined in
  the following list for the current state of this element's <code id=the-button-element:attr-button-type-4><a href=#attr-button-type>type</a></code> attribute, if this element is not <a href=#concept-fe-disabled id=the-button-element:concept-fe-disabled>disabled</a>, and do nothing otherwise:</p>

  <dl><dt> <dfn id=attr-button-type-submit-state>Submit Button</dfn> <dd><p>If the element has a <a href=#form-owner id=the-button-element:form-owner>form owner</a> and the element'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
   <a href=#fully-active id=the-button-element:fully-active>fully active</a>, the element must <a href=#concept-form-submit id=the-button-element:concept-form-submit>submit</a> the
   <a href=#form-owner id=the-button-element:form-owner-2>form owner</a> from the <code id=the-button-element:the-button-element-3><a href=#the-button-element>button</a></code> element.<dt> <dfn id=attr-button-type-reset-state>Reset Button</dfn> <dd><p>If the element has a <a href=#form-owner id=the-button-element:form-owner-3>form owner</a> and the element's <a id=the-button-element: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=the-button-element:fully-active-2>fully active</a>, the element must <a href=#concept-form-reset id=the-button-element:concept-form-reset>reset</a> the
   <a href=#form-owner id=the-button-element:form-owner-4>form owner</a>.<dt> <dfn id=attr-button-type-button-state>Button</dfn>

   <dd><p>Do nothing.</dl>

  

  <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-4><a href=#the-button-element>button</a></code> element with its <a href=#form-owner id=the-button-element:form-owner-5>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-fe-autofocus-2><a href=#attr-fe-autofocus>autofocus</a></code>
  attribute controls focus. 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's <code id=the-button-element:attr-button-type-5><a href=#attr-button-type>type</a></code> attribute is not in the <a href=#attr-button-type-submit-state id=the-button-element:attr-button-type-submit-state-4>Submit Button</a> state.</p>

  <p>The <dfn id=attr-button-value><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, or the empty string otherwise.</p>

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

  

  <p>The <dfn id=dom-button-value><code>value</code></dfn> IDL attribute must
  <a href=#reflect id=the-button-element:reflect>reflect</a> the content attribute of the same name.</p>

  <p>The <dfn id=dom-button-type><code>type</code></dfn> IDL attribute must
  <a href=#reflect id=the-button-element:reflect-2>reflect</a> the content attribute of the same name, <a href=#limited-to-only-known-values id=the-button-element:limited-to-only-known-values>limited to only known
  values</a>.</p>

  <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-fe-autofocus-2><a href=#dom-fe-autofocus>autofocus</a></code>, <code id=the-button-element:dom-fe-disabled-2><a href=#dom-fe-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-fe-name-2><a href=#dom-fe-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>&quot;alert(&apos;This 15-20 minute piece was composed by George Gershwin.&apos;)&quot;</c-><c- p>&gt;</c->
 Show hint
<c- p>&lt;/</c-><c- f>button</c-><c- p>&gt;</c-></code></pre>

  </div>




  <h4 id=the-select-element><span class=secno>4.10.7</span> The <dfn><code>select</code></dfn> element<a href=#the-select-element class=self-link></a></h4>

  <dl class=element><dt><a href=#concept-element-categories id=the-select-element:concept-element-categories>Categories</a>:<dd><a href=#flow-content-2 id=the-select-element:flow-content-2>Flow content</a>.<dd><a href=#phrasing-content-2 id=the-select-element:phrasing-content-2>Phrasing content</a>.<dd><a href=#interactive-content-2 id=the-select-element:interactive-content-2>Interactive content</a>.<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-inheriting</a> <a href=#form-associated-element id=the-select-element:form-associated-element>form-associated element</a>.<dd><a href=#palpable-content-2 id=the-select-element:palpable-content-2>Palpable content</a>.<dt><a href=#concept-element-contexts id=the-select-element:concept-element-contexts>Contexts in which this element can be used</a>:<dd>Where <a href=#phrasing-content-2 id=the-select-element:phrasing-content-2-2>phrasing content</a> is expected.<dt><a href=#concept-element-content-model id=the-select-element:concept-element-content-model>Content model</a>:<dd>Zero or more <code id=the-select-element:the-option-element><a href=#the-option-element>option</a></code>, <code id=the-select-element:the-optgroup-element><a href=#the-optgroup-element>optgroup</a></code>, and <a href=#script-supporting-elements-2 id=the-select-element:script-supporting-elements-2>script-supporting</a> elements.<dt><a href=#concept-element-tag-omission id=the-select-element:concept-element-tag-omission>Tag omission in text/html</a>:<dd>Neither tag is omissible.<dt><a href=#concept-element-attributes id=the-select-element:concept-element-attributes>Content attributes</a>:<dd><a href=#global-attributes id=the-select-element:global-attributes>Global attributes</a><dd><code id=the-select-element:attr-fe-autocomplete><a href=#attr-fe-autocomplete>autocomplete</a></code> — Hint for form autofill feature<dd><code id=the-select-element:attr-fe-autofocus><a href=#attr-fe-autofocus>autofocus</a></code> — Automatically focus the form control when the page is loaded<dd><code id=the-select-element:attr-fe-disabled><a href=#attr-fe-disabled>disabled</a></code> — Whether the form control is disabled<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><code id=the-select-element:attr-select-multiple><a href=#attr-select-multiple>multiple</a></code> — Whether to allow multiple values<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><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><code id=the-select-element:attr-select-size><a href=#attr-select-size>size</a></code> — Size of the control<dt><a href=#concept-element-dom id=the-select-element:concept-element-dom>DOM interface</a>:<dd>
    <pre><code class='idl'>[<c- g>Exposed</c->=<c- n>Window</c->,
 <a href='#htmlconstructor' id='the-select-element:htmlconstructor'><c- g>HTMLConstructor</c-></a>]
<c- b>interface</c-> <dfn id='htmlselectelement'><c- g>HTMLSelectElement</c-></dfn> : <a href='#htmlelement' id='the-select-element:htmlelement'><c- n>HTMLElement</c-></a> {
  [<a href='#cereactions' id='the-select-element:cereactions'><c- g>CEReactions</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>] <c- b>attribute</c-> <c- b>boolean</c-> <a href='#dom-fe-autofocus' id='the-select-element:dom-fe-autofocus'><c- g>autofocus</c-></a>;
  [<a href='#cereactions' id='the-select-element:cereactions-3'><c- g>CEReactions</c-></a>] <c- b>attribute</c-> <c- b>boolean</c-> <a href='#dom-fe-disabled' id='the-select-element:dom-fe-disabled'><c- g>disabled</c-></a>;
  <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-4'><c- g>CEReactions</c-></a>] <c- b>attribute</c-> <c- b>boolean</c-> <a href='#dom-select-multiple' id='the-select-element:dom-select-multiple'><c- g>multiple</c-></a>;
  [<a href='#cereactions' id='the-select-element:cereactions-5'><c- g>CEReactions</c-></a>] <c- b>attribute</c-> <c- b>DOMString</c-> <a href='#dom-fe-name' id='the-select-element:dom-fe-name'><c- g>name</c-></a>;
  [<a href='#cereactions' id='the-select-element:cereactions-6'><c- g>CEReactions</c-></a>] <c- b>attribute</c-> <c- b>boolean</c-> <a href='#dom-select-required' id='the-select-element:dom-select-required'><c- g>required</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-size' id='the-select-element:dom-select-size'><c- g>size</c-></a>;

  <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-8'><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='https://dom.spec.whatwg.org/#interface-element' data-x-internal='element' id='the-select-element:element'><c- n>Element</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'><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-9'><c- g>CEReactions</c-></a>] <c- b>void</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-2'><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-10'><c- g>CEReactions</c-></a>] <c- b>void</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-11'><c- g>CEReactions</c-></a>] <c- b>void</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-12'><c- g>CEReactions</c-></a>] <a href='#dom-select-setter'><c- b>setter</c-></a> <c- b>void</c-> (<c- b>unsigned</c-> <c- b>long</c-> <c- g>index</c->, <a href='#htmloptionelement' id='the-select-element:htmloptionelement-3'><c- n>HTMLOptionElement</c-></a>? <c- g>option</c->);

  [<c- g>SameObject</c->] <c- b>readonly</c-> <c- b>attribute</c-> <a href='https://dom.spec.whatwg.org/#interface-htmlcollection' data-x-internal='htmlcollection' id='the-select-element: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>void</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>readonly</c-> <c- b>attribute</c-> <a href='https://dom.spec.whatwg.org/#interface-nodelist' data-x-internal='nodelist' id='the-select-element: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>
   </dl>
  

  <p>The <code id=the-select-element:the-select-element><a href=#the-select-element>select</a></code> element represents a control for selecting amongst a set of
  options.</p>

  <p>The <dfn id=attr-select-multiple><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-2><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-3><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>

  <p>The <dfn id=attr-select-size><code>size</code></dfn> attribute gives the number of options
  to show to the user. The <code id=the-select-element:attr-select-size-2><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>

  

  <p>The <dfn id=concept-select-size>display size</dfn> of a <code id=the-select-element:the-select-element-4><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
  element's <code id=the-select-element:attr-select-size-3><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-4><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>display size</a> is 4 if the element's <code id=the-select-element:attr-select-multiple-2><a href=#attr-select-multiple>multiple</a></code> content attribute is present, and 1 otherwise.</p>

  

  <p>The <dfn id=concept-select-option-list>list of options</dfn> for a <code id=the-select-element:the-select-element-5><a href=#the-select-element>select</a></code>
  element consists of all the <code id=the-select-element:the-option-element-2><a href=#the-option-element>option</a></code> element children of the <code id=the-select-element:the-select-element-6><a href=#the-select-element>select</a></code>
  element, and all the <code id=the-select-element:the-option-element-3><a href=#the-option-element>option</a></code> element children of all the <code id=the-select-element:the-optgroup-element-2><a href=#the-optgroup-element>optgroup</a></code> element
  children of the <code id=the-select-element:the-select-element-7><a href=#the-select-element>select</a></code> element, 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>

  <p>The <dfn id=attr-select-required><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>If a <code id=the-select-element:the-select-element-8><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-2>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-4><a href=#the-option-element>option</a></code> element in the
  <code id=the-select-element:the-select-element-9><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-5><a href=#the-option-element>option</a></code> element's parent node is the
  <code id=the-select-element:the-select-element-10><a href=#the-select-element>select</a></code> element (and not an <code id=the-select-element:the-optgroup-element-3><a href=#the-optgroup-element>optgroup</a></code> element), then that
  <code id=the-select-element:the-option-element-6><a href=#the-option-element>option</a></code> is the <code id=the-select-element:the-select-element-11><a href=#the-select-element>select</a></code> element's <dfn id=placeholder-label-option>placeholder label option</dfn>.</p>

  <p>If a <code id=the-select-element:the-select-element-12><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-3>display size</a> of 1, then the
  <code id=the-select-element:the-select-element-13><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>

  <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-14><a href=#the-select-element>select</a></code> element does not have a <code id=the-select-element:attr-select-size-5><a href=#attr-select-size>size</a></code> attribute
  with a value greater than 1.</p>

  

  <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-7><a href=#the-option-element>option</a></code> elements in the <code id=the-select-element:the-select-element-15><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-8><a href=#the-option-element>option</a></code> element in the <code id=the-select-element:the-select-element-16><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>

  

  

  <p>If the <code id=the-select-element:attr-select-multiple-5><a href=#attr-select-multiple>multiple</a></code> attribute is absent, and the element
  is not <a href=#concept-fe-disabled id=the-select-element:concept-fe-disabled>disabled</a>, then the user agent should allow the
  user to pick an <code id=the-select-element:the-option-element-9><a href=#the-option-element>option</a></code> element in its <a href=#concept-select-option-list id=the-select-element:concept-select-option-list-6>list
  of options</a> that is itself not <a href=#concept-option-disabled id=the-select-element:concept-option-disabled>disabled</a>. Upon
  this <code id=the-select-element:the-option-element-10><a href=#the-option-element>option</a></code> element being <dfn id=concept-select-pick>picked</dfn> (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), 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-3>selectedness</a> of the picked <code id=the-select-element:the-option-element-11><a href=#the-option-element>option</a></code> element
  to true, set its <a href=#concept-option-dirtiness id=the-select-element:concept-option-dirtiness>dirtiness</a> to true, and then
  <a href=#send-select-update-notifications id=the-select-element:send-select-update-notifications>send <code>select</code> update notifications</a>.</p>

  <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-12><a href=#the-option-element>option</a></code> element in the <code id=the-select-element:the-select-element-17><a href=#the-select-element>select</a></code> element's <a href=#concept-select-option-list id=the-select-element:concept-select-option-list-7>list of options</a> has its <a href=#concept-option-selectedness id=the-select-element:concept-option-selectedness-4>selectedness</a> set to true, and whenever an
  <code id=the-select-element:the-option-element-13><a href=#the-option-element>option</a></code> element with its <a href=#concept-option-selectedness id=the-select-element:concept-option-selectedness-5>selectedness</a> set to true is added to the
  <code id=the-select-element:the-select-element-18><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>,
  the user agent must set the <a href=#concept-option-selectedness id=the-select-element:concept-option-selectedness-6>selectedness</a> of all
  the other <code id=the-select-element:the-option-element-14><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-9>list of
  options</a> to false.</p>

  <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-4>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-15><a href=#the-option-element>option</a></code> whose <a href=#concept-option-selectedness id=the-select-element:concept-option-selectedness-7>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-2><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-8>selectedness</a> of that <code id=the-select-element:the-option-element-16><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-2>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>

  <p>If <a href=#nodes-are-inserted id=the-select-element:nodes-are-inserted>nodes are inserted</a> or <a href=#nodes-are-removed id=the-select-element:nodes-are-removed>nodes are removed</a> causing the <a href=#concept-select-option-list id=the-select-element:concept-select-option-list-10>list of options</a> to gain or lose one or more
  <code id=the-select-element:the-option-element-17><a href=#the-option-element>option</a></code> elements, or if an <code id=the-select-element:the-option-element-18><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-11>list of options</a> <dfn id=ask-for-a-reset>asks for
  a reset</dfn>, then, if the <code id=the-select-element:the-select-element-19><a href=#the-select-element>select</a></code> element's <code id=the-select-element:attr-select-multiple-8><a href=#attr-select-multiple>multiple</a></code> attribute is absent, the user agent must run the
  first applicable set of steps from the following list:</p>

  <dl class=switch><dt>If the <code id=the-select-element:the-select-element-20><a href=#the-select-element>select</a></code>
   element'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-19><a href=#the-option-element>option</a></code>
   elements 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-12>list of
   options</a> have their <a href=#concept-option-selectedness id=the-select-element:concept-option-selectedness-9>selectedness</a> set to
   true<dd><p>Set the <a href=#concept-option-selectedness id=the-select-element:concept-option-selectedness-10>selectedness</a> of the first
   <code id=the-select-element:the-option-element-20><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-13>list of
   options</a> 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> that is not <a href=#concept-option-disabled id=the-select-element:concept-option-disabled-2>disabled</a>, if any, to true.<dt>If two or more <code id=the-select-element:the-option-element-21><a href=#the-option-element>option</a></code> elements in 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-14>list of options</a> have their <a href=#concept-option-selectedness id=the-select-element:concept-option-selectedness-11>selectedness</a> set to true<dd><p>Set the <a href=#concept-option-selectedness id=the-select-element:concept-option-selectedness-12>selectedness</a> of all but the last
   <code id=the-select-element:the-option-element-22><a href=#the-option-element>option</a></code> element with its <a href=#concept-option-selectedness id=the-select-element:concept-option-selectedness-13>selectedness</a> set to true in the <a href=#concept-select-option-list id=the-select-element:concept-select-option-list-15>list of options</a> 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> to
   false.</dl>

  <p>If the <code id=the-select-element:attr-select-multiple-9><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-2>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-14>selectedness</a> of the <code id=the-select-element:the-option-element-23><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-16>list of options</a> that are themselves not <a href=#concept-option-disabled id=the-select-element:concept-option-disabled-3>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-3><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-15>selectedness</a> of the <code id=the-select-element:the-option-element-24><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-3>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>

  <p>When the user agent is to <dfn id=send-select-update-notifications>send <code>select</code> update notifications</dfn>, <a href=#queue-a-task id=the-select-element:queue-a-task>queue
  a task</a>, using the <a href=#user-interaction-task-source id=the-select-element:user-interaction-task-source>user interaction task source</a>, to run these steps:</p>

  <ol><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 href=#event-input>input</a></code> at the <code id=the-select-element:the-select-element-23><a href=#the-select-element>select</a></code> element, 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> attribute initialized to true.<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 the <code id=the-select-element:the-select-element-24><a href=#the-select-element>select</a></code> element, 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.</ol>

  <p>The <a href=#concept-form-reset-control id=the-select-element:concept-form-reset-control>reset algorithm</a> for <code id=the-select-element:the-select-element-25><a href=#the-select-element>select</a></code>
  elements is to go through all the <code id=the-select-element:the-option-element-25><a href=#the-option-element>option</a></code> elements in the element's <a href=#concept-select-option-list id=the-select-element:concept-select-option-list-17>list of options</a>, set their <a href=#concept-option-selectedness id=the-select-element:concept-option-selectedness-16>selectedness</a> to true if the <code id=the-select-element:the-option-element-26><a href=#the-option-element>option</a></code>
  element has a <code id=the-select-element:attr-option-selected><a href=#attr-option-selected>selected</a></code> attribute, and false otherwise,
  set their <a href=#concept-option-dirtiness id=the-select-element:concept-option-dirtiness-4>dirtiness</a> to false, and then have the
  <code id=the-select-element:the-option-element-27><a href=#the-option-element>option</a></code> elements <a href=#ask-for-a-reset id=the-select-element:ask-for-a-reset>ask for a reset</a>.</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-26><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-autofocus-2><a href=#attr-fe-autofocus>autofocus</a></code> attribute controls focus.
  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>

  <p>A <code id=the-select-element:the-select-element-27><a href=#the-select-element>select</a></code> element that is not <a href=#concept-fe-disabled id=the-select-element:concept-fe-disabled-3>disabled</a> is
  <i id=the-select-element:concept-fe-mutable><a href=#concept-fe-mutable>mutable</a></i>.</p>

  <dl class=domintro><dt><var>select</var> . <code id=dom-select-type-dev><a href=#dom-select-type>type</a></code><dd>

    <p>Returns "<code>select-multiple</code>" if the element has a <code id=the-select-element:attr-select-multiple-10><a href=#attr-select-multiple>multiple</a></code> attribute, and "<code>select-one</code>"
    otherwise.</p>

   <dt><var>select</var> . <code id=dom-select-options-dev><a href=#dom-select-options>options</a></code><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-18>list of options</a>.</p>

   <dt><var>select</var> . <code id=dom-select-length-dev><a href=#dom-select-length>length</a></code> [ = <var>value</var> ]<dd>

    <p>Returns the number of elements in the <a href=#concept-select-option-list id=the-select-element:concept-select-option-list-19>list of
    options</a>.</p>

    <p>When set to a smaller number, truncates the number of <code id=the-select-element:the-option-element-28><a href=#the-option-element>option</a></code> elements in the
    <code id=the-select-element:the-select-element-28><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-29><a href=#the-option-element>option</a></code> elements to the
    <code id=the-select-element:the-select-element-29><a href=#the-select-element>select</a></code>.</p>

   <dt><var>element</var> = <var>select</var> . <code id=dom-select-item-dev><a href=#dom-select-item>item</a></code>(<var>index</var>)<dt><var>select</var>[<var>index</var>]<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-20>list of options</a>. The items are sorted 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>.</p>

   <dt><var>element</var> = <var>select</var> . <code id=dom-select-nameditem-dev><a href=#dom-select-nameditem>namedItem</a></code>(<var>name</var>)<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-21>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>

   <dt><var>select</var> . <code id=dom-select-add-dev><a href=#dom-select-add>add</a></code>(<var>element</var> [, <var>before</var> ] )<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-22>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://heycam.github.io/webidl/#hierarchyrequesterror data-x-internal=hierarchyrequesterror>"<code>HierarchyRequestError</code>"</a> <code id=the-select-element:domexception><a data-x-internal=domexception href=https://heycam.github.io/webidl/#dfn-DOMException>DOMException</a></code> if
    <var>element</var> is an ancestor of the element into which it is to be inserted.</p>

   <dt><var>select</var> . <code id=dom-select-selectedoptions-dev><a href=#dom-select-selectedoptions>selectedOptions</a></code><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-23>list
    of options</a> that are selected.</p>

   <dt><var>select</var> . <code id=dom-select-selectedindex-dev><a href=#dom-select-selectedindex>selectedIndex</a></code> [ = <var>value</var> ]<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>

   <dt><var>select</var> . <code id=dom-select-value-dev><a href=#dom-select-value>value</a></code> [ = <var>value</var> ]<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>

   </dl>

  

  <p>The <dfn id=dom-select-type><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-11><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-12><a href=#attr-select-multiple>multiple</a></code>
  attribute is present.</p>

  <p>The <dfn id=dom-select-options><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-30><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>.</p>

  <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://heycam.github.io/webidl/#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>

  <p>The <dfn id=dom-select-length><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>

  <p>The <dfn id=dom-select-item><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>

  <p>The <dfn id=dom-select-nameditem><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>

  <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://heycam.github.io/webidl/#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://heycam.github.io/webidl/#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-31><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-32><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>

  <p>Similarly, the <dfn id=dom-select-add><code>add()</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>

  <p>The <dfn id=dom-select-remove><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-2><a data-x-internal=element href=https://dom.spec.whatwg.org/#interface-element>Element</a></code> when it has no
  arguments.</p>

  <p>The <dfn id=dom-select-selectedoptions><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-33><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-25>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>

  <p>The <dfn id=dom-select-selectedindex><code>selectedIndex</code></dfn> IDL attribute, on
  getting, must 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-30><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-26>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> 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 it must return −1.</p>

  <p>On setting, the <code id=the-select-element:dom-select-selectedindex-2><a href=#dom-select-selectedindex>selectedIndex</a></code> attribute must set
  the <a href=#concept-option-selectedness id=the-select-element:concept-option-selectedness-19>selectedness</a> of all the <code id=the-select-element:the-option-element-31><a href=#the-option-element>option</a></code>
  elements in the <a href=#concept-select-option-list id=the-select-element:concept-select-option-list-27>list of options</a> to false, and
  then the <code id=the-select-element:the-option-element-32><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-28>list of
  options</a> whose <a href=#concept-option-index id=the-select-element:concept-option-index-2>index</a> is the given new value, if
  any, must have its <a href=#concept-option-selectedness id=the-select-element:concept-option-selectedness-20>selectedness</a> set to true and
  its <a href=#concept-option-dirtiness id=the-select-element:concept-option-dirtiness-5>dirtiness</a> set to true.</p>

  <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-34><a href=#the-select-element>select</a></code> element having no <code id=the-select-element:attr-select-multiple-13><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>

  <p>The <dfn id=dom-select-value><code>value</code></dfn> IDL attribute, on getting, must
  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-33><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-29>list of options</a> 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> 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 it must return the empty string.</p>

  <p>On setting, the <code id=the-select-element:dom-select-value-2><a href=#dom-select-value>value</a></code> attribute must set the <a href=#concept-option-selectedness id=the-select-element:concept-option-selectedness-23>selectedness</a> of all the <code id=the-select-element:the-option-element-34><a href=#the-option-element>option</a></code> elements
  in the <a href=#concept-select-option-list id=the-select-element:concept-select-option-list-30>list of options</a> to false, and then the
  first <code id=the-select-element:the-option-element-35><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-31>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>, whose <a href=#concept-option-value id=the-select-element:concept-option-value-4>value</a>
  is equal to the given new value, if any, must have its <a href=#concept-option-selectedness id=the-select-element:concept-option-selectedness-24>selectedness</a> set to true and its <a href=#concept-option-dirtiness id=the-select-element:concept-option-dirtiness-6>dirtiness</a> set to true.</p>

  <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-35><a href=#the-select-element>select</a></code> element having no <code id=the-select-element:attr-select-multiple-14><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>The <dfn id=dom-select-multiple><code>multiple</code></dfn>, <dfn id=dom-select-required><code>required</code></dfn>, and <dfn id=dom-select-size><code>size</code></dfn> IDL attributes must <a href=#reflect id=the-select-element:reflect>reflect</a> the
  respective content attributes of the same name. The <code id=the-select-element:dom-select-size-2><a href=#dom-select-size>size</a></code> IDL
  attribute has a default value of zero.</p> 

  <p class=note>For historical reasons, the default value of the <code id=the-select-element:dom-select-size-3><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-6><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-15><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-fe-autofocus-2><a href=#dom-fe-autofocus>autofocus</a></code>, <code id=the-select-element:dom-fe-disabled-2><a href=#dom-fe-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-fe-name-2><a href=#dom-fe-name>name</a></code> IDL attributes are
  part of the element's forms API.</p>

  

  <div class=example>

   <p>The following example shows how a <code id=the-select-element:the-select-element-36><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>&quot;unittype&quot;</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>&quot;unittype&quot;</c-> <c- e>name</c-><c- o>=</c-><c- s>&quot;unittype&quot;</c-><c- p>&gt;</c->
  <c- p>&lt;</c-><c- f>option</c-> <c- e>value</c-><c- o>=</c-><c- s>&quot;1&quot;</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>&quot;2&quot;</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>&quot;3&quot;</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>&quot;4&quot;</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>&quot;5&quot;</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>&quot;unittype&quot;</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>&quot;&quot;</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>&quot;1&quot;</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>&quot;2&quot;</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>&quot;3&quot;</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>&quot;4&quot;</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>&quot;5&quot;</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>&quot;allowedunits&quot;</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>&quot;allowedunits&quot;</c-> <c- e>name</c-><c- o>=</c-><c- s>&quot;allowedunits&quot;</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>&quot;1&quot;</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>&quot;2&quot;</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>&quot;3&quot;</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>&quot;4&quot;</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>&quot;5&quot;</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>&quot;act2&quot;</c-><c- p>&gt;</c->
  <c- p>&lt;</c-><c- f>option</c-> <c- e>value</c-><c- o>=</c-><c- s>&quot;s1&quot;</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>&quot;s2&quot;</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>&quot;s3&quot;</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>&quot;s4&quot;</c-><c- p>&gt;</c->Schadenfreude
  <c- p>&lt;</c-><c- f>option</c-> <c- e>value</c-><c- o>=</c-><c- s>&quot;s5&quot;</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>&quot;s6&quot;</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>&quot;s7&quot;</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>&quot;s8&quot;</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>&quot;s9&quot;</c-><c- p>&gt;</c->There&apos;s a Fine, Fine Line (Reprise)
  <c- p>&lt;</c-><c- f>option</c-> <c- e>value</c-><c- o>=</c-><c- s>&quot;s10&quot;</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>&quot;s11&quot;</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>



  <h4 id=the-datalist-element><span class=secno>4.10.8</span> The <dfn><code>datalist</code></dfn> element<a href=#the-datalist-element class=self-link></a></h4><div class=status><input onclick=toggleStatus(this) value=⋰ type=button><p class=support><strong>Support:</strong> datalist<span class="and_chr yes"><span>Chrome for Android</span> <span>67+</span></span><span class="chrome yes"><span>Chrome</span> <span>69+</span></span><span class="firefox partial"><span>Firefox (limited)</span> <span>4+</span></span><span class="ie partial"><span>IE (limited)</span> <span>10+</span></span><span class="op_mini no"><span>Opera Mini</span> <span>None</span></span><span class="edge partial"><span>Edge (limited)</span> <span>12+</span></span><span class="samsung yes"><span>Samsung Internet</span> <span>4+</span></span><span class="opera partial"><span>Opera (limited)</span> <span>15+</span></span><span class="android partial"><span>Android Browser (limited)</span> <span>67+</span></span><p class=caniuse>Source: <a href="https://caniuse.com/#feat=datalist">caniuse.com</a></div>

  <dl class=element><dt><a href=#concept-element-categories id=the-datalist-element:concept-element-categories>Categories</a>:<dd><a href=#flow-content-2 id=the-datalist-element:flow-content-2>Flow content</a>.<dd><a href=#phrasing-content-2 id=the-datalist-element:phrasing-content-2>Phrasing content</a>.<dt><a href=#concept-element-contexts id=the-datalist-element:concept-element-contexts>Contexts in which this element can be used</a>:<dd>Where <a href=#phrasing-content-2 id=the-datalist-element:phrasing-content-2-2>phrasing content</a> is expected.<dt><a href=#concept-element-content-model id=the-datalist-element:concept-element-content-model>Content model</a>:<dd>Either: <a href=#phrasing-content-2 id=the-datalist-element:phrasing-content-2-3>phrasing content</a>.<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.<dt><a href=#concept-element-tag-omission id=the-datalist-element:concept-element-tag-omission>Tag omission in text/html</a>:<dd>Neither tag is omissible.<dt><a href=#concept-element-attributes id=the-datalist-element:concept-element-attributes>Content attributes</a>:<dd><a href=#global-attributes id=the-datalist-element:global-attributes>Global attributes</a><dt><a href=#concept-element-dom id=the-datalist-element:concept-element-dom>DOM interface</a>:<dd>
    <pre><code class='idl'>[<c- g>Exposed</c->=<c- n>Window</c->,
 <a href='#htmlconstructor' id='the-datalist-element:htmlconstructor'><c- g>HTMLConstructor</c-></a>]
<c- b>interface</c-> <dfn id='htmldatalistelement'><c- g>HTMLDataListElement</c-></dfn> : <a href='#htmlelement' id='the-datalist-element:htmlelement'><c- n>HTMLElement</c-></a> {
  [<c- g>SameObject</c->] <c- b>readonly</c-> <c- b>attribute</c-> <a href='https://dom.spec.whatwg.org/#interface-htmlcollection' data-x-internal='htmlcollection' id='the-datalist-element: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>
   </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->
 Sex:
 <c- p>&lt;</c-><c- f>input</c-> <c- e>name</c-><c- o>=</c-><c- s>sex</c-> <c- e>list</c-><c- o>=</c-><c- s>sexes</c-><c- p>&gt;</c->
 <c- p>&lt;</c-><c- f>datalist</c-> <c- e>id</c-><c- o>=</c-><c- s>sexes</c-><c- p>&gt;</c->
  <c- p>&lt;</c-><c- f>option</c-> <c- e>value</c-><c- o>=</c-><c- s>&quot;Female&quot;</c-><c- p>&gt;</c->
  <c- p>&lt;</c-><c- f>option</c-> <c- e>value</c-><c- o>=</c-><c- s>&quot;Male&quot;</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->
 Sex:
 <c- p>&lt;</c-><c- f>input</c-> <c- e>name</c-><c- o>=</c-><c- s>sex</c-> <c- e>list</c-><c- o>=</c-><c- s>sexes</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>sexes</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>sex</c-><c- p>&gt;</c->
   <c- p>&lt;</c-><c- f>option</c-> <c- e>value</c-><c- o>=</c-><c- s>&quot;&quot;</c-><c- p>&gt;</c->
   <c- p>&lt;</c-><c- f>option</c-><c- p>&gt;</c->Female
   <c- p>&lt;</c-><c- f>option</c-><c- p>&gt;</c->Male
  <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>.

  <dl class=domintro><dt><var>datalist</var> . <code id=dom-datalist-options-dev><a href=#dom-datalist-options>options</a></code><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>
   </dl>

  

  <p>The <dfn id=dom-datalist-options><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>

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

  


  <h4 id=the-optgroup-element><span class=secno>4.10.9</span> The <dfn><code>optgroup</code></dfn> element<a href=#the-optgroup-element class=self-link></a></h4>

  <dl class=element><dt><a href=#concept-element-categories id=the-optgroup-element:concept-element-categories>Categories</a>:<dd>None.<dt><a href=#concept-element-contexts id=the-optgroup-element:concept-element-contexts>Contexts in which this element can be used</a>:<dd>As a child of a <code id=the-optgroup-element:the-select-element><a href=#the-select-element>select</a></code> element.<dt><a href=#concept-element-content-model id=the-optgroup-element:concept-element-content-model>Content model</a>:<dd>Zero or more <code id=the-optgroup-element:the-option-element><a href=#the-option-element>option</a></code> and <a href=#script-supporting-elements-2 id=the-optgroup-element:script-supporting-elements-2>script-supporting</a> elements.<dt><a href=#concept-element-tag-omission id=the-optgroup-element:concept-element-tag-omission>Tag omission in text/html</a>:<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, or if  there is no more content in
   the parent element.<dt><a href=#concept-element-attributes id=the-optgroup-element:concept-element-attributes>Content attributes</a>:<dd><a href=#global-attributes id=the-optgroup-element:global-attributes>Global attributes</a><dd><code id=the-optgroup-element:attr-optgroup-disabled><a href=#attr-optgroup-disabled>disabled</a></code> — Whether the form control is disabled<dd><code id=the-optgroup-element:attr-optgroup-label><a href=#attr-optgroup-label>label</a></code> — User-visible label<dt><a href=#concept-element-dom id=the-optgroup-element:concept-element-dom>DOM interface</a>:<dd>
    <pre><code class='idl'>[<c- g>Exposed</c->=<c- n>Window</c->,
 <a href='#htmlconstructor' id='the-optgroup-element:htmlconstructor'><c- g>HTMLConstructor</c-></a>]
<c- b>interface</c-> <dfn id='htmloptgroupelement'><c- g>HTMLOptGroupElement</c-></dfn> : <a href='#htmlelement' id='the-optgroup-element:htmlelement'><c- n>HTMLElement</c-></a> {
  [<a href='#cereactions' id='the-optgroup-element:cereactions'><c- g>CEReactions</c-></a>] <c- b>attribute</c-> <c- b>boolean</c-> <a href='#dom-optgroup-disabled' id='the-optgroup-element:dom-optgroup-disabled'><c- g>disabled</c-></a>;
  [<a href='#cereactions' id='the-optgroup-element:cereactions-2'><c- g>CEReactions</c-></a>] <c- b>attribute</c-> <c- b>DOMString</c-> <a href='#dom-optgroup-label' id='the-optgroup-element:dom-optgroup-label'><c- g>label</c-></a>;
};</code></pre>
   </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 group of <code id=the-optgroup-element:the-option-element-2><a href=#the-option-element>option</a></code>
  elements with a common label.</p>

  <p>The element's group of <code id=the-optgroup-element:the-option-element-3><a href=#the-option-element>option</a></code> elements consists of the <code id=the-optgroup-element:the-option-element-4><a href=#the-option-element>option</a></code>
  elements that are children of the <code id=the-optgroup-element:the-optgroup-element-5><a href=#the-optgroup-element>optgroup</a></code> element.</p>

  

  <p>When showing <code id=the-optgroup-element:the-option-element-5><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-6><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-7><a href=#the-option-element>option</a></code> elements.</p>

  

  <p>The <dfn id=attr-optgroup-disabled><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 group of <code id=the-optgroup-element:the-option-element-8><a href=#the-option-element>option</a></code> elements
  together.</p>

  <p>The <dfn id=attr-optgroup-label><code>label</code></dfn> attribute must be specified. Its
  value 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-9><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>The <dfn id=dom-optgroup-disabled><code>disabled</code></dfn> and <dfn id=dom-optgroup-label><code>label</code></dfn> attributes must <a href=#reflect id=the-optgroup-element:reflect>reflect</a> the
  respective content attributes of the same name.</p>

  

  <p class=note>There is no way to select an <code id=the-optgroup-element:the-optgroup-element-6><a href=#the-optgroup-element>optgroup</a></code> element. Only
  <code id=the-optgroup-element:the-option-element-10><a href=#the-option-element>option</a></code> elements can be selected. An <code id=the-optgroup-element:the-optgroup-element-7><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-11><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>&quot;courseselector.dll&quot;</c-> <c- e>method</c-><c- o>=</c-><c- s>&quot;get&quot;</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>&quot;c&quot;</c-><c- p>&gt;</c->
   <c- p>&lt;</c-><c- f>optgroup</c-> <c- e>label</c-><c- o>=</c-><c- s>&quot;8.01 Physics I: Classical Mechanics&quot;</c-><c- p>&gt;</c->
    <c- p>&lt;</c-><c- f>option</c-> <c- e>value</c-><c- o>=</c-><c- s>&quot;8.01.1&quot;</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>&quot;8.01.2&quot;</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>&quot;8.01.3&quot;</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>&quot;8.02 Electricity and Magnestism&quot;</c-><c- p>&gt;</c->
    <c- p>&lt;</c-><c- f>option</c-> <c- e>value</c-><c- o>=</c-><c- s>&quot;8.02.1&quot;</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>&quot;8.02.2&quot;</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>&quot;8.02.3&quot;</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>&quot;8.03 Physics III: Vibrations and Waves&quot;</c-><c- p>&gt;</c->
    <c- p>&lt;</c-><c- f>option</c-> <c- e>value</c-><c- o>=</c-><c- s>&quot;8.03.1&quot;</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>&quot;8.03.2&quot;</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>&quot;8.03.3&quot;</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>&quot;▶ Play&quot;</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><code>option</code></dfn> element<a href=#the-option-element class=self-link></a></h4>

  <dl class=element><dt><a href=#concept-element-categories id=the-option-element:concept-element-categories>Categories</a>:<dd>None.<dt><a href=#concept-element-contexts id=the-option-element:concept-element-contexts>Contexts in which this element can be used</a>:<dd>As a child of a <code id=the-option-element:the-select-element><a href=#the-select-element>select</a></code> element.<dd>As a child of a <code id=the-option-element:the-datalist-element><a href=#the-datalist-element>datalist</a></code> element.<dd>As a child of an <code id=the-option-element:the-optgroup-element><a href=#the-optgroup-element>optgroup</a></code> element.<dt><a href=#concept-element-content-model id=the-option-element:concept-element-content-model>Content model</a>:<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>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>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
   child of a <code id=the-option-element:the-datalist-element-2><a href=#the-datalist-element>datalist</a></code> element: <a href=#text-content id=the-option-element:text-content-2>Text</a> that is not
   <a href=#inter-element-whitespace id=the-option-element:inter-element-whitespace>inter-element whitespace</a>.<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 child
   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-3>Text</a>.<dt><a href=#concept-element-tag-omission id=the-option-element:concept-element-tag-omission>Tag omission in text/html</a>:<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, or
   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, or if there is no more content
   in the parent element.<dt><a href=#concept-element-attributes id=the-option-element:concept-element-attributes>Content attributes</a>:<dd><a href=#global-attributes id=the-option-element:global-attributes>Global attributes</a><dd><code id=the-option-element:attr-option-disabled><a href=#attr-option-disabled>disabled</a></code> — Whether the form control is disabled<dd><code id=the-option-element:attr-option-label-5><a href=#attr-option-label>label</a></code> — User-visible label<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><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><dt><a href=#concept-element-dom id=the-option-element:concept-element-dom>DOM interface</a>:<dd>
    <pre><code class='idl'>[<c- g>Exposed</c->=<c- n>Window</c->,
 <a href='#htmlconstructor' id='the-option-element:htmlconstructor'><c- g>HTMLConstructor</c-></a>,
 <c- g>NamedConstructor</c->=<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-> = &quot;&quot;, <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'><c- g>HTMLOptionElement</c-></dfn> : <a href='#htmlelement' id='the-option-element:htmlelement'><c- n>HTMLElement</c-></a> {
  [<a href='#cereactions' id='the-option-element:cereactions'><c- g>CEReactions</c-></a>] <c- b>attribute</c-> <c- b>boolean</c-> <a href='#dom-option-disabled' id='the-option-element:dom-option-disabled'><c- g>disabled</c-></a>;
  <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>] <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>] <c- b>attribute</c-> <c- b>boolean</c-> <a href='#dom-option-defaultselected' id='the-option-element:dom-option-defaultselected'><c- g>defaultSelected</c-></a>;
  <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>] <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>
   </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>

  <p>The <dfn id=attr-option-disabled><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 is <dfn id=concept-option-disabled>disabled</dfn> if its <code id=the-option-element:attr-option-disabled-2><a href=#attr-option-disabled>disabled</a></code> attribute is present or if it is a child of an
  <code id=the-option-element:the-optgroup-element-3><a href=#the-optgroup-element>optgroup</a></code> element whose <code id=the-option-element:attr-optgroup-disabled><a href=#attr-optgroup-disabled>disabled</a></code> attribute
  is present.</p>

  

  <p>An <code id=the-option-element:the-option-element-7><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>The <dfn id=attr-option-label><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-8><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>

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

  <p>The <dfn id=attr-option-value><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-9><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 value of the element's <code id=the-option-element:dom-option-text-3><a href=#dom-option-text>text</a></code> IDL
  attribute.</p>

  <p>The <dfn id=attr-option-selected><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>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-10><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-2><a href=#attr-option-selected>selected</a></code> content attribute has any effect.</p>

  <p>The <dfn id=concept-option-selectedness>selectedness</dfn> of an <code id=the-option-element:the-option-element-11><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-2>selectedness</a> must be set to true if
  the element has a <code id=the-option-element:attr-option-selected-3><a href=#attr-option-selected>selected</a></code> attribute. Whenever an
  <code id=the-option-element:the-option-element-12><a href=#the-option-element>option</a></code> element's <code id=the-option-element:attr-option-selected-4><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-3>selectedness</a> must be set to true. Whenever an
  <code id=the-option-element:the-option-element-13><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
  <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-4>selectedness</a> must be set to false.</p>

  <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-5>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-6><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-6>selectedness</a> state when using the constructor.</p>

  

  

  <p>A <code id=the-option-element:the-select-element-6><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-14><a href=#the-option-element>option</a></code> element with
  its <code id=the-option-element:attr-option-selected-7><a href=#attr-option-selected>selected</a></code> attribute set.</p>

  

  <p>An <code id=the-option-element:the-option-element-15><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-16><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 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-17><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-18><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>

  

  <dl class=domintro><dt><var>option</var> . <code id=dom-option-selected-dev><a href=#dom-option-selected>selected</a></code><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>

   <dt><var>option</var> . <code id=dom-option-index-dev><a href=#dom-option-index>index</a></code><dd>

    <p>Returns the index of the element in its <code id=the-option-element:the-select-element-7><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>

   <dt><var>option</var> . <code id=dom-option-form-dev><a href=#dom-option-form>form</a></code><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>

   <dt><var>option</var> . <code id=dom-option-text-dev><a href=#dom-option-text>text</a></code><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>

   <dt><var>option</var> = new <code id=dom-option-dev><a href=#dom-option>Option</a></code>( [ <var>text</var> [, <var>value</var> [, <var>defaultSelected</var> [, <var>selected</var> ] ] ] ] )<dd>

    <p>Returns a new <code id=the-option-element:the-option-element-19><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-8><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>

   </dl>

  

  <p>The <dfn id=dom-option-disabled><code>disabled</code></dfn> IDL attribute must
  <a href=#reflect id=the-option-element:reflect>reflect</a> the content attribute of the same name. The <dfn id=dom-option-defaultselected><code>defaultSelected</code></dfn> IDL attribute must
  <a href=#reflect id=the-option-element:reflect-2>reflect</a> the <code id=the-option-element:attr-option-selected-9><a href=#attr-option-selected>selected</a></code> content attribute.</p>

  <p>The <dfn id=dom-option-label><code>label</code></dfn> IDL attribute, on getting, if there
  is a <code id=the-option-element:attr-option-label-8><a href=#attr-option-label>label</a></code> content attribute, must return that attribute's
  value; otherwise, it must return the element's <a href=#concept-option-label id=the-option-element:concept-option-label>label</a>.
  On setting, the element's <code id=the-option-element:attr-option-label-9><a href=#attr-option-label>label</a></code> content attribute must be
  set to the new value.</p>

  <p>The <dfn id=dom-option-value><code>value</code></dfn> IDL attribute, on getting, must
  return the element's <a href=#concept-option-value id=the-option-element:concept-option-value>value</a>. On setting, the element's
  <code id=the-option-element:attr-option-value-6><a href=#attr-option-value>value</a></code> content attribute must be set to the new value.</p>

  <p>The <dfn id=dom-option-selected><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-7>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-8>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>

  <p>The <dfn id=dom-option-index><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>

  <p>The <dfn id=dom-option-text><code>text</code></dfn> IDL attribute, on getting, must
  return the result of <a href=https://infra.spec.whatwg.org/#strip-and-collapse-ascii-whitespace id=the-option-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-option-element:concept-cd-data data-x-internal=concept-cd-data>data</a> of
  all the <code id=the-option-element:text><a data-x-internal=text href=https://dom.spec.whatwg.org/#interface-text>Text</a></code> node descendants of the <code id=the-option-element:the-option-element-20><a href=#the-option-element>option</a></code> element, 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>, excluding any that are descendants of descendants of the <code id=the-option-element:the-option-element-21><a href=#the-option-element>option</a></code> element
  that are themselves <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> elements.</p>

  <p>On setting, the <code id=the-option-element:dom-option-text-4><a href=#dom-option-text>text</a></code> attribute must act as if the
  <code id=the-option-element:textcontent-2><a data-x-internal=textcontent href=https://dom.spec.whatwg.org/#dom-node-textcontent>textContent</a></code> IDL attribute on the element had been set to the new value.</p>

  <p>The <dfn id=dom-option-form><code>form</code></dfn> IDL attribute's behavior depends on
  whether the <code id=the-option-element:the-option-element-22><a href=#the-option-element>option</a></code> element is in a <code id=the-option-element:the-select-element-8><a href=#the-select-element>select</a></code> element or not. If the
  <code id=the-option-element:the-option-element-23><a href=#the-option-element>option</a></code> has a <code id=the-option-element:the-select-element-9><a href=#the-select-element>select</a></code> element as its parent, or has an
  <code id=the-option-element:the-optgroup-element-4><a href=#the-optgroup-element>optgroup</a></code> element as its parent and that <code id=the-option-element:the-optgroup-element-5><a href=#the-optgroup-element>optgroup</a></code> element has a
  <code id=the-option-element:the-select-element-10><a href=#the-select-element>select</a></code> element as its parent, then the <code id=the-option-element:dom-option-form-2><a href=#dom-option-form>form</a></code> IDL
  attribute must return the same value as the <code id=the-option-element:dom-fae-form><a href=#dom-fae-form>form</a></code> IDL attribute
  on that <code id=the-option-element:the-select-element-11><a href=#the-select-element>select</a></code> element. Otherwise, it must return null.</p>

  <p>A constructor 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 id=dom-option><code>Option(<var>text</var>, <var>value</var>,
  <var>defaultSelected</var>, <var>selected</var>)</code></dfn>.  When invoked, the constructor 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>.<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 id=the-option-element:the-option-element-24><a href=#the-option-element>option</a></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>.<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-2><a data-x-internal=text href=https://dom.spec.whatwg.org/#interface-text>Text</a></code> node whose data is <var>text</var>.<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-7><a href=#attr-option-value>value</a></code>" and <var>value</var>.<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.<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-9>selectedness</a> to true; otherwise set its <a href=#concept-option-selectedness id=the-option-element:concept-option-selectedness-10>selectedness</a> to false (even if
   <var>defaultSelected</var> is true).<li><p>Return <var>option</var>.</ol>

  



  <h4 id=the-textarea-element><span class=secno>4.10.11</span> The <dfn><code>textarea</code></dfn> element<a href=#the-textarea-element class=self-link></a></h4>

  <dl class=element><dt><a href=#concept-element-categories id=the-textarea-element:concept-element-categories>Categories</a>:<dd><a href=#flow-content-2 id=the-textarea-element:flow-content-2>Flow content</a>.<dd><a href=#phrasing-content-2 id=the-textarea-element:phrasing-content-2>Phrasing content</a>.<dd><a href=#interactive-content-2 id=the-textarea-element:interactive-content-2>Interactive content</a>.<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-inheriting</a> <a href=#form-associated-element id=the-textarea-element:form-associated-element>form-associated element</a>.<dd><a href=#palpable-content-2 id=the-textarea-element:palpable-content-2>Palpable content</a>.<dt><a href=#concept-element-contexts id=the-textarea-element:concept-element-contexts>Contexts in which this element can be used</a>:<dd>Where <a href=#phrasing-content-2 id=the-textarea-element:phrasing-content-2-2>phrasing content</a> is expected.<dt><a href=#concept-element-content-model id=the-textarea-element:concept-element-content-model>Content model</a>:<dd><a href=#text-content id=the-textarea-element:text-content>Text</a>.<dt><a href=#concept-element-tag-omission id=the-textarea-element:concept-element-tag-omission>Tag omission in text/html</a>:<dd>Neither tag is omissible.<dt><a href=#concept-element-attributes id=the-textarea-element:concept-element-attributes>Content attributes</a>:<dd><a href=#global-attributes id=the-textarea-element:global-attributes>Global attributes</a><dd><code id=the-textarea-element:attr-fe-autocomplete><a href=#attr-fe-autocomplete>autocomplete</a></code> — Hint for form autofill feature<dd><code id=the-textarea-element:attr-fe-autofocus><a href=#attr-fe-autofocus>autofocus</a></code> — Automatically focus the form control when the page is loaded<dd><code id=the-textarea-element:attr-textarea-cols><a href=#attr-textarea-cols>cols</a></code> — Maximum number of characters per line<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><code id=the-textarea-element:attr-fe-disabled><a href=#attr-fe-disabled>disabled</a></code> — Whether the form control is disabled<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><code id=the-textarea-element:attr-textarea-maxlength><a href=#attr-textarea-maxlength>maxlength</a></code> — Maximum length of value<dd><code id=the-textarea-element:attr-textarea-minlength><a href=#attr-textarea-minlength>minlength</a></code> — Minimum length of value<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><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><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><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><code id=the-textarea-element:attr-textarea-rows><a href=#attr-textarea-rows>rows</a></code> — Number of lines to show<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><dt><a href=#concept-element-dom id=the-textarea-element:concept-element-dom>DOM interface</a>:<dd>
    <pre><code class='idl'>[<c- g>Exposed</c->=<c- n>Window</c->,
 <a href='#htmlconstructor' id='the-textarea-element:htmlconstructor'><c- g>HTMLConstructor</c-></a>]
<c- b>interface</c-> <dfn id='htmltextareaelement'><c- g>HTMLTextAreaElement</c-></dfn> : <a href='#htmlelement' id='the-textarea-element:htmlelement'><c- n>HTMLElement</c-></a> {
  [<a href='#cereactions' id='the-textarea-element:cereactions'><c- g>CEReactions</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>] <c- b>attribute</c-> <c- b>boolean</c-> <a href='#dom-fe-autofocus' id='the-textarea-element:dom-fe-autofocus'><c- g>autofocus</c-></a>;
  [<a href='#cereactions' id='the-textarea-element:cereactions-3'><c- g>CEReactions</c-></a>] <c- b>attribute</c-> <c- b>unsigned</c-> <c- b>long</c-> <a href='#dom-textarea-cols' id='the-textarea-element:dom-textarea-cols'><c- g>cols</c-></a>;
  [<a href='#cereactions' id='the-textarea-element:cereactions-4'><c- g>CEReactions</c-></a>] <c- b>attribute</c-> <c- b>DOMString</c-> <a href='#dom-textarea-dirname' id='the-textarea-element:dom-textarea-dirname'><c- g>dirName</c-></a>;
  [<a href='#cereactions' id='the-textarea-element:cereactions-5'><c- g>CEReactions</c-></a>] <c- b>attribute</c-> <c- b>boolean</c-> <a href='#dom-fe-disabled' id='the-textarea-element:dom-fe-disabled'><c- g>disabled</c-></a>;
  <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-6'><c- g>CEReactions</c-></a>] <c- b>attribute</c-> <c- b>long</c-> <a href='#dom-textarea-maxlength' id='the-textarea-element:dom-textarea-maxlength'><c- g>maxLength</c-></a>;
  [<a href='#cereactions' id='the-textarea-element:cereactions-7'><c- g>CEReactions</c-></a>] <c- b>attribute</c-> <c- b>long</c-> <a href='#dom-textarea-minlength' id='the-textarea-element:dom-textarea-minlength'><c- g>minLength</c-></a>;
  [<a href='#cereactions' id='the-textarea-element:cereactions-8'><c- g>CEReactions</c-></a>] <c- b>attribute</c-> <c- b>DOMString</c-> <a href='#dom-fe-name' id='the-textarea-element:dom-fe-name'><c- g>name</c-></a>;
  [<a href='#cereactions' id='the-textarea-element:cereactions-9'><c- g>CEReactions</c-></a>] <c- b>attribute</c-> <c- b>DOMString</c-> <a href='#dom-textarea-placeholder' id='the-textarea-element:dom-textarea-placeholder'><c- g>placeholder</c-></a>;
  [<a href='#cereactions' id='the-textarea-element:cereactions-10'><c- g>CEReactions</c-></a>] <c- b>attribute</c-> <c- b>boolean</c-> <a href='#dom-textarea-readonly' id='the-textarea-element:dom-textarea-readonly'><c- g>readOnly</c-></a>;
  [<a href='#cereactions' id='the-textarea-element:cereactions-11'><c- g>CEReactions</c-></a>] <c- b>attribute</c-> <c- b>boolean</c-> <a href='#dom-textarea-required' id='the-textarea-element:dom-textarea-required'><c- g>required</c-></a>;
  [<a href='#cereactions' id='the-textarea-element:cereactions-12'><c- g>CEReactions</c-></a>] <c- b>attribute</c-> <c- b>unsigned</c-> <c- b>long</c-> <a href='#dom-textarea-rows' id='the-textarea-element:dom-textarea-rows'><c- g>rows</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-wrap' id='the-textarea-element:dom-textarea-wrap'><c- g>wrap</c-></a>;

  <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-14'><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-> [<c- g>TreatNullAs</c->=<c- n>EmptyString</c->] <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>void</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 href='https://dom.spec.whatwg.org/#interface-nodelist' data-x-internal='nodelist' id='the-textarea-element: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>void</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>void</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>void</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-> = &quot;preserve&quot;);
  <c- b>void</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>
   </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 id=attr-textarea-readonly><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>&quot;buffer&quot;</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&apos;t do anything
[ -z &quot;$PS1&quot; ] <c- ni>&amp;amp;&amp;amp;</c-> return

...<c- p>&lt;/</c-><c- f>textarea</c-><c- p>&gt;</c-></code></pre>

  </div>

  

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

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

  <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-a-task id=the-textarea-element:queue-a-task>queue a
  task</a> 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 href=#event-input>input</a></code> at the <code id=the-textarea-element:the-textarea-element-6><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> attribute 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>
  

  <p>A <code id=the-textarea-element:the-textarea-element-7><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>

  <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-8><a href=#the-textarea-element>textarea</a></code>
  elements must 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 the node being cloned to the copy.</p>

  <p>The <a id=the-textarea-element:child-text-content-change-steps href=https://dom.spec.whatwg.org/#concept-node-text-change-ext data-x-internal=child-text-content-change-steps>child text content change steps</a> for <code id=the-textarea-element:the-textarea-element-9><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>

  <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-10><a href=#the-textarea-element>textarea</a></code>
  elements is to set the <a href=#concept-fe-dirty id=the-textarea-element:concept-fe-dirty-4>dirty value flag</a> back to false, and
  set the <a href=#concept-textarea-raw-value id=the-textarea-element:concept-textarea-raw-value-7>raw value</a> of element 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>

  <p>When a <code id=the-textarea-element:the-textarea-element-11><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>

  
  
  <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:the-dir-attribute><a href=#the-dir-attribute>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.<li><p><a href=#queue-a-task id=the-textarea-element:queue-a-task-2>Queue a task</a> 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 href=#event-input>input</a></code> at the <code id=the-textarea-element:the-textarea-element-12><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> attribute initialized to true.</ol>

  

  <p>The <dfn id=attr-textarea-cols><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>

  

  <p>The user agent may use the <code id=the-textarea-element:the-textarea-element-13><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>

  

  <p>The <dfn id=attr-textarea-rows><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>

  

  <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 id=attr-textarea-wrap><code>wrap</code></dfn> attribute is an <a href=#enumerated-attribute id=the-textarea-element:enumerated-attribute>enumerated
  attribute</a> with two keywords and states: the <dfn id=attr-textarea-wrap-soft><code>soft</code></dfn> keyword which maps to the <a href=#attr-textarea-wrap-soft-state id=the-textarea-element:attr-textarea-wrap-soft-state>Soft</a> state, and the <dfn id=attr-textarea-wrap-hard><code>hard</code></dfn> keyword which maps to the <a href=#attr-textarea-wrap-hard-state id=the-textarea-element:attr-textarea-wrap-hard-state>Hard</a> state. The <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 the <a href=#attr-textarea-wrap-soft-state id=the-textarea-element:attr-textarea-wrap-soft-state-2>Soft</a> state.</p>

  <p>The <dfn id=attr-textarea-wrap-soft-state>Soft</dfn> state indicates that the text in the
  <code id=the-textarea-element:the-textarea-element-14><a href=#the-textarea-element>textarea</a></code> is not to be wrapped when it is submitted (though it can still be wrapped in
  the rendering).</p>

  <p>The <dfn id=attr-textarea-wrap-hard-state>Hard</dfn> state indicates that the text in the
  <code id=the-textarea-element:the-textarea-element-15><a href=#the-textarea-element>textarea</a></code> is to have newlines added by the user agent so that the text is wrapped when
  it is submitted.</p>

  <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-2>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 so that line breaks use U+000D CARRIAGE RETURN U+000A LINE
  FEED (CRLF) character pairs, 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>

  <p>The algorithm for obtaining the element's <a href=#concept-fe-api-value id=the-textarea-element:concept-fe-api-value-2>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 the
  <a href=#textarea-line-break-normalisation-transformation id=the-textarea-element:textarea-line-break-normalisation-transformation>textarea line break normalization transformation</a> applied. The
  <dfn id=textarea-line-break-normalisation-transformation>textarea line break
  normalization transformation</dfn> is the following algorithm, as applied to a string:</p>

  <ol><li><p>Replace every U+000D CARRIAGE RETURN U+000A LINE FEED (CRLF) character pair with a single
   U+000A LINE FEED (LF) character.<li><p>Replace every remaining U+000D CARRIAGE RETURN character with a single U+000A LINE FEED
   (LF) character.</ol>

  <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>raw 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>Replace every occurrence of a U+000D CARRIAGE RETURN (CR) character not followed by a
   U+000A LINE FEED (LF) character, and every occurrence of a U+000A LINE FEED (LF) character not
   preceded by a U+000D CARRIAGE RETURN (CR) character, by a two-character string consisting of a
   U+000D CARRIAGE RETURN U+000A LINE FEED (CRLF) character pair.<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-3>Hard</a> state, insert U+000D CARRIAGE RETURN U+000A
   LINE FEED (CRLF) character pairs into the string using a UA-defined 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+000D CARRIAGE RETURN U+000A LINE FEED (CRLF) character pairs.</ol>

  

  <p>The <dfn id=attr-textarea-maxlength><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:javascript-string-length href=https://infra.spec.whatwg.org/#javascript-string-length data-x-internal=javascript-string-length>JavaScript string length</a> of the value of the
  element's <code id=the-textarea-element:textcontent><a data-x-internal=textcontent href=https://dom.spec.whatwg.org/#dom-node-textcontent>textContent</a></code> IDL attribute with the <a href=#textarea-line-break-normalisation-transformation id=the-textarea-element:textarea-line-break-normalisation-transformation-2>textarea line break normalization
  transformation</a> applied is equal to or less than 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 id=attr-textarea-minlength><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 id=attr-textarea-required><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>

  

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

  


  

  <p>The <dfn id=attr-textarea-placeholder><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>
  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-autofocus-2><a href=#attr-fe-autofocus>autofocus</a></code> attribute controls focus.
  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><var>textarea</var> . <code id=dom-textarea-type-dev><a href=#dom-textarea-type>type</a></code><dd>

    <p>Returns the string "<code>textarea</code>".</p>

   <dt><var>textarea</var> . <code id=dom-textarea-value-dev><a href=#dom-textarea-value>value</a></code><dd>

    <p>Returns the current value of the element.</p>

    <p>Can be set, to change the value.</p>

   </dl>

  

  <p>The <dfn id=dom-textarea-cols><code>cols</code></dfn>, <dfn id=dom-textarea-placeholder><code>placeholder</code></dfn>, <dfn id=dom-textarea-required><code>required</code></dfn>, <dfn id=dom-textarea-rows><code>rows</code></dfn>, and <dfn id=dom-textarea-wrap><code>wrap</code></dfn> IDL attributes must <a href=#reflect id=the-textarea-element:reflect>reflect</a> the
  respective content attributes of the same name. The <code id=the-textarea-element:dom-textarea-cols-2><a href=#dom-textarea-cols>cols</a></code>
  and <code id=the-textarea-element:dom-textarea-rows-2><a href=#dom-textarea-rows>rows</a></code> attributes are <a href=#limited-to-only-non-negative-numbers-greater-than-zero-with-fallback id=the-textarea-element:limited-to-only-non-negative-numbers-greater-than-zero-with-fallback>limited to only non-negative
  numbers greater than zero with fallback</a>. The <code id=the-textarea-element:dom-textarea-cols-3><a href=#dom-textarea-cols>cols</a></code>
  IDL attribute's default value is 20. The <code id=the-textarea-element:dom-textarea-rows-3><a href=#dom-textarea-rows>rows</a></code> IDL
  attribute's default value is 2. The <dfn id=dom-textarea-dirname><code>dirName</code></dfn>
  IDL attribute must <a href=#reflect id=the-textarea-element:reflect-2>reflect</a> the <code id=the-textarea-element:attr-fe-dirname-3><a href=#attr-fe-dirname>dirname</a></code> content
  attribute. The <dfn id=dom-textarea-maxlength><code>maxLength</code></dfn> IDL attribute
  must <a href=#reflect id=the-textarea-element:reflect-3>reflect</a> the <code id=the-textarea-element:attr-textarea-maxlength-2><a href=#attr-textarea-maxlength>maxlength</a></code> content
  attribute, <a href=#limited-to-only-non-negative-numbers id=the-textarea-element:limited-to-only-non-negative-numbers>limited to only non-negative numbers</a>. The
  <dfn id=dom-textarea-minlength><code>minLength</code></dfn> IDL attribute must
  <a href=#reflect id=the-textarea-element:reflect-4>reflect</a> the <code id=the-textarea-element:attr-textarea-minlength-2><a href=#attr-textarea-minlength>minlength</a></code> content attribute,
  <a href=#limited-to-only-non-negative-numbers id=the-textarea-element:limited-to-only-non-negative-numbers-2>limited to only non-negative numbers</a>. The
  <dfn id=dom-textarea-readonly><code>readOnly</code></dfn> IDL attribute must
  <a href=#reflect id=the-textarea-element:reflect-5>reflect</a> the <code id=the-textarea-element:attr-textarea-readonly-4><a href=#attr-textarea-readonly>readonly</a></code> content
  attribute.</p>

  <p>The <dfn id=dom-textarea-type><code>type</code></dfn> IDL attribute must return the value
  "<code>textarea</code>".</p>

  <p>The <dfn id=dom-textarea-defaultvalue><code>defaultValue</code></dfn> IDL attribute must,
  on getting, 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>. On setting, it must act as the
  setter for the element's <code id=the-textarea-element:textcontent-2><a data-x-internal=textcontent href=https://dom.spec.whatwg.org/#dom-node-textcontent>textContent</a></code> IDL attribute.</p>

  <p>The <dfn id=dom-textarea-value><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-3>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-4>API value</a>.<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.<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.<li><p>If the new <a href=#concept-fe-api-value id=the-textarea-element:concept-fe-api-value-5>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>".</ol>

  <p>The <dfn id=dom-textarea-textlength><code>textLength</code></dfn> IDL attribute must
  return the <a id=the-textarea-element:javascript-string-length-2 href=https://infra.spec.whatwg.org/#javascript-string-length data-x-internal=javascript-string-length>JavaScript string length</a> of the element's <a href=#concept-fe-api-value id=the-textarea-element:concept-fe-api-value-6>API value</a>.</p>

  <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-fe-autofocus-2><a href=#dom-fe-autofocus>autofocus</a></code>, <code id=the-textarea-element:dom-fe-disabled-2><a href=#dom-fe-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-fe-name-2><a href=#dom-fe-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-3><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>&quot;500&quot;</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>&quot;Dear Francine,</c->

<c- s>They closed the parks this week, so we won&apos;t be able to</c->
<c- s>meet your there. Should we just have dinner?</c->

<c- s>Love,</c->
<c- s>Daddy&quot;</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-4><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><code>output</code></dfn> element<a href=#the-output-element class=self-link></a></h4>

  <dl class=element><dt><a href=#concept-element-categories id=the-output-element:concept-element-categories>Categories</a>:<dd><a href=#flow-content-2 id=the-output-element:flow-content-2>Flow content</a>.<dd><a href=#phrasing-content-2 id=the-output-element:phrasing-content-2>Phrasing content</a>.<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-inheriting</a> <a href=#form-associated-element id=the-output-element:form-associated-element>form-associated element</a>.<dd><a href=#palpable-content-2 id=the-output-element:palpable-content-2>Palpable content</a>.<dt><a href=#concept-element-contexts id=the-output-element:concept-element-contexts>Contexts in which this element can be used</a>:<dd>Where <a href=#phrasing-content-2 id=the-output-element:phrasing-content-2-2>phrasing content</a> is expected.<dt><a href=#concept-element-content-model id=the-output-element:concept-element-content-model>Content model</a>:<dd><a href=#phrasing-content-2 id=the-output-element:phrasing-content-2-3>Phrasing content</a>.<dt><a href=#concept-element-tag-omission id=the-output-element:concept-element-tag-omission>Tag omission in text/html</a>:<dd>Neither tag is omissible.<dt><a href=#concept-element-attributes id=the-output-element:concept-element-attributes>Content attributes</a>:<dd><a href=#global-attributes id=the-output-element:global-attributes>Global attributes</a><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><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><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 <dt><a href=#concept-element-dom id=the-output-element:concept-element-dom>DOM interface</a>:<dd>
    <pre><code class='idl'>[<c- g>Exposed</c->=<c- n>Window</c->,
 <a href='#htmlconstructor' id='the-output-element:htmlconstructor'><c- g>HTMLConstructor</c-></a>]
<c- b>interface</c-> <dfn id='htmloutputelement'><c- g>HTMLOutputElement</c-></dfn> : <a href='#htmlelement' id='the-output-element:htmlelement'><c- n>HTMLElement</c-></a> {
  [<c- g>SameObject</c->, <c- g>PutForwards</c->=<a href='https://dom.spec.whatwg.org/#dom-domtokenlist-value' data-x-internal='dom-domtokenlist-value' id='the-output-element:dom-domtokenlist-value'><c- n>value</c-></a>] <c- b>readonly</c-> <c- b>attribute</c-> <a href='https://dom.spec.whatwg.org/#interface-domtokenlist' data-x-internal='domtokenlist' id='the-output-element:domtokenlist'><c- n>DOMTokenList</c-></a> <a href='#dom-output-htmlfor' id='the-output-element:dom-output-htmlfor'><c- g>htmlFor</c-></a>;
  <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>] <c- b>attribute</c-> <c- b>DOMString</c-> <a href='#dom-fe-name' id='the-output-element:dom-fe-name'><c- g>name</c-></a>;

  <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>void</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 href='https://dom.spec.whatwg.org/#interface-nodelist' data-x-internal='nodelist' id='the-output-element: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>
   </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>

  <p>The <dfn id=attr-output-for><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-2><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> that are
  <a href=#case-sensitive id=the-output-element:case-sensitive>case-sensitive</a>, 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-mode>value mode flag</dfn> which is either <i id=the-output-element:concept-output-mode-value><a href=#concept-output-mode-value>value</a></i> or <i id=the-output-element:concept-output-mode-default><a href=#concept-output-mode-default>default</a></i>. Initially, the <a href=#concept-output-mode id=the-output-element:concept-output-mode>value mode flag</a> must be set to <i id=the-output-element:concept-output-mode-default-2><a href=#concept-output-mode-default>default</a></i>.</p>

  <p>The element also has a <dfn id=concept-output-defaultvalue>default value</dfn>.
  Initially, the <a href=#concept-output-defaultvalue id=the-output-element:concept-output-defaultvalue>default value</a> must be the empty
  string.</p>

  <p>When the <a href=#concept-output-mode id=the-output-element:concept-output-mode-2>value mode flag</a> is in mode <dfn id=concept-output-mode-default><i>default</i></dfn>, the contents of the element represent both
  the value of the element and its <a href=#concept-output-defaultvalue id=the-output-element:concept-output-defaultvalue-2>default value</a>.
  When the <a href=#concept-output-mode id=the-output-element:concept-output-mode-3>value mode flag</a> is in mode <dfn id=concept-output-mode-value><i>value</i></dfn>, the contents of the element represent the
  value of the element only, and the <a href=#concept-output-defaultvalue id=the-output-element:concept-output-defaultvalue-3>default value</a>
  is only accessible using the <code id=the-output-element:dom-output-defaultvalue-2><a href=#dom-output-defaultvalue>defaultValue</a></code> IDL
  attribute.</p>

  <p>Whenever the element's descendants are changed in any way, if the <a href=#concept-output-mode id=the-output-element:concept-output-mode-4>value mode flag</a> is in mode <i id=the-output-element:concept-output-mode-default-3><a href=#concept-output-mode-default>default</a></i>, the element's <a href=#concept-output-defaultvalue id=the-output-element:concept-output-defaultvalue-4>default value</a> must be set to the value of the
  element's <code id=the-output-element:textcontent><a data-x-internal=textcontent href=https://dom.spec.whatwg.org/#dom-node-textcontent>textContent</a></code> IDL attribute.</p>

  <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 set the element's <a href=#concept-output-mode id=the-output-element:concept-output-mode-5>value mode flag</a> to <i id=the-output-element:concept-output-mode-default-4><a href=#concept-output-mode-default>default</a></i> and then to set the element's
  <code id=the-output-element:textcontent-2><a data-x-internal=textcontent href=https://dom.spec.whatwg.org/#dom-node-textcontent>textContent</a></code> IDL attribute to the value of the element's <a href=#concept-output-defaultvalue id=the-output-element:concept-output-defaultvalue-5>default value</a> (thus replacing the element's child
  nodes).</p>

  

  <dl class=domintro><dt><var>output</var> . <code id=dom-output-value-dev><a href=#dom-output-value>value</a></code> [ = <var>value</var> ]<dd>

    <p>Returns the element's current value.</p>

    <p>Can be set, to change the value.</p>

   <dt><var>output</var> . <code id=dom-output-defaultvalue-dev><a href=#dom-output-defaultvalue>defaultValue</a></code> [ = <var>value</var> ]<dd>

    <p>Returns the element's current default value.</p>

    <p>Can be set, to change the default value.</p>

   <dt><var>output</var> . <code id=dom-output-type-dev><a href=#dom-output-type>type</a></code><dd>

    <p>Returns the string "<code>output</code>".</p>

   </dl>

  

  <p>The <dfn id=dom-output-value><code>value</code></dfn> IDL attribute must act like the
  element's <code id=the-output-element:textcontent-3><a data-x-internal=textcontent href=https://dom.spec.whatwg.org/#dom-node-textcontent>textContent</a></code> IDL attribute, except that on setting, in addition, before the
  child nodes are changed, the element's <a href=#concept-output-mode id=the-output-element:concept-output-mode-6>value mode flag</a>
  must be set to <i id=the-output-element:concept-output-mode-value-2><a href=#concept-output-mode-value>value</a></i>.</p>

  <p>The <dfn id=dom-output-defaultvalue><code>defaultValue</code></dfn> IDL attribute, on
  getting, must return the element's <a href=#concept-output-defaultvalue id=the-output-element:concept-output-defaultvalue-6>default
  value</a>. On setting, the attribute must set the element's <a href=#concept-output-defaultvalue id=the-output-element:concept-output-defaultvalue-7>default value</a>, and, if the element's <a href=#concept-output-mode id=the-output-element:concept-output-mode-7>value mode flag</a> is in the mode <i id=the-output-element:concept-output-mode-default-5><a href=#concept-output-mode-default>default</a></i>, set the element's <code id=the-output-element:textcontent-4><a data-x-internal=textcontent href=https://dom.spec.whatwg.org/#dom-node-textcontent>textContent</a></code> IDL
  attribute as well.</p>

  <p>The <dfn id=dom-output-type><code>type</code></dfn> attribute must return the string
  "<code>output</code>".</p>

  <p>The <dfn id=dom-output-htmlfor><code>htmlFor</code></dfn> IDL attribute must
  <a href=#reflect id=the-output-element:reflect>reflect</a> the <code id=the-output-element:attr-output-for-3><a href=#attr-output-for>for</a></code> content attribute.</p>

  <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-fe-name-2><a href=#dom-fe-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>&quot;return false&quot;</c-> <c- e>oninput</c-><c- o>=</c-><c- s>&quot;o.value = a.valueAsNumber + b.valueAsNumber&quot;</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>&quot;a b&quot;</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>&quot;result&quot;</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>&apos;ws://primes.example.net/&apos;</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>&apos;result&apos;</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><code>progress</code></dfn> element<a href=#the-progress-element class=self-link></a></h4><div class=status><input onclick=toggleStatus(this) value=⋰ type=button><p class=support><strong>Support:</strong> progress<span class="and_chr yes"><span>Chrome for Android</span> <span>67+</span></span><span class="chrome yes"><span>Chrome</span> <span>8+</span></span><span class="ios_saf partial"><span>iOS Safari (limited)</span> <span>7.0+</span></span><span class="and_uc yes"><span>UC Browser for Android</span> <span>11.8+</span></span><span class="firefox yes"><span>Firefox</span> <span>6+</span></span><span class="ie yes"><span>IE</span> <span>10+</span></span><span class="op_mini yes"><span>Opera Mini</span> <span>all+</span></span><span class="safari yes"><span>Safari</span> <span>6+</span></span><span class="edge yes"><span>Edge</span> <span>12+</span></span><span class="samsung yes"><span>Samsung Internet</span> <span>4+</span></span><span class="opera yes"><span>Opera</span> <span>11+</span></span><span class="android yes"><span>Android Browser</span> <span>4.4+</span></span><p class=caniuse>Source: <a href="https://caniuse.com/#feat=progress">caniuse.com</a></div>

  <dl class=element><dt><a href=#concept-element-categories id=the-progress-element:concept-element-categories>Categories</a>:<dd><a href=#flow-content-2 id=the-progress-element:flow-content-2>Flow content</a>.<dd><a href=#phrasing-content-2 id=the-progress-element:phrasing-content-2>Phrasing content</a>.<dd><a href=#category-label id=the-progress-element:category-label>Labelable element</a>.<dd><a href=#palpable-content-2 id=the-progress-element:palpable-content-2>Palpable content</a>.<dt><a href=#concept-element-contexts id=the-progress-element:concept-element-contexts>Contexts in which this element can be used</a>:<dd>Where <a href=#phrasing-content-2 id=the-progress-element:phrasing-content-2-2>phrasing content</a> is expected.<dt><a href=#concept-element-content-model id=the-progress-element:concept-element-content-model>Content model</a>:<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.<dt><a href=#concept-element-tag-omission id=the-progress-element:concept-element-tag-omission>Tag omission in text/html</a>:<dd>Neither tag is omissible.<dt><a href=#concept-element-attributes id=the-progress-element:concept-element-attributes>Content attributes</a>:<dd><a href=#global-attributes id=the-progress-element:global-attributes>Global attributes</a><dd><code id=the-progress-element:attr-progress-value><a href=#attr-progress-value>value</a></code> — Current value of the element<dd><code id=the-progress-element:attr-progress-max><a href=#attr-progress-max>max</a></code> — Upper bound of range<dt><a href=#concept-element-dom id=the-progress-element:concept-element-dom>DOM interface</a>:<dd>
    <pre><code class='idl'>[<c- g>Exposed</c->=<c- n>Window</c->,
 <a href='#htmlconstructor' id='the-progress-element:htmlconstructor'><c- g>HTMLConstructor</c-></a>]
<c- b>interface</c-> <dfn id='htmlprogresselement'><c- g>HTMLProgressElement</c-></dfn> : <a href='#htmlelement' id='the-progress-element:htmlelement'><c- n>HTMLElement</c-></a> {
  [<a href='#cereactions' id='the-progress-element:cereactions'><c- g>CEReactions</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>] <c- b>attribute</c-> <c- b>double</c-> <a href='#dom-progress-max' id='the-progress-element:dom-progress-max'><c- g>max</c-></a>;
  <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 href='https://dom.spec.whatwg.org/#interface-nodelist' data-x-internal='nodelist' id='the-progress-element: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>
   </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>

  <p>There are two attributes that determine the current task completion represented by the element.
  The <dfn id=attr-progress-value><code>value</code></dfn> attribute specifies how much of the
  task has been completed, and the <dfn id=attr-progress-max><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>&quot;p&quot;</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>&apos;p&apos;</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>&apos;span&apos;</c-><c- p>)[</c-><c- mi>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 equal to or
  greater than 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>

  

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

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

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

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

  <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><var>progress</var> . <code id=dom-progress-position-dev><a href=#dom-progress-position>position</a></code><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>
   </dl>

  

  <p>If the progress bar is an indeterminate progress bar, then the <dfn id=dom-progress-position><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>

  <p>If the progress bar is an indeterminate progress bar, then the <dfn id=dom-progress-value><code>value</code></dfn> IDL attribute, on getting, must return 0.
  Otherwise, it must return the <a href=#concept-progress-value id=the-progress-element:concept-progress-value-4>current value</a>. On
  setting, the given value must be converted to the <a href=#best-representation-of-the-number-as-a-floating-point-number id=the-progress-element:best-representation-of-the-number-as-a-floating-point-number>best representation of the number as a
  floating-point number</a> and then the <code id=the-progress-element:dom-progress-value-2><a href=#dom-progress-value>value</a></code> content
  attribute must be set to that string.</p>

  <p class=note>Setting the <code id=the-progress-element:dom-progress-value-3><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 <dfn id=dom-progress-max><code>max</code></dfn> IDL attribute must
  <a href=#reflect id=the-progress-element:reflect>reflect</a> the content attribute of the same name, <a href=#limited-to-numbers-greater-than-zero id=the-progress-element:limited-to-numbers-greater-than-zero>limited to numbers greater than
  zero</a>. The default value for <code id=the-progress-element:dom-progress-max-2><a href=#dom-progress-max>max</a></code> is 1.0.</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><code>meter</code></dfn> element<a href=#the-meter-element class=self-link></a></h4><div class=status><input onclick=toggleStatus(this) value=⋰ type=button><p class=support><strong>Support:</strong> meter<span class="and_chr yes"><span>Chrome for Android</span> <span>67+</span></span><span class="chrome yes"><span>Chrome</span> <span>8+</span></span><span class="ios_saf yes"><span>iOS Safari</span> <span>10.3+</span></span><span class="and_uc yes"><span>UC Browser for Android</span> <span>11.8+</span></span><span class="firefox yes"><span>Firefox</span> <span>16+</span></span><span class="ie no"><span>IE</span> <span>None</span></span><span class="op_mini yes"><span>Opera Mini</span> <span>all+</span></span><span class="safari yes"><span>Safari</span> <span>6+</span></span><span class="edge yes"><span>Edge</span> <span>13+</span></span><span class="samsung yes"><span>Samsung Internet</span> <span>4+</span></span><span class="opera yes"><span>Opera</span> <span>11+</span></span><span class="android yes"><span>Android Browser</span> <span>4.4+</span></span><p class=caniuse>Source: <a href="https://caniuse.com/#feat=meter">caniuse.com</a></div>
  

  <dl class=element><dt><a href=#concept-element-categories id=the-meter-element:concept-element-categories>Categories</a>:<dd><a href=#flow-content-2 id=the-meter-element:flow-content-2>Flow content</a>.<dd><a href=#phrasing-content-2 id=the-meter-element:phrasing-content-2>Phrasing content</a>.<dd><a href=#category-label id=the-meter-element:category-label>Labelable element</a>.<dd><a href=#palpable-content-2 id=the-meter-element:palpable-content-2>Palpable content</a>.<dt><a href=#concept-element-contexts id=the-meter-element:concept-element-contexts>Contexts in which this element can be used</a>:<dd>Where <a href=#phrasing-content-2 id=the-meter-element:phrasing-content-2-2>phrasing content</a> is expected.<dt><a href=#concept-element-content-model id=the-meter-element:concept-element-content-model>Content model</a>:<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.<dt><a href=#concept-element-tag-omission id=the-meter-element:concept-element-tag-omission>Tag omission in text/html</a>:<dd>Neither tag is omissible.<dt><a href=#concept-element-attributes id=the-meter-element:concept-element-attributes>Content attributes</a>:<dd><a href=#global-attributes id=the-meter-element:global-attributes>Global attributes</a><dd><code id=the-meter-element:attr-meter-value><a href=#attr-meter-value>value</a></code> — Current value of the element<dd><code id=the-meter-element:attr-meter-min><a href=#attr-meter-min>min</a></code> — Lower bound of range<dd><code id=the-meter-element:attr-meter-max><a href=#attr-meter-max>max</a></code> — Upper bound of range<dd><code id=the-meter-element:attr-meter-low><a href=#attr-meter-low>low</a></code> — High limit of low range<dd><code id=the-meter-element:attr-meter-high><a href=#attr-meter-high>high</a></code> — Low limit of high range<dd><code id=the-meter-element:attr-meter-optimum><a href=#attr-meter-optimum>optimum</a></code> — Optimum value in gauge<dt><a href=#concept-element-dom id=the-meter-element:concept-element-dom>DOM interface</a>:<dd>
    <pre><code class='idl'>[<c- g>Exposed</c->=<c- n>Window</c->,
 <a href='#htmlconstructor' id='the-meter-element:htmlconstructor'><c- g>HTMLConstructor</c-></a>]
<c- b>interface</c-> <dfn id='htmlmeterelement'><c- g>HTMLMeterElement</c-></dfn> : <a href='#htmlelement' id='the-meter-element:htmlelement'><c- n>HTMLElement</c-></a> {
  [<a href='#cereactions' id='the-meter-element:cereactions'><c- g>CEReactions</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>] <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>] <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>] <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>] <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>] <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 href='https://dom.spec.whatwg.org/#interface-nodelist' data-x-internal='nodelist' id='the-meter-element: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>
   </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>

  <p>The <dfn id=attr-meter-min><code>min</code></dfn> attribute specifies the lower bound of
  the range, and the <dfn id=attr-meter-max><code>max</code></dfn> attribute specifies the
  upper bound. The <dfn id=attr-meter-value><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 id=attr-meter-low><code>low</code></dfn> attribute specifies the range that is considered to
  be the "low" part, and the <dfn id=attr-meter-high><code>high</code></dfn> attribute
  specifies the range that is considered to be the "high" part. The <dfn id=attr-meter-optimum><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>

  <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 zero.</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 class=brief><li><var>minimum</var> ≤ <var>value</var> ≤ <var>maximum</var><li><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)<li><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)<li><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)<li><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)</ul>

  <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->
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>&quot;75%&quot;</c-> <c- e>src</c-><c- o>=</c-><c- s>&quot;graph75.png&quot;</c-><c- p>&gt;&lt;/</c-><c- f>meter</c-><c- p>&gt;</c->
Tickets sold: <c- p>&lt;</c-><c- f>meter</c-> <c- e>min</c-><c- o>=</c-><c- s>&quot;0&quot;</c-> <c- e>max</c-><c- o>=</c-><c- s>&quot;100&quot;</c-> <c- e>value</c-><c- o>=</c-><c- s>&quot;75&quot;</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>&quot;centimeters&quot;</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>&quot;centimeters&quot;</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><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><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>

   <dt>The <dfn id=concept-meter-maximum>maximum value</dfn><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>

   <dt>The <dfn id=concept-meter-actual>actual value</dfn><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>

   <dt>The <dfn id=concept-meter-low>low boundary</dfn><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>

   <dt>The <dfn id=concept-meter-high>high boundary</dfn><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>

   <dt>The <dfn id=concept-meter-optimum>optimum point</dfn><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>

   </dl>

  <p>All of which will result in the following inequalities all being true:</p>

  <ul class=brief><li>minimum value ≤ actual value ≤ maximum value<li>minimum value ≤ low boundary ≤ high boundary ≤ maximum value<li>minimum value ≤ optimum point ≤ maximum value</ul>

  <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>&quot;?cmd=hsg&quot;</c-> <c- e>onclick</c-><c- o>=</c-><c- s>&quot;hideSuggestedGroups()&quot;</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>&quot;/group/comp.infosystems.www.authoring.stylesheets/view&quot;</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>&quot;/group/comp.infosystems.www.authoring.stylesheets/subscribe&quot;</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>&quot;0.5&quot;</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>&quot;/group/netscape.public.mozilla.xpinstall/view&quot;</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>&quot;/group/netscape.public.mozilla.xpinstall/subscribe&quot;</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>&quot;0.25&quot;</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>&quot;/group/mozilla.dev.general/view&quot;</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>&quot;/group/mozilla.dev.general/subscribe&quot;</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>&quot;0.25&quot;</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>

  

  <p>The <dfn id=dom-meter-value><code>value</code></dfn> IDL attribute, on getting, must
  return the <a href=#concept-meter-actual id=the-meter-element:concept-meter-actual>actual value</a>. On setting, the given value
  must be converted to the <a href=#best-representation-of-the-number-as-a-floating-point-number id=the-meter-element:best-representation-of-the-number-as-a-floating-point-number>best representation of the number as a floating-point number</a>
  and then the <code id=the-meter-element:attr-meter-value-8><a href=#attr-meter-value>value</a></code> content attribute must be set to that
  string.</p>

  <p>The <dfn id=dom-meter-min><code>min</code></dfn> IDL attribute, on getting, must return
  the <a href=#concept-meter-minimum id=the-meter-element:concept-meter-minimum>minimum value</a>. On setting, the given value must be
  converted to the <a href=#best-representation-of-the-number-as-a-floating-point-number id=the-meter-element:best-representation-of-the-number-as-a-floating-point-number-2>best representation of the number as a floating-point number</a> and
  then the <code id=the-meter-element:attr-meter-min-6><a href=#attr-meter-min>min</a></code> content attribute must be set to that
  string.</p>

  <p>The <dfn id=dom-meter-max><code>max</code></dfn> IDL attribute, on getting, must return
  the <a href=#concept-meter-maximum id=the-meter-element:concept-meter-maximum>maximum value</a>. On setting, the given value must be
  converted to the <a href=#best-representation-of-the-number-as-a-floating-point-number id=the-meter-element:best-representation-of-the-number-as-a-floating-point-number-3>best representation of the number as a floating-point number</a> and
  then the <code id=the-meter-element:attr-meter-max-6><a href=#attr-meter-max>max</a></code> content attribute must be set to that
  string.</p>

  <p>The <dfn id=dom-meter-low><code>low</code></dfn> IDL attribute, on getting, must return
  the <a href=#concept-meter-low id=the-meter-element:concept-meter-low>low boundary</a>. On setting, the given value must be
  converted to the <a href=#best-representation-of-the-number-as-a-floating-point-number id=the-meter-element:best-representation-of-the-number-as-a-floating-point-number-4>best representation of the number as a floating-point number</a> and
  then the <code id=the-meter-element:attr-meter-low-9><a href=#attr-meter-low>low</a></code> content attribute must be set to that
  string.</p>

  <p>The <dfn id=dom-meter-high><code>high</code></dfn> IDL attribute, on getting, must return
  the <a href=#concept-meter-high id=the-meter-element:concept-meter-high>high boundary</a>. On setting, the given value must be
  converted to the <a href=#best-representation-of-the-number-as-a-floating-point-number id=the-meter-element:best-representation-of-the-number-as-a-floating-point-number-5>best representation of the number as a floating-point number</a> and
  then the <code id=the-meter-element:attr-meter-high-9><a href=#attr-meter-high>high</a></code> content attribute must be set to that
  string.</p>

  <p>The <dfn id=dom-meter-optimum><code>optimum</code></dfn> IDL attribute, on getting, must
  return the <a href=#concept-meter-optimum id=the-meter-element:concept-meter-optimum>optimum value</a>. On setting, the given value
  must be converted to the <a href=#best-representation-of-the-number-as-a-floating-point-number id=the-meter-element:best-representation-of-the-number-as-a-floating-point-number-6>best representation of the number as a floating-point number</a>
  and then the <code id=the-meter-element:attr-meter-optimum-7><a href=#attr-meter-optimum>optimum</a></code> content attribute must be set to
  that string.</p>

  <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><code>fieldset</code></dfn> element<a href=#the-fieldset-element class=self-link></a></h4>

  <dl class=element><dt><a href=#concept-element-categories id=the-fieldset-element:concept-element-categories>Categories</a>:<dd><a href=#flow-content-2 id=the-fieldset-element:flow-content-2>Flow content</a>.<dd><a href=#sectioning-root id=the-fieldset-element:sectioning-root>Sectioning root</a>.<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-inheriting</a> <a href=#form-associated-element id=the-fieldset-element:form-associated-element>form-associated element</a>.<dd><a href=#palpable-content-2 id=the-fieldset-element:palpable-content-2>Palpable content</a>.<dt><a href=#concept-element-contexts id=the-fieldset-element:concept-element-contexts>Contexts in which this element can be used</a>:<dd>Where <a href=#flow-content-2 id=the-fieldset-element:flow-content-2-2>flow content</a> is expected.<dt><a href=#concept-element-content-model id=the-fieldset-element:concept-element-content-model>Content model</a>:<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>.<dt><a href=#concept-element-tag-omission id=the-fieldset-element:concept-element-tag-omission>Tag omission in text/html</a>:<dd>Neither tag is omissible.<dt><a href=#concept-element-attributes id=the-fieldset-element:concept-element-attributes>Content attributes</a>:<dd><a href=#global-attributes id=the-fieldset-element:global-attributes>Global attributes</a><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><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><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 <dt><a href=#concept-element-dom id=the-fieldset-element:concept-element-dom>DOM interface</a>:<dd>
    <pre><code class='idl'>[<c- g>Exposed</c->=<c- n>Window</c->,
 <a href='#htmlconstructor' id='the-fieldset-element:htmlconstructor'><c- g>HTMLConstructor</c-></a>]
<c- b>interface</c-> <dfn id='htmlfieldsetelement'><c- g>HTMLFieldSetElement</c-></dfn> : <a href='#htmlelement' id='the-fieldset-element:htmlelement'><c- n>HTMLElement</c-></a> {
  [<a href='#cereactions' id='the-fieldset-element:cereactions'><c- g>CEReactions</c-></a>] <c- b>attribute</c-> <c- b>boolean</c-> <a href='#dom-fieldset-disabled' id='the-fieldset-element:dom-fieldset-disabled'><c- g>disabled</c-></a>;
  <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>] <c- b>attribute</c-> <c- b>DOMString</c-> <a href='#dom-fe-name' id='the-fieldset-element:dom-fe-name'><c- g>name</c-></a>;

  <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 href='https://dom.spec.whatwg.org/#interface-htmlcollection' data-x-internal='htmlcollection' id='the-fieldset-element: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>void</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>
   </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>

  <p>The <dfn id=attr-fieldset-disabled><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>.<div class=status><input onclick=toggleStatus(this) value=⋰ type=button><p class=support><strong>Support:</strong> fieldset-disabled<span class="and_chr yes"><span>Chrome for Android</span> <span>67+</span></span><span class="chrome yes"><span>Chrome</span> <span>20+</span></span><span class="ios_saf yes"><span>iOS Safari</span> <span>6.0+</span></span><span class="and_uc yes"><span>UC Browser for Android</span> <span>11.8+</span></span><span class="firefox yes"><span>Firefox</span> <span>4+</span></span><span class="ie partial"><span>IE (limited)</span> <span>6+</span></span><span class="op_mini partial"><span>Opera Mini (limited)</span> <span>all+</span></span><span class="safari yes"><span>Safari</span> <span>6+</span></span><span class="edge yes"><span>Edge</span> <span>12+</span></span><span class="samsung yes"><span>Samsung Internet</span> <span>4+</span></span><span class="opera yes"><span>Opera</span> <span>10.0+</span></span><span class="android yes"><span>Android Browser</span> <span>4.4+</span></span><p class=caniuse>Source: <a href="https://caniuse.com/#feat=fieldset-disabled">caniuse.com</a></div>

  <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>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.</ul>

  <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><var>fieldset</var> . <code id=dom-fieldset-type-dev><a href=#dom-fieldset-type>type</a></code><dd>

    <p>Returns the string "fieldset".</p>

   <dt><var>fieldset</var> . <code id=dom-fieldset-elements-dev><a href=#dom-fieldset-elements>elements</a></code><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>

   </dl>

  

  <p>The <dfn id=dom-fieldset-disabled><code>disabled</code></dfn> IDL attribute must
  <a href=#reflect id=the-fieldset-element:reflect>reflect</a> the content attribute of the same name.</p>

  <p>The <dfn id=dom-fieldset-type><code>type</code></dfn> IDL attribute must return the string
  "<code>fieldset</code>".</p>

  <p>The <dfn id=dom-fieldset-elements><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>

  <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-fe-name-2><a href=#dom-fe-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>&quot;clubfields&quot;</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>&quot;form.clubfields.disabled = !checked&quot;</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>&quot;[-0-9]+&quot;</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>&quot;clubfields&quot;</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>&quot;form.clubfields.disabled = !checked&quot;</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>&quot;numfields&quot;</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>&quot;form.numfields.disabled = !checked&quot;</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>&quot;[-0-9]+&quot;</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>&quot;letfields&quot;</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>&quot;form.letfields.disabled = !checked&quot;</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>&quot;[A-Za-z]+&quot;</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>


  <h4 id=the-legend-element><span class=secno>4.10.16</span> The <dfn><code>legend</code></dfn> element<a href=#the-legend-element class=self-link></a></h4>

  <dl class=element><dt><a href=#concept-element-categories id=the-legend-element:concept-element-categories>Categories</a>:<dd>None.<dt><a href=#concept-element-contexts id=the-legend-element:concept-element-contexts>Contexts in which this element can be used</a>:<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.<dt><a href=#concept-element-content-model id=the-legend-element:concept-element-content-model>Content model</a>:<dd><a href=#phrasing-content-2 id=the-legend-element:phrasing-content-2>Phrasing content</a>.<dt><a href=#concept-element-tag-omission id=the-legend-element:concept-element-tag-omission>Tag omission in text/html</a>:<dd>Neither tag is omissible.<dt><a href=#concept-element-attributes id=the-legend-element:concept-element-attributes>Content attributes</a>:<dd><a href=#global-attributes id=the-legend-element:global-attributes>Global attributes</a><dt><a href=#concept-element-dom id=the-legend-element:concept-element-dom>DOM interface</a>:<dd>
    <pre><code class='idl'>[<c- g>Exposed</c->=<c- n>Window</c->,
 <a href='#htmlconstructor' id='the-legend-element:htmlconstructor'><c- g>HTMLConstructor</c-></a>]
<c- b>interface</c-> <dfn id='htmllegendelement'><c- g>HTMLLegendElement</c-></dfn> : <a href='#htmlelement' id='the-legend-element:htmlelement'><c- n>HTMLElement</c-></a> {
  <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>;
};</code></pre>
   </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.</p>

  <dl class=domintro><dt><var>legend</var> . <code id=dom-legend-form-dev><a href=#dom-legend-form>form</a></code><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>

   </dl>

  

  <p>The <dfn id=dom-legend-form><code>form</code></dfn> IDL attribute's behavior depends on
  whether the <code id=the-legend-element:the-legend-element-3><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-4><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>

  



  <h4 id=form-control-infrastructure><span class=secno>4.10.17</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.17.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>  awesome@example.com</kbd>"
  (with leading whitespace) into <a href="#e-mail-state-(type=email)" id="a-form-control's-value:e-mail-state-(type=email)">an email field</a>, the
  user's input would be the string "  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>To define the behavior of constraint validation in the face of the <code id="a-form-control's-value:the-input-element-3"><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-4"><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-2"><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-6">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-7">value</a>.</p>

  <p>The <code id="a-form-control's-value:the-select-element"><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-8">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.17.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.17.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 id=form-owner>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>

  <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 id=attr-fae-form><code>form</code></dfn> attribute specified to override this.<div class=status><input onclick=toggleStatus(this) value=⋰ type=button><p class=support><strong>Support:</strong> form-attribute<span class="and_chr yes"><span>Chrome for Android</span> <span>67+</span></span><span class="chrome yes"><span>Chrome</span> <span>10+</span></span><span class="ios_saf yes"><span>iOS Safari</span> <span>5.0+</span></span><span class="and_uc yes"><span>UC Browser for Android</span> <span>11.8+</span></span><span class="firefox yes"><span>Firefox</span> <span>4+</span></span><span class="ie no"><span>IE</span> <span>None</span></span><span class="op_mini yes"><span>Opera Mini</span> <span>all+</span></span><span class="safari yes"><span>Safari</span> <span>5.1+</span></span><span class="edge yes"><span>Edge</span> <span>16+</span></span><span class="samsung yes"><span>Samsung Internet</span> <span>4+</span></span><span class="opera yes"><span>Opera</span> <span>9.5+</span></span><span class="android yes"><span>Android Browser</span> <span>3+</span></span><p class=caniuse>Source: <a href="https://caniuse.com/#feat=form-attribute">caniuse.com</a></div>

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

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

  

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

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

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

  <p>When a <a href=#form-associated-element id=association-of-controls-and-forms:form-associated-element-9>form-associated element</a> or one of its ancestors <a href=#nodes-are-inserted id=association-of-controls-and-forms:nodes-are-inserted>is inserted</a>, then:

  <ol><li><p>If the <a href=#form-associated-element id=association-of-controls-and-forms:form-associated-element-10>form-associated element</a>'s <a href=#parser-inserted-flag id=association-of-controls-and-forms:parser-inserted-flag>parser inserted flag</a> is set,
   then return.

   <li><p><a href=#reset-the-form-owner id=association-of-controls-and-forms:reset-the-form-owner>Reset the form owner</a> of the <a href=#form-associated-element id=association-of-controls-and-forms:form-associated-element-11>form-associated element</a>.</ol>

  <p>When a <a href=#form-associated-element id=association-of-controls-and-forms:form-associated-element-12>form-associated element</a> or one of its ancestors <a href=#nodes-are-removed id=association-of-controls-and-forms:nodes-are-removed>is removed</a>, then:

  <ol><li><p>If the <a href=#form-associated-element id=association-of-controls-and-forms:form-associated-element-13>form-associated element</a> has a <a href=#form-owner id=association-of-controls-and-forms:form-owner-4>form owner</a> and the
   <a href=#form-associated-element id=association-of-controls-and-forms:form-associated-element-14>form-associated element</a> and its <a href=#form-owner id=association-of-controls-and-forms:form-owner-5>form owner</a> are no longer in the same
   <a id=association-of-controls-and-forms:tree-4 href=https://dom.spec.whatwg.org/#concept-tree data-x-internal=tree>tree</a>, then <a href=#reset-the-form-owner id=association-of-controls-and-forms:reset-the-form-owner-2>reset the form owner</a> of the <a href=#form-associated-element id=association-of-controls-and-forms:form-associated-element-15>form-associated
   element</a>.</ol>

  <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-16>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-3>reset the form owner</a> of that element.</p>

  <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-17>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-5 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-4>reset the
  form owner</a> of that <a href=#form-associated-element id=association-of-controls-and-forms:form-associated-element-18>form-associated element</a>.</p>

  <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-19>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>, then the user agent must <a href=#reset-the-form-owner id=association-of-controls-and-forms:reset-the-form-owner-5>reset the form owner</a> of that
  <a href=#form-associated-element id=association-of-controls-and-forms:form-associated-element-20>form-associated element</a>.</p>

  <p>When the user agent is 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-21>form-associated
  element</a> <var>element</var>, it must run the following steps:</p>

  <ol><li><p>Unset <var>element</var>'s <a href=#parser-inserted-flag id=association-of-controls-and-forms:parser-inserted-flag-2>parser inserted flag</a>.<li>
    <p>If all of the following conditions are true

    <ul class=brief><li><var>element</var>'s <a href=#form-owner id=association-of-controls-and-forms:form-owner-6>form owner</a> is not null
     <li><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
     <li><var>element</var>'s <a href=#form-owner id=association-of-controls-and-forms:form-owner-7>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
    </ul>

    <p>then do nothing, and return.</p>
   <li><p>Set <var>element</var>'s <a href=#form-owner id=association-of-controls-and-forms:form-owner-8>form owner</a> to null.<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-6 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 href=#case-sensitive id=association-of-controls-and-forms:case-sensitive>case-sensitively</a> equal to <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.</ol>
   <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.</ol>

  <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>&quot;a&quot;</c-><c- p>&gt;</c->
  <c- p>&lt;</c-><c- f>div</c-> <c- e>id</c-><c- o>=</c-><c- s>&quot;b&quot;</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>&apos;b&apos;</c-><c- p>).</c->innerHTML <c- o>=</c->
     <c- t>&apos;&lt;table&gt;&lt;tr&gt;&lt;td&gt;&lt;/form&gt;&lt;form id=&quot;c&quot;&gt;&lt;input id=&quot;d&quot;&gt;&lt;/table&gt;&apos;</c-> <c- o>+</c->
     <c- t>&apos;&lt;input id=&quot;e&quot;&gt;&apos;</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-9>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-10>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-innerhtml><a data-x-internal=dom-innerhtml href=https://w3c.github.io/DOM-Parsing/#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></code> tag.</p>

  </div>

  

  <dl class=domintro><dt><var>element</var> . <code id=dom-fae-form-dev><a href=#dom-fae-form>form</a></code><dd>

    <p>Returns the element's <a href=#form-owner id=association-of-controls-and-forms:form-owner-11>form owner</a>.</p>

    <p>Returns null if there isn't one.</p>

   </dl>

  

  <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-22>form-associated elements</a> have a <dfn id=dom-fae-form><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-12>form owner</a>, or null if
  there isn't one.</p>

  



  <h4 id=attributes-common-to-form-controls><span class=secno>4.10.18</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.18.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>

  <p>The <dfn id=attr-fe-name><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. 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>

  

  <p>The <dfn id=dom-fe-name><code>name</code></dfn> IDL attribute must <a href=#reflect id=naming-form-controls:-the-name-attribute:reflect>reflect</a>
  the <code id=naming-form-controls:-the-name-attribute:attr-fe-name-2><a href=#attr-fe-name>name</a></code> content attribute.</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-3><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>&quot;form&quot;</c-><c- p>);</c->
<c- a>let</c-> input <c- o>=</c-> document<c- p>.</c->createElement<c- p>(</c-><c- u>&quot;input&quot;</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; &quot;get&quot;</c->
input<c- p>.</c->name <c- o>=</c-> <c- u>&quot;method&quot;</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.18.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>

  <p>The <dfn id=attr-fe-dirname><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>&quot;addcomment.cgi&quot;</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>&quot;comment&quot;</c-> <c- e>dirname</c-><c- o>=</c-><c- s>&quot;comment.dir&quot;</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>&quot;mode&quot;</c-> <c- e>type</c-><c- o>=</c-><c- s>submit</c-> <c- e>value</c-><c- o>=</c-><c- s>&quot;add&quot;</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.18.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 id=attr-fe-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:javascript-string-length href=https://infra.spec.whatwg.org/#javascript-string-length data-x-internal=javascript-string-length>JavaScript string 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>

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

  

  <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:javascript-string-length-2 href=https://infra.spec.whatwg.org/#javascript-string-length data-x-internal=javascript-string-length>JavaScript string 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>

  <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:javascript-string-length-3 href=https://infra.spec.whatwg.org/#javascript-string-length data-x-internal=javascript-string-length>JavaScript string
  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, the <a href=#textarea-line-break-normalisation-transformation id=limiting-user-input-length:-the-maxlength-attribute:textarea-line-break-normalisation-transformation>textarea line break normalization transformation</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.18.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 id=attr-fe-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:javascript-string-length href=https://infra.spec.whatwg.org/#javascript-string-length data-x-internal=javascript-string-length>JavaScript string 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>

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

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

  

  <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:javascript-string-length-2 href=https://infra.spec.whatwg.org/#javascript-string-length data-x-internal=javascript-string-length>JavaScript string 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 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>&quot;/events/menu.cgi&quot;</c-> <c- e>method</c-><c- o>=</c-><c- s>&quot;post&quot;</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>&quot;breakfast&quot;</c-> <c- e>minlength</c-><c- o>=</c-><c- s>&quot;10&quot;</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>&quot;lunch&quot;</c-> <c- e>minlength</c-><c- o>=</c-><c- s>&quot;10&quot;</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>&quot;dinner&quot;</c-> <c- e>minlength</c-><c- o>=</c-><c- s>&quot;10&quot;</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>&quot;Submit Request&quot;</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.18.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>

  <p>The <dfn id=attr-fe-disabled><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>

  <p>A form control is <dfn id=concept-fe-disabled>disabled</dfn> if any of the following
  conditions are met:</p>

  <ol><li>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>, or
   <code id=enabling-and-disabling-form-controls:-the-disabled-attribute:the-textarea-element><a href=#the-textarea-element>textarea</a></code> element, 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).<li>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.</ol>

  

  <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><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-2>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>

  <p>The <dfn id=dom-fe-disabled><code>disabled</code></dfn> IDL attribute must
  <a href=#reflect id=enabling-and-disabling-form-controls:-the-disabled-attribute:reflect>reflect</a> the <code id=enabling-and-disabling-form-controls:-the-disabled-attribute:attr-fe-disabled-3><a href=#attr-fe-disabled>disabled</a></code> content attribute.</p>

  


  <h5 id=form-submission><span class=secno>4.10.18.6</span> Form submission<a href=#form-submission class=self-link></a></h5>

  <p><dfn id=attributes-for-form-submission>Attributes for form submission</dfn> can be specified both on <code id=form-submission:the-form-element><a href=#the-form-element>form</a></code> elements
  and on <a href=#concept-submit-button id=form-submission:concept-submit-button>submit buttons</a> (elements that represent buttons
  that submit forms, e.g. an <code id=form-submission:the-input-element><a href=#the-input-element>input</a></code> element whose <code id=form-submission: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:submit-button-state-(type=submit)">Submit Button</a> state).

  <div class=status><input onclick=toggleStatus(this) value=⋰ type=button><p class=support><strong>Support:</strong> form-submit-attributes<span class="and_chr yes"><span>Chrome for Android</span> <span>67+</span></span><span class="chrome yes"><span>Chrome</span> <span>15+</span></span><span class="ios_saf yes"><span>iOS Safari</span> <span>5.0+</span></span><span class="and_uc yes"><span>UC Browser for Android</span> <span>11.8+</span></span><span class="firefox yes"><span>Firefox</span> <span>4+</span></span><span class="ie yes"><span>IE</span> <span>10+</span></span><span class="op_mini yes"><span>Opera Mini</span> <span>all+</span></span><span class="safari yes"><span>Safari</span> <span>5.1+</span></span><span class="edge yes"><span>Edge</span> <span>12+</span></span><span class="samsung yes"><span>Samsung Internet</span> <span>4+</span></span><span class="opera yes"><span>Opera</span> <span>10.6+</span></span><span class="android yes"><span>Android Browser</span> <span>4+</span></span><p class=caniuse>Source: <a href="https://caniuse.com/#feat=form-submit-attributes">caniuse.com</a></div><p>The <a href=#attributes-for-form-submission id=form-submission:attributes-for-form-submission>attributes for form submission</a> that may be specified on <code id=form-submission:the-form-element-2><a href=#the-form-element>form</a></code>
  elements are <code id=form-submission:attr-fs-action><a href=#attr-fs-action>action</a></code>, <code id=form-submission:attr-fs-enctype><a href=#attr-fs-enctype>enctype</a></code>, <code id=form-submission:attr-fs-method><a href=#attr-fs-method>method</a></code>, <code id=form-submission:attr-fs-novalidate><a href=#attr-fs-novalidate>novalidate</a></code>, and <code id=form-submission: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-for-form-submission-2>attributes for form submission</a> that may be specified on <a href=#concept-submit-button id=form-submission:concept-submit-button-2>submit buttons</a> are <code id=form-submission:attr-fs-formaction><a href=#attr-fs-formaction>formaction</a></code>, <code id=form-submission:attr-fs-formenctype><a href=#attr-fs-formenctype>formenctype</a></code>, <code id=form-submission:attr-fs-formmethod><a href=#attr-fs-formmethod>formmethod</a></code>, <code id=form-submission:attr-fs-formnovalidate><a href=#attr-fs-formnovalidate>formnovalidate</a></code>, and <code id=form-submission: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:the-form-element-3><a href=#the-form-element>form</a></code> element.</p>

  <hr>

  <p>The <dfn id=attr-fs-action><code>action</code></dfn> and <dfn id=attr-fs-formaction><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: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: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:concept-submit-button-3>submit button</a> and has such an attribute, or the value of its
  <a href=#form-owner id=form-submission:form-owner>form owner</a>'s <code id=form-submission: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>

  <p>The <dfn id=attr-fs-method><code>method</code></dfn> and <dfn id=attr-fs-formmethod><code>formmethod</code></dfn> content attributes are <a href=#enumerated-attribute id=form-submission:enumerated-attribute>enumerated attributes</a> with the following keywords and
  states:</p>

  <ul><li>The keyword <dfn id=attr-fs-method-get-keyword><code>get</code></dfn>, mapping to the
   state <dfn id=attr-fs-method-get>GET</dfn>, indicating the HTTP GET method.<li>The keyword <dfn id=attr-fs-method-post-keyword><code>post</code></dfn>, mapping to the
   state <dfn id=attr-fs-method-post>POST</dfn>, indicating the HTTP POST method.<li>The keyword <dfn id=attr-fs-method-dialog-keyword><code>dialog</code></dfn>, mapping to
   the state <dfn id=attr-fs-method-dialog>dialog</dfn>, indicating that submitting the
   <code id=form-submission:the-form-element-4><a href=#the-form-element>form</a></code> is intended to close the <code id=form-submission:the-dialog-element><a href=#the-dialog-element>dialog</a></code> box in which the form finds
   itself, if any, and otherwise not submit.</ul>

  <p>The <i id=form-submission:invalid-value-default><a href=#invalid-value-default>invalid value default</a></i> for these attributes is the <a href=#attr-fs-method-get id=form-submission:attr-fs-method-get>GET</a> state. The <i id=form-submission:missing-value-default><a href=#missing-value-default>missing value default</a></i> for the <code id=form-submission:attr-fs-method-2><a href=#attr-fs-method>method</a></code> attribute is also the <a href=#attr-fs-method-get id=form-submission:attr-fs-method-get-2>GET</a> state. (There is no <i id=form-submission:missing-value-default-2><a href=#missing-value-default>missing value default</a></i> or <i id=form-submission:invalid-value-default-2><a href=#invalid-value-default>invalid value default</a></i> for the
  <code id=form-submission:attr-fs-formmethod-2><a href=#attr-fs-formmethod>formmethod</a></code> attribute.)</p>

  <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:concept-submit-button-4>submit button</a> and has a <code id=form-submission: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:concept-fs-method>method</a> is that attribute's state; otherwise, it is the <a href=#form-owner id=form-submission:form-owner-2>form
  owner</a>'s <code id=form-submission:attr-fs-method-3><a href=#attr-fs-method>method</a></code> attribute's state.</p>

  <div class=example>

   <p>Here the <code id=form-submission: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: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>&quot;get&quot;</c-> <c- e>action</c-><c- o>=</c-><c- s>&quot;/search.cgi&quot;</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:attr-fs-method-5><a href=#attr-fs-method>method</a></code> attribute is used to
   specify the value "<code id=form-submission: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>&quot;post&quot;</c-> <c- e>action</c-><c- o>=</c-><c- s>&quot;/post-message.cgi&quot;</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>&quot;Submit message&quot;</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:the-form-element-5><a href=#the-form-element>form</a></code> is used with a <code id=form-submission:the-dialog-element-2><a href=#the-dialog-element>dialog</a></code>. The <code id=form-submission:attr-fs-method-6><a href=#attr-fs-method>method</a></code> attribute's "<code id=form-submission: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>&quot;ship&quot;</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>&quot;board&quot;</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>&quot;call&quot;</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>&apos;ship&apos;</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>&apos;board&apos;</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>

  <p>The <dfn id=attr-fs-enctype><code>enctype</code></dfn> and <dfn id=attr-fs-formenctype><code>formenctype</code></dfn> content attributes are <a href=#enumerated-attribute id=form-submission:enumerated-attribute-2>enumerated attributes</a> with the following keywords and
  states:</p>

  <ul><li>The "<dfn id=attr-fs-enctype-urlencoded><code>application/x-www-form-urlencoded</code></dfn>" keyword and corresponding state.<li>The "<dfn id=attr-fs-enctype-formdata><code>multipart/form-data</code></dfn>" keyword and corresponding state.<li>The "<dfn id=attr-fs-enctype-text><code>text/plain</code></dfn>" keyword and corresponding state.</ul>

  <p>The <i id=form-submission:invalid-value-default-3><a href=#invalid-value-default>invalid value default</a></i> for these attributes is the <code id=form-submission:attr-fs-enctype-urlencoded><a href=#attr-fs-enctype-urlencoded>application/x-www-form-urlencoded</a></code> state. The <i id=form-submission:missing-value-default-3><a href=#missing-value-default>missing value default</a></i> for the <code id=form-submission:attr-fs-enctype-2><a href=#attr-fs-enctype>enctype</a></code> attribute is also the <code id=form-submission:attr-fs-enctype-urlencoded-2><a href=#attr-fs-enctype-urlencoded>application/x-www-form-urlencoded</a></code> state. (There is no
  <i id=form-submission:missing-value-default-4><a href=#missing-value-default>missing value default</a></i> for the <code id=form-submission:attr-fs-formenctype-2><a href=#attr-fs-formenctype>formenctype</a></code> attribute.)</p>

  <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:concept-submit-button-5>submit button</a> and has a <code id=form-submission: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:concept-fs-enctype>enctype</a> is that attribute's state; otherwise, it is the
  <a href=#form-owner id=form-submission:form-owner-3>form owner</a>'s <code id=form-submission:attr-fs-enctype-3><a href=#attr-fs-enctype>enctype</a></code> attribute's state.</p>

  <hr>

  <p>The <dfn id=attr-fs-target><code>target</code></dfn> and <dfn id=attr-fs-formtarget><code>formtarget</code></dfn> content attributes, if specified, must have
  values that are <a href=#valid-browsing-context-name-or-keyword id=form-submission:valid-browsing-context-name-or-keyword>valid browsing context names
  or keywords</a>.</p>

  <hr>

  <p>The <dfn id=attr-fs-novalidate><code>novalidate</code></dfn> and <dfn id=attr-fs-formnovalidate><code>formnovalidate</code></dfn> content attributes are <a href=#boolean-attribute id=form-submission:boolean-attribute>boolean attributes</a>. If present, they indicate that the form is
  not to be validated during submission.</p>

  <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:concept-submit-button-6>submit button</a> and the element's <code id=form-submission: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:form-owner-4>form owner</a>'s <code id=form-submission:attr-fs-novalidate-2><a href=#attr-fs-novalidate>novalidate</a></code> attribute is present,
  and false otherwise.</p>

  <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>&quot;editor.cgi&quot;</c-> <c- e>method</c-><c- o>=</c-><c- s>&quot;post&quot;</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>&quot;Submit essay&quot;</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>&quot;Save essay&quot;</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>&quot;Cancel&quot;</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>

  <p>The <dfn id=dom-fs-action><code>action</code></dfn> IDL attribute must
  <a href=#reflect id=form-submission:reflect>reflect</a> the content attribute of the same name, except that on getting, when the
  content attribute is missing or its value is the empty string, the element's <a id=form-submission: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:the-document's-address" data-x-internal="the-document's-address">URL</a> must be returned instead. The
  <dfn id=dom-fs-target><code>target</code></dfn> IDL attribute must <a href=#reflect id=form-submission:reflect-2>reflect</a> the
  content attribute of the same name. The <dfn id=dom-fs-method><code>method</code></dfn> and
  <dfn id=dom-fs-enctype><code>enctype</code></dfn> IDL attributes must <a href=#reflect id=form-submission:reflect-3>reflect</a>
  the respective content attributes of the same name, <a href=#limited-to-only-known-values id=form-submission:limited-to-only-known-values>limited to only known values</a>. The
  <dfn id=dom-fs-encoding><code>encoding</code></dfn> IDL attribute must <a href=#reflect id=form-submission:reflect-4>reflect</a>
  the <code id=form-submission:attr-fs-enctype-4><a href=#attr-fs-enctype>enctype</a></code> content attribute, <a href=#limited-to-only-known-values id=form-submission:limited-to-only-known-values-2>limited to only known
  values</a>. The <dfn id=dom-fs-novalidate><code>noValidate</code></dfn> IDL attribute must
  <a href=#reflect id=form-submission:reflect-5>reflect</a> the <code id=form-submission:attr-fs-novalidate-3><a href=#attr-fs-novalidate>novalidate</a></code> content attribute. The
  <dfn id=dom-fs-formaction><code>formAction</code></dfn> IDL attribute must
  <a href=#reflect id=form-submission:reflect-6>reflect</a> the <code id=form-submission:attr-fs-formaction-3><a href=#attr-fs-formaction>formaction</a></code> content attribute,
  except that on getting, when the content attribute is missing or its value is the empty string,
  the element's <a id=form-submission: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="form-submission:the-document's-address-2" data-x-internal="the-document's-address">URL</a> must be
  returned instead. The <dfn id=dom-fs-formenctype><code>formEnctype</code></dfn> IDL
  attribute must <a href=#reflect id=form-submission:reflect-7>reflect</a> the <code id=form-submission:attr-fs-formenctype-4><a href=#attr-fs-formenctype>formenctype</a></code>
  content attribute, <a href=#limited-to-only-known-values id=form-submission:limited-to-only-known-values-3>limited to only known values</a>. The <dfn id=dom-fs-formmethod><code>formMethod</code></dfn> IDL attribute must <a href=#reflect id=form-submission:reflect-8>reflect</a> the
  <code id=form-submission:attr-fs-formmethod-4><a href=#attr-fs-formmethod>formmethod</a></code> content attribute, <a href=#limited-to-only-known-values id=form-submission:limited-to-only-known-values-4>limited to only known
  values</a>. The <dfn id=dom-fs-formnovalidate><code>formNoValidate</code></dfn> IDL
  attribute must <a href=#reflect id=form-submission:reflect-9>reflect</a> the <code id=form-submission:attr-fs-formnovalidate-3><a href=#attr-fs-formnovalidate>formnovalidate</a></code> content attribute. The <dfn id=dom-fs-formtarget><code>formTarget</code></dfn> IDL attribute must <a href=#reflect id=form-submission:reflect-10>reflect</a> the
  <code id=form-submission:attr-fs-formtarget-2><a href=#attr-fs-formtarget>formtarget</a></code> content attribute.

  </p>


  <h6 id=autofocusing-a-form-control:-the-autofocus-attribute><span class=secno>4.10.18.6.1</span> Autofocusing a form control: the <code id=autofocusing-a-form-control:-the-autofocus-attribute:attr-fe-autofocus><a href=#attr-fe-autofocus>autofocus</a></code> attribute<a href=#autofocusing-a-form-control:-the-autofocus-attribute class=self-link></a></h6><div class=status><input onclick=toggleStatus(this) value=⋰ type=button><p class=support><strong>Support:</strong> autofocus<span class="and_chr yes"><span>Chrome for Android</span> <span>67+</span></span><span class="chrome yes"><span>Chrome</span> <span>5+</span></span><span class="ios_saf no"><span>iOS Safari</span> <span>None</span></span><span class="and_uc no"><span>UC Browser for Android</span> <span>None</span></span><span class="firefox yes"><span>Firefox</span> <span>4+</span></span><span class="ie yes"><span>IE</span> <span>10+</span></span><span class="op_mini no"><span>Opera Mini</span> <span>None</span></span><span class="safari yes"><span>Safari</span> <span>5+</span></span><span class="edge yes"><span>Edge</span> <span>12+</span></span><span class="samsung yes"><span>Samsung Internet</span> <span>4+</span></span><span class="opera yes"><span>Opera</span> <span>9.5+</span></span><span class="android yes"><span>Android Browser</span> <span>3+</span></span><p class=caniuse>Source: <a href="https://caniuse.com/#feat=autofocus">caniuse.com</a></div>

  

  <p>The <dfn id=attr-fe-autofocus><code>autofocus</code></dfn> content attribute allows the
  author to indicate that a control is to be focused as soon as the page is loaded or as soon as the
  <code id=autofocusing-a-form-control:-the-autofocus-attribute:the-dialog-element><a href=#the-dialog-element>dialog</a></code> within which it finds itself is shown, allowing the user to just start typing
  without having to manually focus the main control.</p>

  <p>The <code id=autofocusing-a-form-control:-the-autofocus-attribute:attr-fe-autofocus-2><a href=#attr-fe-autofocus>autofocus</a></code> attribute is a <a href=#boolean-attribute id=autofocusing-a-form-control:-the-autofocus-attribute:boolean-attribute>boolean
  attribute</a>.</p>

  <p>An element's <dfn id=nearest-ancestor-autofocus-scoping-root-element>nearest ancestor autofocus scoping root element</dfn> is the element itself
  if the element is a <code id=autofocusing-a-form-control:-the-autofocus-attribute:the-dialog-element-2><a href=#the-dialog-element>dialog</a></code> element, or else is the element's nearest ancestor
  <code id=autofocusing-a-form-control:-the-autofocus-attribute:the-dialog-element-3><a href=#the-dialog-element>dialog</a></code> element, if any, or else is the element's last <a id=autofocusing-a-form-control:-the-autofocus-attribute:inclusive-ancestor href=https://dom.spec.whatwg.org/#concept-tree-inclusive-ancestor data-x-internal=inclusive-ancestor>inclusive ancestor</a>
  element.</p>

  <p>There must not be two elements with the same <a href=#nearest-ancestor-autofocus-scoping-root-element id=autofocusing-a-form-control:-the-autofocus-attribute:nearest-ancestor-autofocus-scoping-root-element>nearest ancestor autofocus scoping root
  element</a> that both have the <code id=autofocusing-a-form-control:-the-autofocus-attribute:attr-fe-autofocus-3><a href=#attr-fe-autofocus>autofocus</a></code> attribute
  specified.</p>

  

  <p>When an element with the <code id=autofocusing-a-form-control:-the-autofocus-attribute:attr-fe-autofocus-4><a href=#attr-fe-autofocus>autofocus</a></code> attribute specified
  is <a href=#insert-an-element-into-a-document id=autofocusing-a-form-control:-the-autofocus-attribute:insert-an-element-into-a-document>inserted into a document</a>, <a href=#queue-a-task id=autofocusing-a-form-control:-the-autofocus-attribute:queue-a-task>queue a
  task</a> on the <a href=#user-interaction-task-source id=autofocusing-a-form-control:-the-autofocus-attribute:user-interaction-task-source>user interaction task source</a> to 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.<li><p>Let <var>target</var> be the element's <a id=autofocusing-a-form-control:-the-autofocus-attribute:node-document href=https://dom.spec.whatwg.org/#concept-node-document data-x-internal=node-document>node document</a>.<li><p>If <var>target</var> has no <a href=#concept-document-bc id=autofocusing-a-form-control:-the-autofocus-attribute:concept-document-bc>browsing context</a>,
   then return.<li><p>If <var>target</var>'s <a href=#concept-document-bc id=autofocusing-a-form-control:-the-autofocus-attribute:concept-document-bc-2>browsing context</a> has no
   <a href=#top-level-browsing-context id=autofocusing-a-form-control:-the-autofocus-attribute:top-level-browsing-context>top-level browsing context</a> (e.g., it is a <a href=#nested-browsing-context id=autofocusing-a-form-control:-the-autofocus-attribute:nested-browsing-context>nested browsing context</a> with
   no <a href=#parent-browsing-context id=autofocusing-a-form-control:-the-autofocus-attribute:parent-browsing-context>parent browsing context</a>), then return.<li><p>If <var>target</var>'s <a href=#active-sandboxing-flag-set id=autofocusing-a-form-control:-the-autofocus-attribute:active-sandboxing-flag-set>active sandboxing flag set</a> has the
   <a href=#sandboxed-automatic-features-browsing-context-flag id=autofocusing-a-form-control:-the-autofocus-attribute:sandboxed-automatic-features-browsing-context-flag>sandboxed automatic features browsing context flag</a>, then return.<li><p>If <var>target</var>'s <a href=#concept-origin id=autofocusing-a-form-control:-the-autofocus-attribute:concept-origin>origin</a> is not the <a href=#same-origin id=autofocusing-a-form-control:-the-autofocus-attribute:same-origin>same</a> as the <a href=#concept-origin id=autofocusing-a-form-control:-the-autofocus-attribute:concept-origin-2>origin</a> of the <a id=autofocusing-a-form-control:-the-autofocus-attribute:node-document-2 href=https://dom.spec.whatwg.org/#concept-node-document data-x-internal=node-document>node document</a> of the currently
   focused element in <var>target</var>'s <a href=#top-level-browsing-context id=autofocusing-a-form-control:-the-autofocus-attribute:top-level-browsing-context-2>top-level browsing context</a>, then
   return.<li><p>If <var>target</var>'s <a href=#concept-origin id=autofocusing-a-form-control:-the-autofocus-attribute:concept-origin-3>origin</a> is not the <a href=#same-origin id=autofocusing-a-form-control:-the-autofocus-attribute:same-origin-2>same</a> as the <a href=#concept-origin id=autofocusing-a-form-control:-the-autofocus-attribute:concept-origin-4>origin</a> of the <a href=#active-document id=autofocusing-a-form-control:-the-autofocus-attribute:active-document>active document</a> of
   <var>target</var>'s <a href=#top-level-browsing-context id=autofocusing-a-form-control:-the-autofocus-attribute:top-level-browsing-context-3>top-level browsing context</a>, then return.<li><p>If the user agent has already reached the last step of this list of steps in response to
   an element being <a href=#insert-an-element-into-a-document id=autofocusing-a-form-control:-the-autofocus-attribute:insert-an-element-into-a-document-2>inserted</a> into a
   <code id=autofocusing-a-form-control:-the-autofocus-attribute:document><a href=#document>Document</a></code> whose <a href=#top-level-browsing-context id=autofocusing-a-form-control:-the-autofocus-attribute:top-level-browsing-context-4>top-level browsing context</a>'s <a href=#active-document id=autofocusing-a-form-control:-the-autofocus-attribute:active-document-2>active
   document</a> is the same as <var>target</var>'s <a href=#top-level-browsing-context id=autofocusing-a-form-control:-the-autofocus-attribute:top-level-browsing-context-5>top-level browsing
   context</a>'s <a href=#active-document id=autofocusing-a-form-control:-the-autofocus-attribute:active-document-3>active document</a>, then return.<li><p>Run the <a href=#focusing-steps id=autofocusing-a-form-control:-the-autofocus-attribute:focusing-steps>focusing steps</a> for the element. User agents may also change the
   scrolling position of the document, or perform some other action that brings the element to the
   user's attention.</ol>

  <p class=note>This handles the automatic focusing during document load. The <code id=autofocusing-a-form-control:-the-autofocus-attribute:dom-dialog-show><a href=#dom-dialog-show>show()</a></code> and <code id=autofocusing-a-form-control:-the-autofocus-attribute:dom-dialog-showmodal><a href=#dom-dialog-showmodal>showModal()</a></code>
  methods of <code id=autofocusing-a-form-control:-the-autofocus-attribute:the-dialog-element-4><a href=#the-dialog-element>dialog</a></code> elements also processes the <code id=autofocusing-a-form-control:-the-autofocus-attribute:attr-fe-autofocus-5><a href=#attr-fe-autofocus>autofocus</a></code> attribute.</p>

  <p class=note>Focusing the control does not imply that the user agent has to focus the browser
  window if it has lost focus.</p>

  <p>The <dfn id=dom-fe-autofocus><code>autofocus</code></dfn> IDL attribute must
  <a href=#reflect id=autofocusing-a-form-control:-the-autofocus-attribute:reflect>reflect</a> the content attribute of the same name.</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>&quot;256&quot;</c-> <c- e>name</c-><c- o>=</c-><c- s>&quot;q&quot;</c-> <c- e>value</c-><c- o>=</c-><c- s>&quot;&quot;</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>&quot;submit&quot;</c-> <c- e>value</c-><c- o>=</c-><c- s>&quot;Search&quot;</c-><c- p>&gt;</c-></code></pre>
  </div>

  <h5 id=autofill><span class=secno>4.10.18.7</span> Autofill<a href=#autofill class=self-link></a></h5><div class=status><input onclick=toggleStatus(this) value=⋰ type=button><p class=support><strong>Support:</strong> input-autocomplete-onoff<span class="and_chr yes"><span>Chrome for Android</span> <span>67+</span></span><span class="chrome partial"><span>Chrome (limited)</span> <span>27+</span></span><span class="ios_saf yes"><span>iOS Safari</span> <span>5.0+</span></span><span class="and_uc yes"><span>UC Browser for Android</span> <span>11.8+</span></span><span class="firefox partial"><span>Firefox (limited)</span> <span>30+</span></span><span class="ie partial"><span>IE (limited)</span> <span>11+</span></span><span class="op_mini yes"><span>Opera Mini</span> <span>all+</span></span><span class="safari partial"><span>Safari (limited)</span> <span>7+</span></span><span class="edge partial"><span>Edge (limited)</span> <span>12+</span></span><span class="samsung yes"><span>Samsung Internet</span> <span>4+</span></span><span class="opera yes"><span>Opera</span> <span>9+</span></span><span class="android yes"><span>Android Browser</span> <span>2.1+</span></span><p class=caniuse>Source: <a href="https://caniuse.com/#feat=input-autocomplete-onoff">caniuse.com</a></div>

  <h6 id=autofilling-form-controls:-the-autocomplete-attribute><span class=secno>4.10.18.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>

  <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 id=attr-fe-autocomplete><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>

  <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 id=attr-fe-autocomplete-section><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>&quot;section-blue shipping street-address&quot;</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>&quot;section-blue shipping address-level2&quot;</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>&quot;section-blue shipping postal-code&quot;</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>&quot;section-red shipping street-address&quot;</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>&quot;section-red shipping address-level2&quot;</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>&quot;section-red shipping postal-code&quot;</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>

    <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 id=attr-fe-autocomplete-shipping><code>shipping</code></dfn>", meaning the field
     is part of the shipping address or contact information

     <li>"<dfn id=attr-fe-autocomplete-billing><code>billing</code></dfn>", meaning the field
     is part of the billing address or contact information

    </ul>

   <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>"<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>"<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>"<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>"<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>"<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>"<code id=autofilling-form-controls:-the-autocomplete-attribute:attr-fe-autocomplete-nickname><a href=#attr-fe-autocomplete-nickname>nickname</a></code>"
       <li>"<code id=autofilling-form-controls:-the-autocomplete-attribute:attr-fe-autocomplete-username><a href=#attr-fe-autocomplete-username>username</a></code>"
       <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>"<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>"<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>"<code id=autofilling-form-controls:-the-autocomplete-attribute:attr-fe-autocomplete-organization><a href=#attr-fe-autocomplete-organization>organization</a></code>"
       <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>"<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>"<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>"<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>"<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>"<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>"<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>"<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>"<code id=autofilling-form-controls:-the-autocomplete-attribute:attr-fe-autocomplete-country><a href=#attr-fe-autocomplete-country>country</a></code>"
       <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>"<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>"<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>"<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>"<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>"<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>"<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>"<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>"<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>"<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>"<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>"<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>"<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>"<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>"<code id=autofilling-form-controls:-the-autocomplete-attribute:attr-fe-autocomplete-language><a href=#attr-fe-autocomplete-language>language</a></code>"
       <li>"<code id=autofilling-form-controls:-the-autocomplete-attribute:attr-fe-autocomplete-bday><a href=#attr-fe-autocomplete-bday>bday</a></code>"
       <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>"<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>"<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>"<code id=autofilling-form-controls:-the-autocomplete-attribute:attr-fe-autocomplete-sex><a href=#attr-fe-autocomplete-sex>sex</a></code>"
       <li>"<code id=autofilling-form-controls:-the-autocomplete-attribute:attr-fe-autocomplete-url><a href=#attr-fe-autocomplete-url>url</a></code>"
       <li>"<code id=autofilling-form-controls:-the-autocomplete-attribute:attr-fe-autocomplete-photo><a href=#attr-fe-autocomplete-photo>photo</a></code>"
      </ul>

      <p>(See the table below for descriptions of these values.)</p>

     <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 id=attr-fe-autocomplete-home><code>home</code></dfn>", meaning the field is
         for contacting someone at their residence

         <li>"<dfn id=attr-fe-autocomplete-work><code>work</code></dfn>", meaning the field is
         for contacting someone at their workplace

         <li>"<dfn id=attr-fe-autocomplete-mobile><code>mobile</code></dfn>", meaning the field is for contacting someone regardless of location

         <li>"<dfn id=attr-fe-autocomplete-fax><code>fax</code></dfn>", meaning the field
         describes a fax machine's contact details

         <li>"<dfn id=attr-fe-autocomplete-pager><code>pager</code></dfn>", meaning the field
         describes a pager's or beeper's contact details

        </ul>

       <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>"<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>"<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>"<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>"<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>"<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>"<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>"<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>"<code id=autofilling-form-controls:-the-autocomplete-attribute:attr-fe-autocomplete-email><a href=#attr-fe-autocomplete-email>email</a></code>"
         <li>"<code id=autofilling-form-controls:-the-autocomplete-attribute:attr-fe-autocomplete-impp><a href=#attr-fe-autocomplete-impp>impp</a></code>"
        </ul>

        <p>(See the table below for descriptions of these values.)</p>

       </ol>

     </ul>

   </ol>

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

   <dd>

    <p>The "<dfn id=attr-fe-autocomplete-off><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 id=attr-fe-autocomplete-on><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>

   <dt>When wearing the <a href=#autofill-anchor-mantle id=autofilling-form-controls:-the-autocomplete-attribute:autofill-anchor-mantle-3>autofill anchor mantle</a>...

   <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>&quot;step2.cgi&quot;</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>&quot;CHF&quot;</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>&quot;15.00&quot;</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>&quot;Continue...&quot;</c-><c- p>&gt;</c->
<c- p>&lt;/</c-><c- f>form</c-><c- p>&gt;</c-></code></pre>

    </div>

   </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>

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

  <table><thead><tr><th colspan=4> Field name
     <th> Meaning
     <th> Canonical Format
     <th> Canonical Format Example
     <th> Control group
   <tbody><tr><td colspan=4>"<dfn id=attr-fe-autocomplete-name><code>name</code></dfn>"
     <td>Full name
     <td>Free-form text, no newlines
     <td>Sir Timothy John Berners-Lee, OM, KBE, FRS, FREng, FRSA
     <td><a href=#control-group-text id=autofilling-form-controls:-the-autocomplete-attribute:control-group-text>Text</a>
    <tr><td class=non-rectangular-cell-indentation rowspan=5>
      <td colspan=3>"<dfn id=attr-fe-autocomplete-honorific-prefix><code>honorific-prefix</code></dfn>"
      <td>Prefix or title (e.g. "Mr.", "Ms.", "Dr.", "<span lang=fr>M<sup>lle</sup></span>")
      <td>Free-form text, no newlines
      <td>Sir
     <td><a href=#control-group-text id=autofilling-form-controls:-the-autocomplete-attribute:control-group-text-2>Text</a>
    <tr><td colspan=3>"<dfn id=attr-fe-autocomplete-given-name><code>given-name</code></dfn>"
      <td>Given name (in some Western cultures, also known as the <i>first name</i>)
      <td>Free-form text, no newlines
      <td>Timothy
     <td><a href=#control-group-text id=autofilling-form-controls:-the-autocomplete-attribute:control-group-text-3>Text</a>
    <tr><td colspan=3>"<dfn id=attr-fe-autocomplete-additional-name><code>additional-name</code></dfn>"
      <td>Additional names (in some Western cultures, also known as <i>middle names</i>, forenames other than the first name)
      <td>Free-form text, no newlines
      <td>John
     <td><a href=#control-group-text id=autofilling-form-controls:-the-autocomplete-attribute:control-group-text-4>Text</a>
    <tr><td colspan=3>"<dfn id=attr-fe-autocomplete-family-name><code>family-name</code></dfn>"
      <td>Family name (in some Western cultures, also known as the <i>last name</i> or <i>surname</i>)
      <td>Free-form text, no newlines
      <td>Berners-Lee
     <td><a href=#control-group-text id=autofilling-form-controls:-the-autocomplete-attribute:control-group-text-5>Text</a>
    <tr><td colspan=3>"<dfn id=attr-fe-autocomplete-honorific-suffix><code>honorific-suffix</code></dfn>"
      <td>Suffix (e.g. "Jr.", "B.Sc.", "MBASW", "II")
      <td>Free-form text, no newlines
      <td>OM, KBE, FRS, FREng, FRSA
     <td><a href=#control-group-text id=autofilling-form-controls:-the-autocomplete-attribute:control-group-text-6>Text</a>
    <tr><td colspan=4>"<dfn id=attr-fe-autocomplete-nickname><code>nickname</code></dfn>"
     <td>Nickname, screen name, handle: a typically short name used instead of the full name
     <td>Free-form text, no newlines
     <td>Tim
     <td><a href=#control-group-text id=autofilling-form-controls:-the-autocomplete-attribute:control-group-text-7>Text</a>
    <tr><td colspan=4>"<dfn id=attr-fe-autocomplete-organization-title><code>organization-title</code></dfn>"
     <td>Job title (e.g. "Software Engineer", "Senior Vice President", "Deputy Managing Director")
     <td>Free-form text, no newlines
     <td>Professor
     <td><a href=#control-group-text id=autofilling-form-controls:-the-autocomplete-attribute:control-group-text-8>Text</a>
    <tr><td colspan=4>"<dfn id=attr-fe-autocomplete-username><code>username</code></dfn>"
     <td>A username
     <td>Free-form text, no newlines
     <td>timbl
     <td><a href=#control-group-text id=autofilling-form-controls:-the-autocomplete-attribute:control-group-text-9>Text</a>
    <tr><td colspan=4>"<dfn id=attr-fe-autocomplete-new-password><code>new-password</code></dfn>"
     <td>A new password (e.g. when creating an account or changing a password)
     <td>Free-form text, no newlines
     <td>GUMFXbadyrS3
     <td><a href=#control-group-password id=autofilling-form-controls:-the-autocomplete-attribute:control-group-password>Password</a>
    <tr><td colspan=4>"<dfn id=attr-fe-autocomplete-current-password><code>current-password</code></dfn>"
     <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>Free-form text, no newlines
     <td>qwerty 
     <td><a href=#control-group-password id=autofilling-form-controls:-the-autocomplete-attribute:control-group-password-2>Password</a>
   <tbody><tr><td colspan=4>"<dfn id=attr-fe-autocomplete-organization><code>organization</code></dfn>"
     <td>Company name corresponding to the person, address, or contact information in the other fields associated with this field
     <td>Free-form text, no newlines
     <td>World Wide Web Consortium
     <td><a href=#control-group-text id=autofilling-form-controls:-the-autocomplete-attribute:control-group-text-10>Text</a>
    <tr><td colspan=4>"<dfn id=attr-fe-autocomplete-street-address><code>street-address</code></dfn>"
     <td>Street address (multiple lines, newlines preserved)
     <td>Free-form text
     <td>32 Vassar Street<br>
MIT Room 32-G524
     <td><a href=#control-group-multiline id=autofilling-form-controls:-the-autocomplete-attribute:control-group-multiline>Multiline</a>
    <tr><td class=non-rectangular-cell-indentation rowspan=3>
      <td colspan=3>"<dfn id=attr-fe-autocomplete-address-line1><code>address-line1</code></dfn>"
      <td rowspan=3>Street address (one line per field)
      <td>Free-form text, no newlines
      <td>32 Vassar Street
     <td><a href=#control-group-text id=autofilling-form-controls:-the-autocomplete-attribute:control-group-text-11>Text</a>
    <tr><td colspan=3>"<dfn id=attr-fe-autocomplete-address-line2><code>address-line2</code></dfn>"
      <td>Free-form text, no newlines
      <td>MIT Room 32-G524
     <td><a href=#control-group-text id=autofilling-form-controls:-the-autocomplete-attribute:control-group-text-12>Text</a>
    <tr><td colspan=3>"<dfn id=attr-fe-autocomplete-address-line3><code>address-line3</code></dfn>"
      <td>Free-form text, no newlines
      <td>
     <td><a href=#control-group-text id=autofilling-form-controls:-the-autocomplete-attribute:control-group-text-13>Text</a>
    <tr><td colspan=4>"<dfn id=attr-fe-autocomplete-address-level4><code>address-level4</code></dfn>"
     <td>The most fine-grained <a href=#more-on-address-levels>administrative level</a>, in
     addresses with four administrative levels
     <td>Free-form text, no newlines
     <td>
     <td><a href=#control-group-text id=autofilling-form-controls:-the-autocomplete-attribute:control-group-text-14>Text</a>
    <tr><td colspan=4>"<dfn id=attr-fe-autocomplete-address-level3><code>address-level3</code></dfn>"
     <td>The <a href=#more-on-address-levels>third administrative level</a>, in addresses with
     three or more administrative levels
     <td>Free-form text, no newlines
     <td>
     <td><a href=#control-group-text id=autofilling-form-controls:-the-autocomplete-attribute:control-group-text-15>Text</a>
    <tr><td colspan=4>"<dfn id=attr-fe-autocomplete-address-level2><code>address-level2</code></dfn>"
     <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>Free-form text, no newlines
     <td>Cambridge
     <td><a href=#control-group-text id=autofilling-form-controls:-the-autocomplete-attribute:control-group-text-16>Text</a>
    <tr><td colspan=4>"<dfn id=attr-fe-autocomplete-address-level1><code>address-level1</code></dfn>"
     <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>Free-form text, no newlines
     <td>MA
     <td><a href=#control-group-text id=autofilling-form-controls:-the-autocomplete-attribute:control-group-text-17>Text</a>
    <tr><td colspan=4>"<dfn id=attr-fe-autocomplete-country><code>country</code></dfn>"
     <td>Country code
     <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>US
     <td><a href=#control-group-text id=autofilling-form-controls:-the-autocomplete-attribute:control-group-text-18>Text</a>
    <tr><td colspan=4>"<dfn id=attr-fe-autocomplete-country-name><code>country-name</code></dfn>"
     <td>Country name
     <td>Free-form text, no newlines; <a href=#autofill-country>derived from <code>country</code> in some cases</a>
     <td>US
     <td><a href=#control-group-text id=autofilling-form-controls:-the-autocomplete-attribute:control-group-text-19>Text</a>
    <tr><td colspan=4>"<dfn id=attr-fe-autocomplete-postal-code><code>postal-code</code></dfn>"
     <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>Free-form text, no newlines
     <td>02139
     <td><a href=#control-group-text id=autofilling-form-controls:-the-autocomplete-attribute:control-group-text-20>Text</a>
   <tbody><tr><td colspan=4>"<dfn id=attr-fe-autocomplete-cc-name><code>cc-name</code></dfn>"
     <td>Full name as given on the payment instrument
     <td>Free-form text, no newlines
     <td>Tim Berners-Lee
     <td><a href=#control-group-text id=autofilling-form-controls:-the-autocomplete-attribute:control-group-text-21>Text</a>
    <tr><td class=non-rectangular-cell-indentation rowspan=3>
      <td colspan=3>"<dfn id=attr-fe-autocomplete-cc-given-name><code>cc-given-name</code></dfn>"
      <td>Given name as given on the payment instrument (in some Western cultures, also known as the <i>first name</i>)
      <td>Free-form text, no newlines
      <td>Tim
     <td><a href=#control-group-text id=autofilling-form-controls:-the-autocomplete-attribute:control-group-text-22>Text</a>
    <tr><td colspan=3>"<dfn id=attr-fe-autocomplete-cc-additional-name><code>cc-additional-name</code></dfn>"
      <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>Free-form text, no newlines
      <td>
     <td><a href=#control-group-text id=autofilling-form-controls:-the-autocomplete-attribute:control-group-text-23>Text</a>
    <tr><td colspan=3>"<dfn id=attr-fe-autocomplete-cc-family-name><code>cc-family-name</code></dfn>"
      <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>Free-form text, no newlines
      <td>Berners-Lee
     <td><a href=#control-group-text id=autofilling-form-controls:-the-autocomplete-attribute:control-group-text-24>Text</a>
    <tr><td colspan=4>"<dfn id=attr-fe-autocomplete-cc-number><code>cc-number</code></dfn>"
     <td>Code identifying the payment instrument (e.g. the credit card number)
     <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>4114360123456785 
     <td><a href=#control-group-text id=autofilling-form-controls:-the-autocomplete-attribute:control-group-text-25>Text</a>
    <tr><td colspan=4>"<dfn id=attr-fe-autocomplete-cc-exp><code>cc-exp</code></dfn>"
     <td>Expiration date of the payment instrument
     <td><a href=#valid-month-string id=autofilling-form-controls:-the-autocomplete-attribute:valid-month-string>Valid month string</a>
     <td>2014-12
     <td><a href=#control-group-month id=autofilling-form-controls:-the-autocomplete-attribute:control-group-month>Month</a>
    <tr><td class=non-rectangular-cell-indentation rowspan=2>
      <td colspan=3>"<dfn id=attr-fe-autocomplete-cc-exp-month><code>cc-exp-month</code></dfn>"
      <td>Month component of the expiration date of the payment instrument
      <td><a href=#valid-integer id=autofilling-form-controls:-the-autocomplete-attribute:valid-integer>Valid integer</a> in the range 1..12
      <td>12
      <td><a href=#control-group-numeric id=autofilling-form-controls:-the-autocomplete-attribute:control-group-numeric>Numeric</a>
    <tr><td colspan=3>"<dfn id=attr-fe-autocomplete-cc-exp-year><code>cc-exp-year</code></dfn>"
      <td>Year component of the expiration date of the payment instrument
      <td><a href=#valid-integer id=autofilling-form-controls:-the-autocomplete-attribute:valid-integer-2>Valid integer</a> greater than zero
      <td>2014
      <td><a href=#control-group-numeric id=autofilling-form-controls:-the-autocomplete-attribute:control-group-numeric-2>Numeric</a>
    <tr><td colspan=4>"<dfn id=attr-fe-autocomplete-cc-csc><code>cc-csc</code></dfn>"
     <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><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>419
     <td><a href=#control-group-text id=autofilling-form-controls:-the-autocomplete-attribute:control-group-text-26>Text</a>
    <tr><td colspan=4>"<dfn id=attr-fe-autocomplete-cc-type><code>cc-type</code></dfn>"
     <td>Type of payment instrument
     <td>Free-form text, no newlines
     <td>Visa
     <td><a href=#control-group-text id=autofilling-form-controls:-the-autocomplete-attribute:control-group-text-27>Text</a>
   <tbody><tr><td colspan=4>"<dfn id=attr-fe-autocomplete-transaction-currency><code>transaction-currency</code></dfn>"
     <td>The currency that the user would prefer the transaction to use
     <td>ISO 4217 currency code <a href=#refsISO4217>[ISO4217]</a>
     <td>GBP
     <td><a href=#control-group-text id=autofilling-form-controls:-the-autocomplete-attribute:control-group-text-28>Text</a>
    <tr><td colspan=4>"<dfn id=attr-fe-autocomplete-transaction-amount><code>transaction-amount</code></dfn>"
     <td>The amount that the user would like for the transaction (e.g. when entering a bid or sale price)
     <td><a href=#valid-floating-point-number id=autofilling-form-controls:-the-autocomplete-attribute:valid-floating-point-number>Valid floating-point number</a>
     <td>401.00
     <td><a href=#control-group-numeric id=autofilling-form-controls:-the-autocomplete-attribute:control-group-numeric-3>Numeric</a>
   <tbody><tr><td colspan=4>"<dfn id=attr-fe-autocomplete-language><code>language</code></dfn>"
     <td>Preferred language
     <td>Valid BCP 47 language tag <a href=#refsBCP47>[BCP47]</a>
     <td>en
     <td><a href=#control-group-text id=autofilling-form-controls:-the-autocomplete-attribute:control-group-text-29>Text</a>
    <tr><td colspan=4>"<dfn id=attr-fe-autocomplete-bday><code>bday</code></dfn>"
     <td>Birthday
     <td><a href=#valid-date-string id=autofilling-form-controls:-the-autocomplete-attribute:valid-date-string>Valid date string</a>
     <td>1955-06-08
     <td><a href=#control-group-date id=autofilling-form-controls:-the-autocomplete-attribute:control-group-date>Date</a>
    <tr><td class=non-rectangular-cell-indentation rowspan=3>
      <td colspan=3>"<dfn id=attr-fe-autocomplete-bday-day><code>bday-day</code></dfn>"
      <td>Day component of birthday
      <td><a href=#valid-integer id=autofilling-form-controls:-the-autocomplete-attribute:valid-integer-3>Valid integer</a> in the range 1..31
      <td>8
      <td><a href=#control-group-numeric id=autofilling-form-controls:-the-autocomplete-attribute:control-group-numeric-4>Numeric</a>
    <tr><td colspan=3>"<dfn id=attr-fe-autocomplete-bday-month><code>bday-month</code></dfn>"
      <td>Month component of birthday
      <td><a href=#valid-integer id=autofilling-form-controls:-the-autocomplete-attribute:valid-integer-4>Valid integer</a> in the range 1..12
      <td>6
      <td><a href=#control-group-numeric id=autofilling-form-controls:-the-autocomplete-attribute:control-group-numeric-5>Numeric</a>
    <tr><td colspan=3>"<dfn id=attr-fe-autocomplete-bday-year><code>bday-year</code></dfn>"
      <td>Year component of birthday
      <td><a href=#valid-integer id=autofilling-form-controls:-the-autocomplete-attribute:valid-integer-5>Valid integer</a> greater than zero
      <td>1955
      <td><a href=#control-group-numeric id=autofilling-form-controls:-the-autocomplete-attribute:control-group-numeric-6>Numeric</a>
    <tr><td colspan=4>"<dfn id=attr-fe-autocomplete-sex><code>sex</code></dfn>"
     <td>Gender identity (e.g. Female, Fa'afafine)
     <td>Free-form text, no newlines
     <td>Male
     <td><a href=#control-group-text id=autofilling-form-controls:-the-autocomplete-attribute:control-group-text-30>Text</a>
    <tr><td colspan=4>"<dfn id=attr-fe-autocomplete-url><code>url</code></dfn>"
     <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><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>https://www.w3.org/People/Berners-Lee/
     <td><a href=#control-group-url id=autofilling-form-controls:-the-autocomplete-attribute:control-group-url>URL</a>
    <tr><td colspan=4>"<dfn id=attr-fe-autocomplete-photo><code>photo</code></dfn>"
     <td>Photograph, icon, or other image corresponding to the company, person, address, or contact information in the other fields associated with this field
     <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>https://www.w3.org/Press/Stock/Berners-Lee/2001-europaeum-eighth.jpg
     <td> <a href=#control-group-url id=autofilling-form-controls:-the-autocomplete-attribute:control-group-url-2>URL</a>
   <tbody><tr><td colspan=4>"<dfn id=attr-fe-autocomplete-tel><code>tel</code></dfn>"
     <td>Full telephone number, including country code
     <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>+1 617 253 5702
     <td><a href=#control-group-tel id=autofilling-form-controls:-the-autocomplete-attribute:control-group-tel>Tel</a>
    <tr><td class=non-rectangular-cell-indentation rowspan=6>
      <td colspan=3>"<dfn id=attr-fe-autocomplete-tel-country-code><code>tel-country-code</code></dfn>"
      <td>Country code component of the telephone number
      <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>+1
      <td><a href=#control-group-text id=autofilling-form-controls:-the-autocomplete-attribute:control-group-text-31>Text</a>
    <tr><td colspan=3>"<dfn id=attr-fe-autocomplete-tel-national><code>tel-national</code></dfn>"
      <td>Telephone number without the county code component, with a country-internal prefix applied if applicable
      <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>617 253 5702
      <td><a href=#control-group-text id=autofilling-form-controls:-the-autocomplete-attribute:control-group-text-32>Text</a>
    <tr><td class=non-rectangular-cell-indentation rowspan=4>
       <td colspan=2>"<dfn id=attr-fe-autocomplete-tel-area-code><code>tel-area-code</code></dfn>"
       <td>Area code component of the telephone number, with a country-internal prefix applied if applicable
       <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>617
       <td><a href=#control-group-text id=autofilling-form-controls:-the-autocomplete-attribute:control-group-text-33>Text</a>
    <tr><td colspan=2>"<dfn id=attr-fe-autocomplete-tel-local><code>tel-local</code></dfn>"
       <td>Telephone number without the country code and area code components
       <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>2535702
       <td><a href=#control-group-text id=autofilling-form-controls:-the-autocomplete-attribute:control-group-text-34>Text</a>
    <tr><td class=non-rectangular-cell-indentation rowspan=2>
        <td>"<dfn id=attr-fe-autocomplete-tel-local-prefix><code>tel-local-prefix</code></dfn>"
        <td>First part of the component of the telephone number that follows the area code, when that component is split into two components
        <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>253
        <td><a href=#control-group-text id=autofilling-form-controls:-the-autocomplete-attribute:control-group-text-35>Text</a>
    <tr><td>"<dfn id=attr-fe-autocomplete-tel-local-suffix><code>tel-local-suffix</code></dfn>"
        <td>Second part of the component of the telephone number that follows the area code, when that component is split into two components
        <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>5702
        <td><a href=#control-group-text id=autofilling-form-controls:-the-autocomplete-attribute:control-group-text-36>Text</a>
    <tr><td colspan=4>"<dfn id=attr-fe-autocomplete-tel-extension><code>tel-extension</code></dfn>"
     <td>Telephone number internal extension code
     <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>1000
     <td><a href=#control-group-text id=autofilling-form-controls:-the-autocomplete-attribute:control-group-text-37>Text</a>
    <tr><td colspan=4>"<dfn id=attr-fe-autocomplete-email><code>email</code></dfn>"
     <td>E-mail address
     <td><a href=#valid-e-mail-address id=autofilling-form-controls:-the-autocomplete-attribute:valid-e-mail-address>Valid e-mail address</a>
     <td>timbl@w3.org
     <td><a href=#control-group-e-mail id=autofilling-form-controls:-the-autocomplete-attribute:control-group-e-mail>E-mail</a>
    <tr><td colspan=4>"<dfn id=attr-fe-autocomplete-impp><code>impp</code></dfn>"
     <td>URL representing an instant messaging protocol endpoint (for example, "<code>aim:goim?screenname=example</code>" or "<code>xmpp:fred@example.net</code>")
     <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>irc://example.org/timbl,isuser
     <td><a href=#control-group-url id=autofilling-form-controls:-the-autocomplete-attribute:control-group-url-3>URL</a>
  </table>

  <p>The groups correspond to controls as follows:</p>

  <dl><dt><dfn id=control-group-text>Text</dfn>

   <dd><code id=autofilling-form-controls:-the-autocomplete-attribute:the-input-element-2><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><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-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><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-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><code id=autofilling-form-controls:-the-autocomplete-attribute:the-textarea-element><a href=#the-textarea-element>textarea</a></code> elements
   <dd><code id=autofilling-form-controls:-the-autocomplete-attribute:the-select-element><a href=#the-select-element>select</a></code> elements

   <dt><dfn id=control-group-multiline>Multiline</dfn>

   <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-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><code id=autofilling-form-controls:-the-autocomplete-attribute:the-textarea-element-2><a href=#the-textarea-element>textarea</a></code> elements
   <dd><code id=autofilling-form-controls:-the-autocomplete-attribute:the-select-element-2><a href=#the-select-element>select</a></code> elements

   <dt><dfn id=control-group-password>Password</dfn>

   <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-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><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-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><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-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><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-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><code id=autofilling-form-controls:-the-autocomplete-attribute:the-textarea-element-3><a href=#the-textarea-element>textarea</a></code> elements
   <dd><code id=autofilling-form-controls:-the-autocomplete-attribute:the-select-element-3><a href=#the-select-element>select</a></code> elements

   <dt><dfn id=control-group-url>URL</dfn>

   <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-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><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-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><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-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><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-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><code id=autofilling-form-controls:-the-autocomplete-attribute:the-textarea-element-4><a href=#the-textarea-element>textarea</a></code> elements
   <dd><code id=autofilling-form-controls:-the-autocomplete-attribute:the-select-element-4><a href=#the-select-element>select</a></code> elements

   <dt><dfn id=control-group-e-mail>E-mail</dfn>

   <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-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><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-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><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-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><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-17><a href=#attr-input-type>type</a></code> attribute in the <a href="#e-mail-state-(type=email)" id="autofilling-form-controls:-the-autocomplete-attribute:e-mail-state-(type=email)">E-mail</a> state
   <dd><code id=autofilling-form-controls:-the-autocomplete-attribute:the-textarea-element-5><a href=#the-textarea-element>textarea</a></code> elements
   <dd><code id=autofilling-form-controls:-the-autocomplete-attribute:the-select-element-5><a href=#the-select-element>select</a></code> elements

   <dt><dfn id=control-group-tel>Tel</dfn>

   <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-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><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-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><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-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><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-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><code id=autofilling-form-controls:-the-autocomplete-attribute:the-textarea-element-6><a href=#the-textarea-element>textarea</a></code> elements
   <dd><code id=autofilling-form-controls:-the-autocomplete-attribute:the-select-element-6><a href=#the-select-element>select</a></code> elements

   <dt><dfn id=control-group-numeric>Numeric</dfn>

   <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-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><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-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><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-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><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-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><code id=autofilling-form-controls:-the-autocomplete-attribute:the-textarea-element-7><a href=#the-textarea-element>textarea</a></code> elements
   <dd><code id=autofilling-form-controls:-the-autocomplete-attribute:the-select-element-7><a href=#the-select-element>select</a></code> elements

   <dt><dfn id=control-group-month>Month</dfn>

   <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-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><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-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><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-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><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-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><code id=autofilling-form-controls:-the-autocomplete-attribute:the-textarea-element-8><a href=#the-textarea-element>textarea</a></code> elements
   <dd><code id=autofilling-form-controls:-the-autocomplete-attribute:the-select-element-8><a href=#the-select-element>select</a></code> elements

   <dt><dfn id=control-group-date>Date</dfn>

   <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-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><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-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><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-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><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-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><code id=autofilling-form-controls:-the-autocomplete-attribute:the-textarea-element-9><a href=#the-textarea-element>textarea</a></code> elements
   <dd><code id=autofilling-form-controls:-the-autocomplete-attribute:the-select-element-9><a href=#the-select-element>select</a></code> elements



  </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.18.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>, 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=#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>

  <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>.<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>.<li><p>If <var>tokens</var> is empty, then jump to the step labeled
   <i>default</i>.<li><p>Let <var>index</var> be the index of the last token in <var>tokens</var>.<li>

    <p>If the <var>index</var>th token in <var>tokens</var> is not 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 one of the tokens given in the first column of the following
    table, or if the number of tokens in <var>tokens</var> is greater than the maximum
    number given in the cell in the second column of that token's row, then jump to the step labeled
    <i>default</i>. Otherwise, let <var>field</var> be the string given in the cell of the
    first column of the matching row, and let <var>category</var> be the value of the cell
    in the third column of that same row.</p>

    <table><thead><tr><th>Token
       <th>Maximum number of tokens
       <th>Category
     <tbody><tr><td>"<code id=autofill-processing-model:attr-fe-autocomplete-off><a href=#attr-fe-autocomplete-off>off</a></code>"
       <td>1
       <td>Off
      <tr><td>"<code id=autofill-processing-model:attr-fe-autocomplete-on><a href=#attr-fe-autocomplete-on>on</a></code>"
       <td>1
       <td>Automatic
     <tbody><tr><td>"<code id=autofill-processing-model:attr-fe-autocomplete-name><a href=#attr-fe-autocomplete-name>name</a></code>"
       <td>3
       <td>Normal
      <tr><td>"<code id=autofill-processing-model:attr-fe-autocomplete-honorific-prefix><a href=#attr-fe-autocomplete-honorific-prefix>honorific-prefix</a></code>"
       <td>3
       <td>Normal
      <tr><td>"<code id=autofill-processing-model:attr-fe-autocomplete-given-name><a href=#attr-fe-autocomplete-given-name>given-name</a></code>"
       <td>3
       <td>Normal
      <tr><td>"<code id=autofill-processing-model:attr-fe-autocomplete-additional-name><a href=#attr-fe-autocomplete-additional-name>additional-name</a></code>"
       <td>3
       <td>Normal
      <tr><td>"<code id=autofill-processing-model:attr-fe-autocomplete-family-name><a href=#attr-fe-autocomplete-family-name>family-name</a></code>"
       <td>3
       <td>Normal
      <tr><td>"<code id=autofill-processing-model:attr-fe-autocomplete-honorific-suffix><a href=#attr-fe-autocomplete-honorific-suffix>honorific-suffix</a></code>"
       <td>3
       <td>Normal
      <tr><td>"<code id=autofill-processing-model:attr-fe-autocomplete-nickname><a href=#attr-fe-autocomplete-nickname>nickname</a></code>"
       <td>3
       <td>Normal
      <tr><td>"<code id=autofill-processing-model:attr-fe-autocomplete-organization-title><a href=#attr-fe-autocomplete-organization-title>organization-title</a></code>"
       <td>3
       <td>Normal
      <tr><td>"<code id=autofill-processing-model:attr-fe-autocomplete-username><a href=#attr-fe-autocomplete-username>username</a></code>"
       <td>3
       <td>Normal
      <tr><td>"<code id=autofill-processing-model:attr-fe-autocomplete-new-password><a href=#attr-fe-autocomplete-new-password>new-password</a></code>"
       <td>3
       <td>Normal
      <tr><td>"<code id=autofill-processing-model:attr-fe-autocomplete-current-password><a href=#attr-fe-autocomplete-current-password>current-password</a></code>"
       <td>3
       <td>Normal
      <tr><td>"<code id=autofill-processing-model:attr-fe-autocomplete-organization><a href=#attr-fe-autocomplete-organization>organization</a></code>"
       <td>3
       <td>Normal
      <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>3
       <td>Normal
      <tr><td>"<code id=autofill-processing-model:attr-fe-autocomplete-address-line1><a href=#attr-fe-autocomplete-address-line1>address-line1</a></code>"
       <td>3
       <td>Normal
      <tr><td>"<code id=autofill-processing-model:attr-fe-autocomplete-address-line2><a href=#attr-fe-autocomplete-address-line2>address-line2</a></code>"
       <td>3
       <td>Normal
      <tr><td>"<code id=autofill-processing-model:attr-fe-autocomplete-address-line3><a href=#attr-fe-autocomplete-address-line3>address-line3</a></code>"
       <td>3
       <td>Normal
      <tr><td>"<code id=autofill-processing-model:attr-fe-autocomplete-address-level4><a href=#attr-fe-autocomplete-address-level4>address-level4</a></code>"
       <td>3
       <td>Normal
      <tr><td>"<code id=autofill-processing-model:attr-fe-autocomplete-address-level3><a href=#attr-fe-autocomplete-address-level3>address-level3</a></code>"
       <td>3
       <td>Normal
      <tr><td>"<code id=autofill-processing-model:attr-fe-autocomplete-address-level2><a href=#attr-fe-autocomplete-address-level2>address-level2</a></code>"
       <td>3
       <td>Normal
      <tr><td>"<code id=autofill-processing-model:attr-fe-autocomplete-address-level1><a href=#attr-fe-autocomplete-address-level1>address-level1</a></code>"
       <td>3
       <td>Normal
      <tr><td>"<code id=autofill-processing-model:attr-fe-autocomplete-country><a href=#attr-fe-autocomplete-country>country</a></code>"
       <td>3
       <td>Normal
      <tr><td>"<code id=autofill-processing-model:attr-fe-autocomplete-country-name><a href=#attr-fe-autocomplete-country-name>country-name</a></code>"
       <td>3
       <td>Normal
      <tr><td>"<code id=autofill-processing-model:attr-fe-autocomplete-postal-code><a href=#attr-fe-autocomplete-postal-code>postal-code</a></code>"
       <td>3
       <td>Normal
      <tr><td>"<code id=autofill-processing-model:attr-fe-autocomplete-cc-name><a href=#attr-fe-autocomplete-cc-name>cc-name</a></code>"
       <td>3
       <td>Normal
      <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>3
       <td>Normal
      <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>3
       <td>Normal
      <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>3
       <td>Normal
      <tr><td>"<code id=autofill-processing-model:attr-fe-autocomplete-cc-number><a href=#attr-fe-autocomplete-cc-number>cc-number</a></code>"
       <td>3
       <td>Normal
      <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>3
       <td>Normal
      <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>3
       <td>Normal
      <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>3
       <td>Normal
      <tr><td>"<code id=autofill-processing-model:attr-fe-autocomplete-cc-csc><a href=#attr-fe-autocomplete-cc-csc>cc-csc</a></code>"
       <td>3
       <td>Normal
      <tr><td>"<code id=autofill-processing-model:attr-fe-autocomplete-cc-type><a href=#attr-fe-autocomplete-cc-type>cc-type</a></code>"
       <td>3
       <td>Normal
      <tr><td>"<code id=autofill-processing-model:attr-fe-autocomplete-transaction-currency><a href=#attr-fe-autocomplete-transaction-currency>transaction-currency</a></code>"
       <td>3
       <td>Normal
      <tr><td>"<code id=autofill-processing-model:attr-fe-autocomplete-transaction-amount><a href=#attr-fe-autocomplete-transaction-amount>transaction-amount</a></code>"
       <td>3
       <td>Normal
      <tr><td>"<code id=autofill-processing-model:attr-fe-autocomplete-language><a href=#attr-fe-autocomplete-language>language</a></code>"
       <td>3
       <td>Normal
      <tr><td>"<code id=autofill-processing-model:attr-fe-autocomplete-bday><a href=#attr-fe-autocomplete-bday>bday</a></code>"
       <td>3
       <td>Normal
      <tr><td>"<code id=autofill-processing-model:attr-fe-autocomplete-bday-day><a href=#attr-fe-autocomplete-bday-day>bday-day</a></code>"
       <td>3
       <td>Normal
      <tr><td>"<code id=autofill-processing-model:attr-fe-autocomplete-bday-month><a href=#attr-fe-autocomplete-bday-month>bday-month</a></code>"
       <td>3
       <td>Normal
      <tr><td>"<code id=autofill-processing-model:attr-fe-autocomplete-bday-year><a href=#attr-fe-autocomplete-bday-year>bday-year</a></code>"
       <td>3
       <td>Normal
      <tr><td>"<code id=autofill-processing-model:attr-fe-autocomplete-sex><a href=#attr-fe-autocomplete-sex>sex</a></code>"
       <td>3
       <td>Normal
      <tr><td>"<code id=autofill-processing-model:attr-fe-autocomplete-url><a href=#attr-fe-autocomplete-url>url</a></code>"
       <td>3
       <td>Normal
      <tr><td>"<code id=autofill-processing-model:attr-fe-autocomplete-photo><a href=#attr-fe-autocomplete-photo>photo</a></code>"
       <td>3
       <td>Normal
     <tbody><tr><td>"<code id=autofill-processing-model:attr-fe-autocomplete-tel><a href=#attr-fe-autocomplete-tel>tel</a></code>"
       <td>4
       <td>Contact
      <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>4
       <td>Contact
      <tr><td>"<code id=autofill-processing-model:attr-fe-autocomplete-tel-national><a href=#attr-fe-autocomplete-tel-national>tel-national</a></code>"
       <td>4
       <td>Contact
      <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>4
       <td>Contact
      <tr><td>"<code id=autofill-processing-model:attr-fe-autocomplete-tel-local><a href=#attr-fe-autocomplete-tel-local>tel-local</a></code>"
       <td>4
       <td>Contact
      <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>4
       <td>Contact
      <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>4
       <td>Contact
      <tr><td>"<code id=autofill-processing-model:attr-fe-autocomplete-tel-extension><a href=#attr-fe-autocomplete-tel-extension>tel-extension</a></code>"
       <td>4
       <td>Contact
      <tr><td>"<code id=autofill-processing-model:attr-fe-autocomplete-email><a href=#attr-fe-autocomplete-email>email</a></code>"
       <td>4
       <td>Contact
      <tr><td>"<code id=autofill-processing-model:attr-fe-autocomplete-impp><a href=#attr-fe-autocomplete-impp>impp</a></code>"
       <td>4
       <td>Contact
    </table>

   <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>.<li><p>If <var>category</var> is Off, let the element's <a href=#autofill-field-name id=autofill-processing-model:autofill-field-name-2>autofill field name</a>
   be the string "<code>off</code>", let its <a href=#autofill-hint-set id=autofill-processing-model:autofill-hint-set-3>autofill hint set</a> be empty, and
   let its <a href=#idl-exposed-autofill-value id=autofill-processing-model:idl-exposed-autofill-value>IDL-exposed autofill value</a> be the string "<code>off</code>". Then,
   return.</p>

   <li><p>If <var>category</var> is Automatic, let the element's <a href=#autofill-field-name id=autofill-processing-model:autofill-field-name-3>autofill field
   name</a> be the string "<code>on</code>", let its <a href=#autofill-hint-set id=autofill-processing-model:autofill-hint-set-4>autofill hint set</a> be
   empty, and let its <a href=#idl-exposed-autofill-value id=autofill-processing-model:idl-exposed-autofill-value-2>IDL-exposed autofill value</a> be the string "<code>on</code>". Then, return.</p>

   <li><p>Let <var>scope tokens</var> be an empty list.<li><p>Let <var>hint tokens</var> be an empty set.<li><p>Let <var>IDL value</var> have the same value as <var>field</var>.<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>.<li><p>Decrement <var>index</var> by one.<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>"<code id=autofill-processing-model:attr-fe-autocomplete-work><a href=#attr-fe-autocomplete-work>work</a></code>"
     <li>"<code id=autofill-processing-model:attr-fe-autocomplete-mobile><a href=#attr-fe-autocomplete-mobile>mobile</a></code>"
     <li>"<code id=autofill-processing-model:attr-fe-autocomplete-fax-2><a href=#attr-fe-autocomplete-fax>fax</a></code>"
     <li>"<code id=autofill-processing-model:attr-fe-autocomplete-pager><a href=#attr-fe-autocomplete-pager>pager</a></code>"
    </ul>

    <p>The substeps are:</p>

    <ol><li><p>Let <var>contact</var> be the matching string from the list above.<li><p>Insert <var>contact</var> at the start of <var>scope
     tokens</var>.<li><p>Add <var>contact</var> to <var>hint tokens</var>.<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> (which at this
     point will always be <var>field</var>).<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>.<li><p>Decrement <var>index</var> by one.</ol>

   <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>"<code id=autofill-processing-model:attr-fe-autocomplete-billing-2><a href=#attr-fe-autocomplete-billing>billing</a></code>"
    </ul>

    <p>The substeps are:</p>

    <ol><li><p>Let <var>mode</var> be the matching string from the list above.<li><p>Insert <var>mode</var> at the start of <var>scope
     tokens</var>.<li><p>Add <var>mode</var> to <var>hint tokens</var>.<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> (which at this
     point will either be <var>field</var> or the concatenation of <var>contact</var>, a space, and <var>field</var>).<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>.<li><p>Decrement <var>index</var> by one.</ol>

   <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>.<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>.<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>.<li><p>Insert <var>section</var> at the start of <var>scope tokens</var>.<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>.<li><p><i>Done</i>: Let the element's <a href=#autofill-hint-set id=autofill-processing-model:autofill-hint-set-5>autofill hint set</a> be <var>hint
   tokens</var>.</p>

   <li><p>Let the element's <a href=#autofill-scope id=autofill-processing-model:autofill-scope-2>autofill scope</a> be <var>scope tokens</var>.</p>

   <li><p>Let the element's <a href=#autofill-field-name id=autofill-processing-model:autofill-field-name-4>autofill field name</a> be <var>field</var>.</p>

   <li><p>Let the element's <a href=#idl-exposed-autofill-value id=autofill-processing-model:idl-exposed-autofill-value-3>IDL-exposed autofill value</a> be <var>IDL value</var>.</p>

   <li><p>Return.<li><p><i>Default</i>: Let the element's <a href=#idl-exposed-autofill-value id=autofill-processing-model:idl-exposed-autofill-value-4>IDL-exposed autofill value</a> be 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> be empty.<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 let the element's <a href=#autofill-field-name id=autofill-processing-model:autofill-field-name-5>autofill field
   name</a> be the empty string and return.<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.<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 let the element's
    <a href=#autofill-field-name id=autofill-processing-model:autofill-field-name-6>autofill field name</a> be "<code id=autofill-processing-model:attr-fe-autocomplete-off-2><a href=#attr-fe-autocomplete-off>off</a></code>".</p>

    <p>Otherwise, let the element's <a href=#autofill-field-name id=autofill-processing-model:autofill-field-name-7>autofill field name</a> be "<code id=autofill-processing-model:attr-fe-autocomplete-on-2><a href=#attr-fe-autocomplete-on>on</a></code>".</p>

   </ol>

  <hr>

  <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="#e-mail-state-(type=email)" id="autofill-processing-model:e-mail-state-(type=email)">E-mail</a> state and with the <code id=autofill-processing-model:attr-input-multiple><a href=#attr-input-multiple>multiple</a></code> attribute specified<dd>The element's <a href=#concept-fe-values id=autofill-processing-model:concept-fe-values>value<em>s</em></a>.<dt>Any other <code id=autofill-processing-model:the-input-element-3><a href=#the-input-element>input</a></code> element<dt>A <code id=autofill-processing-model:the-textarea-element-2><a href=#the-textarea-element>textarea</a></code> element<dd>The element's <a href=#concept-fe-value id=autofill-processing-model:concept-fe-value>value</a>.<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<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.<dt>Any other <code id=autofill-processing-model:the-select-element-4><a href=#the-select-element>select</a></code> element<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.</dl>

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

   <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=#traverse-the-history id=autofill-processing-model:traverse-the-history>traversing the history</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>&quot;text&quot;</c-> <c- e>name</c-><c- o>=</c-><c- s>&quot;ac&quot;</c-> <c- e>autocomplete</c-><c- o>=</c-><c- s>&quot;off&quot;</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>&quot;password&quot;</c-> <c- e>name</c-><c- o>=</c-><c- s>&quot;pin&quot;</c-> <c- e>autocomplete</c-><c- o>=</c-><c- s>&quot;off&quot;</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>&quot;country&quot;</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>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>

   <dt>When wearing the <a href=#autofill-anchor-mantle id=autofill-processing-model:autofill-anchor-mantle-3>autofill anchor mantle</a>...

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

   </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>&quot;nickname&quot;</c-> <c- e>value</c-><c- o>=</c-><c- s>&quot;TreePlate&quot;</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>&quot;nickname&quot;</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>&quot;additional-name&quot;</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><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>&quot;bday&quot;</c-><c- p>&gt;</c-></code></pre>
     <td>
      2012-07
     <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.)
    <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>&quot;bday&quot;</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>
      July
     <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.
    <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>&quot;bday-month&quot;</c-><c- p>&gt;</c-></code></pre>
     <td>
      7
     <td>
      User agent converts "July" to a month number in the range 1..12, like the field.
    <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>&quot;bday-month&quot;</c-><c- p>&gt;</c-></code></pre>
     <td>
      6
     <td>
      User agent converts "July" to a month number in the range 0..11, like the field.
    <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>&quot;bday-month&quot;</c-><c- p>&gt;</c-></code></pre>
     <td>
     <td>
      User agent doesn't fill in the field, since it can't make a good guess as to what the form expects.
   </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>New <a href=#autofill-field-name id=autofill-processing-model:autofill-field-name-23>autofill field name</a>

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

      "<code id=autofill-processing-model:attr-fe-autocomplete-username-2><a href=#attr-fe-autocomplete-username>username</a></code>"


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

      "<code id=autofill-processing-model:attr-fe-autocomplete-current-password-2><a href=#attr-fe-autocomplete-current-password>current-password</a></code>"


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

      "<code id=autofill-processing-model:attr-fe-autocomplete-new-password-2><a href=#attr-fe-autocomplete-new-password>new-password</a></code>"


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

      "<code id=autofill-processing-model:attr-fe-autocomplete-new-password-4><a href=#attr-fe-autocomplete-new-password>new-password</a></code>"


  </table>

  <p>The <dfn id=dom-fe-autocomplete><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>, and on setting, must
  <a href=#reflect id=autofill-processing-model:reflect>reflect</a> the content attribute of the same name.</p>

  


  <h4 id=textFieldSelection><span class=secno>4.10.19</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><var>element</var> . <code id=dom-textarea/input-select-dev><a href=#dom-textarea/input-select>select</a></code>()<dd>

    <p>Selects everything in the text control.</p>

   <dt><var>element</var> . <code id=dom-textarea/input-selectionstart-dev><a href=#dom-textarea/input-selectionstart>selectionStart</a></code> [ = <var>value</var> ]<dd>

    <p>Returns the offset to the start of the selection.</p>

    <p>Can be set, to change the start of the selection.</p>

   <dt><var>element</var> . <code id=dom-textarea/input-selectionend-dev><a href=#dom-textarea/input-selectionend>selectionEnd</a></code> [ = <var>value</var> ]<dd>

    <p>Returns the offset to the end of the selection.</p>

    <p>Can be set, to change the end of the selection.</p>

   <dt><var>element</var> . <code id=dom-textarea/input-selectiondirection-dev><a href=#dom-textarea/input-selectiondirection>selectionDirection</a></code> [ = <var>value</var> ]<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>

   <dt><var>element</var> . <code id=dom-textarea/input-setselectionrange-dev><a href=#dom-textarea/input-setselectionrange>setSelectionRange</a></code>(<var>start</var>, <var>end</var> [, <var>direction</var>] )<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>

   <dt><var>element</var> . <code id=dom-textarea/input-setrangetext-dev><a href=#dom-textarea/input-setrangetext>setRangeText</a></code>(<var>replacement</var> [, <var>start</var>, <var>end</var> [, <var>selectionMode</var> ] ] )<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>"<dd>Selects the newly inserted text.<dt>"<code id=dom-selectionmode-start-dev><a href=#dom-selectionmode-start>start</a></code>"<dd>Moves the selection to just before the inserted text.<dt>"<code id=dom-selectionmode-end-dev><a href=#dom-selectionmode-end>end</a></code>"<dd>Moves the selection to just after the selected text.<dt>"<code id=dom-selectionmode-preserve-dev><a href=#dom-selectionmode-preserve>preserve</a></code>"<dd>Attempts to preserve the selection. This is the default.</dl>

   </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>). 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,

   <pre><code class='html'><c- p>&lt;</c-><c- f>textarea</c-> <c- e>id</c-><c- o>=</c-><c- s>&quot;demo&quot;</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>&quot;A\r\nB&quot;</c-><c- p>;</c->
 demo<c- p>.</c->setRangeText<c- p>(</c-><c- u>&quot;replaced&quot;</c-><c- p>,</c-> <c- mi>0</c-><c- p>,</c-> <c- mi>2</c-><c- p>);</c->
 assert<c- p>(</c->demo<c- p>.</c->value <c- o>===</c-> <c- u>&quot;replacedB&quot;</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>Whenever the <a href=#concept-textarea/input-relevant-value id=textFieldSelection:concept-textarea/input-relevant-value>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-2>relevant value</a>, set it to the end of the
     <a href=#concept-textarea/input-relevant-value id=textFieldSelection:concept-textarea/input-relevant-value-3>relevant value</a>.<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-4>relevant value</a>, set it to the end of the
     <a href=#concept-textarea/input-relevant-value id=textFieldSelection:concept-textarea/input-relevant-value-5>relevant value</a>.<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-6>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-7>relevant value</a>, removing
     any selection.</ol>
   <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-8>relevant value</a>, set it to the end of the
   <a href=#concept-textarea/input-relevant-value id=textFieldSelection:concept-textarea/input-relevant-value-9>relevant value</a>.</ol>

  <p class=note>In some cases where the <a href=#concept-textarea/input-relevant-value id=textFieldSelection:concept-textarea/input-relevant-value-10>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>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>

  <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>".
  This direction is set when the user manipulates the selection. The exact meaning of the selection
  direction depends on the platform. 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>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-2>selection direction</a> to "<code>forward</code>".</p>

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


  <p>The <dfn id=dom-textarea/input-select><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></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><p><a href=#set-the-selection-range id=textFieldSelection:set-the-selection-range-2>Set the selection range</a> with 0 and infinity.</ol>

  <p>The <dfn id=dom-textarea/input-selectionstart><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.<li><p>If there is no <a href=#concept-textarea/input-selection id=textFieldSelection:concept-textarea/input-selection-4>selection</a>, return
   the offset (in logical order) within the <a href=#concept-textarea/input-relevant-value id=textFieldSelection:concept-textarea/input-relevant-value-11>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>.<li><p>Return the offset (in logical order) 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 start of the <a href=#concept-textarea/input-selection id=textFieldSelection:concept-textarea/input-selection-5>selection</a>.</ol>

  <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://heycam.github.io/webidl/#invalidstateerror data-x-internal=invalidstateerror>"<code>InvalidStateError</code>"</a>
   <code id=textFieldSelection:domexception><a data-x-internal=domexception href=https://heycam.github.io/webidl/#dfn-DOMException>DOMException</a></code>.<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.<li><p>If <var>end</var> is less than the given value, set <var>end</var> to the given
   value.<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.</ol>

  <p>The <dfn id=dom-textarea/input-selectionend><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.<li><p>If there is no <a href=#concept-textarea/input-selection id=textFieldSelection:concept-textarea/input-selection-6>selection</a>, return
   the offset (in logical order) 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 <a href=#concept-textarea/input-cursor id=textFieldSelection:concept-textarea/input-cursor-6>text entry
   cursor</a>.<li><p>Return the offset (in logical order) 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 end of the <a href=#concept-textarea/input-selection id=textFieldSelection:concept-textarea/input-selection-7>selection</a>.</ol>

  <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://heycam.github.io/webidl/#invalidstateerror data-x-internal=invalidstateerror>"<code>InvalidStateError</code>"</a>
   <code id=textFieldSelection:domexception-2><a data-x-internal=domexception href=https://heycam.github.io/webidl/#dfn-DOMException>DOMException</a></code>.<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.</ol>

  <p>The <dfn id=dom-textarea/input-selectiondirection><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.<li><p>Return this element's <a href=#selection-direction id=textFieldSelection:selection-direction-3>selection direction</a>.</ol>

  <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://heycam.github.io/webidl/#invalidstateerror data-x-internal=invalidstateerror>"<code>InvalidStateError</code>"</a> <code id=textFieldSelection:domexception-3><a data-x-internal=domexception href=https://heycam.github.io/webidl/#dfn-DOMException>DOMException</a></code>.<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.</ol>

  <p>The <dfn id=dom-textarea/input-setselectionrange><code>setSelectionRange(<var>start</var>, <var>end</var>,
  <var>direction</var>)</code></dfn> method, when invoked, must run the following steps:<div class=status><input onclick=toggleStatus(this) value=⋰ type=button><p class=support><strong>Support:</strong> input-selection<span class="and_chr yes"><span>Chrome for Android</span> <span>67+</span></span><span class="chrome yes"><span>Chrome</span> <span>4+</span></span><span class="ios_saf yes"><span>iOS Safari</span> <span>4.0+</span></span><span class="and_uc yes"><span>UC Browser for Android</span> <span>11.8+</span></span><span class="firefox yes"><span>Firefox</span> <span>2+</span></span><span class="ie yes"><span>IE</span> <span>9+</span></span><span class="op_mini no"><span>Opera Mini</span> <span>None</span></span><span class="safari yes"><span>Safari</span> <span>4+</span></span><span class="edge yes"><span>Edge</span> <span>12+</span></span><span class="samsung yes"><span>Samsung Internet</span> <span>4+</span></span><span class="opera yes"><span>Opera</span> <span>10.6+</span></span><span class="android yes"><span>Android Browser</span> <span>2.1+</span></span><p class=caniuse>Source: <a href="https://caniuse.com/#feat=input-selection">caniuse.com</a></div>

  <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://heycam.github.io/webidl/#invalidstateerror data-x-internal=invalidstateerror>"<code>InvalidStateError</code>"</a> <code id=textFieldSelection:domexception-4><a data-x-internal=domexception href=https://heycam.github.io/webidl/#dfn-DOMException>DOMException</a></code>.<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>.</ol>

  <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 zero.<li><p>If <var>end</var> is null, let <var>end</var> be zero.<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 characters within the <a href=#concept-textarea/input-relevant-value id=textFieldSelection:concept-textarea/input-relevant-value-15>relevant value</a> starting with the character
   at the <var>start</var>th position (in logical order) and ending with the character at the <span>(<var>end</var>-1)</span>th position. Arguments greater than the length of the <a href=#concept-textarea/input-relevant-value id=textFieldSelection:concept-textarea/input-relevant-value-16>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>.<li><p>If <var>direction</var> is not a <a href=#case-sensitive id=textFieldSelection:case-sensitive>case-sensitive</a> match for either the string
   "<code>backward</code>" or "<code>forward</code>", or if the
   <var>direction</var> argument was omitted, set <var>direction</var> to "<code>none</code>".<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>.<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-4>direction</a>), then <a href=#queue-a-task id=textFieldSelection:queue-a-task>queue a
   task</a>, using the <a href=#user-interaction-task-source id=textFieldSelection:user-interaction-task-source>user interaction task source</a>, 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.</ol>


  <p>The <dfn id=dom-textarea/input-setrangetext><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://heycam.github.io/webidl/#invalidstateerror data-x-internal=invalidstateerror>"<code>InvalidStateError</code>"</a>
   <code id=textFieldSelection:domexception-5><a data-x-internal=domexception href=https://heycam.github.io/webidl/#dfn-DOMException>DOMException</a></code>.<li><p>Set this element's <a href=#concept-fe-dirty id=textFieldSelection:concept-fe-dirty>dirty value flag</a> to
   true.<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><p>If <var>start</var> is greater than <var>end</var>, then throw an
   <a id=textFieldSelection:indexsizeerror href=https://heycam.github.io/webidl/#indexsizeerror data-x-internal=indexsizeerror>"<code>IndexSizeError</code>"</a> <code id=textFieldSelection:domexception-6><a data-x-internal=domexception href=https://heycam.github.io/webidl/#dfn-DOMException>DOMException</a></code>.<li><p>If <var>start</var> is greater than the length of the <a href=#concept-textarea/input-relevant-value id=textFieldSelection:concept-textarea/input-relevant-value-17>relevant value</a> of the text control, then
   set it to the length of the <a href=#concept-textarea/input-relevant-value id=textFieldSelection:concept-textarea/input-relevant-value-18>relevant
   value</a> of the text control.<li><p>If <var>end</var> is greater than the length of the <a href=#concept-textarea/input-relevant-value id=textFieldSelection:concept-textarea/input-relevant-value-19>relevant value</a> of the text control, then
   set it to the length of the <a href=#concept-textarea/input-relevant-value id=textFieldSelection:concept-textarea/input-relevant-value-20>relevant
   value</a> of the text control.<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.<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.<li><p>If <var>start</var> is less than <var>end</var>, delete the sequence of characters within
   the element's <a href=#concept-textarea/input-relevant-value id=textFieldSelection:concept-textarea/input-relevant-value-21>relevant value</a> starting
   with the character at the <var>start</var>th position (in logical order) and ending with the
   character at the <span>(<var>end</var>-1)</span>th position.<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-22>relevant value</a> of the text control,
   immediately before the <var>start</var>th character.<li><p>Let <var>new length</var> be the length of the value of the first argument.<li><p>Let <var>new end</var> be the sum of <var>start</var> and <var>new length</var>.<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 id=dom-selectionmode-select><code>select</code></dfn>"<dd>

      <p>Let <var>selection start</var> be <var>start</var>.</p>

      <p>Let <var>selection end</var> be <var>new end</var>.</p>

     <dt>If the fourth argument's value is "<dfn id=dom-selectionmode-start><code>start</code></dfn>"<dd>

      <p>Let <var>selection start</var> and <var>selection end</var> be <var>start</var>.</p>

     <dt>If the fourth argument's value is "<dfn id=dom-selectionmode-end><code>end</code></dfn>"<dd>

      <p>Let <var>selection start</var> and <var>selection end</var> be <var>new end</var>.</p>

     <dt>If the fourth argument's value is "<dfn id=dom-selectionmode-preserve><code>preserve</code></dfn>"<dt>If the method has only one argument<dd>

      <ol><li><p>Let <var>old length</var> be <var>end</var> minus <var>start</var>.</p>

       <li><p>Let <var>delta</var> be <var>new length</var> minus <var>old length</var>.</p>

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

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

       </ol>

     </dl>

   <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>.</ol>

  <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'><c- g>SelectionMode</c-></dfn> {
  <c- s>&quot;</c-><a href='#dom-selectionmode-select' id='textFieldSelection:dom-selectionmode-select'><c- s>select</c-></a><c- s>&quot;</c->,
  <c- s>&quot;</c-><a href='#dom-selectionmode-start' id='textFieldSelection:dom-selectionmode-start'><c- s>start</c-></a><c- s>&quot;</c->,
  <c- s>&quot;</c-><a href='#dom-selectionmode-end' id='textFieldSelection:dom-selectionmode-end'><c- s>end</c-></a><c- s>&quot;</c->,
  <c- s>&quot;</c-><a href='#dom-selectionmode-preserve' id='textFieldSelection:dom-selectionmode-preserve'><c- s>preserve</c-></a><c- s>&quot;</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>&quot;http://&quot;</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.20</span> Constraints<a href=#constraints class=self-link></a></h4>

  <h5 id=definitions><span class=secno>4.10.20.1</span> Definitions<a href=#definitions class=self-link></a></h5>

  

  <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 is an <code id=definitions:the-object-element><a href=#the-object-element>object</a></code> element.)</p>

  <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. The user
  agent should use the <a href=#custom-validity-error-message id=definitions:custom-validity-error-message-2>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> <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.<dt> <dfn id=suffering-from-a-type-mismatch>Suffering from a type mismatch</dfn> <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="#e-mail-state-(type=email)" id="definitions:e-mail-state-(type=email)">E-mail</a>, <a href="#url-state-(type=url)" id="definitions:url-state-(type=url)">URL</a>).
   <dt> <dfn id=suffering-from-a-pattern-mismatch>Suffering from a pattern mismatch</dfn> <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.<dt> <dfn id=suffering-from-being-too-long>Suffering from being too long</dfn> <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>). <dt> <dfn id=suffering-from-being-too-short>Suffering from being too short</dfn> <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>). <dt> <dfn id=suffering-from-an-underflow>Suffering from an underflow</dfn> <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.<dt> <dfn id=suffering-from-an-overflow>Suffering from an overflow</dfn> <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.<dt> <dfn id=suffering-from-a-step-mismatch>Suffering from a step mismatch</dfn> <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.<dt> <dfn id=suffering-from-bad-input>Suffering from bad input</dfn> <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.<dt> <dfn id=suffering-from-a-custom-error>Suffering from a custom error</dfn> <dd> <p>When a control's <a href=#custom-validity-error-message id=definitions:custom-validity-error-message-3>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) is not the empty
   string.</p> </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>

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

  



  

  <h5 id=constraint-validation><span class=secno>4.10.20.2</span> Constraint validation<a href=#constraint-validation class=self-link></a></h5>

  <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>.<li><p>Let <var>invalid controls</var> be an initially empty list of elements.<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.<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.<li><p>Otherwise, add <var>field</var> to <var>invalid
     controls</var>.</ol>

   <li><p>If <var>invalid controls</var> is empty, then return a <i>positive</i> result.<li><p>Let <var>unhandled invalid controls</var> be an initially empty list of
   elements.<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.<li><p>If <var>notCanceled</var> is true, then add <var>field</var> to <var>unhandled invalid
     controls</var>.</ol>

   <li><p>Return a <i>negative</i> result with the list of elements in the <var>unhandled
   invalid controls</var> list.</ol>

  <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>.<li><p>If the result was <i>positive</i>, then return that result.<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. 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. User agents may report more than one constraint violation. 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). 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:the-hidden-attribute><a href=#the-hidden-attribute>hidden</a></code> attribute set) then user agents may report a script
   error.<li><p>Return a <i>negative</i> result.</ol>

  



  <h5 id=the-constraint-validation-api><span class=secno>4.10.20.3</span> The <dfn>constraint validation API</dfn><a href=#the-constraint-validation-api class=self-link></a></h5><div class=status><input onclick=toggleStatus(this) value=⋰ type=button><p class=support><strong>Support:</strong> constraint-validation<span class="and_chr yes"><span>Chrome for Android</span> <span>67+</span></span><span class="chrome yes"><span>Chrome</span> <span>40+</span></span><span class="ios_saf yes"><span>iOS Safari</span> <span>10.0+</span></span><span class="and_uc yes"><span>UC Browser for Android</span> <span>11.8+</span></span><span class="firefox yes"><span>Firefox</span> <span>51+</span></span><span class="ie partial"><span>IE (limited)</span> <span>10+</span></span><span class="op_mini no"><span>Opera Mini</span> <span>None</span></span><span class="safari yes"><span>Safari</span> <span>10+</span></span><span class="edge yes"><span>Edge</span> <span>17+</span></span><span class="samsung yes"><span>Samsung Internet</span> <span>4+</span></span><span class="opera yes"><span>Opera</span> <span>27+</span></span><span class="android yes"><span>Android Browser</span> <span>67+</span></span><p class=caniuse>Source: <a href="https://caniuse.com/#feat=constraint-validation">caniuse.com</a></div>

  <dl class=domintro><dt><var>element</var> . <code id=dom-cva-willvalidate-dev><a href=#dom-cva-willvalidate>willValidate</a></code><dd>

    <p>Returns true if the element will be validated when the form is submitted; false
    otherwise.</p>

   <dt><var>element</var> . <code id=dom-cva-setcustomvalidity-dev><a href=#dom-cva-setcustomvalidity>setCustomValidity</a></code>(<var>message</var>)<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>

   <dt><var>element</var> . <code id=the-constraint-validation-api:dom-cva-validity><a href=#dom-cva-validity>validity</a></code> . <code id=dom-validitystate-valuemissing-dev><a href=#dom-validitystate-valuemissing>valueMissing</a></code><dd>

    <p>Returns true if the element has no value but is a required field; false otherwise.</p>

   <dt><var>element</var> . <code id=the-constraint-validation-api:dom-cva-validity-2><a href=#dom-cva-validity>validity</a></code> . <code id=dom-validitystate-typemismatch-dev><a href=#dom-validitystate-typemismatch>typeMismatch</a></code><dd>

    <p>Returns true if the element's value is not in the correct syntax; false otherwise.</p>

   <dt><var>element</var> . <code id=the-constraint-validation-api:dom-cva-validity-3><a href=#dom-cva-validity>validity</a></code> . <code id=dom-validitystate-patternmismatch-dev><a href=#dom-validitystate-patternmismatch>patternMismatch</a></code><dd>

    <p>Returns true if the element's value doesn't match the provided pattern; false otherwise.</p>

   <dt><var>element</var> . <code id=the-constraint-validation-api:dom-cva-validity-4><a href=#dom-cva-validity>validity</a></code> . <code id=dom-validitystate-toolong-dev><a href=#dom-validitystate-toolong>tooLong</a></code><dd>

    <p>Returns true if the element's value is longer than the provided maximum length; false otherwise.</p>

   <dt><var>element</var> . <code id=the-constraint-validation-api:dom-cva-validity-5><a href=#dom-cva-validity>validity</a></code> . <code id=dom-validitystate-tooshort-dev><a href=#dom-validitystate-tooshort>tooShort</a></code><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>

   <dt><var>element</var> . <code id=the-constraint-validation-api:dom-cva-validity-6><a href=#dom-cva-validity>validity</a></code> . <code id=dom-validitystate-rangeunderflow-dev><a href=#dom-validitystate-rangeunderflow>rangeUnderflow</a></code><dd>

    <p>Returns true if the element's value is lower than the provided minimum; false otherwise.</p>

   <dt><var>element</var> . <code id=the-constraint-validation-api:dom-cva-validity-7><a href=#dom-cva-validity>validity</a></code> . <code id=dom-validitystate-rangeoverflow-dev><a href=#dom-validitystate-rangeoverflow>rangeOverflow</a></code><dd>

    <p>Returns true if the element's value is higher than the provided maximum; false otherwise.</p>

   <dt><var>element</var> . <code id=the-constraint-validation-api:dom-cva-validity-8><a href=#dom-cva-validity>validity</a></code> . <code id=dom-validitystate-stepmismatch-dev><a href=#dom-validitystate-stepmismatch>stepMismatch</a></code><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>

   <dt><var>element</var> . <code id=the-constraint-validation-api:dom-cva-validity-9><a href=#dom-cva-validity>validity</a></code> . <code id=dom-validitystate-badinput-dev><a href=#dom-validitystate-badinput>badInput</a></code><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>

   <dt><var>element</var> . <code id=the-constraint-validation-api:dom-cva-validity-10><a href=#dom-cva-validity>validity</a></code> . <code id=dom-validitystate-customerror-dev><a href=#dom-validitystate-customerror>customError</a></code><dd>

    <p>Returns true if the element has a custom error; false otherwise.</p>

   <dt><var>element</var> . <code id=the-constraint-validation-api:dom-cva-validity-11><a href=#dom-cva-validity>validity</a></code> . <code id=dom-validitystate-valid-dev><a href=#dom-validitystate-valid>valid</a></code><dd>

    <p>Returns true if the element's value has no validity problems; false otherwise.</p>

   <dt><var>valid</var> = <var>element</var> . <code id=dom-cva-checkvalidity-dev><a href=#dom-cva-checkvalidity>checkValidity</a></code>()<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>

   <dt><var>valid</var> = <var>element</var> . <code id=dom-cva-reportvalidity-dev><a href=#dom-cva-reportvalidity>reportValidity</a></code>()<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>

   <dt><var>element</var> . <code id=dom-cva-validationmessage-dev><a href=#dom-cva-validationmessage>validationMessage</a></code><dd>

    <p>Returns the error message that would be shown to the user if the element was to be checked
    for validity.</p>

   </dl>

  

  <p>The <dfn id=dom-cva-willvalidate><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>

  <p>The <dfn id=dom-cva-setcustomvalidity><code>setCustomValidity(<var>message</var>)</code></dfn> method, when
  invoked, must set the <a href=#custom-validity-error-message id=the-constraint-validation-api:custom-validity-error-message>custom validity error message</a> to <var>message</var>.</p>

  

  <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>&quot;text&quot;</c-> <c- e>oninput</c-><c- o>=</c-><c- s>&quot;check(this)&quot;</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>&quot;good&quot;</c-> <c- o>||</c->
       input<c- p>.</c->value <c- o>==</c-> <c- u>&quot;fine&quot;</c-> <c- o>||</c->
       input<c- p>.</c->value <c- o>==</c-> <c- u>&quot;tired&quot;</c-><c- p>)</c-> <c- p>{</c->
     input<c- p>.</c->setCustomValidity<c- p>(</c-><c- t>&apos;&quot;&apos;</c-> <c- o>+</c-> input<c- p>.</c->value <c- o>+</c-> <c- t>&apos;&quot; is not a feeling.&apos;</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>&apos;&apos;</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>

  

  <p>The <dfn id=dom-cva-validity><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>

<pre><code class='idl'>[<c- g>Exposed</c->=<c- n>Window</c->]
<c- b>interface</c-> <dfn id='validitystate'><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>

  <p>A <code id=the-constraint-validation-api:validitystate-2><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 id=dom-validitystate-valuemissing><code>valueMissing</code></dfn><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> <dt><dfn id=dom-validitystate-typemismatch><code>typeMismatch</code></dfn><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> <dt><dfn id=dom-validitystate-patternmismatch><code>patternMismatch</code></dfn><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> <dt><dfn id=dom-validitystate-toolong><code>tooLong</code></dfn><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> <dt><dfn id=dom-validitystate-tooshort><code>tooShort</code></dfn><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> <dt><dfn id=dom-validitystate-rangeunderflow><code>rangeUnderflow</code></dfn><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> <dt><dfn id=dom-validitystate-rangeoverflow><code>rangeOverflow</code></dfn><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> <dt><dfn id=dom-validitystate-stepmismatch><code>stepMismatch</code></dfn><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> <dt><dfn id=dom-validitystate-badinput><code>badInput</code></dfn><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> <dt><dfn id=dom-validitystate-customerror><code>customError</code></dfn><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> <dt><dfn id=dom-validitystate-valid><code>valid</code></dfn><dd> <p>None of the other conditions are true.</p> </dl>

  <p>The <dfn id=dom-cva-checkvalidity><code>checkValidity()</code></dfn> method, when
  invoked, must run these steps:</p>

  <ol><li>
    <p>If this element is a <a href=#candidate-for-constraint-validation id=the-constraint-validation-api:candidate-for-constraint-validation-2>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 this element, 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).<li><p>Return false.</ol>

   <li><p>Return true.</ol>

  <p>The <dfn id=dom-cva-reportvalidity><code>reportValidity()</code></dfn> method, when
  invoked, must run these steps:

  <ol><li>
    <p>If this element 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-2>satisfy its constraints</a>, then:

    <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 this element, 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.<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 this element, and may change the scrolling
     position of the document, or perform some other action that brings this element to the user's
     attention. User agents may report more than one constraint violation, if this element suffers
     from multiple problems at once. If this element is not <a href=#being-rendered id=the-constraint-validation-api:being-rendered>being rendered</a>, then the
     user agent may, instead of notifying the user, <a href=#report-the-error id=the-constraint-validation-api:report-the-error>report the error</a> for the
     <a href=#running-script id=the-constraint-validation-api:running-script>running script</a>.</p>

     <li><p>Return false.</ol>

   <li><p>Return true.</ol>

  <p>The <dfn id=dom-cva-validationmessage><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-4>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.<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-5>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.</ol>

  



  <h5 id=security-forms><span class=secno>4.10.20.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.21</span> <dfn>Form submission</dfn><a href=#form-submission-2 class=self-link></a></h4>

  

  <h5 id=introduction-5><span class=secno>4.10.21.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>&quot;/find.cgi&quot;</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>&quot;/find.cgi&quot;</c-> <c- e>method</c-><c- o>=</c-><c- s>post</c-> <c- e>enctype</c-><c- o>=</c-><c- s>&quot;multipart/form-data&quot;</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.21.2</span> Implicit submission<a href=#implicit-submission class=self-link></a></h5>

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

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

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

  <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 do nothing if the form has more than one <i>field that blocks implicit
  submission</i>, and must <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 otherwise.</p>

  <p>For the purpose of the previous paragraph, an element is a <i>field that blocks implicit
  submission</i> 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="#url-state-(type=url)" id="implicit-submission:url-state-(type=url)">URL</a>,
  <a href="#telephone-state-(type=tel)" id="implicit-submission:telephone-state-(type=tel)">Telephone</a>,
  <a href="#e-mail-state-(type=email)" id="implicit-submission:e-mail-state-(type=email)">E-mail</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>

  


  

  <h5 id=form-submission-algorithm><span class=secno>4.10.21.3</span> Form submission algorithm<a href=#form-submission-algorithm class=self-link></a></h5>

  <p>When a <code id=form-submission-algorithm:the-form-element><a href=#the-form-element>form</a></code> element <var>form</var> is <dfn id=concept-form-submit>submitted</dfn> from an element <var>submitter</var>
  (typically a button), optionally with a <var>submitted from <code id=form-submission-algorithm:dom-form-submit><a href=#dom-form-submit>submit()</a></code> method</var> flag set, the user agent must run the
  following steps:</p>

  <ol><li><p>If <var>form</var> <a href=#cannot-navigate id=form-submission-algorithm:cannot-navigate>cannot navigate</a>, then return.<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>.<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.<li><p>Let <var>form browsing context</var> be the <a href=#concept-document-bc id=form-submission-algorithm:concept-document-bc>browsing
   context</a> of <var>form document</var>.<li><p>If the <var>submitted from <code id=form-submission-algorithm:dom-form-submit-2><a href=#dom-form-submit>submit()</a></code>
   method</var> flag is not set, and 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 (the constraint validation concluded that there were invalid fields and probably
   informed the user of this) then <a href=https://dom.spec.whatwg.org/#concept-event-fire id=form-submission-algorithm:concept-event-fire data-x-internal=concept-event-fire>fire an event</a> named
   <code id=form-submission-algorithm:event-invalid><a href=#event-invalid>invalid</a></code> at the <var>form</var> element and then return.<li>
    <p>If the <var>submitted from <code id=form-submission-algorithm:dom-form-submit-3><a href=#dom-form-submit>submit()</a></code> method</var> flag
    is not set, then:

    <ol><li><p>Let <var>continue</var> be the result of <a href=https://dom.spec.whatwg.org/#concept-event-fire id=form-submission-algorithm:concept-event-fire-2 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>, with 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.<li><p>If <var>continue</var> is false, then return.<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>
     </ol>

   

   

   <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><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>.<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>.<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><p><a href=#parse-a-url id=form-submission-algorithm:parse-a-url>Parse</a> the <a id=form-submission-algorithm:url href=https://url.spec.whatwg.org/#concept-url data-x-internal=url>URL</a> <var>action</var>, relative
   to the <var>submitter</var> element'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>. If this fails, return.<li><p>Let <var>parsed action</var> be the <a href=#resulting-url-record id=form-submission-algorithm:resulting-url-record>resulting URL record</a>.<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>.<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>.<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>.<li><p>Let <var>target</var> be the <var>submitter</var> element's <code id=form-submission-algorithm:attr-fs-formtarget><a href=#attr-fs-formtarget>formtarget</a></code> attribute value, if the element is a <a href=#concept-submit-button id=form-submission-algorithm:concept-submit-button>submit button</a> and has such an attribute. Otherwise, let it
   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>form owner</a>.<li><p>Let <var>target browsing context</var> and <var>replace</var> be the result of applying
   <a href=#the-rules-for-choosing-a-browsing-context-given-a-browsing-context-name id=form-submission-algorithm:the-rules-for-choosing-a-browsing-context-given-a-browsing-context-name>the rules for choosing a browsing context</a> using <var>target</var> and <var>form
   browsing context</var>.<li><p>If <var>target browsing context</var> is null, then return.<li><p>If <var>form document</var> has not yet <a href=#completely-loaded id=form-submission-algorithm:completely-loaded>completely loaded</a> and the
   <var>submitted from <code id=form-submission-algorithm:dom-form-submit-4><a href=#dom-form-submit>submit()</a></code> method</var> flag is set, then
   set <var>replace</var> to true.<li>

    <p>If the value of <var>method</var> is <a href=#attr-fs-method-dialog id=form-submission-algorithm:attr-fs-method-dialog>dialog</a> then jump to the <a href=#submit-dialog id=form-submission-algorithm:submit-dialog>submit
    dialog</a> steps.</p>

    <p>Otherwise, select the appropriate row in the table below based on the value of <var>scheme</var> as given by the first cell of each row. Then, select the appropriate cell
    on that row based on the value of <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>
      <th> <a href=#attr-fs-method-get id=form-submission-algorithm:attr-fs-method-get>GET</a>
      <th> <a href=#attr-fs-method-post id=form-submission-algorithm:attr-fs-method-post>POST</a>
     <tbody><tr><th> <code>http</code>
      <td> <a href=#submit-mutate-action id=form-submission-algorithm:submit-mutate-action>Mutate action URL</a>
      <td> <a href=#submit-body id=form-submission-algorithm:submit-body>Submit as entity body</a>
     <tr><th> <code>https</code>
      <td> <a href=#submit-mutate-action id=form-submission-algorithm:submit-mutate-action-2>Mutate action URL</a>
      <td> <a href=#submit-body id=form-submission-algorithm:submit-body-2>Submit as entity body</a>
     <tr><th> <code>ftp</code>
      <td> <a href=#submit-get-action id=form-submission-algorithm:submit-get-action>Get action URL</a>
      <td> <a href=#submit-get-action id=form-submission-algorithm:submit-get-action-2>Get action URL</a>
     <tr><th> <code>javascript</code>
      <td> <a href=#submit-get-action id=form-submission-algorithm:submit-get-action-3>Get action URL</a>
      <td> <a href=#submit-get-action id=form-submission-algorithm:submit-get-action-4>Get action URL</a>
     <tr><th> <code>data</code>
      <td> <a href=#submit-mutate-action id=form-submission-algorithm:submit-mutate-action-3>Mutate action URL</a>
      <td> <a href=#submit-get-action id=form-submission-algorithm:submit-get-action-5>Get action URL</a>
     <tr><th> <code>mailto</code>
      <td> <a href=#submit-mailto-headers id=form-submission-algorithm:submit-mailto-headers>Mail with headers</a>
      <td> <a href=#submit-mailto-body id=form-submission-algorithm:submit-mailto-body>Mail as body</a>
    </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-2><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-3><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 particular resource <var>destination</var>, it must run the following steps:</p>

    <ol><li><p>If the <code id=form-submission-algorithm:the-form-element-4><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>.<li>

      <p>Let the <code id=form-submission-algorithm:the-form-element-5><a href=#the-form-element>form</a></code>'s <a href=#planned-navigation id=form-submission-algorithm:planned-navigation-3>planned navigation</a> be a new <a href=#concept-task id=form-submission-algorithm:concept-task-2>task</a> that consists of running the following steps:</p>

      <ol><li><p>Let the <code id=form-submission-algorithm:the-form-element-6><a href=#the-form-element>form</a></code>'s <a href=#planned-navigation id=form-submission-algorithm:planned-navigation-4>planned navigation</a> be null.<li><p><a href=#navigate id=form-submission-algorithm:navigate>Navigate</a> <var>target browsing context</var> to
       <var>destination</var>. If <var>replace</var> is true, then <var>target browsing
       context</var> must be navigated with <a href=#replacement-enabled id=form-submission-algorithm:replacement-enabled>replacement enabled</a>.</p>

      </ol>

      <p>For the purposes of this task, <var>target browsing context</var> and <var>replace</var> are the variables that were set up when the overall form submission
      algorithm was run, with their values as they stood when this <a href=#planned-navigation id=form-submission-algorithm:planned-navigation-5>planned navigation</a>
      was <a href=#queue-a-task id=form-submission-algorithm:queue-a-task>queued</a>.</p>

     <li>

      <p><a href=#queue-a-task id=form-submission-algorithm:queue-a-task-2>Queue the task</a> that is the <code id=form-submission-algorithm:the-form-element-7><a href=#the-form-element>form</a></code>'s new
      <a href=#planned-navigation id=form-submission-algorithm:planned-navigation-6>planned navigation</a>.</p>

      <p>The <a href=#task-source id=form-submission-algorithm:task-source>task source</a> for this task is the <a href=#dom-manipulation-task-source id=form-submission-algorithm:dom-manipulation-task-source>DOM manipulation task
      source</a>.</p>

     </ol>

    <p>The behaviors are as follows:</p>

    <dl><dt><dfn id=submit-mutate-action>Mutate action URL</dfn>
     <dd>

      <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>entry
      list</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>

     <dt><dfn id=submit-body>Submit as entity body</dfn>
     <dd>
      <p>Switch on <var>enctype</var>:

      <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><dd>
        <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>entry
        list</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>MIME type</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>
       <dt><code id=form-submission-algorithm:attr-fs-enctype-formdata><a href=#attr-fs-enctype-formdata>multipart/form-data</a></code><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>MIME type</var> be the concatenation of the string "<code>multipart/form-data;</code>", a U+0020 SPACE character, the string "<code>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>
       <dt><code id=form-submission-algorithm:attr-fs-enctype-text><a href=#attr-fs-enctype-text>text/plain</a></code><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><code>text/plain</code>
        encoding algorithm</a> with <var>entry list</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>MIME type</var> be "<code>text/plain</code>".</p>
       </dl>

      <p><a href=#plan-to-navigate id=form-submission-algorithm:plan-to-navigate-2>Plan to navigate</a> to a new <a href=https://fetch.spec.whatwg.org/#concept-request id=form-submission-algorithm:concept-request data-x-internal=concept-request>request</a> whose
      <a href=https://fetch.spec.whatwg.org/#concept-request-url id=form-submission-algorithm:concept-request-url data-x-internal=concept-request-url>url</a> is <var>parsed action</var>, <a href=https://fetch.spec.whatwg.org/#concept-request-method id=form-submission-algorithm:concept-request-method data-x-internal=concept-request-method>method</a> is <var>method</var>, <a href=https://fetch.spec.whatwg.org/#concept-request-header-list id=form-submission-algorithm:concept-request-header-list data-x-internal=concept-request-header-list>header list</a> consists of `<code>Content-Type</code>`/<var>MIME type</var>, and <a href=https://fetch.spec.whatwg.org/#concept-request-body id=form-submission-algorithm:concept-request-body data-x-internal=concept-request-body>body</a> is <var>body</var>.</p>

     <dt><dfn id=submit-get-action>Get action URL</dfn>
     <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>

     <dt><dfn id=submit-mailto-headers>Mail with headers</dfn>
     <dd>
      <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>entry
      list</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>
     <dt><dfn id=submit-mailto-body>Mail as body</dfn>
     <dd>
      <p>Switch on <var>enctype</var>:

      <dl class=switch><dt><code id=form-submission-algorithm:attr-fs-enctype-text-2><a href=#attr-fs-enctype-text>text/plain</a></code><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>entry list</var>.</p>

        <p>Set <var>body</var> to the result of concatenating the result of <a href=https://url.spec.whatwg.org/#utf-8-percent-encode id=form-submission-algorithm:utf-8-percent-encode data-x-internal=utf-8-percent-encode>UTF-8 percent encoding</a> each code point in <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>
       <dt>Otherwise<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>entry
       list</var> and <var>encoding</var>.</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>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>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>
     <dt><dfn id=submit-dialog>Submit dialog</dfn>
     <dd>

      <p>Let <var>subject</var> be the nearest ancestor <code id=form-submission-algorithm:the-dialog-element><a href=#the-dialog-element>dialog</a></code> element of <var>form</var>, if any.</p>

      <p>If there isn't one, or if it does not have an <code id=form-submission-algorithm:attr-dialog-open><a href=#attr-dialog-open>open</a></code>
      attribute, do nothing. Otherwise, proceed as follows:</p>

      <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 let <var>result</var>
      be the string formed by concatenating the <a href=#concept-input-type-image-coordinate id=form-submission-algorithm:concept-input-type-image-coordinate>selected coordinate</a>'s <var>x</var>-component, expressed as a base-ten number using <a id=form-submission-algorithm:ascii-digits href=https://infra.spec.whatwg.org/#ascii-digit data-x-internal=ascii-digits>ASCII digits</a>, a
      U+002C COMMA character (,), and the <a href=#concept-input-type-image-coordinate id=form-submission-algorithm:concept-input-type-image-coordinate-2>selected
      coordinate</a>'s <var>y</var>-component, expressed in the same way as the <var>x</var>-component.</p>

      <p>Otherwise, if <var>submitter</var> has a <a href=#concept-fe-value id=form-submission-algorithm:concept-fe-value>value</a>, then let <var>result</var> be that <a href=#concept-fe-value id=form-submission-algorithm:concept-fe-value-2>value</a>.</p>

      <p>Otherwise, there is no <var>result</var>.</p>

      <p>Then, <a href=#close-the-dialog id=form-submission-algorithm:close-the-dialog>close the dialog</a> <var>subject</var>. If there is a <var>result</var>, let that be the return value.</p>

     </dl>

   </ol>


  <h5 id=constructing-form-data-set><span class=secno>4.10.21.4</span> Constructing the entry list<a href=#constructing-form-data-set class=self-link></a></h5>

  <p>The algorithm 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>, and an optional <var>encoding</var>, is as
  follows. If not specified otherwise, <var>submitter</var> is null.</p>

  <ol><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>.<li><p>Let <var>entry list</var> be a new empty <a id=constructing-form-data-set:list href=https://infra.spec.whatwg.org/#list data-x-internal=list>list</a> of <a href=https://xhr.spec.whatwg.org/#concept-formdata-entry id=constructing-form-data-set:formdata-entry data-x-internal=formdata-entry>entries</a>.<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 is true:</p>

      <ul><li>The <var>field</var> element has a <code id=constructing-form-data-set:the-datalist-element><a href=#the-datalist-element>datalist</a></code> element ancestor.<li>The <var>field</var> element is <a href=#concept-fe-disabled id=constructing-form-data-set:concept-fe-disabled>disabled</a>.<li>The <var>field</var> element is a <a href=#concept-button id=constructing-form-data-set:concept-button>button</a> but
       it is not <var>submitter</var>.<li>The <var>field</var> element 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.<li>The <var>field</var> element 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.<li>The <var>field</var> element is not 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, and either the <var>field</var> element does not have a <code id=constructing-form-data-set:attr-fe-name><a href=#attr-fe-name>name</a></code> attribute
       specified, or its <code id=constructing-form-data-set:attr-fe-name-2><a href=#attr-fe-name>name</a></code> attribute's value is the empty
       string.<li>The <var>field</var> element is an <code id=constructing-form-data-set:the-object-element><a href=#the-object-element>object</a></code> element that is not using
       a <a href=#plugin id=constructing-form-data-set:plugin>plugin</a>.</ul>

      <p>Then continue.</p>
     <li>
      <p>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="#image-button-state-(type=image)" id="constructing-form-data-set:image-button-state-(type=image)-2">Image Button</a> state, then:</p>

      <ol><li><p>If the <var>field</var> element has a <code id=constructing-form-data-set:attr-fe-name-3><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 a single U+002E FULL STOP character (.). Otherwise, let <var>name</var> be the empty string.<li><p>Let <var>name<sub>x</sub></var> be the string consisting of the
       concatenation of <var>name</var> and a single U+0078 LATIN SMALL LETTER X character
       (x).<li><p>Let <var>name<sub>y</sub></var> be the string consisting of the
       concatenation of <var>name</var> and a single U+0079 LATIN SMALL LETTER Y character
       (y).<li><p>The <var>field</var> element is <var>submitter</var>, and before
       this algorithm was invoked the user <a href=#concept-input-type-image-coordinate id=constructing-form-data-set:concept-input-type-image-coordinate>indicated a coordinate</a>. Let <var>x</var> be the <var>x</var>-component of the coordinate selected by the
       user, and let <var>y</var> be the <var>y</var>-component of the coordinate
       selected by the user.<li><p><a href=#append-an-entry id=constructing-form-data-set:append-an-entry>Append an entry</a> to <var>entry list</var> with <var>name<sub>x</sub></var>
       and <var>x</var>.<li><p><a href=#append-an-entry id=constructing-form-data-set:append-an-entry-2>Append an entry</a> to <var>entry list</var> with <var>name<sub>y</sub></var>
       and <var>y</var>.<li><p>Continue.</ol>
     <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.<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=#append-an-entry id=constructing-form-data-set:append-an-entry-3>append an entry</a> to <var>entry
     list</var> 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.<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="#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>".<li><p><a href=#append-an-entry id=constructing-form-data-set:append-an-entry-4>Append an entry</a> to <var>entry list</var> with <var>name</var> and
       <var>value</var>.</ol>
     <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="#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=#append-an-entry id=constructing-form-data-set:append-an-entry-5>append an entry</a> to <var>entry list</var> with <var>name</var> and a new
       <code id=constructing-form-data-set:file><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://tools.ietf.org/html/rfc2046#section-4.5.1>application/octet-stream</a></code> as type,
       and an empty body.</p>
       

       <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=#append-an-entry id=constructing-form-data-set:append-an-entry-6>append an entry</a> to <var>entry list</var> with <var>name</var> and
       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 representing the file.</p>
      </ol>
     <li><p>Otherwise, if the <var>field</var> element is an <code id=constructing-form-data-set:the-object-element-2><a href=#the-object-element>object</a></code> element:
     try to obtain a form submission value from the <a href=#plugin id=constructing-form-data-set:plugin-2>plugin</a>, and if that is successful,
     <a href=#append-an-entry id=constructing-form-data-set:append-an-entry-7>append an entry</a> to <var>entry list</var> with <var>name</var> and the returned
     form submission value.<li>
      <p>Otherwise, if the <var>field</var> element is an <code id=constructing-form-data-set:the-input-element-7><a href=#the-input-element>input</a></code> element whose <code id=constructing-form-data-set:attr-input-type-7><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 "<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> if <var>encoding</var> is given, and "<code>UTF-8</code>"
       otherwise.<li><p><a href=#append-an-entry id=constructing-form-data-set:append-an-entry-8>Append an entry</a> to <var>entry list</var> with <var>name</var> and
       <var>charset</var>.</ol>
     <li>
      <p>Otherwise, if the <var>field</var> element is a <code id=constructing-form-data-set:the-textarea-element><a href=#the-textarea-element>textarea</a></code> element, <a href=#append-an-entry id=constructing-form-data-set:append-an-entry-9>append
      an entry</a> to <var>entry list</var> 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 the <var>prevent
      line break normalization flag</var> set.</p>

      <p class=note>In the case of the <a href=#concept-fe-value id=constructing-form-data-set:concept-fe-value-2>value</a> of
      <code id=constructing-form-data-set:the-textarea-element-2><a href=#the-textarea-element>textarea</a></code> elements, the line break normalization is already performed during the
      conversion of the control's <a href=#concept-textarea-raw-value id=constructing-form-data-set:concept-textarea-raw-value>raw value</a> into
      the control's <a href=#concept-fe-value id=constructing-form-data-set:concept-fe-value-3>value</a> (which also performs any necessary
      line wrapping).</p>
     <li><p>Otherwise, <a href=#append-an-entry id=constructing-form-data-set:append-an-entry-10>append an entry</a> to <var>entry list</var> with <var>name</var>
     and the <a href=#concept-fe-value id=constructing-form-data-set:concept-fe-value-4>value</a> of the <var>field</var> element.<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, and that
      attribute's value is not the empty string, then:</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.<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>').<li><p><a href=#append-an-entry id=constructing-form-data-set:append-an-entry-11>Append an entry</a> to <var>entry list</var> with <var>dirname</var> and
       <var>dir</var>.</ol>

      <p class=note>An element can only have a <code id=constructing-form-data-set:attr-fe-dirname-3><a href=#attr-fe-dirname>dirname</a></code>
      attribute if it is a <code id=constructing-form-data-set:the-textarea-element-3><a href=#the-textarea-element>textarea</a></code> element or an <code id=constructing-form-data-set:the-input-element-8><a href=#the-input-element>input</a></code> element whose
      <code id=constructing-form-data-set:attr-input-type-8><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="constructing-form-data-set: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="constructing-form-data-set:text-(type=text)-state-and-search-state-(type=search)-2">Search</a> state.</p>
     </ol>
   <li><p>Return <var>entry list</var>.</ol>

  <p>To <dfn id=append-an-entry>append an entry</dfn> to <var>entry list</var>, given <var>name</var>,
  <var>value</var>, and optional <var>prevent line break normalization flag</var>, run these
  steps:</p>

  <ol><li><p>For <var>name</var>, 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), by a string consisting of a
   U+000D (CR) and U+000A (LF).<li><p>Replace <var>name</var> with the result of <a id=constructing-form-data-set:converting-to-a-sequence-of-unicode-scalar-values href=https://heycam.github.io/webidl/#dfn-obtain-unicode data-x-internal=converting-to-a-sequence-of-unicode-scalar-values>converting to a sequence of Unicode
   scalar values</a>.<li>
    <p>If <var>value</var> is not a <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, then:</p>

    <ol><li><p>If the <var>prevent line break normalization flag</var> is unset, 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>value</var>, by a string consisting of a U+000D (CR) and
     U+000A (LF).<li><p>Replace <var>value</var> with the result of <a id=constructing-form-data-set:converting-to-a-sequence-of-unicode-scalar-values-2 href=https://heycam.github.io/webidl/#dfn-obtain-unicode data-x-internal=converting-to-a-sequence-of-unicode-scalar-values>converting to a sequence of Unicode
     scalar values</a>.</ol>
   <li><p><a id=constructing-form-data-set:create-an-entry href=https://xhr.spec.whatwg.org/#create-an-entry data-x-internal=create-an-entry>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 data-x-internal=list-append>append</a> it to <var>entry list</var>.</ol>

  


  

  <h5 id=selecting-a-form-submission-encoding><span class=secno>4.10.21.5</span> Selecting a form submission encoding<a href=#selecting-a-form-submission-encoding class=self-link></a></h5>

  <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>.<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.<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>.<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>.<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>.<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>.<li><p>Return the first encoding in <var>candidate encodings</var>.</ol>
   <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>.</ol>

  


  <h5 id=url-encoded-form-data><span class=secno>4.10.21.6</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 the WHATWG URL standard 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.21.7</span> Multipart form data<a href=#multipart-form-data class=self-link></a></h5>

  

  

  

  <p>The <dfn id=multipart/form-data-encoding-algorithm data-export=""><code>multipart/form-data</code> encoding algorithm</dfn>, given an
  <var>entry list</var> and <var>encoding</var>, is as follows:</p>

  <ol><li><p>Let <var>result</var> be the empty string.<li>

    <p>For each <a href=https://xhr.spec.whatwg.org/#concept-formdata-entry id=multipart-form-data:formdata-entry data-x-internal=formdata-entry>entry</a> in <var>entry list</var>:</p>

    <ol><li><p>For each character in the entry's name and value that cannot be expressed using the
     selected character encoding, replace the character by a string consisting of a U+0026 AMPERSAND
     character (&amp;), a U+0023 NUMBER SIGN character (#), one or more <a id=multipart-form-data:ascii-digits href=https://infra.spec.whatwg.org/#ascii-digit data-x-internal=ascii-digits>ASCII digits</a>
     representing the code point of the character in base ten, and finally a U+003B (;).</ol>

   <li>

    <p>Encode the (now mutated) <var>entry list</var> using the rules described by RFC 7578,
    <cite>Returning Values from Forms: <code>multipart/form-data</code></cite>, and return
    the resulting byte stream. <a href=#refsRFC7578>[RFC7578]</a></p>

    <p>Each entry in <var>entry list</var> is a <i>field</i>, the name of the entry is the <i>field
    name</i> and the value of the entry is the <i>field value</i>.</p>

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

    <p>The parts of the generated <code id=multipart-form-data:multipart/form-data><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. Their names and
    values must be encoded using the character encoding selected above.</p>

    <p>File names included in the generated <code id=multipart-form-data:multipart/form-data-2><a href=#multipart/form-data>multipart/form-data</a></code> resource (as part of
    file fields) must use the character encoding selected above, though the precise name may be
    approximated if necessary (e.g. newlines could be removed from file names, quotes could be
    changed to "%22", and characters not expressible in the selected character encoding could be
    replaced by other characters).

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

   </ol>

  

  <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.21.8</span> Plain text form data<a href=#plain-text-form-data class=self-link></a></h5>

  

  <p>The <dfn id=text/plain-encoding-algorithm><code>text/plain</code> encoding algorithm</dfn>, given an <var>entry
  list</var>, is as follows:</p>

  <ol><li><p>Let <var>result</var> be the empty string.<li>
    <p>For each <a href=https://xhr.spec.whatwg.org/#concept-formdata-entry id=plain-text-form-data:formdata-entry data-x-internal=formdata-entry>entry</a> in <var>entry list</var>:</p>

    <ol><li><p>If the entry's value is a <code id=plain-text-form-data:file><a data-x-internal=file href=https://w3c.github.io/FileAPI/#dfn-file>File</a></code> object, then set its value to the
     <code id=plain-text-form-data:file-2><a data-x-internal=file href=https://w3c.github.io/FileAPI/#dfn-file>File</a></code> object's <code id=plain-text-form-data:dom-file-name><a data-x-internal=dom-file-name href=https://w3c.github.io/FileAPI/#dfn-name>name</a></code>.<li><p>Append the entry's name to <var>result</var>.<li><p>Append a single U+003D EQUALS SIGN character (=) to <var>result</var>.<li><p>Append the entry's value to <var>result</var>.<li><p>Append a U+000D CARRIAGE RETURN (CR) U+000A LINE FEED (LF) character pair to <var>result</var>.</ol>
   <li><p>Return <var>result</var>.</ol>

  

  <p>Payloads using the <code id=plain-text-form-data:text/plain><a data-x-internal=text/plain href=https://tools.ietf.org/html/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>



  

  <h4 id=resetting-a-form><span class=secno>4.10.22</span> Resetting a form<a href=#resetting-a-form class=self-link></a></h4>

  <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.<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>.</ol>

  <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 href=#event-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><code>details</code></dfn> element<a href=#the-details-element class=self-link></a></h4><div class=status><input onclick=toggleStatus(this) value=⋰ type=button><p class=support><strong>Support:</strong> details<span class="and_chr yes"><span>Chrome for Android</span> <span>67+</span></span><span class="chrome yes"><span>Chrome</span> <span>12+</span></span><span class="ios_saf yes"><span>iOS Safari</span> <span>6.0+</span></span><span class="and_uc yes"><span>UC Browser for Android</span> <span>11.8+</span></span><span class="firefox yes"><span>Firefox</span> <span>49+</span></span><span class="ie no"><span>IE</span> <span>None</span></span><span class="safari yes"><span>Safari</span> <span>6+</span></span><span class="edge no"><span>Edge</span> <span>None</span></span><span class="samsung yes"><span>Samsung Internet</span> <span>4+</span></span><span class="opera yes"><span>Opera</span> <span>15+</span></span><span class="android yes"><span>Android Browser</span> <span>4+</span></span><p class=caniuse>Source: <a href="https://caniuse.com/#feat=details">caniuse.com</a></div>

  <dl class=element><dt><a href=#concept-element-categories id=the-details-element:concept-element-categories>Categories</a>:<dd><a href=#flow-content-2 id=the-details-element:flow-content-2>Flow content</a>.<dd><a href=#sectioning-root id=the-details-element:sectioning-root>Sectioning root</a>.<dd><a href=#interactive-content-2 id=the-details-element:interactive-content-2>Interactive content</a>.<dd><a href=#palpable-content-2 id=the-details-element:palpable-content-2>Palpable content</a>.<dt><a href=#concept-element-contexts id=the-details-element:concept-element-contexts>Contexts in which this element can be used</a>:<dd>Where <a href=#flow-content-2 id=the-details-element:flow-content-2-2>flow content</a> is expected.<dt><a href=#concept-element-content-model id=the-details-element:concept-element-content-model>Content model</a>:<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>.<dt><a href=#concept-element-tag-omission id=the-details-element:concept-element-tag-omission>Tag omission in text/html</a>:<dd>Neither tag is omissible.<dt><a href=#concept-element-attributes id=the-details-element:concept-element-attributes>Content attributes</a>:<dd><a href=#global-attributes id=the-details-element:global-attributes>Global attributes</a><dd><code id=the-details-element:attr-details-open><a href=#attr-details-open>open</a></code> — Whether the details are visible<dt><a href=#concept-element-dom id=the-details-element:concept-element-dom>DOM interface</a>:<dd>
    <pre><code class='idl'>[<c- g>Exposed</c->=<c- n>Window</c->,
 <a href='#htmlconstructor' id='the-details-element:htmlconstructor'><c- g>HTMLConstructor</c-></a>]
<c- b>interface</c-> <dfn id='htmldetailselement'><c- g>HTMLDetailsElement</c-></dfn> : <a href='#htmlelement' id='the-details-element:htmlelement'><c- n>HTMLElement</c-></a> {
  [<a href='#cereactions' id='the-details-element:cereactions'><c- g>CEReactions</c-></a>] <c- b>attribute</c-> <c- b>boolean</c-> <a href='#dom-details-open' id='the-details-element:dom-details-open'><c- g>open</c-></a>;
};</code></pre>
   </dl>

  <p>The <code id=the-details-element:the-details-element><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>The <code id=the-details-element:the-details-element-2><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 id=attr-details-open><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-2><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-3><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>

  <p>Whenever the <code id=the-details-element:attr-details-open-4><a href=#attr-details-open>open</a></code> attribute is added to or removed from
  a <code id=the-details-element:the-details-element-3><a href=#the-details-element>details</a></code> element, the user agent must <a href=#queue-a-task id=the-details-element:queue-a-task>queue a task</a> that runs 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-4><a href=#the-details-element>details</a></code> element:</p>

  <ol><li>

    <p>If another <a href=#concept-task id=the-details-element:concept-task>task</a> has been <a href=#queue-a-task id=the-details-element:queue-a-task-2>queued</a> to run the <a href=#details-notification-task-steps id=the-details-element:details-notification-task-steps>details notification task steps</a> for this
    <code id=the-details-element:the-details-element-5><a href=#the-details-element>details</a></code> element, then return.</p>

    <p class=note>When the <code id=the-details-element:attr-details-open-5><a href=#attr-details-open>open</a></code> attribute is toggled
    several times in succession, these steps essentially get coalesced so that only one event is
    fired.</p>

   <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 the <code id=the-details-element:the-details-element-6><a href=#the-details-element>details</a></code> element.</ol>

  <p>The <a href=#task-source id=the-details-element:task-source>task source</a> for this task must be the <a href=#dom-manipulation-task-source id=the-details-element:dom-manipulation-task-source>DOM manipulation task
  source</a>.</p>

  <p>The <dfn id=dom-details-open><code>open</code></dfn> IDL attribute must
  <a href=#reflect id=the-details-element:reflect>reflect</a> the <code id=the-details-element:attr-details-open-6><a href=#attr-details-open>open</a></code> content attribute.</p>

  

  <div class=example>

   <p>The following example shows the <code id=the-details-element:the-details-element-7><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>&quot;progress window&quot;</c-><c- p>&gt;</c->
 <c- p>&lt;</c-><c- f>h1</c-><c- p>&gt;</c->Copying &quot;Really Achieving Your Childhood Dreams&quot;<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>&quot;375505392&quot;</c-> <c- e>value</c-><c- o>=</c-><c- s>&quot;97543282&quot;</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-8><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>&quot;Pillar Magazine.pdf&quot;</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-9><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 class=example>

   <p>Because the <code id=the-details-element:attr-details-open-7><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><code>summary</code></dfn> element<a href=#the-summary-element class=self-link></a></h4>

  <dl class=element><dt><a href=#concept-element-categories id=the-summary-element:concept-element-categories>Categories</a>:<dd>None.<dt><a href=#concept-element-contexts id=the-summary-element:concept-element-contexts>Contexts in which this element can be used</a>:<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.<dt><a href=#concept-element-content-model id=the-summary-element:concept-element-content-model>Content model</a>:<dd>Either: <a href=#phrasing-content-2 id=the-summary-element:phrasing-content-2>phrasing content</a>.<dd>Or: one element of <a href=#heading-content-2 id=the-summary-element:heading-content-2>heading content</a>.<dt><a href=#concept-element-tag-omission id=the-summary-element:concept-element-tag-omission>Tag omission in text/html</a>:<dd>Neither tag is omissible.<dt><a href=#concept-element-attributes id=the-summary-element:concept-element-attributes>Content attributes</a>:<dd><a href=#global-attributes id=the-summary-element:global-attributes>Global attributes</a><dt><a href=#concept-element-dom id=the-summary-element:concept-element-dom>DOM interface</a>:<dd>Uses <code id=the-summary-element:htmlelement><a href=#htmlelement>HTMLElement</a></code>.</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>

  

  <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-3><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-4><a href=#the-summary-element>summary</a></code> element has no parent node, then return.<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 node.</p>

   <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.</p>

   <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.<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>
   </ol>

  




  <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><dd>The name of the command as seen by the user.<dt><dfn id=command-facet-accesskey>Access Key</dfn><dd>A key combination selected by the user agent that triggers the command. A command might not
   have an Access Key.<dt><dfn id=command-facet-hiddenstate>Hidden State</dfn><dd>Whether the command is hidden or not (basically, whether it should be shown in menus).<dt><dfn id=command-facet-disabledstate>Disabled State</dfn><dd>Whether the command is relevant and can be triggered or not.<dt><dfn id=command-facet-action>Action</dfn><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.</dl>

  <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 class=brief><li>The <a href=#command-facet-hiddenstate id=facets-2:command-facet-hiddenstate>Hidden State</a> facet is false (visible)<li>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> that has an associated <a href=#concept-document-bc id=facets-2:concept-document-bc>browsing context</a>.<li>Neither the element nor any of its ancestors has a <code id=facets-2:the-hidden-attribute><a href=#the-hidden-attribute>hidden</a></code>
   attribute specified.</ul>

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

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

  <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 string given by the
  element's <code id=using-the-a-element-to-define-a-command:textcontent><a data-x-internal=textcontent href=https://dom.spec.whatwg.org/#dom-node-textcontent>textContent</a></code> IDL attribute.</p>

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

  <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:the-hidden-attribute><a href=#the-hidden-attribute>hidden</a></code> attribute, and false otherwise.</p>

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

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


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

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

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

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


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

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

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

  <ul><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.<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 string given by the
    <code id=using-the-input-element-to-define-a-command:textcontent><a data-x-internal=textcontent href=https://dom.spec.whatwg.org/#dom-node-textcontent>textContent</a></code> 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 DOM terms, this is the
    string given by <code><var>element</var>.labels[0].textContent</code>.)<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.<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.</ul>

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

  <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:the-hidden-attribute><a href=#the-hidden-attribute>hidden</a></code> attribute, and false otherwise.</p>

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

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


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

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

  <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 value of <code id=using-the-option-element-to-define-a-command:the-option-element-3><a href=#the-option-element>option</a></code> element's <code id=using-the-option-element-to-define-a-command:textcontent><a data-x-internal=textcontent href=https://dom.spec.whatwg.org/#dom-node-textcontent>textContent</a></code> IDL attribute,
  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>

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

  <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:the-hidden-attribute><a href=#the-hidden-attribute>hidden</a></code> attribute, and false otherwise.</p>

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

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


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

  <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>.<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.<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>.</ul>

  <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 string given by the
  element's <code id=using-the-accesskey-attribute-on-a-legend-element-to-define-a-command:textcontent><a data-x-internal=textcontent href=https://dom.spec.whatwg.org/#dom-node-textcontent>textContent</a></code> IDL attribute.</p>

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

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

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

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

  <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 <code id=using-the-accesskey-attribute-to-define-a-command-on-other-elements:textcontent><a data-x-internal=textcontent href=https://dom.spec.whatwg.org/#dom-node-textcontent>textContent</a></code> 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 DOM terms, this is
  the string given by <code><var>element</var>.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 <code id=using-the-accesskey-attribute-to-define-a-command-on-other-elements:textcontent-2><a data-x-internal=textcontent href=https://dom.spec.whatwg.org/#dom-node-textcontent>textContent</a></code> of the element
  itself.</p>

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

  <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:the-hidden-attribute><a href=#the-hidden-attribute>hidden</a></code> attribute, and false otherwise.</p>

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

  <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><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.</ol>

  


  <h4 id=the-dialog-element><span class=secno>4.11.4</span> The <dfn><code>dialog</code></dfn> element<a href=#the-dialog-element class=self-link></a></h4><div class=status><input onclick=toggleStatus(this) value=⋰ type=button><p class=support><strong>Support:</strong> dialog<span class="and_chr yes"><span>Chrome for Android</span> <span>67+</span></span><span class="chrome yes"><span>Chrome</span> <span>37+</span></span><span class="ios_saf no"><span>iOS Safari</span> <span>None</span></span><span class="and_uc yes"><span>UC Browser for Android</span> <span>11.8+</span></span><span class="firefox no"><span>Firefox</span> <span>None</span></span><span class="ie no"><span>IE</span> <span>None</span></span><span class="op_mini no"><span>Opera Mini</span> <span>None</span></span><span class="safari no"><span>Safari</span> <span>None</span></span><span class="edge no"><span>Edge</span> <span>None</span></span><span class="samsung yes"><span>Samsung Internet</span> <span>4+</span></span><span class="opera yes"><span>Opera</span> <span>24+</span></span><span class="android yes"><span>Android Browser</span> <span>67+</span></span><p class=caniuse>Source: <a href="https://caniuse.com/#feat=dialog">caniuse.com</a></div>

  <dl class=element><dt><a href=#concept-element-categories id=the-dialog-element:concept-element-categories>Categories</a>:<dd><a href=#flow-content-2 id=the-dialog-element:flow-content-2>Flow content</a>.<dd><a href=#sectioning-root id=the-dialog-element:sectioning-root>Sectioning root</a>.<dt><a href=#concept-element-contexts id=the-dialog-element:concept-element-contexts>Contexts in which this element can be used</a>:<dd>Where <a href=#flow-content-2 id=the-dialog-element:flow-content-2-2>flow content</a> is expected.<dt><a href=#concept-element-content-model id=the-dialog-element:concept-element-content-model>Content model</a>:<dd><a href=#flow-content-2 id=the-dialog-element:flow-content-2-3>Flow content</a>.<dt><a href=#concept-element-tag-omission id=the-dialog-element:concept-element-tag-omission>Tag omission in text/html</a>:<dd>Neither tag is omissible.<dt><a href=#concept-element-attributes id=the-dialog-element:concept-element-attributes>Content attributes</a>:<dd><a href=#global-attributes id=the-dialog-element:global-attributes>Global attributes</a><dd><code id=the-dialog-element:attr-dialog-open><a href=#attr-dialog-open>open</a></code> — Whether the dialog box is showing<dt><a href=#concept-element-dom id=the-dialog-element:concept-element-dom>DOM interface</a>:<dd>
    <pre><code class='idl'>[<c- g>Exposed</c->=<c- n>Window</c->,
 <a href='#htmlconstructor' id='the-dialog-element:htmlconstructor'><c- g>HTMLConstructor</c-></a>]
<c- b>interface</c-> <dfn id='htmldialogelement'><c- g>HTMLDialogElement</c-></dfn> : <a href='#htmlelement' id='the-dialog-element:htmlelement'><c- n>HTMLElement</c-></a> {
  [<a href='#cereactions' id='the-dialog-element:cereactions'><c- g>CEReactions</c-></a>] <c- b>attribute</c-> <c- b>boolean</c-> <a href='#dom-dialog-open' id='the-dialog-element:dom-dialog-open'><c- g>open</c-></a>;
  <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>] <c- b>void</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-3'><c- g>CEReactions</c-></a>] <c- b>void</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-4'><c- g>CEReactions</c-></a>] <c- b>void</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->);
};</code></pre>
   </dl>

  <p>The <code id=the-dialog-element:the-dialog-element><a href=#the-dialog-element>dialog</a></code> element represents a part of an application that a user interacts with
  to perform a task, for example a dialog box, inspector, or window.</p>

  <p>The <dfn id=attr-dialog-open><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-2><a href=#the-dialog-element>dialog</a></code> element is active and
  that the user can interact with it.</p>

  

  <p>A <code id=the-dialog-element:the-dialog-element-3><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 class=note>
   <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:

   <ul><li><p>The <code id=the-dialog-element:event-close><a href=#event-close>close</a></code> event will not be fired.<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=#canceling-dialogs>user-agent provided cancelation interface</a>, will no longer be able
    to close the dialog.<li><p>If the dialog was shown using its <code id=the-dialog-element:dom-dialog-showmodal-2><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>.</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-close-3><a href=#dom-dialog-close>close()</a></code> method to close the dialog, or the <code id=the-dialog-element:the-hidden-attribute><a href=#the-hidden-attribute>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-4><a href=#the-dialog-element>dialog</a></code> elements.</p>


  <dl class=domintro><dt><var>dialog</var> . <code id=dom-dialog-show-dev><a href=#dom-dialog-show>show</a></code>()<dd>

    <p>Displays the <code id=the-dialog-element:the-dialog-element-5><a href=#the-dialog-element>dialog</a></code> element.</p>

   <dt><var>dialog</var> . <code id=dom-dialog-showmodal-dev><a href=#dom-dialog-showmodal>showModal</a></code>()<dd>

    <p>Displays the <code id=the-dialog-element:the-dialog-element-6><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><a href=#attr-fe-autofocus>autofocus</a></code> attribute.</p>

   <dt><var>dialog</var> . <code id=dom-dialog-close-dev><a href=#dom-dialog-close>close</a></code>( [ <var>result</var> ] )<dd>

    <p>Closes the <code id=the-dialog-element:the-dialog-element-7><a href=#the-dialog-element>dialog</a></code> element.</p>

    <p>The argument, if provided, provides a return value.</p>

   <dt><var>dialog</var> . <code id=dom-dialog-returnvalue-dev><a href=#dom-dialog-returnvalue>returnValue</a></code> [ = <var>result</var> ]<dd>

    <p>Returns the <code id=the-dialog-element:the-dialog-element-8><a href=#the-dialog-element>dialog</a></code>'s return value.</p>

    <p>Can be set, to update the return value.</p>

   </dl>



  

  <p>When the <dfn id=dom-dialog-show><code>show()</code></dfn> method is invoked, the user
  agent must run the following steps:</p>

  <ol><li><p>If the element already has an <code id=the-dialog-element:attr-dialog-open-5><a href=#attr-dialog-open>open</a></code> attribute, then
   return.<li><p>Add an <code id=the-dialog-element:attr-dialog-open-6><a href=#attr-dialog-open>open</a></code> attribute to the <code id=the-dialog-element:the-dialog-element-9><a href=#the-dialog-element>dialog</a></code>
   element, whose value is the empty string.<li><p>Set the <code id=the-dialog-element:the-dialog-element-10><a href=#the-dialog-element>dialog</a></code> to the <a href=#normal-alignment id=the-dialog-element:normal-alignment>normal alignment</a> mode.<li><p>Run the <a href=#dialog-focusing-steps id=the-dialog-element:dialog-focusing-steps>dialog focusing steps</a> for the <code id=the-dialog-element:the-dialog-element-11><a href=#the-dialog-element>dialog</a></code> element.</ol>

  <p>When the <dfn id=dom-dialog-showmodal><code>showModal()</code></dfn> method is invoked,
  the user agent must run the following steps:</p>

  <ol><li><p>Let <var>subject</var> be the <code id=the-dialog-element:the-dialog-element-12><a href=#the-dialog-element>dialog</a></code> element on which the method was
   invoked.<li><p>If <var>subject</var> already has an <code id=the-dialog-element:attr-dialog-open-7><a href=#attr-dialog-open>open</a></code>
   attribute, then throw an <a id=the-dialog-element:invalidstateerror href=https://heycam.github.io/webidl/#invalidstateerror data-x-internal=invalidstateerror>"<code>InvalidStateError</code>"</a> <code id=the-dialog-element:domexception><a data-x-internal=domexception href=https://heycam.github.io/webidl/#dfn-DOMException>DOMException</a></code>.<li><p>If <var>subject</var> is not <a id=the-dialog-element:connected href=https://dom.spec.whatwg.org/#connected data-x-internal=connected>connected</a>, then throw an
   <a id=the-dialog-element:invalidstateerror-2 href=https://heycam.github.io/webidl/#invalidstateerror data-x-internal=invalidstateerror>"<code>InvalidStateError</code>"</a> <code id=the-dialog-element:domexception-2><a data-x-internal=domexception href=https://heycam.github.io/webidl/#dfn-DOMException>DOMException</a></code>.<li><p>Add an <code id=the-dialog-element:attr-dialog-open-8><a href=#attr-dialog-open>open</a></code> attribute to <var>subject</var>, whose value is the empty string.<li><p>Set the <code id=the-dialog-element:the-dialog-element-13><a href=#the-dialog-element>dialog</a></code> to the <a href=#centered-alignment id=the-dialog-element:centered-alignment>centered alignment</a> mode.<li><p>Let <var>subject</var>'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> 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>.<li><p>If <var>subject</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>'s <a id=the-dialog-element:top-layer href=https://fullscreen.spec.whatwg.org/#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 data-x-internal=list-contains>contain</a> <var>subject</var>, then <a href=https://fullscreen.spec.whatwg.org/#top-layer-add id=the-dialog-element:top-layer-add data-x-internal=top-layer-add>add</a> <var>subject</var> to <var>subject</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-2 href=https://fullscreen.spec.whatwg.org/#top-layer data-x-internal=top-layer>top layer</a>.<li><p>Run the <a href=#dialog-focusing-steps id=the-dialog-element:dialog-focusing-steps-2>dialog focusing steps</a> for <var>subject</var>.</ol>

  <p>The <dfn id=dialog-focusing-steps>dialog focusing steps</dfn> for a <code id=the-dialog-element:the-dialog-element-14><a href=#the-dialog-element>dialog</a></code> element <var>subject</var> are as follows:</p>

  <ol><li><p>If <var>subject</var> is <a href=#inert id=the-dialog-element:inert>inert</a>, return.<li>

    <p>Let <var>control</var> be the first descendant element of <var>subject</var>, in <a id=the-dialog-element:tree-order href=https://dom.spec.whatwg.org/#concept-tree-order data-x-internal=tree-order>tree
    order</a>, that is not <a href=#inert id=the-dialog-element:inert-2>inert</a> and has the <code id=the-dialog-element:attr-fe-autofocus-2><a href=#attr-fe-autofocus>autofocus</a></code> attribute specified.</p>

    <p>If there isn't one, then let <var>control</var> be the first non-<a href=#inert id=the-dialog-element:inert-3>inert</a>
    descendant element of <var>subject</var>, in tree order.

    <p>If there isn't one of those either, then let <var>control</var> be <var>subject</var>.</p>

   <li><p>Run the <a href=#focusing-steps id=the-dialog-element:focusing-steps>focusing steps</a> for <var>control</var>.</ol>

  <p>If at any time a <code id=the-dialog-element:the-dialog-element-15><a href=#the-dialog-element>dialog</a></code> element is <a href=#remove-an-element-from-a-document id=the-dialog-element:remove-an-element-from-a-document>removed from a <code>Document</code></a>, then if that <code id=the-dialog-element:the-dialog-element-16><a href=#the-dialog-element>dialog</a></code> is in that
  <code id=the-dialog-element:document-2><a href=#document>Document</a></code>'s <a id=the-dialog-element:top-layer-3 href=https://fullscreen.spec.whatwg.org/#top-layer data-x-internal=top-layer>top layer</a>, it must be <a href=https://infra.spec.whatwg.org/#list-remove id=the-dialog-element:list-remove data-x-internal=list-remove>removed</a> from it.</p>

  <p>When the <dfn id=dom-dialog-close><code>close()</code></dfn> method is invoked, the user
  agent must <a href=#close-the-dialog id=the-dialog-element:close-the-dialog>close the dialog</a> that the method was invoked on. If the method was invoked
  with an argument, that argument must be used as the return value; otherwise, there is no return
  value.</p>


  <p>When a <code id=the-dialog-element:the-dialog-element-17><a href=#the-dialog-element>dialog</a></code> element <var>subject</var> is to be <dfn id=close-the-dialog>closed</dfn>, optionally with a return value <var>result</var>, the user agent
  must run the following steps:</p>

  <ol><li><p>If <var>subject</var> does not have an <code id=the-dialog-element:attr-dialog-open-9><a href=#attr-dialog-open>open</a></code>
   attribute, then return.<li><p>Remove <var>subject</var>'s <code id=the-dialog-element:attr-dialog-open-10><a href=#attr-dialog-open>open</a></code>
   attribute.<li><p>If the argument <var>result</var> was provided, then set the <code id=the-dialog-element:dom-dialog-returnvalue-2><a href=#dom-dialog-returnvalue>returnValue</a></code> attribute to the value of <var>result</var>.<li><p>If <var>subject</var> is in its <code id=the-dialog-element:document-3><a href=#document>Document</a></code>'s <a id=the-dialog-element:top-layer-4 href=https://fullscreen.spec.whatwg.org/#top-layer data-x-internal=top-layer>top layer</a>, then <a href=https://infra.spec.whatwg.org/#list-remove id=the-dialog-element:list-remove-2 data-x-internal=list-remove>remove</a> it.<li><p><a href=#queue-a-task id=the-dialog-element:queue-a-task>Queue a task</a> to <a href=https://dom.spec.whatwg.org/#concept-event-fire id=the-dialog-element:concept-event-fire data-x-internal=concept-event-fire>fire an event</a> named
   <code id=the-dialog-element:event-close-2><a href=#event-close>close</a></code> at <var>subject</var>.</ol>

  <p>The <dfn id=dom-dialog-returnvalue><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>

  <hr>

  <p id=canceling-dialogs><strong>Canceling dialogs</strong>: When <code id=the-dialog-element:document-4><a href=#document>Document</a></code> is
  <a href=#blocked-by-a-modal-dialog id=the-dialog-element:blocked-by-a-modal-dialog-3>blocked by a modal dialog</a> <var>dialog</var>, user agents may provide a user interface
  that, upon activation, <a href=#queue-a-task id=the-dialog-element:queue-a-task-2>queues a task</a> to run these steps:

  <ol><li><p>Let <var>close</var> be 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-cancel><a href=#event-cancel>cancel</a></code> at <var>dialog</var>, 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.<li><p>If <var>close</var> is true and <var>dialog</var> has an <code id=the-dialog-element:attr-dialog-open-11><a href=#attr-dialog-open>open</a></code> attribute, then <a href=#close-the-dialog id=the-dialog-element:close-the-dialog-2>close the dialog</a> with no
   return value.</ol>

  <p class=note>An example of such a UI mechanism would be the user pressing the "Escape" key.</p>

  <hr>

  <p>A <code id=the-dialog-element:the-dialog-element-18><a href=#the-dialog-element>dialog</a></code> element is in one of two modes: <dfn id=normal-alignment>normal alignment</dfn> or
  <dfn id=centered-alignment>centered alignment</dfn>. When a <code id=the-dialog-element:the-dialog-element-19><a href=#the-dialog-element>dialog</a></code> element is created, it must be placed in
  the <a href=#normal-alignment id=the-dialog-element:normal-alignment-2>normal alignment</a> mode. In this mode, normal CSS requirements apply to the
  element. The <a href=#centered-alignment id=the-dialog-element:centered-alignment-2>centered alignment</a> mode is only used for <code id=the-dialog-element:the-dialog-element-20><a href=#the-dialog-element>dialog</a></code> elements
  that are in the <a id=the-dialog-element:top-layer-5 href=https://fullscreen.spec.whatwg.org/#top-layer data-x-internal=top-layer>top layer</a>. <a href=#refsFULLSCREEN>[FULLSCREEN]</a> <a href=#refsCSS>[CSS]</a></p>

  <p>When an element <var>subject</var> is placed in <a href=#centered-alignment id=the-dialog-element:centered-alignment-3>centered alignment</a> mode, and when
  it is in that mode and has new rendering boxes created, the user agent must set up the element
  such that its static position of the edge that corresponds to <var>subject</var>'s parent's
  <a id=the-dialog-element:block-start href=https://drafts.csswg.org/css-writing-modes/#block-start data-x-internal=block-start>block-start</a> edge, for the purposes of calculating the <a id=the-dialog-element:used-value href=https://drafts.csswg.org/css-cascade/#used-value data-x-internal=used-value>used value</a> of the
  appropriate box offset property (<a id="the-dialog-element:'top'" href=https://drafts.csswg.org/css2/visuren.html#propdef-top data-x-internal="'top'">'top'</a>, <a id="the-dialog-element:'right'" href=https://drafts.csswg.org/css2/visuren.html#propdef-right data-x-internal="'right'">'right'</a>, <a id="the-dialog-element:'bottom'" href=https://drafts.csswg.org/css2/visuren.html#propdef-bottom data-x-internal="'bottom'">'bottom'</a>,
  or <a id="the-dialog-element:'left'" href=https://drafts.csswg.org/css2/visuren.html#propdef-left data-x-internal="'left'">'left'</a>), is the value that would place the element's <a id=the-dialog-element:margin-edge href=https://drafts.csswg.org/css2/box.html#margin-edge data-x-internal=margin-edge>margin edge</a> on
  the side that corresponds to <var>subject</var>'s parent's <a id=the-dialog-element:block-start-2 href=https://drafts.csswg.org/css-writing-modes/#block-start data-x-internal=block-start>block-start</a> side as far
  from the same-side edge of the <a id=the-dialog-element:viewport href=https://drafts.csswg.org/css2/visuren.html#viewport data-x-internal=viewport>viewport</a> as the element's opposing side <a id=the-dialog-element:margin-edge-2 href=https://drafts.csswg.org/css2/box.html#margin-edge data-x-internal=margin-edge>margin
  edge</a> from that same-side edge of the <a id=the-dialog-element:viewport-2 href=https://drafts.csswg.org/css2/visuren.html#viewport data-x-internal=viewport>viewport</a>, if the element's dimension
  (<a id="the-dialog-element:'width'" href=https://drafts.csswg.org/css2/visudet.html#the-width-property data-x-internal="'width'">'width'</a> or <a id="the-dialog-element:'height'" href=https://drafts.csswg.org/css2/visudet.html#the-height-property data-x-internal="'height'">'height'</a>) in <var>subject</var>'s parent's <a id=the-dialog-element:block-flow-direction href=https://drafts.csswg.org/css-writing-modes/#block-flow-direction data-x-internal=block-flow-direction>block flow
  direction</a> is less than the same-axis dimension of the <a id=the-dialog-element:viewport-3 href=https://drafts.csswg.org/css2/visuren.html#viewport data-x-internal=viewport>viewport</a>, and otherwise
  is the value that would place the element's <a id=the-dialog-element:margin-edge-3 href=https://drafts.csswg.org/css2/box.html#margin-edge data-x-internal=margin-edge>margin edge</a> on the side that corresponds
  to <var>subject</var>'s parent's <a id=the-dialog-element:block-start-3 href=https://drafts.csswg.org/css-writing-modes/#block-start data-x-internal=block-start>block-start</a> side at the same-side edge of the
  <a id=the-dialog-element:viewport-4 href=https://drafts.csswg.org/css2/visuren.html#viewport data-x-internal=viewport>viewport</a>.</p>

  <p>If there is a <code id=the-dialog-element:the-dialog-element-21><a href=#the-dialog-element>dialog</a></code> element with <a href=#centered-alignment id=the-dialog-element:centered-alignment-4>centered alignment</a> and that is
  <a href=#being-rendered id=the-dialog-element:being-rendered>being rendered</a> when its <a href=#browsing-context id=the-dialog-element:browsing-context>browsing context</a> changes <a id=the-dialog-element:viewport-5 href=https://drafts.csswg.org/css2/visuren.html#viewport data-x-internal=viewport>viewport</a>
  dimensions (as measured in <a href=https://drafts.csswg.org/css-values/#px id="the-dialog-element:'px'" data-x-internal="'px'">CSS pixels</a>), or when this
  <code id=the-dialog-element:the-dialog-element-22><a href=#the-dialog-element>dialog</a></code> element's parent changes <a id=the-dialog-element:block-flow-direction-2 href=https://drafts.csswg.org/css-writing-modes/#block-flow-direction data-x-internal=block-flow-direction>block flow direction</a>, then the user
  agent must recreate the element's boxes, recalculating its edge that corresponds to this
  <code id=the-dialog-element:the-dialog-element-23><a href=#the-dialog-element>dialog</a></code> element's parent's <a id=the-dialog-element:block-start-4 href=https://drafts.csswg.org/css-writing-modes/#block-start data-x-internal=block-start>block-start</a> edge as in the previous
  paragraph.</p>

  <p>This static position of a <code id=the-dialog-element:the-dialog-element-24><a href=#the-dialog-element>dialog</a></code> element's edge with <a href=#centered-alignment id=the-dialog-element:centered-alignment-5>centered
  alignment</a> must remain the element's static position of that edge until its boxes are
  recreated. (The element's static position is only used in calculating the <a id=the-dialog-element:used-value-2 href=https://drafts.csswg.org/css-cascade/#used-value data-x-internal=used-value>used value</a>
  of the appropriate box offset property (<a id="the-dialog-element:'top'-2" href=https://drafts.csswg.org/css2/visuren.html#propdef-top data-x-internal="'top'">'top'</a>, <a id="the-dialog-element:'right'-2" href=https://drafts.csswg.org/css2/visuren.html#propdef-right data-x-internal="'right'">'right'</a>,
  <a id="the-dialog-element:'bottom'-2" href=https://drafts.csswg.org/css2/visuren.html#propdef-bottom data-x-internal="'bottom'">'bottom'</a>, or <a id="the-dialog-element:'left'-2" href=https://drafts.csswg.org/css2/visuren.html#propdef-left data-x-internal="'left'">'left'</a>) in certain situations; it's not used, for instance,
  to position the element if its <a id="the-dialog-element:'position'" href=https://drafts.csswg.org/css-position/#position-property data-x-internal="'position'">'position'</a> property is set to
  <a id="the-dialog-element:'static'" href=https://drafts.csswg.org/css-position/#valdef-position-static data-x-internal="'static'">'static'</a>.)</p>

  <p>User agents in visual interactive media should allow the user to pan the <a id=the-dialog-element:viewport-6 href=https://drafts.csswg.org/css2/visuren.html#viewport data-x-internal=viewport>viewport</a>
  to access all parts of a <code id=the-dialog-element:the-dialog-element-25><a href=#the-dialog-element>dialog</a></code> element's <a id=the-dialog-element:border-box href=https://drafts.csswg.org/css2/box.html#x14 data-x-internal=border-box>border box</a>, even if the
  element is larger than the <a id=the-dialog-element:viewport-7 href=https://drafts.csswg.org/css2/visuren.html#viewport data-x-internal=viewport>viewport</a> and the <a id=the-dialog-element:viewport-8 href=https://drafts.csswg.org/css2/visuren.html#viewport data-x-internal=viewport>viewport</a> would otherwise not
  have a scroll mechanism (e.g. because the <a id=the-dialog-element:viewport-9 href=https://drafts.csswg.org/css2/visuren.html#viewport data-x-internal=viewport>viewport</a>'s <a id="the-dialog-element:'overflow'" href=https://drafts.csswg.org/css-overflow/#propdef-overflow data-x-internal="'overflow'">'overflow'</a> property
  is set to <a id="the-dialog-element:'hidden'" href=https://drafts.csswg.org/css-overflow/#valdef-overflow-hidden data-x-internal="'hidden'">'hidden'</a>).</p>

  <hr>

  <p>The <dfn id=dom-dialog-open><code>open</code></dfn> IDL attribute must
  <a href=#reflect id=the-dialog-element:reflect>reflect</a> the <code id=the-dialog-element:attr-dialog-open-12><a href=#attr-dialog-open>open</a></code> content attribute.</p>

  

  <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>&quot;submit()&quot;</c-> <c- e>value</c-><c- o>=</c-><c- s>&quot;Add Coins&quot;</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>




  <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 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 data-dfn-type=element data-lt=script><span class=secno>4.12.1</span> The <dfn id=script><code>script</code></dfn> element<a href=#the-script-element class=self-link></a></h4>

  <dl class=element><dt><a href=#concept-element-categories id=the-script-element:concept-element-categories>Categories</a>:<dd><a href=#metadata-content-2 id=the-script-element:metadata-content-2>Metadata content</a>.<dd><a href=#flow-content-2 id=the-script-element:flow-content-2>Flow content</a>.<dd><a href=#phrasing-content-2 id=the-script-element:phrasing-content-2>Phrasing content</a>.<dd><a href=#script-supporting-elements-2 id=the-script-element:script-supporting-elements-2>Script-supporting element</a>.<dt><a href=#concept-element-contexts id=the-script-element:concept-element-contexts>Contexts in which this element can be used</a>:<dd>Where <a href=#metadata-content-2 id=the-script-element:metadata-content-2-2>metadata content</a> is expected.<dd>Where <a href=#phrasing-content-2 id=the-script-element:phrasing-content-2-2>phrasing content</a> is expected.<dd>Where <a href=#script-supporting-elements-2 id=the-script-element:script-supporting-elements-2-2>script-supporting elements</a> are expected.<dt><a href=#concept-element-content-model id=the-script-element:concept-element-content-model>Content model</a>:<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>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>.<dt><a href=#concept-element-tag-omission id=the-script-element:concept-element-tag-omission>Tag omission in text/html</a>:<dd>Neither tag is omissible.<dt><a href=#concept-element-attributes id=the-script-element:concept-element-attributes>Content attributes</a>:<dd><a href=#global-attributes id=the-script-element:global-attributes>Global attributes</a><dd><code id=the-script-element:attr-script-src-3><a href=#attr-script-src>src</a></code> — Address of the resource<dd><code id=the-script-element:attr-script-type-2><a href=#attr-script-type>type</a></code> — Type of script<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><code id=the-script-element:attr-script-async><a href=#attr-script-async>async</a></code> — Execute script when available, without blocking<dd><code id=the-script-element:attr-script-defer><a href=#attr-script-defer>defer</a></code> — Defer script execution<dd><code id=the-script-element:attr-script-crossorigin><a href=#attr-script-crossorigin>crossorigin</a></code> — How the element handles crossorigin requests<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><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<dt><a href=#concept-element-dom id=the-script-element:concept-element-dom>DOM interface</a>:<dd>
    <pre><code class='idl'>[<c- g>Exposed</c->=<c- n>Window</c->,
 <a href='#htmlconstructor' id='the-script-element:htmlconstructor'><c- g>HTMLConstructor</c-></a>]
<c- b>interface</c-> <dfn id='htmlscriptelement'><c- g>HTMLScriptElement</c-></dfn> : <a href='#htmlelement' id='the-script-element:htmlelement'><c- n>HTMLElement</c-></a> {
  [<a href='#cereactions' id='the-script-element:cereactions'><c- g>CEReactions</c-></a>] <c- b>attribute</c-> <c- b>USVString</c-> <a href='#dom-script-src' id='the-script-element:dom-script-src'><c- g>src</c-></a>;
  [<a href='#cereactions' id='the-script-element:cereactions-2'><c- g>CEReactions</c-></a>] <c- b>attribute</c-> <c- b>DOMString</c-> <a href='#dom-script-type' id='the-script-element:dom-script-type'><c- g>type</c-></a>;
  [<a href='#cereactions' id='the-script-element:cereactions-3'><c- g>CEReactions</c-></a>] <c- b>attribute</c-> <c- b>boolean</c-> <a href='#dom-script-nomodule' id='the-script-element:dom-script-nomodule'><c- g>noModule</c-></a>;
  [<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>] <c- b>attribute</c-> <c- b>boolean</c-> <a href='#dom-script-defer' id='the-script-element:dom-script-defer'><c- g>defer</c-></a>;
  [<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-text' id='the-script-element:dom-script-text'><c- g>text</c-></a>;
  [<a href='#cereactions' id='the-script-element:cereactions-8'><c- g>CEReactions</c-></a>] <c- b>attribute</c-> <c- b>DOMString</c-> <a href='#dom-script-integrity' id='the-script-element:dom-script-integrity'><c- g>integrity</c-></a>;
  [<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-referrerpolicy' id='the-script-element:dom-script-referrerpolicy'><c- g>referrerPolicy</c-></a>;

};</code></pre>
   </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 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>

  <p>The <dfn id=attr-script-type><code>type</code></dfn> attribute allows customization of
  the type of script represented:<div class=status><input onclick=toggleStatus(this) value=⋰ type=button><p class=support><strong>Support:</strong> es6-module<span class="and_chr yes"><span>Chrome for Android</span> <span>67+</span></span><span class="chrome yes"><span>Chrome</span> <span>61+</span></span><span class="ios_saf yes"><span>iOS Safari</span> <span>11.0+</span></span><span class="and_uc no"><span>UC Browser for Android</span> <span>None</span></span><span class="firefox yes"><span>Firefox</span> <span>60+</span></span><span class="ie no"><span>IE</span> <span>None</span></span><span class="op_mini no"><span>Opera Mini</span> <span>None</span></span><span class="safari yes"><span>Safari</span> <span>11+</span></span><span class="edge yes"><span>Edge</span> <span>16+</span></span><span class="samsung no"><span>Samsung Internet</span> <span>None</span></span><span class="opera yes"><span>Opera</span> <span>48+</span></span><span class="android yes"><span>Android Browser</span> <span>67+</span></span><p class=caniuse>Source: <a href="https://caniuse.com/#feat=es6-module">caniuse.com</a></div>

  <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.github.io/ecma262/#prod-Script>Script</a></i> top-level production. Classic scripts are affected by the
    <code id=the-script-element:attr-script-async-2><a href=#attr-script-async>async</a></code> and <code id=the-script-element:attr-script-defer-2><a href=#attr-script-defer>defer</a></code>
    attributes, but only when the <code id=the-script-element:attr-script-src-4><a href=#attr-script-src>src</a></code> attribute is set.
    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.<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 the string
    "<code>module</code>" means that the script is a <a href=#module-script id=the-script-element:module-script-2>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.github.io/ecma262/#prod-Module>Module</a></i> top-level
    production. Module scripts are not affected by the <code id=the-script-element:attr-script-defer-3><a href=#attr-script-defer>defer</a></code>
    attribute, but are affected by the <code id=the-script-element:attr-script-async-3><a href=#attr-script-async>async</a></code> attribute
    (regardless of the state of the <code id=the-script-element:attr-script-src-5><a href=#attr-script-src>src</a></code> attribute).<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. None of the <code id=the-script-element:the-script-element-2><a href=#the-script-element>script</a></code> attributes (except <code id=the-script-element:attr-script-type-4><a href=#attr-script-type>type</a></code> itself) have any effect on data blocks. 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.</ul>

  <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. If this specification ever adds additional types of
  <a href=#the-script-element id=the-script-element:the-script-element-3>script</a>, they will be triggered by setting the <code id=the-script-element:attr-script-type-5><a href=#attr-script-type>type</a></code> attribute to something which is not a MIME type, like how
  the "<code>module</code>" value denotes <a href=#module-script id=the-script-element:module-script-3>module
  scripts</a>. 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>

  <p><a href=#classic-script id=the-script-element:classic-script-2>Classic scripts</a> and <a href=#module-script id=the-script-element:module-script-4>module
  scripts</a> may either be embedded inline or may be imported from an external file using the
  <dfn data-dfn-for=script id=attr-script-src data-dfn-type=element-attr data-export=""><code>src</code></dfn> attribute, which if specified gives the <a id=the-script-element:url href=https://url.spec.whatwg.org/#concept-url data-x-internal=url>URL</a>
  of the external script resource to use. If <code id=the-script-element:attr-script-src-6><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>. The contents of
  inline <code id=the-script-element:the-script-element-4><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.github.io/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.github.io/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=#module-script id=the-script-element:module-script-5>module scripts</a> respectively. <a href=#refsJAVASCRIPT>[JAVASCRIPT]</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-6><a href=#attr-script-type>type</a></code>
  attribute, and the contents of the <code id=the-script-element:the-script-element-5><a href=#the-script-element>script</a></code> element must conform to the requirements
  defined for the format used. The <code id=the-script-element:attr-script-src-7><a href=#attr-script-src>src</a></code>, <code id=the-script-element:attr-script-async-4><a href=#attr-script-async>async</a></code>, <code id=the-script-element:attr-script-nomodule-2><a href=#attr-script-nomodule>nomodule</a></code>,
  <code id=the-script-element:attr-script-defer-4><a href=#attr-script-defer>defer</a></code>, <code id=the-script-element:attr-script-crossorigin-2><a href=#attr-script-crossorigin>crossorigin</a></code>, <code id=the-script-element:attr-script-integrity-2><a href=#attr-script-integrity>integrity</a></code>, and <code id=the-script-element:attr-script-referrerpolicy-2><a href=#attr-script-referrerpolicy>referrerpolicy</a></code> attributes must not be specified.</p>

  <p>The <dfn id=attr-script-nomodule><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-6>module scripts</a>. This allows selective execution of <a href=#module-script id=the-script-element:module-script-7>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>. The <code id=the-script-element:attr-script-nomodule-3><a href=#attr-script-nomodule>nomodule</a></code> attribute must not be
  specified on <a href=#module-script id=the-script-element:module-script-8>module scripts</a> (and will be ignored if it
  is).</p>

  <p>The <dfn id=attr-script-async><code>async</code></dfn> and <dfn id=attr-script-defer><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. <a href=#classic-script id=the-script-element:classic-script-5>Classic scripts</a> may specify <code id=the-script-element:attr-script-defer-5><a href=#attr-script-defer>defer</a></code> or <code id=the-script-element:attr-script-async-5><a href=#attr-script-async>async</a></code>, but must
  not specify either unless the <code id=the-script-element:attr-script-src-8><a href=#attr-script-src>src</a></code> attribute is present.
  <a href=#module-script id=the-script-element:module-script-9>Module scripts</a> may specify the <code id=the-script-element:attr-script-async-6><a href=#attr-script-async>async</a></code> attribute, but must not specify the <code id=the-script-element:attr-script-defer-6><a href=#attr-script-defer>defer</a></code> attribute.<div class=status><input onclick=toggleStatus(this) value=⋰ type=button><p class=support><strong>Support:</strong> script-defer<span class="and_chr yes"><span>Chrome for Android</span> <span>67+</span></span><span class="chrome yes"><span>Chrome</span> <span>8+</span></span><span class="ios_saf yes"><span>iOS Safari</span> <span>5.0+</span></span><span class="and_uc yes"><span>UC Browser for Android</span> <span>11.8+</span></span><span class="firefox yes"><span>Firefox</span> <span>3.5+</span></span><span class="ie yes"><span>IE</span> <span>10+</span></span><span class="op_mini no"><span>Opera Mini</span> <span>None</span></span><span class="safari yes"><span>Safari</span> <span>5+</span></span><span class="edge yes"><span>Edge</span> <span>12+</span></span><span class="samsung yes"><span>Samsung Internet</span> <span>4+</span></span><span class="opera yes"><span>Opera</span> <span>15+</span></span><span class="android yes"><span>Android Browser</span> <span>3+</span></span><p class=caniuse>Source: <a href="https://caniuse.com/#feat=script-defer">caniuse.com</a><p class=support><strong>Support:</strong> script-async<span class="and_chr yes"><span>Chrome for Android</span> <span>67+</span></span><span class="chrome yes"><span>Chrome</span> <span>8+</span></span><span class="ios_saf yes"><span>iOS Safari</span> <span>5.0+</span></span><span class="and_uc yes"><span>UC Browser for Android</span> <span>11.8+</span></span><span class="firefox yes"><span>Firefox</span> <span>3.6+</span></span><span class="ie yes"><span>IE</span> <span>10+</span></span><span class="op_mini no"><span>Opera Mini</span> <span>None</span></span><span class="safari yes"><span>Safari</span> <span>5.1+</span></span><span class="edge yes"><span>Edge</span> <span>12+</span></span><span class="samsung yes"><span>Samsung Internet</span> <span>4+</span></span><span class="opera yes"><span>Opera</span> <span>15+</span></span><span class="android yes"><span>Android Browser</span> <span>3+</span></span><p class=caniuse>Source: <a href="https://caniuse.com/#feat=script-async">caniuse.com</a></div>

  <p>There are several possible modes that can be selected using these attributes, and depending on
  the script's type.</p>

  <p>For <a href=#classic-script id=the-script-element:classic-script-6>classic scripts</a>, if the <code id=the-script-element:attr-script-async-7><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-8><a href=#attr-script-async>async</a></code> attribute is not
  present but the <code id=the-script-element:attr-script-defer-7><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-10>module scripts</a>, if the <code id=the-script-element:attr-script-async-9><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-8><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 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
  below (in this section) 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-6><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>The <code id=the-script-element:attr-script-defer-9><a href=#attr-script-defer>defer</a></code> attribute may be specified even if the <code id=the-script-element:attr-script-async-10><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-10><a href=#attr-script-defer>defer</a></code> (and not <code id=the-script-element:attr-script-async-11><a href=#attr-script-async>async</a></code>) to fall back to the <code id=the-script-element:attr-script-defer-11><a href=#attr-script-defer>defer</a></code> behavior instead of the blocking behavior that
  is the default.</p>

  <p>The <dfn id=attr-script-crossorigin><code>crossorigin</code></dfn> attribute is a
  <a href=#cors-settings-attribute id=the-script-element:cors-settings-attribute>CORS settings attribute</a>. For <a href=#classic-script id=the-script-element:classic-script-7>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 <a href=#module-script id=the-script-element:module-script-11>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 data-x-internal=concept-request-credentials-mode>credentials mode</a> used for
  cross-origin requests.</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-12>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-integrity data-dfn-type=element-attr data-export=""><code>integrity</code></dfn> attribute represents 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> for requests which this
  element is responsible for. The value is text. The <code id=the-script-element:attr-script-integrity-3><a href=#attr-script-integrity>integrity</a></code> attribute must not be specified when embedding a
  <a href=#module-script id=the-script-element:module-script-13>module script</a> or when the <code id=the-script-element:attr-script-src-9><a href=#attr-script-src>src</a></code> attribute is not
  specified. <a href=#refsSRI>[SRI]</a></p>

  <p>The <dfn id=attr-script-referrerpolicy><code>referrerpolicy</code></dfn> attribute is a
  <a href=#referrer-policy-attribute id=the-script-element:referrer-policy-attribute>referrer policy attribute</a>. Its purpose is to set the <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 when <a href=https://fetch.spec.whatwg.org/#concept-fetch id=the-script-element:concept-fetch-2 data-x-internal=concept-fetch>fetching</a> the script, as well as any scripts imported
  from it. <a href=#refsREFERRERPOLICY>[REFERRERPOLICY]</a></p>

  <div class=example>
   <p>An example of a &lt;script>'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>src</c-><c- o>=</c-><c- s>&quot;main.js&quot;</c-> <c- e>referrerpolicy</c-><c- o>=</c-><c- s>&quot;origin&quot;</c-><c- p>&gt;</c->
  fetch<c- p>(</c-><c- t>&apos;/api/data&apos;</c-><c- p>);</c->   <c- c1>// not fetched with &lt;script&gt;&apos;s referrer policy</c->
  <c- kr>import</c-><c- p>(</c-><c- t>&apos;./utils.mjs&apos;</c-><c- p>);</c-> <c- c1>// is fetched with &lt;script&gt;&apos;s referrer policy (&quot;origin&quot; in this case)</c->
<c- p>&lt;/</c-><c- f>script</c-><c- p>&gt;</c-></code></pre>
  </div>

  <p>Changing the <code id=the-script-element:attr-script-src-10><a href=#attr-script-src>src</a></code>, <code id=the-script-element:attr-script-type-7><a href=#attr-script-type>type</a></code>, <code id=the-script-element:attr-script-nomodule-4><a href=#attr-script-nomodule>nomodule</a></code>, <code id=the-script-element:attr-script-async-12><a href=#attr-script-async>async</a></code>, <code id=the-script-element:attr-script-defer-12><a href=#attr-script-defer>defer</a></code>, <code id=the-script-element:attr-script-crossorigin-3><a href=#attr-script-crossorigin>crossorigin</a></code>, <code id=the-script-element:attr-script-integrity-4><a href=#attr-script-integrity>integrity</a></code>, and <code id=the-script-element:attr-script-referrerpolicy-3><a href=#attr-script-referrerpolicy>referrerpolicy</a></code> attributes dynamically has no direct effect; these
  attributes are only used at specific times described below.</p> 

  

  <p>The IDL attributes <dfn id=dom-script-src><code>src</code></dfn>, <dfn id=dom-script-type><code>type</code></dfn>, <dfn id=dom-script-defer><code>defer</code></dfn>, and <dfn id=dom-script-integrity><code>integrity</code></dfn>, must each <a href=#reflect id=the-script-element:reflect>reflect</a> the
  respective content attributes of the same name.</p>

  <p>The <dfn id=dom-script-referrerpolicy><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-4><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>limited to only known values</a>.</p>

  <p>The <dfn id=dom-script-crossorigin><code>crossOrigin</code></dfn> IDL attribute must
  <a href=#reflect id=the-script-element:reflect-3>reflect</a> the <code id=the-script-element:attr-script-crossorigin-4><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-2>limited to only known values</a>.</p>

  <p>The <dfn id=dom-script-nomodule><code>noModule</code></dfn> IDL attribute must
  <a href=#reflect id=the-script-element:reflect-4>reflect</a> the <code id=the-script-element:attr-script-nomodule-5><a href=#attr-script-nomodule>nomodule</a></code> content
  attribute.</p>

  <p>The <dfn id=dom-script-async><code>async</code></dfn> IDL attribute controls whether the
  element will execute asynchronously or not. If the element's <a href=#non-blocking id=the-script-element:non-blocking>"non-blocking"</a> flag is
  set, then, on getting, the <code id=the-script-element:dom-script-async-2><a href=#dom-script-async>async</a></code> IDL attribute must return
  true, and on setting, the <a href=#non-blocking id=the-script-element:non-blocking-2>"non-blocking"</a> flag must first be unset, and then the
  content attribute must be removed if the IDL attribute's new value is false, and must be set to
  the empty string if the IDL attribute's new value is true. If the element's
  <a href=#non-blocking id=the-script-element:non-blocking-3>"non-blocking"</a> flag is <em>not</em> set, the IDL attribute must <a href=#reflect id=the-script-element:reflect-5>reflect</a>
  the <code id=the-script-element:attr-script-async-13><a href=#attr-script-async>async</a></code> content attribute.</p>

  

  <dl class=domintro><dt><var>script</var> . <code id=dom-script-text-dev><a href=#dom-script-text>text</a></code> [ = <var>value</var> ]<dd>

    <p>Returns the <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> of the element.</p>

    <p>Can be set, to replace the element's children with the given value.</p>

   </dl>

  

  <p>The IDL attribute <dfn id=dom-script-text><code>text</code></dfn> must return 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 <code id=the-script-element:the-script-element-7><a href=#the-script-element>script</a></code> element. On setting, it must act the
  same way as the <code id=the-script-element:textcontent><a data-x-internal=textcontent href=https://dom.spec.whatwg.org/#dom-node-textcontent>textContent</a></code> IDL attribute.</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-innerhtml><a data-x-internal=dom-innerhtml href=https://w3c.github.io/DOM-Parsing/#dom-element-innerhtml>innerHTML</a></code> and <code id=the-script-element:dom-outerhtml><a data-x-internal=dom-outerhtml href=https://w3c.github.io/DOM-Parsing/#dom-element-outerhtml>outerHTML</a></code>
  attributes, they do not execute at all.</p>

  <div class=example>

   <p>In this example, two <code id=the-script-element:the-script-element-9><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>&quot;game-engine.js&quot;</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>&quot;text/x-game-map&quot;</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-10><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-11><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- mi>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- mi>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- mi>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- mi>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- mi>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>&quot;pricecalc&quot;</c-> <c- e>onsubmit</c-><c- o>=</c-><c- s>&quot;return false&quot;</c-> <c- e>onchange</c-><c- o>=</c-><c- s>&quot;calculate(this)&quot;</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-> &quot;XZ&quot; 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>

   <p>The following sample 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 include an
   external <a href=#module-script id=the-script-element:module-script-14>module script</a>.

   <pre><code class='html'><c- p>&lt;</c-><c- f>script</c-> <c- e>type</c-><c- o>=</c-><c- s>&quot;module&quot;</c-> <c- e>src</c-><c- o>=</c-><c- s>&quot;app.mjs&quot;</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-13><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=#module-script id=the-script-element:module-script-15>module script</a> created by the
   former <code id=the-script-element:the-script-element-14><a href=#the-script-element>script</a></code> element will be imported.</p>

  </div>

  <div id=script-nomodule-example class=example>

  <p>This example shows how to include a <a href=#module-script id=the-script-element:module-script-16>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>&quot;module&quot;</c-> <c- e>src</c-><c- o>=</c-><c- s>&quot;app.mjs&quot;</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>src</c-><c- o>=</c-><c- s>&quot;classic-app-bundle.js&quot;</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=#module-script id=the-script-element:module-script-17>module scripts</a>, the
  <code id=the-script-element:the-script-element-15><a href=#the-script-element>script</a></code> element with the <code id=the-script-element:attr-script-nomodule-6><a href=#attr-script-nomodule>nomodule</a></code> attribute
  will be ignored, and the <code id=the-script-element:the-script-element-16><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>" will be fetched and
  evaluated (as a <a href=#module-script id=the-script-element:module-script-18>module script</a>). Conversely, older user agents will ignore 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-9><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-18><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-7><a href=#attr-script-nomodule>nomodule</a></code> attribute.</p>

  </div>

  <div id=script-type-module-example-2 class=example>

   <p>The following sample shows how a <code id=the-script-element:the-script-element-19><a href=#the-script-element>script</a></code> element can be used to write an inline
   <a href=#module-script id=the-script-element:module-script-19>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>&quot;module&quot;</c-><c- p>&gt;</c->
 <c- kr>import</c-> <c- p>{</c-> walkAllTextNodeDescendants <c- p>}</c-> from <c- u>&quot;./dom-utils.mjs&quot;</c-><c- p>;</c->

 <c- kr>const</c-> substitutions <c- o>=</c-> <c- k>new</c-> Map<c- p>([</c->
   <c- p>[</c-><c- u>&quot;witnesses&quot;</c-><c- p>,</c-> <c- u>&quot;these dudes I know&quot;</c-><c- p>]</c->
   <c- p>[</c-><c- u>&quot;allegedly&quot;</c-><c- p>,</c-> <c- u>&quot;kinda probably&quot;</c-><c- p>]</c->
   <c- p>[</c-><c- u>&quot;new study&quot;</c-><c- p>,</c-> <c- u>&quot;Tumblr post&quot;</c-><c- p>]</c->
   <c- p>[</c-><c- u>&quot;rebuild&quot;</c-><c- p>,</c-> <c- u>&quot;avenge&quot;</c-><c- p>]</c->
   <c- p>[</c-><c- u>&quot;space&quot;</c-><c- p>,</c-> <c- u>&quot;spaaace&quot;</c-><c- p>]</c->
   <c- p>[</c-><c- u>&quot;Google glass&quot;</c-><c- p>,</c-> <c- u>&quot;Virtual Boy&quot;</c-><c- p>]</c->
   <c- p>[</c-><c- u>&quot;smartphone&quot;</c-><c- p>,</c-> <c- u>&quot;Pokédex&quot;</c-><c- p>]</c->
   <c- p>[</c-><c- u>&quot;electric&quot;</c-><c- p>,</c-> <c- u>&quot;atomic&quot;</c-><c- p>]</c->
   <c- p>[</c-><c- u>&quot;Senator&quot;</c-><c- p>,</c-> <c- u>&quot;Elf-Lord&quot;</c-><c- p>]</c->
   <c- p>[</c-><c- u>&quot;car&quot;</c-><c- p>,</c-> <c- u>&quot;cat&quot;</c-><c- p>]</c->
   <c- p>[</c-><c- u>&quot;election&quot;</c-><c- p>,</c-> <c- u>&quot;eating contest&quot;</c-><c- p>]</c->
   <c- p>[</c-><c- u>&quot;Congressional leaders&quot;</c-><c- p>,</c-> <c- u>&quot;river spirits&quot;</c-><c- p>]</c->
   <c- p>[</c-><c- u>&quot;homeland security&quot;</c-><c- p>,</c-> <c- u>&quot;Homestar Runner&quot;</c-><c- p>]</c->
   <c- p>[</c-><c- u>&quot;could not be reached for comment&quot;</c-><c- p>,</c-> <c- u>&quot;is guilty and everyone knows it&quot;</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- kr>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>&quot;ig&quot;</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 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-20><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>

  

  <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>The first is a flag indicating whether or not the script block has been <dfn id=already-started>"already
  started"</dfn>. Initially, <code id=script-processing-model:the-script-element-2><a href=#the-script-element>script</a></code> elements must have this flag unset (script blocks,
  when created, are not "already started"). 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-3><a href=#the-script-element>script</a></code> elements must set the "already started" flag on the copy if
  it is set on the element being cloned.</p>

  <p>The second is a flag indicating whether the element was <dfn data-dfn-for=script id=parser-inserted data-dfn-type=dfn data-export="">"parser-inserted"</dfn>. Initially,
  <code id=script-processing-model:the-script-element-4><a href=#the-script-element>script</a></code> elements must have this flag unset. 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-5><a href=#the-script-element>script</a></code> elements they insert and affects the
  processing of those elements.</p>

  <p>The third is a flag indicating whether the element will be <dfn id=non-blocking>"non-blocking"</dfn>.
  Initially, <code id=script-processing-model:the-script-element-6><a href=#the-script-element>script</a></code> elements must have this flag set. It is unset 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. In
  addition, whenever a <code id=script-processing-model:the-script-element-8><a href=#the-script-element>script</a></code> element whose <a href=#non-blocking id=script-processing-model:non-blocking>"non-blocking"</a> flag is set
  has an <code id=script-processing-model:attr-script-async><a href=#attr-script-async>async</a></code> content attribute added, the element's
  <a href=#non-blocking id=script-processing-model:non-blocking-2>"non-blocking"</a> flag must be unset.</p> 

  <p>The fourth is a flag indicating whether or not the script block is <dfn id=ready-to-be-parser-executed>"ready to be
  parser-executed"</dfn>. Initially, <code id=script-processing-model:the-script-element-9><a href=#the-script-element>script</a></code> elements must have this flag unset (script
  blocks, when created, are not "ready to be parser-executed"). This flag is used only 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>The fifth is <dfn id=concept-script-type>the script's type</dfn>, which is either "<code>classic</code>" or "<code>module</code>". It is determined when the script is
  <a href=#prepare-a-script id=script-processing-model:prepare-a-script>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>The sixth is a flag indicating whether or not the script is <dfn id=concept-script-external>from an external file</dfn>. It is determined when the script is
  <a href=#prepare-a-script id=script-processing-model:prepare-a-script-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>Finally, a <code id=script-processing-model:the-script-element-10><a href=#the-script-element>script</a></code> element has <dfn id=concept-script-script data-export="">the script's script</dfn>, which is a <a href=#concept-script id=script-processing-model:concept-script>script</a>
  resulting from <a href=#prepare-a-script id=script-processing-model:prepare-a-script-3>preparing</a> the element. This is set
  asynchronously after the classic script or module graph is fetched. Once it is set, either to a
  <a href=#concept-script id=script-processing-model:concept-script-2>script</a> in the case of success or to null in the case of
  failure, the fetching algorithms will note that <dfn id=the-script-is-ready>the script is ready</dfn>, which can trigger
  other actions.  The user agent must <a href=#delay-the-load-event id=script-processing-model:delay-the-load-event>delay the load
  event</a> of the element's <a id=script-processing-model:node-document href=https://dom.spec.whatwg.org/#concept-node-document data-x-internal=node-document>node document</a> until <a href=#the-script-is-ready id=script-processing-model:the-script-is-ready>the script is
  ready</a>.</p>

  <hr>

  <p>When a <code id=script-processing-model:the-script-element-11><a href=#the-script-element>script</a></code> element that is not marked as being <a href=#parser-inserted id=script-processing-model:parser-inserted-2>"parser-inserted"</a>
  experiences one of the events listed in the following list, the user agent must
  <a href=#immediately id=script-processing-model:immediately>immediately</a> <a href=#prepare-a-script id=script-processing-model:prepare-a-script-4>prepare</a> the <code id=script-processing-model:the-script-element-12><a href=#the-script-element>script</a></code>
  element:</p>

  <ul><li>The <code id=script-processing-model:the-script-element-13><a href=#the-script-element>script</a></code> element <a href=#becomes-connected id=script-processing-model:becomes-connected>becomes connected</a>.<li>The <code id=script-processing-model:the-script-element-14><a href=#the-script-element>script</a></code> element is <a id=script-processing-model:connected href=https://dom.spec.whatwg.org/#connected data-x-internal=connected>connected</a> and a node or document fragment is
   <a href=#nodes-are-inserted id=script-processing-model:nodes-are-inserted>inserted</a> into the <code id=script-processing-model:the-script-element-15><a href=#the-script-element>script</a></code> element, after any
   <code id=script-processing-model:the-script-element-16><a href=#the-script-element>script</a></code> elements <a href=#nodes-are-inserted id=script-processing-model:nodes-are-inserted-2>inserted</a> at that time.<li>The <code id=script-processing-model:the-script-element-17><a href=#the-script-element>script</a></code> element is <a id=script-processing-model:connected-2 href=https://dom.spec.whatwg.org/#connected data-x-internal=connected>connected</a> and has a <code id=script-processing-model:attr-script-src-2><a href=#attr-script-src>src</a></code> attribute set where previously the element had no such
   attribute.</ul>

  <p>To <dfn id=prepare-a-script data-export="">prepare a script</dfn>, the user agent must
  act as follows:</p>

  <ol><li>

    <p>If the <code id=script-processing-model:the-script-element-18><a href=#the-script-element>script</a></code> element is marked as having <a href=#already-started id=script-processing-model:already-started>"already started"</a>, then
    return. The script is not executed.</p>

   <li>

    <p>If the element has its <a href=#parser-inserted id=script-processing-model:parser-inserted-3>"parser-inserted"</a> flag set, then set <var>was-parser-inserted</var> to true and unset the element's
    <a href=#parser-inserted id=script-processing-model:parser-inserted-4>"parser-inserted"</a> flag. Otherwise, set <var>was-parser-inserted</var> to
    false.</p>

    <p class=note>This is done so that if parser-inserted <code id=script-processing-model:the-script-element-19><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>

    <p>If <var>was-parser-inserted</var> is true and the element does not have an <code id=script-processing-model:attr-script-async-2><a href=#attr-script-async>async</a></code> attribute, then set the element's
    <a href=#non-blocking id=script-processing-model:non-blocking-3>"non-blocking"</a> flag to true.</p>

    <p class=note>This is done so that if a parser-inserted <code id=script-processing-model:the-script-element-20><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 a non-blocking fashion even if the <code id=script-processing-model:attr-script-async-3><a href=#attr-script-async>async</a></code>
    attribute isn't set.</p>

   <li><p>Let <var>source text</var> be the element'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>.<li id=script-processing-empty>

    <p>If the element 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. The script is not executed.</p>

   <li><p>If the element is not <a id=script-processing-model:connected-3 href=https://dom.spec.whatwg.org/#connected data-x-internal=connected>connected</a>, then return. The script is not
   executed.<li id=script-processing-prepare>

    <p>If either:</p>

    <ul class=brief><li>the <code id=script-processing-model:the-script-element-21><a href=#the-script-element>script</a></code> element has a <code id=script-processing-model:attr-script-type-2><a href=#attr-script-type>type</a></code> attribute
     and its value is the empty string, or<li>the <code id=script-processing-model:the-script-element-22><a href=#the-script-element>script</a></code> element 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<li>the <code id=script-processing-model:the-script-element-23><a href=#the-script-element>script</a></code> element 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, then</ul>

    <p>...let <var>the script block's type string</var> for this <code id=script-processing-model:the-script-element-24><a href=#the-script-element>script</a></code> element be
    "<code>text/javascript</code>".</p>

    <p>Otherwise, if the <code id=script-processing-model:the-script-element-25><a href=#the-script-element>script</a></code> element has a <code id=script-processing-model:attr-script-type-5><a href=#attr-script-type>type</a></code> attribute, let <var>the script block's type string</var>
    for this <code id=script-processing-model:the-script-element-26><a href=#the-script-element>script</a></code> element 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, the element 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> for this <code id=script-processing-model:the-script-element-27><a href=#the-script-element>script</a></code> element
    be the concatenation of the string "<code>text/</code>" followed by the value of the
    <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>

    <p>Determine <a href=#concept-script-type id=script-processing-model:concept-script-type>the script's type</a> as follows:</p>

    <ul><li>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>, <a href=#concept-script-type id=script-processing-model:concept-script-type-2>the script's type</a> is "<code>classic</code>".<li>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>", <a href=#concept-script-type id=script-processing-model:concept-script-type-3>the
     script's type</a> is "<code>module</code>".<li>If neither of the above conditions are true, then return. No script is executed.</ul>

   <li>

    <p>If <var>was-parser-inserted</var> is true, then flag the element as
    <a href=#parser-inserted id=script-processing-model:parser-inserted-5>"parser-inserted"</a> again, and set the element's <a href=#non-blocking id=script-processing-model:non-blocking-4>"non-blocking"</a> flag to
    false.</p>

   <li id=script-processing-start>

    <p>Set the element's <a href=#already-started id=script-processing-model:already-started-2>"already started"</a> flag.</p>

   <li>

    <p>If the element is flagged as <a href=#parser-inserted id=script-processing-model:parser-inserted-6>"parser-inserted"</a>, but the element'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> is not the <code id=script-processing-model:document><a href=#document>Document</a></code> of the parser that created the
    element, then return.</p>

   <li id=script-processing-noscript>

    <p>If <a href=#concept-n-noscript id=script-processing-model:concept-n-noscript>scripting is disabled</a> for the <code id=script-processing-model:the-script-element-28><a href=#the-script-element>script</a></code>
    element, then return. The script is not executed.</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 data-x-internal=domparser href=https://w3c.github.io/DOM-Parsing/#the-domparser-interface>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-2><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>

   <p>If the <code id=script-processing-model:the-script-element-29><a href=#the-script-element>script</a></code> element has a <code id=script-processing-model:attr-script-nomodule><a href=#attr-script-nomodule>nomodule</a></code>
   content attribute and <a href=#concept-script-type id=script-processing-model:concept-script-type-4>the script's type</a> is "<code>classic</code>", then return. The script is not executed.</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 id=script-processing-csp><p>If the <code id=script-processing-model:the-script-element-30><a href=#the-script-element>script</a></code> element 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 executed upon the <code id=script-processing-model:the-script-element-31><a href=#the-script-element>script</a></code> element, "<code>script</code>", and <var>source text</var>, then return. The script is not executed.
   <a href=#refsCSP>[CSP]</a><li id=script-processing-for>

    <p>If the <code id=script-processing-model:the-script-element-32><a href=#the-script-element>script</a></code> element 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 <a href=#concept-script-type id=script-processing-model:concept-script-type-5>the script's type</a> is "<code>classic</code>",
    then:</p>

    <ol><li><p>Let <var>for</var> be the value of the <code id=script-processing-model:attr-script-for-2><a href=#attr-script-for>for</a></code>
     attribute.<li><p>Let <var>event</var> be the value of the <code id=script-processing-model:attr-script-event-2><a href=#attr-script-event>event</a></code> attribute.<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>.<li><p>If <var>for</var> is not 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>window</code>", then return. The script is not executed.<li><p>If <var>event</var> is not 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
     either the string "<code>onload</code>" or the string "<code>onload()</code>", then return. The script is not executed.</ol>

   <li id=script-processing-encoding>

    <p>If the <code id=script-processing-model:the-script-element-33><a href=#the-script-element>script</a></code> element 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 the <code id=script-processing-model:the-script-element-34><a href=#the-script-element>script</a></code> element 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, let <var>encoding</var> be the same as <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> of the <code id=script-processing-model:the-script-element-35><a href=#the-script-element>script</a></code> element'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>.</p>

    <p class=note>If <a href=#concept-script-type id=script-processing-model:concept-script-type-6>the script's type</a> is "<code>module</code>", this encoding will be ignored.</p>

   <li><p>Let <var>classic script CORS setting</var> be the current state of the element's <code id=script-processing-model:attr-script-crossorigin><a href=#attr-script-crossorigin>crossorigin</a></code> content attribute.<li><p>Let <var>module script credentials mode</var> be the <a href=#module-script-credentials-mode id=script-processing-model:module-script-credentials-mode>module script credentials
   mode</a> for the element's <code id=script-processing-model:attr-script-crossorigin-2><a href=#attr-script-crossorigin>crossorigin</a></code> content
   attribute.</p>

   <li><p>Let <var>cryptographic nonce</var> be the element's <a href=#cryptographicnonce id=script-processing-model:cryptographicnonce>[[CryptographicNonce]]</a>
   internal slot's value.<li>

    <p>If the <code id=script-processing-model:the-script-element-36><a href=#the-script-element>script</a></code> element 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><p>Let <var>referrer policy</var> be the current state of the element's <code id=script-processing-model:attr-script-referrerpolicy><a href=#attr-script-referrerpolicy>referrerpolicy</a></code> content attribute.<li><p>Let <var>parser metadata</var> be "<code>parser-inserted</code>" if the
   <code id=script-processing-model:the-script-element-37><a href=#the-script-element>script</a></code> element has been flagged as <a href=#parser-inserted id=script-processing-model:parser-inserted-7>"parser-inserted"</a>, and
   "<code>not-parser-inserted</code>" otherwise.<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>, and <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>.<li><p>Let <var>settings object</var> be the element'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>'s
   <a href=#relevant-settings-object id=script-processing-model:relevant-settings-object>relevant settings object</a>.<li id=script-processing-src-prepare>

    <p>If the element 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>Let <var>src</var> be the value of the element's <code id=script-processing-model:attr-script-src-6><a href=#attr-script-src>src</a></code> attribute.<li><p>If <var>src</var> is the empty string, <a href=#queue-a-task id=script-processing-model:queue-a-task>queue a task</a> 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 the element, and return.<li><p>Set the element's <a href=#concept-script-external id=script-processing-model:concept-script-external>from an external file</a>
     flag.<li><p><a href=#parse-a-url id=script-processing-model:parse-a-url>Parse</a> <var>src</var> relative to the element'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>.<li><p>If the previous step failed, <a href=#queue-a-task id=script-processing-model:queue-a-task-2>queue a task</a> 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 the element, and return. Otherwise, let <var>url</var> be the <a href=#resulting-url-record id=script-processing-model:resulting-url-record>resulting URL
     record</a>.<li>
      <p>Switch on <a href=#concept-script-type id=script-processing-model:concept-script-type-7>the script's type</a>:</p>

      <dl class=switch><dt>"<code>classic</code>"<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>, and <var>encoding</var>.</p>
       <dt>"<code>module</code>"<dd>
        <p><a href=#fetch-a-module-script-tree id=script-processing-model:fetch-a-module-script-tree>Fetch a module script graph</a> given <var>url</var>, <var>settings
        object</var>, "<code>script</code>", and <var>options</var>.</p>
       </dl>

      <p>When the chosen algorithm asynchronously completes, set <a href=#concept-script-script id=script-processing-model:concept-script-script>the script's script</a> to the result. At that time,
      <a href=#the-script-is-ready id=script-processing-model:the-script-is-ready-2>the script is ready</a>.</p>

      <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 the element will be inserted into the document (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 the element is <a href=#insert-an-element-into-a-document id=script-processing-model:insert-an-element-into-a-document>inserted into the document</a>, the load must have started as described in this
      step. If the UA performs such prefetching, but the element is never inserted in the document,
      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>

     </ol>

   <li id=establish-script-block-source>

    <p>If the element does not have a <code id=script-processing-model:attr-script-src-9><a href=#attr-script-src>src</a></code> content attribute,
    run these substeps:</p>

    <ol><li><p>Let <var>base URL</var> be the <code id=script-processing-model:the-script-element-38><a href=#the-script-element>script</a></code> element'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>'s <a href=#document-base-url id=script-processing-model:document-base-url>document base URL</a>.<li>
      <p>Switch on <a href=#concept-script-type id=script-processing-model:concept-script-type-8>the script's type</a>:</p>

      <dl class=switch><dt>"<code>classic</code>"<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>.<li><p>Set <a href=#concept-script-script id=script-processing-model:concept-script-script-2>the script's script</a> to
         <var>script</var>.<li><p><a href=#the-script-is-ready id=script-processing-model:the-script-is-ready-3>The script is ready</a>.</ol>
       <dt>"<code>module</code>"<dd>
        <ol><li><p>Let <var>script</var> be the result of <a href=#creating-a-module-script id=script-processing-model:creating-a-module-script>creating a module script</a> using
         <var>source text</var>, <var>settings object</var>, <var>base URL</var>, and
         <var>options</var>.<li><p>If this returns null, set <a href=#concept-script-script id=script-processing-model:concept-script-script-3>the script's
         script</a> to null and return; <a href=#the-script-is-ready id=script-processing-model:the-script-is-ready-4>the script is ready</a>.<li><p><a href=#fetch-the-descendants-of-and-instantiate-a-module-script id=script-processing-model:fetch-the-descendants-of-and-instantiate-a-module-script>Fetch the
         descendants of and instantiate</a> <var>script</var>, given <var>settings object</var>
         and the destination "<code>script</code>". When this asynchronously completes,
         set <a href=#concept-script-script id=script-processing-model:concept-script-script-4>the script's script</a> to the result. At
         that time, <a href=#the-script-is-ready id=script-processing-model:the-script-is-ready-5>the script is ready</a>.</ol>
       </dl>
     </ol>
   <li>

    <p>Then, follow the first of the following options that describes the situation:</p>

    <dl class=switch><dt id=script-processing-defer>If <a href=#concept-script-type id=script-processing-model:concept-script-type-9>the script's
     type</a> is "<code>classic</code>", and the element has a <code id=script-processing-model:attr-script-src-10><a href=#attr-script-src>src</a></code> attribute, and the element has a <code id=script-processing-model:attr-script-defer><a href=#attr-script-defer>defer</a></code> attribute, and the element has been flagged as
     <a href=#parser-inserted id=script-processing-model:parser-inserted-8>"parser-inserted"</a>, and the element does not have an <code id=script-processing-model:attr-script-async-4><a href=#attr-script-async>async</a></code> attribute<dt id=script-processing-module-noasync-parser-inserted>If <a href=#concept-script-type id=script-processing-model:concept-script-type-10>the script's type</a> is "<code>module</code>", and
     the element has been flagged as <a href=#parser-inserted id=script-processing-model:parser-inserted-9>"parser-inserted"</a>, and the element does not have
     an <code id=script-processing-model:attr-script-async-5><a href=#attr-script-async>async</a></code> attribute<dd>

      <p>Add the element to the end of the <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> associated with the <code id=script-processing-model:document-3><a href=#document>Document</a></code> of the parser that
      created the element.</p>

      <p>When <a href=#the-script-is-ready id=script-processing-model:the-script-is-ready-6>the script is ready</a>, set the element's <a href=#ready-to-be-parser-executed id=script-processing-model:ready-to-be-parser-executed>"ready to be
      parser-executed"</a> flag. The parser will handle executing the script.</p>

     <dt id=script-processing-parser-inserted>If <a href=#concept-script-type id=script-processing-model:concept-script-type-11>the script's
     type</a> is "<code>classic</code>", and the element has a <code id=script-processing-model:attr-script-src-11><a href=#attr-script-src>src</a></code> attribute, and the element has been flagged as
     <a href=#parser-inserted id=script-processing-model:parser-inserted-10>"parser-inserted"</a>, and the element does not have an <code id=script-processing-model:attr-script-async-6><a href=#attr-script-async>async</a></code> attribute<dd>

      <p>The element is the <a href=#pending-parsing-blocking-script id=script-processing-model:pending-parsing-blocking-script>pending parsing-blocking script</a> of the
      <code id=script-processing-model:document-4><a href=#document>Document</a></code> of the parser that created the element. (There can only be one such
      script per <code id=script-processing-model:document-5><a href=#document>Document</a></code> at a time.)</p>

      <p>When <a href=#the-script-is-ready id=script-processing-model:the-script-is-ready-7>the script is ready</a>, set the element's <a href=#ready-to-be-parser-executed id=script-processing-model:ready-to-be-parser-executed-2>"ready to be
      parser-executed"</a> flag. The parser will handle executing the script.</p>

     <dt id=script-processing-src-sync>If <a href=#concept-script-type id=script-processing-model:concept-script-type-12>the script's
     type</a> is "<code>classic</code>", and the element has a <code id=script-processing-model:attr-script-src-12><a href=#attr-script-src>src</a></code> attribute, and the element does not have an <code id=script-processing-model:attr-script-async-7><a href=#attr-script-async>async</a></code> attribute, and the element does not have the
     <a href=#non-blocking id=script-processing-model:non-blocking-5>"non-blocking"</a> flag set<dt id=script-processing-module-noasync>If <a href=#concept-script-type id=script-processing-model:concept-script-type-13>the script's
     type</a> is "<code>module</code>", and the element does not have an <code id=script-processing-model:attr-script-async-8><a href=#attr-script-async>async</a></code> attribute, and the element does not have the
     <a href=#non-blocking id=script-processing-model:non-blocking-6>"non-blocking"</a> flag set<dd>

      <p>Add the element to the end of the <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> associated with the <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> of the <code id=script-processing-model:the-script-element-39><a href=#the-script-element>script</a></code>
      element at the time the <a href=#prepare-a-script id=script-processing-model:prepare-a-script-5>prepare a script</a> algorithm started.</p>

      <p>When <a href=#the-script-is-ready id=script-processing-model:the-script-is-ready-8>the script is ready</a>, run the following steps:</p>

      <ol><li><p>If the element is not now the first element in the <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> to which it was added above, then mark the
       element as ready but return without executing the script yet.<li><p><i>Execution</i>: <a href=#execute-the-script-block id=script-processing-model:execute-the-script-block>Execute the script block</a> corresponding to the first
       script element in this <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-2>list of scripts that will execute in order as soon as
       possible</a>.<li><p>Remove the first element from this <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-3>list of scripts that will execute in order as
       soon as possible</a>.<li><p>If this <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-4>list of scripts that will execute in order as soon as possible</a> is
       still not empty and the first entry has already been marked as ready, then jump back to the
       step labeled <i>execution</i>.</ol>

     <dt id=script-processing-src>If <a href=#concept-script-type id=script-processing-model:concept-script-type-14>the script's type</a>
     is "<code>classic</code>", and the element has a <code id=script-processing-model:attr-script-src-13><a href=#attr-script-src>src</a></code> attribute<dt id=script-processing-module-async>If <a href=#concept-script-type id=script-processing-model:concept-script-type-15>the script's
     type</a> is "<code>module</code>"<dd>

      <p>The element must be added to the <dfn id=set-of-scripts-that-will-execute-as-soon-as-possible>set of scripts that will execute as soon as
      possible</dfn> of the <a id=script-processing-model:node-document-8 href=https://dom.spec.whatwg.org/#concept-node-document data-x-internal=node-document>node document</a> of the <code id=script-processing-model:the-script-element-40><a href=#the-script-element>script</a></code> element at the
      time the <a href=#prepare-a-script id=script-processing-model:prepare-a-script-6>prepare a script</a> algorithm started.</p>

      <p>When <a href=#the-script-is-ready id=script-processing-model:the-script-is-ready-9>the script is ready</a>, <a href=#execute-the-script-block id=script-processing-model:execute-the-script-block-2>execute the script block</a> and then
      remove the element from the <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>

     <dt id=script-processing-style-delayed>If the element does not have a <code id=script-processing-model:attr-script-src-14><a href=#attr-script-src>src</a></code> attribute, and the element has been flagged as
     <a href=#parser-inserted id=script-processing-model:parser-inserted-11>"parser-inserted"</a>, and either the parser that created the <code id=script-processing-model:the-script-element-41><a href=#the-script-element>script</a></code> 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, and the <code id=script-processing-model:document-6><a href=#document>Document</a></code> of the <a href=#html-parser id=script-processing-model:html-parser-4>HTML
     parser</a> or <a href=#xml-parser id=script-processing-model:xml-parser-4>XML parser</a> that created the <code id=script-processing-model:the-script-element-42><a href=#the-script-element>script</a></code> element <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><dd>

      <p>The element is the <a href=#pending-parsing-blocking-script id=script-processing-model:pending-parsing-blocking-script-2>pending parsing-blocking script</a> of the
      <code id=script-processing-model:document-7><a href=#document>Document</a></code> of the parser that created the element. (There can only be one such
      script per <code id=script-processing-model:document-8><a href=#document>Document</a></code> at a time.)</p>

      <p>Set the element's <a href=#ready-to-be-parser-executed id=script-processing-model:ready-to-be-parser-executed-3>"ready to be parser-executed"</a> flag. The parser will handle
      executing the script.</p>

     <dt id=script-processing-inline>Otherwise<dd><a href=#immediately id=script-processing-model:immediately-2>Immediately</a> <a href=#execute-the-script-block id=script-processing-model:execute-the-script-block-3>execute the script block</a>, even if other scripts are
     already executing.</dl>

   </ol>

  <p>The <dfn id=pending-parsing-blocking-script>pending parsing-blocking script</dfn> of a <code id=script-processing-model:document-9><a href=#document>Document</a></code> is used by the
  <code id=script-processing-model:document-10><a href=#document>Document</a></code>'s parser(s).</p>

  <p class=note>If a <code id=script-processing-model:the-script-element-43><a href=#the-script-element>script</a></code> element that blocks a parser gets moved to another
  <code id=script-processing-model:document-11><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 there
  was <a href=#a-style-sheet-that-is-blocking-scripts id=script-processing-model:a-style-sheet-that-is-blocking-scripts>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-12><a href=#document>Document</a></code> before the style sheet loads, 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>

  

  <p>When the user agent is required to <dfn id=execute-the-script-block>execute a script
  block</dfn>, it must run the following steps.</p>

  <ol><li>

    <p>If the element is flagged as <a href=#parser-inserted id=script-processing-model:parser-inserted-12>"parser-inserted"</a>, but the element's
    <a id=script-processing-model:node-document-9 href=https://dom.spec.whatwg.org/#concept-node-document data-x-internal=node-document>node document</a> is not the <code id=script-processing-model:document-13><a href=#document>Document</a></code> of the parser that created the element,
    then return.</p>

   <li>

    <p>If <a href=#concept-script-script id=script-processing-model:concept-script-script-5>the script's script</a> is null, <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 the element, and return.</p>

   <li>

    <p>If the script is <a href=#concept-script-external id=script-processing-model:concept-script-external-2>from an external file</a>, or
    <a href=#concept-script-type id=script-processing-model:concept-script-type-16>the script's type</a> is "<code>module</code>",
    then increment the <a href=#ignore-destructive-writes-counter id=script-processing-model:ignore-destructive-writes-counter>ignore-destructive-writes counter</a> of the <code id=script-processing-model:the-script-element-44><a href=#the-script-element>script</a></code>
    element's <a id=script-processing-model:node-document-10 href=https://dom.spec.whatwg.org/#concept-node-document data-x-internal=node-document>node document</a>. Let <var>neutralized doc</var> be that
    <code id=script-processing-model:document-14><a href=#document>Document</a></code>.</p>

   <li>

    <p>Let <var>old script element</var> be the value to which the <code id=script-processing-model:the-script-element-45><a href=#the-script-element>script</a></code>
    element's <a id=script-processing-model:node-document-11 href=https://dom.spec.whatwg.org/#concept-node-document data-x-internal=node-document>node document</a>'s <code id=script-processing-model:dom-document-currentscript><a href=#dom-document-currentscript>currentScript</a></code> object was most recently
    set.</p>

   <li>

    <p>Switch on <a href=#concept-script-type id=script-processing-model:concept-script-type-17>the script's type</a>:</p>

    <dl class=switch><dt>"<code>classic</code>"<dd>
      <ol><li>
        <p>If the <code id=script-processing-model:the-script-element-46><a href=#the-script-element>script</a></code> element'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 the <code id=script-processing-model:the-script-element-47><a href=#the-script-element>script</a></code> element's <a id=script-processing-model:node-document-12 href=https://dom.spec.whatwg.org/#concept-node-document data-x-internal=node-document>node document</a>'s <code id=script-processing-model:dom-document-currentscript-2><a href=#dom-document-currentscript>currentScript</a></code> attribute to the
        <code id=script-processing-model:the-script-element-48><a href=#the-script-element>script</a></code> element. 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 the
        <code id=script-processing-model:the-script-element-49><a href=#the-script-element>script</a></code> element 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><p><a href=#run-a-classic-script id=script-processing-model:run-a-classic-script>Run the classic script</a> given by <a href=#concept-script-script id=script-processing-model:concept-script-script-6>the script's script</a>.</ol>
     <dt>"<code>module</code>"<dd>
      <ol><li><p>Set the <code id=script-processing-model:the-script-element-50><a href=#the-script-element>script</a></code> element's <a id=script-processing-model:node-document-13 href=https://dom.spec.whatwg.org/#concept-node-document data-x-internal=node-document>node document</a>'s <code id=script-processing-model:dom-document-currentscript-4><a href=#dom-document-currentscript>currentScript</a></code> attribute to null.<li><p><a href=#run-a-module-script id=script-processing-model:run-a-module-script>Run the module script</a> given by <a href=#concept-script-script id=script-processing-model:concept-script-script-7>the script's script</a>.</ol>
     </dl>

   <li>

    <p>Set the <code id=script-processing-model:the-script-element-51><a href=#the-script-element>script</a></code> element's <a id=script-processing-model:node-document-14 href=https://dom.spec.whatwg.org/#concept-node-document data-x-internal=node-document>node document</a>'s <code id=script-processing-model:dom-document-currentscript-5><a href=#dom-document-currentscript>currentScript</a></code> attribute to <var>old script
    element</var>.</p>

   <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>neutralized doc</var>, if it was incremented in the earlier step.</p>

   <li>

    <p>If the script is <a href=#concept-script-external id=script-processing-model:concept-script-external-3>from an external file</a>, 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-load><a href=#event-load>load</a></code> at the <code id=script-processing-model:the-script-element-52><a href=#the-script-element>script</a></code> element.</p>

   </ol>

  


  <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. 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>.</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-a-script id=scriptingLanguages:prepare-a-script>prepare a script</a>
  algorithm and the WHATWG Fetch standard. <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 "<code>&lt;!--</code>" as "<code>&lt;\!--</code>", "<code>&lt;script</code>" as "<code>&lt;\script</code>", and "<code>&lt;/script</code>" as "<code>&lt;\/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:textcontent><a data-x-internal=textcontent href=https://dom.spec.whatwg.org/#dom-node-textcontent>textContent</a></code> of a <code id=restrictions-for-contents-of-script-elements:the-script-element-2><a href=#the-script-element>script</a></code> element 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->&apos;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->&apos;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>&quot;&lt;!--&quot;</c->
<c- nc>comment-close</c-> <c- o>=</c-> <c- l>&quot;--&gt;&quot;</c->
<c- nc>script-open</c->   <c- o>=</c-> <c- l>&quot;&lt;&quot;</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>var</c-> example <c- o>=</c-> <c- t>&apos;Consider this string: &lt;!-- &lt;script&gt;&apos;</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>var</c-> example <c- o>=</c-> <c- t>&apos;Consider this string: &lt;!-- &lt;script&gt;&apos;</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></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>var</c-> example <c- o>=</c-> <c- t>&apos;Consider this string: &lt;!-- &lt;script&gt;&apos;</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: `\s` is an escape sequence for `s`.</c->
  <c- a>var</c-> example <c- o>=</c-> <c- t>&apos;Consider this string: &lt;\!-- &lt;\script&gt;&apos;</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 href='https://infra.spec.whatwg.org/#scalar-value' data-x-internal='scalar-value' id='inline-documentation-for-external-scripts: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 href='https://infra.spec.whatwg.org/#scalar-value' data-x-internal='scalar-value' id='inline-documentation-for-external-scripts:scalar-value-2'><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 href='https://infra.spec.whatwg.org/#scalar-value' data-x-internal='scalar-value' id='inline-documentation-for-external-scripts:scalar-value-3'><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>&quot;cool-effects.js&quot;</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?></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
   be marked <a href=#parser-inserted id=scriptTagXSLT:parser-inserted>"parser-inserted"</a> 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.<li><p>The <code id=scriptTagXSLT:dom-xsltprocessor-transformtodocument><a href=#dom-xsltprocessor-transformtodocument>XSLTProcessor.transformToDocument()</a></code> method
   adds elements to a <code id=scriptTagXSLT:document><a href=#document>Document</a></code> that does not have a <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> flag set in the
   <a href=#prepare-a-script id=scriptTagXSLT:prepare-a-script>prepare a script</a> algorithm and never get executed (<a href=#concept-bc-noscript id=scriptTagXSLT:concept-bc-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 be marked <a href=#parser-inserted id=scriptTagXSLT:parser-inserted-2>"parser-inserted"</a>, 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.<li><p>The <code id=scriptTagXSLT:dom-xsltprocessor-transformtofragment><a href=#dom-xsltprocessor-transformtofragment>XSLTProcessor.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 that aren't <a href=#parser-inserted id=scriptTagXSLT:parser-inserted-3>"parser-inserted"</a> and
   that don't have their <a href=#already-started id=scriptTagXSLT:already-started-2>"already started"</a> flag set, so that they will execute when the
   fragment is inserted into a document.</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><code>noscript</code></dfn> element<a href=#the-noscript-element class=self-link></a></h4>

  <dl class=element><dt><a href=#concept-element-categories id=the-noscript-element:concept-element-categories>Categories</a>:<dd><a href=#metadata-content-2 id=the-noscript-element:metadata-content-2>Metadata content</a>.<dd><a href=#flow-content-2 id=the-noscript-element:flow-content-2>Flow content</a>.<dd><a href=#phrasing-content-2 id=the-noscript-element:phrasing-content-2>Phrasing content</a>.<dt><a href=#concept-element-contexts id=the-noscript-element:concept-element-contexts>Contexts in which this element can be used</a>:<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>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.<dt><a href=#concept-element-content-model id=the-noscript-element:concept-element-content-model>Content model</a>:<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>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>Otherwise: text that conforms to the requirements given in the prose.<dt><a href=#concept-element-tag-omission id=the-noscript-element:concept-element-tag-omission>Tag omission in text/html</a>:<dd>Neither tag is omissible.<dt><a href=#concept-element-attributes id=the-noscript-element:concept-element-attributes>Content attributes</a>:<dd><a href=#global-attributes id=the-noscript-element:global-attributes>Global attributes</a><dt><a href=#concept-element-dom id=the-noscript-element:concept-element-dom>DOM interface</a>:<dd>Uses <code id=the-noscript-element:htmlelement><a href=#htmlelement>HTMLElement</a></code>.</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<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.<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<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>.<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<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).<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<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>
    

    <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>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>Set the <code id=the-noscript-element:dom-outerhtml><a data-x-internal=dom-outerhtml href=https://w3c.github.io/DOM-Parsing/#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.) <a href=#refsDOMPARSING>[DOMPARSING]</a></ol>

     </ol>

   </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>&quot;calcSquare.php&quot;</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>&quot;x&quot;</c-> <c- e>name</c-><c- o>=</c-><c- s>&quot;x&quot;</c-> <c- e>type</c-><c- o>=</c-><c- s>&quot;number&quot;</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>&apos;x&apos;</c-><c- p>);</c->
  <c- a>var</c-> output <c- o>=</c-> document<c- p>.</c->createElement<c- p>(</c-><c- t>&apos;p&apos;</c-><c- p>);</c->
  output<c- p>.</c->textContent <c- o>=</c-> <c- t>&apos;Type a number; it will be squared right then!&apos;</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>&apos; squared is &apos;</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>&quot;Calculate Square&quot;</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>&quot;calcSquare.php&quot;</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>&quot;x&quot;</c-> <c- e>name</c-><c- o>=</c-><c- s>&quot;x&quot;</c-> <c- e>type</c-><c- o>=</c-><c- s>&quot;number&quot;</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>&quot;submit&quot;</c-> <c- e>type</c-><c- o>=</c-><c- s>submit</c-> <c- e>value</c-><c- o>=</c-><c- s>&quot;Calculate Square&quot;</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>&apos;x&apos;</c-><c- p>);</c->
  <c- a>var</c-> output <c- o>=</c-> document<c- p>.</c->createElement<c- p>(</c-><c- t>&apos;p&apos;</c-><c- p>);</c->
  output<c- p>.</c->textContent <c- o>=</c-> <c- t>&apos;Type a number; it will be squared right then!&apos;</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>&apos; squared is &apos;</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>&apos;submit&apos;</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><code>template</code></dfn> element<a href=#the-template-element class=self-link></a></h4><div class=status><input onclick=toggleStatus(this) value=⋰ type=button><p class=support><strong>Support:</strong> template<span class="and_chr yes"><span>Chrome for Android</span> <span>67+</span></span><span class="chrome yes"><span>Chrome</span> <span>35+</span></span><span class="ios_saf yes"><span>iOS Safari</span> <span>9.0+</span></span><span class="and_uc yes"><span>UC Browser for Android</span> <span>11.8+</span></span><span class="firefox yes"><span>Firefox</span> <span>22+</span></span><span class="ie no"><span>IE</span> <span>None</span></span><span class="op_mini no"><span>Opera Mini</span> <span>None</span></span><span class="safari yes"><span>Safari</span> <span>9+</span></span><span class="edge yes"><span>Edge</span> <span>15+</span></span><span class="samsung yes"><span>Samsung Internet</span> <span>4+</span></span><span class="opera yes"><span>Opera</span> <span>22+</span></span><span class="android yes"><span>Android Browser</span> <span>4.4+</span></span><p class=caniuse>Source: <a href="https://caniuse.com/#feat=template">caniuse.com</a></div>

  <dl class=element><dt><a href=#concept-element-categories id=the-template-element:concept-element-categories>Categories</a>:<dd><a href=#metadata-content-2 id=the-template-element:metadata-content-2>Metadata content</a>.<dd><a href=#flow-content-2 id=the-template-element:flow-content-2>Flow content</a>.<dd><a href=#phrasing-content-2 id=the-template-element:phrasing-content-2>Phrasing content</a>.<dd><a href=#script-supporting-elements-2 id=the-template-element:script-supporting-elements-2>Script-supporting element</a>.<dt><a href=#concept-element-contexts id=the-template-element:concept-element-contexts>Contexts in which this element can be used</a>:<dd>Where <a href=#metadata-content-2 id=the-template-element:metadata-content-2-2>metadata content</a> is expected.<dd>Where <a href=#phrasing-content-2 id=the-template-element:phrasing-content-2-2>phrasing content</a> is expected.<dd>Where <a href=#script-supporting-elements-2 id=the-template-element:script-supporting-elements-2-2>script-supporting elements</a> are expected.<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.<dt><a href=#concept-element-content-model id=the-template-element:concept-element-content-model>Content model</a>:<dd><a href=#concept-content-nothing id=the-template-element:concept-content-nothing>Nothing</a> (for clarification, <a href=#template-example>see example</a>).<dt><a href=#concept-element-tag-omission id=the-template-element:concept-element-tag-omission>Tag omission in text/html</a>:<dd>Neither tag is omissible.<dt><a href=#concept-element-attributes id=the-template-element:concept-element-attributes>Content attributes</a>:<dd><a href=#global-attributes id=the-template-element:global-attributes>Global attributes</a><dt><a href=#concept-element-dom id=the-template-element:concept-element-dom>DOM interface</a>:<dd>
    <pre><code class='idl'>[<c- g>Exposed</c->=<c- n>Window</c->,
 <a href='#htmlconstructor' id='the-template-element:htmlconstructor'><c- g>HTMLConstructor</c-></a>]
<c- b>interface</c-> <dfn id='htmltemplateelement'><c- g>HTMLTemplateElement</c-></dfn> : <a href='#htmlelement' id='the-template-element:htmlelement'><c- n>HTMLElement</c-></a> {
  <c- b>readonly</c-> <c- b>attribute</c-> <a href='https://dom.spec.whatwg.org/#interface-documentfragment' data-x-internal='documentfragment' id='the-template-element:documentfragment'><c- n>DocumentFragment</c-></a> <a href='#dom-template-content' id='the-template-element:dom-template-content'><c- g>content</c-></a>;
};</code></pre>
</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 <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>

   <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>&quot;en&quot;</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>&quot;template&quot;</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- mi>3</c-><c- p>;</c->
   <c- kr>const</c-> fragment <c- o>=</c-> document<c- p>.</c->getElementById<c- p>(</c-><c- t>&apos;template&apos;</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- mi>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><var>template</var> . <code id=dom-template-content-dev><a href=#dom-template-content>content</a></code><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>

   </dl>

  

  <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>.<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.<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.</ol>

  <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> (that does not have a
       <a href=#concept-document-bc id=the-template-element:concept-document-bc>browsing context</a>). 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.<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.<li><p>Let <var>doc</var>'s <a href=#associated-inert-template-document id=the-template-element:associated-inert-template-document>associated inert template document</a> be <var>new doc</var>.</ol>

     <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>.</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><p>Return <var>doc</var>.</ol>

  <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><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>.</ol>

  <p>The <dfn id=dom-template-content><code>content</code></dfn> IDL attribute must return the
  <code id=the-template-element:the-template-element-20><a href=#the-template-element>template</a></code> element's <a href=#template-contents id=the-template-element:template-contents-8>template contents</a>.</p>

  <hr>

  <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 a <code id=the-template-element:the-template-element-21><a href=#the-template-element>template</a></code>
  element <var>node</var> being cloned to a copy <var>copy</var> must run the
  following steps:</p>

  <ol><li><p>If the <var>clone children flag</var> is not set in the calling <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> algorithm, return.<li><p>Let <var>copied contents</var> be the result of <a href=https://dom.spec.whatwg.org/#concept-node-clone id=the-template-element:concept-node-clone-2 data-x-internal=concept-node-clone>cloning</a> all the children of <var>node</var>'s
   <a href=#template-contents id=the-template-element:template-contents-9>template contents</a>, with <var>document</var> set to <var>copy</var>'s <a href=#template-contents id=the-template-element:template-contents-10>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>, and with the <var>clone children
   flag</var> set.<li><p>Append <var>copied contents</var> to <var>copy</var>'s <a href=#template-contents id=the-template-element:template-contents-11>template
   contents</a>.</ol>

  

  <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>&apos;en&apos;</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>&apos;Pillar&apos;</c-><c- p>,</c-> color<c- o>:</c-> <c- t>&apos;Ticked Tabby&apos;</c-><c- p>,</c-> sex<c- o>:</c-> <c- t>&apos;Female (neutered)&apos;</c-><c- p>,</c-> legs<c- o>:</c-> <c- mi>3</c-> <c- p>},</c->
   <c- p>{</c-> name<c- o>:</c-> <c- t>&apos;Hedral&apos;</c-><c- p>,</c-> color<c- o>:</c-> <c- t>&apos;Tuxedo&apos;</c-><c- p>,</c-> sex<c- o>:</c-> <c- t>&apos;Male (neutered)&apos;</c-><c- p>,</c-> legs<c- o>:</c-> <c- mi>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>&quot;row&quot;</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>&apos;#row&apos;</c-><c- p>);</c->
 <c- k>for</c-> <c- p>(</c-><c- a>var</c-> i <c- o>=</c-> <c- mi>0</c-><c- p>;</c-> i <c- o>&lt;</c-> data<c- p>.</c->length<c- p>;</c-> i <c- o>+=</c-> <c- mi>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>&apos;td&apos;</c-><c- p>);</c->
   cells<c- p>[</c-><c- mi>0</c-><c- p>].</c->textContent <c- o>=</c-> cat<c- p>.</c->name<c- p>;</c->
   cells<c- p>[</c-><c- mi>1</c-><c- p>].</c->textContent <c- o>=</c-> cat<c- p>.</c->color<c- p>;</c->
   cells<c- p>[</c-><c- mi>2</c-><c- p>].</c->textContent <c- o>=</c-> cat<c- p>.</c->sex<c- p>;</c->
   cells<c- p>[</c-><c- mi>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.<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>.<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>

  </ul>

  



  <h4 id=the-slot-element><span class=secno>4.12.4</span> The <dfn><code>slot</code></dfn> element<a href=#the-slot-element class=self-link></a></h4>

  <dl class=element><dt><a href=#concept-element-categories id=the-slot-element:concept-element-categories>Categories</a>:<dd><a href=#flow-content-2 id=the-slot-element:flow-content-2>Flow content</a>.<dd><a href=#phrasing-content-2 id=the-slot-element:phrasing-content-2>Phrasing content</a>.<dt><a href=#concept-element-contexts id=the-slot-element:concept-element-contexts>Contexts in which this element can be used</a>:<dd>Where <a href=#phrasing-content-2 id=the-slot-element:phrasing-content-2-2>phrasing content</a> is expected.<dt><a href=#concept-element-content-model id=the-slot-element:concept-element-content-model>Content model</a>:<dd><a href=#transparent id=the-slot-element:transparent>Transparent</a><dt><a href=#concept-element-tag-omission id=the-slot-element:concept-element-tag-omission>Tag omission in text/html</a>:<dd>Neither tag is omissible.<dt><a href=#concept-element-attributes id=the-slot-element:concept-element-attributes>Content attributes</a>:<dd><a href=#global-attributes id=the-slot-element:global-attributes>Global attributes</a><dd><code id=the-slot-element:attr-slot-name><a href=#attr-slot-name>name</a></code> — Name of shadow tree slot<dt><a href=#concept-element-dom id=the-slot-element:concept-element-dom>DOM interface</a>:<dd>
    <pre><code class='idl'>[<c- g>Exposed</c->=<c- n>Window</c->,
 <a href='#htmlconstructor' id='the-slot-element:htmlconstructor'><c- g>HTMLConstructor</c-></a>]
<c- b>interface</c-> <dfn id='htmlslotelement'><c- g>HTMLSlotElement</c-></dfn> : <a href='#htmlelement' id='the-slot-element:htmlelement'><c- n>HTMLElement</c-></a> {
  [<a href='#cereactions' id='the-slot-element:cereactions'><c- g>CEReactions</c-></a>] <c- b>attribute</c-> <c- b>DOMString</c-> <a href='#dom-slot-name' id='the-slot-element:dom-slot-name'><c- g>name</c-></a>;
  <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>dictionary</c-> <dfn id='assignednodesoptions'><c- g>AssignedNodesOptions</c-></dfn> {
  <c- b>boolean</c-> <c- g>flatten</c-> = <c- b>false</c->;
};</code></pre>
   </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 id=attr-slot-name><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><var>slot</var> . <code id=dom-slot-name-dev><a href=#dom-slot-name>name</a></code><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>.<dt><var>slot</var> . <code id=dom-slot-assignednodes-dev><a href=#dom-slot-assignednodes>assignedNodes</a></code>()<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>.<dt><var>slot</var> . <code id=the-slot-element:dom-slot-assignednodes-2><a href=#dom-slot-assignednodes>assignedNodes</a></code>({ flatten: true })<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.<dt><var>slot</var> . <code id=dom-slot-assignedelements-dev><a href=#dom-slot-assignedelements>assignedElements</a></code>()<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.<dt><var>slot</var> . <code id=the-slot-element:dom-slot-assignedelements-2><a href=#dom-slot-assignedelements>assignedElements</a></code>({ flatten: true })<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.</dl>

  <p>The <dfn id=dom-slot-name><code>name</code></dfn> IDL attribute must <a href=#reflect id=the-slot-element:reflect>reflect</a>
  the content attribute of the same name.</p>

  <p>The <dfn id=dom-slot-assignednodes><code>assignedNodes(<var>options</var>)</code></dfn>
  method, when invoked, must run these steps:</p>

  <ol><li><p>If the value of <var>options</var>'s <code>flatten</code> member is false, then
   return this element'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>.<li><p>Return the result of <a id=the-slot-element:finding-flattened-slotables href=https://dom.spec.whatwg.org/#find-flattened-slotables data-x-internal=finding-flattened-slotables>finding flattened slotables</a> with this element.</ol>

  <p>The <dfn id=dom-slot-assignedelements><code>assignedElements(<var>options</var>)</code></dfn>
  method, when invoked, must run these steps:</p>

  <ol><li><p>If the value of <var>options</var>'s <code>flatten</code> member is false, then
   return this element'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><a data-x-internal=element href=https://dom.spec.whatwg.org/#interface-element>Element</a></code>
   nodes.<li><p>Return the result of <a id=the-slot-element:finding-flattened-slotables-2 href=https://dom.spec.whatwg.org/#find-flattened-slotables data-x-internal=finding-flattened-slotables>finding flattened slotables</a> with this element, 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.</ol>



  <h4 id=the-canvas-element><span class=secno>4.12.5</span> The <dfn id=canvas><code>canvas</code></dfn> element<a href=#the-canvas-element class=self-link></a></h4><div class=status><input onclick=toggleStatus(this) value=⋰ type=button><p class=support><strong>Support:</strong> canvas<span class="and_chr yes"><span>Chrome for Android</span> <span>67+</span></span><span class="chrome yes"><span>Chrome</span> <span>4+</span></span><span class="ios_saf yes"><span>iOS Safari</span> <span>3.2+</span></span><span class="and_uc yes"><span>UC Browser for Android</span> <span>11.8+</span></span><span class="firefox yes"><span>Firefox</span> <span>3.6+</span></span><span class="ie yes"><span>IE</span> <span>9+</span></span><span class="op_mini partial"><span>Opera Mini (limited)</span> <span>all+</span></span><span class="safari yes"><span>Safari</span> <span>4+</span></span><span class="edge yes"><span>Edge</span> <span>12+</span></span><span class="samsung yes"><span>Samsung Internet</span> <span>4+</span></span><span class="opera yes"><span>Opera</span> <span>9+</span></span><span class="android yes"><span>Android Browser</span> <span>3+</span></span><p class=caniuse>Source: <a href="https://caniuse.com/#feat=canvas">caniuse.com</a></div>

  <dl class=element><dt><a href=#concept-element-categories id=the-canvas-element:concept-element-categories>Categories</a>:<dd><a href=#flow-content-2 id=the-canvas-element:flow-content-2>Flow content</a>.<dd><a href=#phrasing-content-2 id=the-canvas-element:phrasing-content-2>Phrasing content</a>.<dd><a href=#embedded-content-category id=the-canvas-element:embedded-content-category>Embedded content</a>.<dd><a href=#palpable-content-2 id=the-canvas-element:palpable-content-2>Palpable content</a>.<dt><a href=#concept-element-contexts id=the-canvas-element:concept-element-contexts>Contexts in which this element can be used</a>:<dd>Where <a href=#embedded-content-category id=the-canvas-element:embedded-content-category-2>embedded content</a> is expected.<dt><a href=#concept-element-content-model id=the-canvas-element:concept-element-content-model>Content model</a>:<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>, <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, and elements that would not be
   <a href=#interactive-content-2 id=the-canvas-element:interactive-content-2-2>interactive content</a> except for having the <code id=the-canvas-element:attr-tabindex><a href=#attr-tabindex>tabindex</a></code> attribute specified.<dt><a href=#concept-element-tag-omission id=the-canvas-element:concept-element-tag-omission>Tag omission in text/html</a>:<dd>Neither tag is omissible.<dt><a href=#concept-element-attributes id=the-canvas-element:concept-element-attributes>Content attributes</a>:<dd><a href=#global-attributes id=the-canvas-element:global-attributes>Global attributes</a><dd><code id=the-canvas-element:attr-canvas-width><a href=#attr-canvas-width>width</a></code> — Horizontal dimension<dd><code id=the-canvas-element:attr-canvas-height><a href=#attr-canvas-height>height</a></code> — Vertical dimension<dt><a href=#concept-element-dom id=the-canvas-element:concept-element-dom>DOM interface</a>:<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 href='https://www.khronos.org/registry/webgl/specs/latest/1.0/#WebGLRenderingContext' data-x-internal='webglrenderingcontext' id='the-canvas-element:webglrenderingcontext'><c- n>WebGLRenderingContext</c-></a> <c- b>or</c-> <a href='https://www.khronos.org/registry/webgl/specs/latest/2.0/#WebGL2RenderingContext' data-x-internal='webgl2renderingcontext' id='the-canvas-element:webgl2renderingcontext'><c- n>WebGL2RenderingContext</c-></a>) <dfn id='renderingcontext'><c- g>RenderingContext</c-></dfn>;

[<c- g>Exposed</c->=<c- n>Window</c->,
 <a href='#htmlconstructor' id='the-canvas-element:htmlconstructor'><c- g>HTMLConstructor</c-></a>]
<c- b>interface</c-> <dfn id='htmlcanvaselement'><c- g>HTMLCanvasElement</c-></dfn> : <a href='#htmlelement' id='the-canvas-element:htmlelement'><c- n>HTMLElement</c-></a> {
  [<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->, <c- b>optional</c-> <c- b>any</c-> <c- g>quality</c->);
  <c- b>void</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->, <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'><c- g>BlobCallback</c-></dfn> = <c- b>void</c-> (<a href='https://w3c.github.io/FileAPI/#dfn-Blob' data-x-internal='blob' id='the-canvas-element:blob'><c- n>Blob</c-></a>? <c- g>blob</c->);</code></pre>
   </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> 

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

  <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 id=attr-canvas-width><code>width</code></dfn> and <dfn id=attr-canvas-height><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>

  <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://heycam.github.io/webidl/#invalidstateerror data-x-internal=invalidstateerror>"<code>InvalidStateError</code>"</a> <code id=the-canvas-element:domexception><a data-x-internal=domexception href=https://heycam.github.io/webidl/#dfn-DOMException>DOMException</a></code>
  and leave the attribute's value unchanged.</p>

  <p>The <a id=the-canvas-element:intrinsic-dimensions href=https://drafts.csswg.org/css2/conform.html#intrinsic data-x-internal=intrinsic-dimensions>intrinsic 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>

  <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> 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>, or <dfn id=concept-canvas-webgl2>webgl2</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 an <a href=#intrinsic-width id=the-canvas-element:intrinsic-width>intrinsic 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 an <a href=#intrinsic-height id=the-canvas-element:intrinsic-height>intrinsic 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 calling the <code id=the-canvas-element:offscreencontext-commit><a href=#offscreencontext-commit>commit()</a></code> method of 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 href=#intrinsic-width id=the-canvas-element:intrinsic-width-2>intrinsic width</a>, whose height
  is the element's <a href=#intrinsic-height id=the-canvas-element:intrinsic-height-2>intrinsic height</a>, and whose appearance is the element's bitmap.</p>

  <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>
      <p>Action</p>

   <tbody><tr><th>
      <p><a href=#concept-canvas-2d id=the-canvas-element:concept-canvas-2d>2d</a></p>
     <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>

    <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>
     <td>
      <p>Follow the behavior defined in the WebGL specifications. <a href=#refsWEBGL>[WEBGL]</a></p>

    <tr><th>
      <p><a href=#concept-canvas-bitmaprenderer id=the-canvas-element:concept-canvas-bitmaprenderer>bitmaprenderer</a></p>
     <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>

    <tr><th>
      <p><a href=#concept-canvas-placeholder id=the-canvas-element:concept-canvas-placeholder-3>placeholder</a></p>
     <td>
      <p>Do nothing.</p>

    <tr><th>
      <p><a href=#concept-canvas-none id=the-canvas-element:concept-canvas-none-2>none</a></p>
     <td>
      <p>Do nothing.</p>
  </table>

  <p>The <dfn id=dom-canvas-width><code>width</code></dfn> and <dfn id=dom-canvas-height><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>

  

  <hr>

  <dl class=domintro><dt><var>context</var> = <var>canvas</var> . <code id=dom-canvas-getcontext-dev><a href=#dom-canvas-getcontext>getContext</a></code>(<var>contextId</var> [, <var>options</var> ] )<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>", or "<code id=the-canvas-element:canvas-context-webgl2><a href=#canvas-context-webgl2>webgl2</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. <a href=#refsWEBGL>[WEBGL]</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>
   </dl>

  

  <p>The <dfn id=dom-canvas-getcontext><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:

  <ol><li><p>If <var>options</var> is not an <a href=https://heycam.github.io/webidl/#idl-object id=the-canvas-element:idl-object data-x-internal=idl-object>object</a>, then set
   <var>options</var> to null.<li><p>Set <var>options</var> to the result of <a href=https://heycam.github.io/webidl/#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.<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>
       <th><a href=#concept-canvas-none id=the-canvas-element:concept-canvas-none-3>none</a>
       <th><a href=#concept-canvas-2d id=the-canvas-element:concept-canvas-2d-2>2d</a>
       <th><a href=#concept-canvas-bitmaprenderer id=the-canvas-element:concept-canvas-bitmaprenderer-2>bitmaprenderer</a>
       <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><a href=#concept-canvas-placeholder id=the-canvas-element:concept-canvas-placeholder-4>placeholder</a>
     <tbody><tr><th>"<dfn id=canvas-context-2d><code>2d</code></dfn>"
       <td>
        Follow the <a href=#2d-context-creation-algorithm id=the-canvas-element:2d-context-creation-algorithm>2D context creation algorithm</a> defined in the section below, passing
        it this <code id=the-canvas-element:the-canvas-element-36><a href=#the-canvas-element>canvas</a></code> element and <var>options</var>, to obtain a
        <code id=the-canvas-element:canvasrenderingcontext2d-3><a href=#canvasrenderingcontext2d>CanvasRenderingContext2D</a></code> object; if this does not throw an exception, then set
        this <code id=the-canvas-element:the-canvas-element-37><a href=#the-canvas-element>canvas</a></code> element'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>, and return the
        <code id=the-canvas-element:canvasrenderingcontext2d-4><a href=#canvasrenderingcontext2d>CanvasRenderingContext2D</a></code> object.
       <td>
        Return the same object as was returned the last time the method was invoked with this same
        first argument.
       <td>
        Return null.
       <td>
        Return null.
       <td>
        Throw an <a id=the-canvas-element:invalidstateerror-2 href=https://heycam.github.io/webidl/#invalidstateerror data-x-internal=invalidstateerror>"<code>InvalidStateError</code>"</a> <code id=the-canvas-element:domexception-2><a data-x-internal=domexception href=https://heycam.github.io/webidl/#dfn-DOMException>DOMException</a></code>.
      <tr><th>"<dfn id=canvas-context-bitmaprenderer><code>bitmaprenderer</code></dfn>"
       <td>
        Follow the <a href=#imagebitmaprenderingcontext-creation-algorithm id=the-canvas-element:imagebitmaprenderingcontext-creation-algorithm><code>ImageBitmapRenderingContext</code> creation algorithm</a> defined
        in the section below, passing it this <code id=the-canvas-element:the-canvas-element-38><a href=#the-canvas-element>canvas</a></code> element and <var>options</var>, to
        obtain an <code id=the-canvas-element:imagebitmaprenderingcontext-3><a href=#imagebitmaprenderingcontext>ImageBitmapRenderingContext</a></code> object; then set this <code id=the-canvas-element:the-canvas-element-39><a href=#the-canvas-element>canvas</a></code>
        element'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>, and return the
        <code id=the-canvas-element:imagebitmaprenderingcontext-4><a href=#imagebitmaprenderingcontext>ImageBitmapRenderingContext</a></code> object.
       <td>
        Return null.
       <td>
        Return the same object as was returned the last time the method was invoked with this same
        first argument.
       <td>
        Return null.
       <td>
        Throw an <a id=the-canvas-element:invalidstateerror-3 href=https://heycam.github.io/webidl/#invalidstateerror data-x-internal=invalidstateerror>"<code>InvalidStateError</code>"</a> <code id=the-canvas-element:domexception-3><a data-x-internal=domexception href=https://heycam.github.io/webidl/#dfn-DOMException>DOMException</a></code>.
      <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
       <td>
        Follow the instructions given in the WebGL specifications' <i>Context Creation</i> sections
        to obtain a <code id=the-canvas-element:webglrenderingcontext-2><a data-x-internal=webglrenderingcontext href=https://www.khronos.org/registry/webgl/specs/latest/1.0/#WebGLRenderingContext>WebGLRenderingContext</a></code>, <code id=the-canvas-element:webgl2renderingcontext-2><a data-x-internal=webgl2renderingcontext href=https://www.khronos.org/registry/webgl/specs/latest/2.0/#WebGL2RenderingContext>WebGL2RenderingContext</a></code>, or
        null; if the returned value is null, then return null; otherwise, set this
        <code id=the-canvas-element:the-canvas-element-40><a href=#the-canvas-element>canvas</a></code> element'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>, and return the
        <code id=the-canvas-element:webglrenderingcontext-3><a data-x-internal=webglrenderingcontext href=https://www.khronos.org/registry/webgl/specs/latest/1.0/#WebGLRenderingContext>WebGLRenderingContext</a></code> or <code id=the-canvas-element:webgl2renderingcontext-3><a data-x-internal=webgl2renderingcontext href=https://www.khronos.org/registry/webgl/specs/latest/2.0/#WebGL2RenderingContext>WebGL2RenderingContext</a></code> object. <a href=#refsWEBGL>[WEBGL]</a>
       <td>
        Return null.
       <td>
        Return null.
       <td>
        Return the same object as was returned the last time the method was invoked with this same
        first argument.
       <td>
        Throw an <a id=the-canvas-element:invalidstateerror-4 href=https://heycam.github.io/webidl/#invalidstateerror data-x-internal=invalidstateerror>"<code>InvalidStateError</code>"</a> <code id=the-canvas-element:domexception-4><a data-x-internal=domexception href=https://heycam.github.io/webidl/#dfn-DOMException>DOMException</a></code>.
      <tr><th>An unsupported value*
       <td>
        Return null.
       <td>
        Return null.
       <td>
        Return null.
       <td>
        Return null.
       <td>
        Throw an <a id=the-canvas-element:invalidstateerror-5 href=https://heycam.github.io/webidl/#invalidstateerror data-x-internal=invalidstateerror>"<code>InvalidStateError</code>"</a> <code id=the-canvas-element:domexception-5><a data-x-internal=domexception href=https://heycam.github.io/webidl/#dfn-DOMException>DOMException</a></code>.
    </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>
   </ol>

  <hr>

  

  <dl class=domintro><dt><var>url</var> = <var>canvas</var> . <code id=dom-canvas-todataurl-dev><a href=#dom-canvas-todataurl>toDataURL</a></code>( [ <var>type</var> [, <var>quality</var> ] ] )<dd>

    <p>Returns a <a href=https://tools.ietf.org/html/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>

   <dt><var>canvas</var> . <code id=dom-canvas-toblob-dev><a href=#dom-canvas-toblob>toBlob</a></code>(<var>callback</var> [, <var>type</var> [, quality ] ] )<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>

   <dt><var>canvas</var> . <code id=dom-canvas-transfercontroltooffscreen-dev><a href=#dom-canvas-transfercontroltooffscreen>transferControlToOffscreen</a></code>()<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-41><a href=#the-canvas-element>canvas</a></code> element as a placeholder. Once the <code id=the-canvas-element:the-canvas-element-42><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 intrinsic size can no longer be
    changed, and it cannot have a rendering context. The content of the placeholder canvas is
    updated by calling the <code id=the-canvas-element:offscreencontext-commit-2><a href=#offscreencontext-commit>commit()</a></code> method of the
    <code id=the-canvas-element:offscreencanvas-6><a href=#offscreencanvas>OffscreenCanvas</a></code> object's rendering context.
    </p>
   </dl>

  

  <p>The <dfn id=dom-canvas-todataurl><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-43><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://heycam.github.io/webidl/#securityerror data-x-internal=securityerror>"<code>SecurityError</code>"</a> <code id=the-canvas-element:domexception-6><a data-x-internal=domexception href=https://heycam.github.io/webidl/#dfn-DOMException>DOMException</a></code>.</p>


   <li><p>If this <code id=the-canvas-element:the-canvas-element-44><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://tools.ietf.org/html/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.)<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 they were given.<li><p>If <var>file</var> is null then return "<code>data:,</code>".<li><p>Return a <a href=https://tools.ietf.org/html/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>

   

  </ol>

  <p>The <dfn id=dom-canvas-toblob><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-45><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://heycam.github.io/webidl/#securityerror data-x-internal=securityerror>"<code>SecurityError</code>"</a> <code id=the-canvas-element:domexception-7><a data-x-internal=domexception href=https://heycam.github.io/webidl/#dfn-DOMException>DOMException</a></code>.<li><p>Let <var>result</var> be null.<li><p>If this <code id=the-canvas-element:the-canvas-element-46><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-47><a href=#the-canvas-element>canvas</a></code> element's bitmap.

   <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 they were given.<li>
      <p><a href=#queue-a-task id=the-canvas-element:queue-a-task>Queue a task</a> 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-48><a href=#the-canvas-element>canvas</a></code> element, representing <var>result</var>. <a href=#refsFILEAPI>[FILEAPI]</a><li><p><a href=https://heycam.github.io/webidl/#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> ».</ol>

      <p>The <a href=#task-source id=the-canvas-element:task-source>task source</a> for this task is the
      <dfn id=canvas-blob-serialisation-task-source>canvas blob serialization task
      source</dfn>.</p>
     </ol>
   </ol>

  <p>The <dfn id=dom-canvas-transfercontroltooffscreen><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-49><a href=#the-canvas-element>canvas</a></code> element's <a href=#concept-canvas-context-mode id=the-canvas-element:concept-canvas-context-mode-10>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-6 href=https://heycam.github.io/webidl/#invalidstateerror data-x-internal=invalidstateerror>"<code>InvalidStateError</code>"</a> <code id=the-canvas-element:domexception-8><a data-x-internal=domexception href=https://heycam.github.io/webidl/#dfn-DOMException>DOMException</a></code>.<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-50><a href=#the-canvas-element>canvas</a></code> element.<li><p>Set the <a href=#offscreencanvas-placeholder id=the-canvas-element:offscreencanvas-placeholder>placeholder <code>canvas</code>
   element</a> of <var>offscreenCanvas</var> to be a weak reference to this <code id=the-canvas-element:the-canvas-element-51><a href=#the-canvas-element>canvas</a></code>
   element.<li><p>Set this <code id=the-canvas-element:the-canvas-element-52><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> to <a href=#concept-canvas-placeholder id=the-canvas-element:concept-canvas-placeholder-5>placeholder</a>.<li><p>Return <var>offscreenCanvas</var>.</ol>

  

  

  <h5 id=2dcontext><span class=secno>4.12.5.1</span> The 2D rendering context<a href=#2dcontext class=self-link></a></h5>

  

  <pre><code class='idl'><c- b>typedef</c-> (<a href='#htmlimageelement' id='2dcontext:htmlimageelement'><c- n>HTMLImageElement</c-></a> <c- b>or</c->
         <a href='https://svgwg.org/svg2-draft/embedded.html#InterfaceSVGImageElement' data-x-internal='svgimageelement' id='2dcontext:svgimageelement'><c- n>SVGImageElement</c-></a>) <dfn id='htmlorsvgimageelement'><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>) <dfn id='canvasimagesource'><c- g>CanvasImageSource</c-></dfn>;

<c- b>enum</c-> <dfn id='canvasfillrule'><c- g>CanvasFillRule</c-></dfn> { <c- s>&quot;</c-><a href='#dom-context-2d-fillrule-nonzero' id='2dcontext:dom-context-2d-fillrule-nonzero'><c- s>nonzero</c-></a><c- s>&quot;</c->, <c- s>&quot;</c-><a href='#dom-context-2d-fillrule-evenodd' id='2dcontext:dom-context-2d-fillrule-evenodd'><c- s>evenodd</c-></a><c- s>&quot;</c-> };

<c- b>dictionary</c-> <dfn id='canvasrenderingcontext2dsettings'><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>enum</c-> <dfn id='imagesmoothingquality'><c- g>ImageSmoothingQuality</c-></dfn> { <c- s>&quot;</c-><a href='#dom-context-2d-imagesmoothingquality-low' id='2dcontext:dom-context-2d-imagesmoothingquality-low'><c- s>low</c-></a><c- s>&quot;</c->, <c- s>&quot;</c-><a href='#dom-context-2d-imagesmoothingquality-medium' id='2dcontext:dom-context-2d-imagesmoothingquality-medium'><c- s>medium</c-></a><c- s>&quot;</c->, <c- s>&quot;</c-><a href='#dom-context-2d-imagesmoothingquality-high' id='2dcontext:dom-context-2d-imagesmoothingquality-high'><c- s>high</c-></a><c- s>&quot;</c-> };

[<c- g>Exposed</c->=<c- n>Window</c->]
<c- b>interface</c-> <dfn id='canvasrenderingcontext2d'><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='#canvasstate' id='2dcontext:canvasstate'><c- n>CanvasState</c-></a>;
<a href='#canvasrenderingcontext2d' id='2dcontext:canvasrenderingcontext2d-2'><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-3'><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-4'><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-5'><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-6'><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-7'><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-8'><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-9'><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-10'><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-11'><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-12'><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-13'><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-14'><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-15'><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-16'><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='canvasstate'><c- g>CanvasState</c-></dfn> {
  // state
  <c- b>void</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>void</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>interface</c-> <c- b>mixin</c-> <dfn id='canvastransform'><c- g>CanvasTransform</c-></dfn> {
  // transformations (default transform is the identity matrix)
  <c- b>void</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>void</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>void</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>void</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 href='https://drafts.fxtf.org/geometry/#dommatrix' data-x-internal='dommatrix' id='2dcontext: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>void</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>void</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 href='https://drafts.fxtf.org/geometry/#dictdef-dommatrix2dinit' data-x-internal='dommatrix2dinit' id='2dcontext:dommatrix2dinit'><c- n>DOMMatrix2DInit</c-></a> <c- g>transform</c->);
  <c- b>void</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'><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'><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'><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='#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->, [<c- g>TreatNullAs</c->=<c- n>EmptyString</c->] <c- b>DOMString</c-> <c- g>repetition</c->);

};

<c- b>interface</c-> <c- b>mixin</c-> <dfn id='canvasshadowstyles'><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 href='https://drafts.csswg.org/css-color/#transparent-black' data-x-internal='transparent-black' id='2dcontext:transparent-black'>transparent black</a>)
};

<c- b>interface</c-> <c- b>mixin</c-> <dfn id='canvasfilters'><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 &quot;none&quot;)
};

<c- b>interface</c-> <c- b>mixin</c-> <dfn id='canvasrect'><c- g>CanvasRect</c-></dfn> {
  // rects
  <c- b>void</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>void</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>void</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'><c- g>CanvasDrawPath</c-></dfn> {
  // path API (see also <a href='#canvaspath' id='2dcontext:canvaspath-2'>CanvasPath</a>)
  <c- b>void</c-> <a href='#dom-context-2d-beginpath' id='2dcontext:dom-context-2d-beginpath'><c- g>beginPath</c-></a>();
  <c- b>void</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-> = &quot;<a href='#dom-context-2d-fillrule-nonzero' id='2dcontext:dom-context-2d-fillrule-nonzero-2'>nonzero</a>&quot;);
  <c- b>void</c-> <a href='#dom-context-2d-fill' id='2dcontext:dom-context-2d-fill-2'><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-> = &quot;<a href='#dom-context-2d-fillrule-nonzero' id='2dcontext:dom-context-2d-fillrule-nonzero-3'>nonzero</a>&quot;);
  <c- b>void</c-> <a href='#dom-context-2d-stroke' id='2dcontext:dom-context-2d-stroke'><c- g>stroke</c-></a>();
  <c- b>void</c-> <a href='#dom-context-2d-stroke' id='2dcontext:dom-context-2d-stroke-2'><c- g>stroke</c-></a>(<a href='#path2d' id='2dcontext:path2d-2'><c- n>Path2D</c-></a> <c- g>path</c->);
  <c- b>void</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-> = &quot;<a href='#dom-context-2d-fillrule-nonzero' id='2dcontext:dom-context-2d-fillrule-nonzero-4'>nonzero</a>&quot;);
  <c- b>void</c-> <a href='#dom-context-2d-clip' id='2dcontext:dom-context-2d-clip-2'><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-> = &quot;<a href='#dom-context-2d-fillrule-nonzero' id='2dcontext:dom-context-2d-fillrule-nonzero-5'>nonzero</a>&quot;);
  <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-> = &quot;<a href='#dom-context-2d-fillrule-nonzero' id='2dcontext:dom-context-2d-fillrule-nonzero-6'>nonzero</a>&quot;);
  <c- b>boolean</c-> <a href='#dom-context-2d-ispointinpath' id='2dcontext:dom-context-2d-ispointinpath-2'><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-> = &quot;<a href='#dom-context-2d-fillrule-nonzero' id='2dcontext:dom-context-2d-fillrule-nonzero-7'>nonzero</a>&quot;);
  <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' id='2dcontext:dom-context-2d-ispointinstroke-2'><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'><c- g>CanvasUserInterface</c-></dfn> {
  <c- b>void</c-> <a href='#dom-context-2d-drawfocusifneeded' id='2dcontext:dom-context-2d-drawfocusifneeded'><c- g>drawFocusIfNeeded</c-></a>(<a href='https://dom.spec.whatwg.org/#interface-element' data-x-internal='element' id='2dcontext:element'><c- n>Element</c-></a> <c- g>element</c->);
  <c- b>void</c-> <a href='#dom-context-2d-drawfocusifneeded' id='2dcontext:dom-context-2d-drawfocusifneeded-2'><c- g>drawFocusIfNeeded</c-></a>(<a href='#path2d' id='2dcontext:path2d-6'><c- n>Path2D</c-></a> <c- g>path</c->, <a href='https://dom.spec.whatwg.org/#interface-element' data-x-internal='element' id='2dcontext:element-2'><c- n>Element</c-></a> <c- g>element</c->);
  <c- b>void</c-> <a href='#dom-context-2d-scrollpathintoview' id='2dcontext:dom-context-2d-scrollpathintoview'><c- g>scrollPathIntoView</c-></a>();
  <c- b>void</c-> <a href='#dom-context-2d-scrollpathintoview' id='2dcontext:dom-context-2d-scrollpathintoview-2'><c- g>scrollPathIntoView</c-></a>(<a href='#path2d' id='2dcontext:path2d-7'><c- n>Path2D</c-></a> <c- g>path</c->);
};

<c- b>interface</c-> <c- b>mixin</c-> <dfn id='canvastext'><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>void</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>void</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'><c- g>CanvasDrawImage</c-></dfn> {
  // drawing images
  <c- b>void</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>void</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>void</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'><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- b>long</c-> <c- g>sw</c->, <c- b>long</c-> <c- g>sh</c->);
  <a href='#imagedata' id='2dcontext:imagedata-2'><c- n>ImageData</c-></a> <a href='#dom-context-2d-createimagedata' id='2dcontext:dom-context-2d-createimagedata-2'><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- 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>void</c-> <a href='#dom-context-2d-putimagedata' id='2dcontext:dom-context-2d-putimagedata'><c- g>putImageData</c-></a>(<a href='#imagedata' id='2dcontext:imagedata-5'><c- n>ImageData</c-></a> <c- g>imagedata</c->, <c- b>long</c-> <c- g>dx</c->, <c- b>long</c-> <c- g>dy</c->);
  <c- b>void</c-> <a href='#dom-context-2d-putimagedata' id='2dcontext:dom-context-2d-putimagedata-2'><c- g>putImageData</c-></a>(<a href='#imagedata' id='2dcontext:imagedata-6'><c- n>ImageData</c-></a> <c- g>imagedata</c->, <c- b>long</c-> <c- g>dx</c->, <c- b>long</c-> <c- g>dy</c->, <c- b>long</c-> <c- g>dirtyX</c->, <c- b>long</c-> <c- g>dirtyY</c->, <c- b>long</c-> <c- g>dirtyWidth</c->, <c- b>long</c-> <c- g>dirtyHeight</c->);
};

<c- b>enum</c-> <dfn id='canvaslinecap'><c- g>CanvasLineCap</c-></dfn> { <c- s>&quot;butt&quot;</c->, <c- s>&quot;round&quot;</c->, <c- s>&quot;square&quot;</c-> };
<c- b>enum</c-> <dfn id='canvaslinejoin'><c- g>CanvasLineJoin</c-></dfn> { <c- s>&quot;round&quot;</c->, <c- s>&quot;bevel&quot;</c->, <c- s>&quot;miter&quot;</c-> };
<c- b>enum</c-> <dfn id='canvastextalign'><c- g>CanvasTextAlign</c-></dfn> { <c- s>&quot;</c-><a href='#dom-context-2d-textalign-start' id='2dcontext:dom-context-2d-textalign-start'><c- s>start</c-></a><c- s>&quot;</c->, <c- s>&quot;</c-><a href='#dom-context-2d-textalign-end' id='2dcontext:dom-context-2d-textalign-end'><c- s>end</c-></a><c- s>&quot;</c->, <c- s>&quot;</c-><a href='#dom-context-2d-textalign-left' id='2dcontext:dom-context-2d-textalign-left'><c- s>left</c-></a><c- s>&quot;</c->, <c- s>&quot;</c-><a href='#dom-context-2d-textalign-right' id='2dcontext:dom-context-2d-textalign-right'><c- s>right</c-></a><c- s>&quot;</c->, <c- s>&quot;</c-><a href='#dom-context-2d-textalign-center' id='2dcontext:dom-context-2d-textalign-center'><c- s>center</c-></a><c- s>&quot;</c-> };
<c- b>enum</c-> <dfn id='canvastextbaseline'><c- g>CanvasTextBaseline</c-></dfn> { <c- s>&quot;</c-><a href='#dom-context-2d-textbaseline-top' id='2dcontext:dom-context-2d-textbaseline-top'><c- s>top</c-></a><c- s>&quot;</c->, <c- s>&quot;</c-><a href='#dom-context-2d-textbaseline-hanging' id='2dcontext:dom-context-2d-textbaseline-hanging'><c- s>hanging</c-></a><c- s>&quot;</c->, <c- s>&quot;</c-><a href='#dom-context-2d-textbaseline-middle' id='2dcontext:dom-context-2d-textbaseline-middle'><c- s>middle</c-></a><c- s>&quot;</c->, <c- s>&quot;</c-><a href='#dom-context-2d-textbaseline-alphabetic' id='2dcontext:dom-context-2d-textbaseline-alphabetic'><c- s>alphabetic</c-></a><c- s>&quot;</c->, <c- s>&quot;</c-><a href='#dom-context-2d-textbaseline-ideographic' id='2dcontext:dom-context-2d-textbaseline-ideographic'><c- s>ideographic</c-></a><c- s>&quot;</c->, <c- s>&quot;</c-><a href='#dom-context-2d-textbaseline-bottom' id='2dcontext:dom-context-2d-textbaseline-bottom'><c- s>bottom</c-></a><c- s>&quot;</c-> };
<c- b>enum</c-> <dfn id='canvasdirection'><c- g>CanvasDirection</c-></dfn> { <c- s>&quot;</c-><a href='#dom-context-2d-direction-ltr' id='2dcontext:dom-context-2d-direction-ltr'><c- s>ltr</c-></a><c- s>&quot;</c->, <c- s>&quot;</c-><a href='#dom-context-2d-direction-rtl' id='2dcontext:dom-context-2d-direction-rtl'><c- s>rtl</c-></a><c- s>&quot;</c->, <c- s>&quot;</c-><a href='#dom-context-2d-direction-inherit' id='2dcontext:dom-context-2d-direction-inherit'><c- s>inherit</c-></a><c- s>&quot;</c-> };

<c- b>interface</c-> <c- b>mixin</c-> <dfn id='canvaspathdrawingstyles'><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 &quot;butt&quot;)
  <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 &quot;miter&quot;)
  <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>void</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'><c- g>CanvasTextDrawingStyles</c-></dfn> {
  // text
  <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: &quot;start&quot;)
  <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: &quot;alphabetic&quot;)
  <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: &quot;inherit&quot;)
};

<c- b>interface</c-> <c- b>mixin</c-> <dfn id='canvaspath'><c- g>CanvasPath</c-></dfn> {
  // shared path API methods
  <c- b>void</c-> <a href='#dom-context-2d-closepath' id='2dcontext:dom-context-2d-closepath'><c- g>closePath</c-></a>();
  <c- b>void</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>void</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>void</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>void</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>void</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>void</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>void</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>anticlockwise</c-> = <c- b>false</c->); 
  <c- b>void</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>anticlockwise</c-> = <c- b>false</c->); 
};

[<c- g>Exposed</c->=(<c- n>Window</c->,<c- n>Worker</c->)]
<c- b>interface</c-> <dfn id='canvasgradient'><c- g>CanvasGradient</c-></dfn> {
  // opaque object
  <c- b>void</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'><c- g>CanvasPattern</c-></dfn> {
  // opaque object
  <c- b>void</c-> <a href='#dom-canvaspattern-settransform' id='2dcontext:dom-canvaspattern-settransform'><c- g>setTransform</c-></a>(<c- b>optional</c-> <a href='https://drafts.fxtf.org/geometry/#dictdef-dommatrix2dinit' data-x-internal='dommatrix2dinit' id='2dcontext:dommatrix2dinit-2'><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'><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>;
};

[<a href='#dom-imagedata' id='2dcontext: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->),
 <a href='#dom-imagedata' id='2dcontext:dom-imagedata-2'><c- g>Constructor</c-></a>(<a href='https://heycam.github.io/webidl/#idl-Uint8ClampedArray' data-x-internal='idl-uint8clampedarray' id='2dcontext:idl-uint8clampedarray'><c- b>Uint8ClampedArray</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- g>Exposed</c->=(<c- n>Window</c->,<c- n>Worker</c->),
 <a href='#serializable' id='2dcontext:serializable'><c- g>Serializable</c-></a>]
<c- b>interface</c-> <dfn id='imagedata'><c- g>ImageData</c-></dfn> {
  <c- b>readonly</c-> <c- b>attribute</c-> <c- b>unsigned</c-> <c- b>long</c-> <a href='#dom-imagedata-width' id='2dcontext: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='2dcontext:dom-imagedata-height'><c- g>height</c-></a>;
  <c- b>readonly</c-> <c- b>attribute</c-> <a href='https://heycam.github.io/webidl/#idl-Uint8ClampedArray' data-x-internal='idl-uint8clampedarray' id='2dcontext:idl-uint8clampedarray-2'><c- b>Uint8ClampedArray</c-></a> <a href='#dom-imagedata-data' id='2dcontext:dom-imagedata-data'><c- g>data</c-></a>;
};

[<a href='#dom-path2d' id='2dcontext:dom-path2d'><c- g>Constructor</c-></a>(<c- b>optional</c-> (<a href='#path2d' id='2dcontext:path2d-8'><c- n>Path2D</c-></a> <c- b>or</c-> <c- b>DOMString</c->) <c- g>path</c->),
 <c- g>Exposed</c->=(<c- n>Window</c->,<c- n>Worker</c->)]
<c- b>interface</c-> <dfn id='path2d'><c- g>Path2D</c-></dfn> {
  <c- b>void</c-> <a href='#dom-path2d-addpath' id='2dcontext:dom-path2d-addpath'><c- g>addPath</c-></a>(<a href='#path2d' id='2dcontext:path2d-9'><c- n>Path2D</c-></a> <c- g>path</c->, <c- b>optional</c-> <a href='https://drafts.fxtf.org/geometry/#dictdef-dommatrix2dinit' data-x-internal='dommatrix2dinit' id='2dcontext:dommatrix2dinit-3'><c- n>DOMMatrix2DInit</c-></a> <c- g>transform</c->);
};
<a href='#path2d' id='2dcontext:path2d-10'><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-3><a href=#dom-context-2d-stroke>stroke()</a></code> method on <code id=2dcontext:canvasrenderingcontext2d-17><a href=#canvasrenderingcontext2d>CanvasRenderingContext2D</a></code>
  objects.</p>

  <dl class=domintro><dt><var>context</var> = <var>canvas</var> . <code id=2dcontext:dom-canvas-getcontext><a href=#dom-canvas-getcontext>getContext</a></code>('2d' [, { [ <code id=2dcontext:dom-canvasrenderingcontext2dsettings-alpha-2><a href=#dom-canvasrenderingcontext2dsettings-alpha>alpha</a></code>: false ] } ] )<dd>

    <p>Returns a <code id=2dcontext:canvasrenderingcontext2d-18><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> setting is
    provided and set to false, then the canvas is forced to always be opaque.</p>

   <dt><var>context</var> . <code id=dom-context-2d-canvas-dev><a href=#dom-context-2d-canvas>canvas</a></code><dd>

    <p>Returns the <code id=2dcontext:the-canvas-element-2><a href=#the-canvas-element>canvas</a></code> element.</p>

   </dl>

  

  <p>A <code id=2dcontext:canvasrenderingcontext2d-19><a href=#canvasrenderingcontext2d>CanvasRenderingContext2D</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=2dcontext:output-bitmap>output bitmap</a> has an <a href=#concept-canvas-origin-clean id=2dcontext: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=2dcontext:concept-canvas-origin-clean-2>origin-clean</a> flag must be set to true.</p>


  <p>The <code id=2dcontext:canvasrenderingcontext2d-20><a href=#canvasrenderingcontext2d>CanvasRenderingContext2D</a></code> object also has an <dfn id=concept-canvas-alpha>alpha</dfn> flag, which can be set to true or false. Initially,
  when the context is created, its <a href=#concept-canvas-alpha id=2dcontext:concept-canvas-alpha>alpha</a> flag must be
  set to true. When a <code id=2dcontext:canvasrenderingcontext2d-21><a href=#canvasrenderingcontext2d>CanvasRenderingContext2D</a></code> object has its <a href=#concept-canvas-alpha id=2dcontext:concept-canvas-alpha-2>alpha</a> flag set to false, then its alpha channel 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=2dcontext:opaque-black href=https://drafts.csswg.org/css-color/#opaque-black data-x-internal=opaque-black>opaque black</a> instead
  of <a id=2dcontext:transparent-black-2 href=https://drafts.csswg.org/css-color/#transparent-black data-x-internal=transparent-black>transparent black</a>; <code id=2dcontext:dom-context-2d-clearrect-2><a href=#dom-context-2d-clearrect>clearRect()</a></code>
  always results in <a id=2dcontext: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=2dcontext:dom-context-2d-getimagedata-2><a href=#dom-context-2d-getimagedata>getImageData()</a></code> is always 255, the <code id=2dcontext:dom-context-2d-putimagedata-3><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=2dcontext:output-bitmap-2>output
  bitmap</a>'s alpha channel; for instance, drawing a 50% transparent white square on a freshly
  created <a href=#output-bitmap id=2dcontext:output-bitmap-3>output bitmap</a> with its <a href=#concept-canvas-alpha id=2dcontext:concept-canvas-alpha-3>alpha</a>
  flag set to false will result in a fully-opaque gray square.</p>

  <hr>

  <p>The <code id=2dcontext:canvasrenderingcontext2d-22><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-4>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-5>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>

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

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

  <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://heycam.github.io/webidl/#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><a href=#canvasrenderingcontext2dsettings>CanvasRenderingContext2DSettings</a></code>. (This can throw an exception.).<li><p>Let <var>context</var> be a new <code id=2dcontext:canvasrenderingcontext2d-23><a href=#canvasrenderingcontext2d>CanvasRenderingContext2D</a></code> object.<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>.<li><p>Set <var>context</var>'s <a href=#output-bitmap id=2dcontext:output-bitmap-8>output bitmap</a> to the same bitmap as
   <var>target</var>'s bitmap (so that they are shared).<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.<li>
    <p>Process each of the members of <var>settings</var> as follows:</p>

    <dl><dt><dfn id=dom-canvasrenderingcontext2dsettings-alpha><code>alpha</code></dfn><dd>If false, then set <var>context</var>'s <a href=#concept-canvas-alpha id=2dcontext:concept-canvas-alpha-4>alpha</a>
     flag to false.</dl>
   <li><p>Return <var>context</var>.</ol>

  <hr>

  <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>Reset the rendering context to its default state</a>.<li><p>Resize the <a href=#output-bitmap id=2dcontext:output-bitmap-9>output bitmap</a> to the new <var>width</var> and <var>height</var>
   and clear it to <a id=2dcontext:transparent-black-3 href=https://drafts.csswg.org/css-color/#transparent-black data-x-internal=transparent-black>transparent black</a>.<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.<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>.<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>.</ol>

  <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>&apos;2d&apos;</c-><c- p>);</c->
context<c- p>.</c->fillRect<c- p>(</c-><c- mi>0</c-><c- p>,</c-><c- mi>0</c-><c- p>,</c-><c- mi>50</c-><c- p>,</c-><c- mi>50</c-><c- p>);</c->
canvas<c- p>.</c->setAttribute<c- p>(</c-><c- t>&apos;width&apos;</c-><c- p>,</c-> <c- t>&apos;300&apos;</c-><c- p>);</c-> <c- c1>// clears the canvas</c->
context<c- p>.</c->fillRect<c- p>(</c-><c- mi>0</c-><c- p>,</c-><c- mi>100</c-><c- p>,</c-><c- mi>50</c-><c- p>,</c-><c- mi>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- mi>100</c-><c- p>,</c-><c- mi>0</c-><c- p>,</c-><c- mi>50</c-><c- p>,</c-><c- mi>50</c-><c- p>);</c-> <c- c1>// only this square remains</c-></code></pre>
  </div>

  <hr>

  <p>The <dfn id=dom-context-2d-canvas><code>canvas</code></dfn> attribute must return the
  value it was initialized to when the object was created.</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 value "<dfn id=dom-context-2d-fillrule-nonzero><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 id=dom-context-2d-fillrule-evenodd><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 id=dom-context-2d-imagesmoothingquality-low><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 id=dom-context-2d-imagesmoothingquality-medium><code>medium</code></dfn>" value
  indicates a preference for a medium level of image interpolation quality.</p>

  <p>The "<dfn id=dom-context-2d-imagesmoothingquality-high><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/css2/conform.html#intrinsic id=implementation-notes:intrinsic-dimensions data-x-internal=intrinsic-dimensions>intrinsic 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-state><span class=secno>4.12.5.1.2</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 class=brief><li>The current <a href=#transformations id=the-canvas-state:transformations>transformation matrix</a>.<li>The current <a href=#clipping-region id=the-canvas-state:clipping-region>clipping region</a>.<li>The current values of the following attributes: <code id=the-canvas-state:dom-context-2d-strokestyle><a href=#dom-context-2d-strokestyle>strokeStyle</a></code>, <code id=the-canvas-state:dom-context-2d-fillstyle><a href=#dom-context-2d-fillstyle>fillStyle</a></code>, <code id=the-canvas-state:dom-context-2d-globalalpha><a href=#dom-context-2d-globalalpha>globalAlpha</a></code>, <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-shadowcolor><a href=#dom-context-2d-shadowcolor>shadowColor</a></code>, <code id=the-canvas-state:dom-context-2d-filter><a href=#dom-context-2d-filter>filter</a></code>, <code id=the-canvas-state:dom-context-2d-globalcompositeoperation><a href=#dom-context-2d-globalcompositeoperation>globalCompositeOperation</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-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>.<li>The current <a href=#dash-list id=the-canvas-state:dash-list>dash list</a>.</ul>

  <p class=note>The <a href=#current-default-path id=the-canvas-state:current-default-path>current default path</a> and the rendering context's bitmaps are not
  part of the drawing state. The <a href=#current-default-path id=the-canvas-state:current-default-path-2>current default path</a> is persistent, and can only be
  reset using the <code id=the-canvas-state:dom-context-2d-beginpath><a href=#dom-context-2d-beginpath>beginPath()</a></code> method. The bitmaps
  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>

  <dl class=domintro><dt><var>context</var> . <code id=dom-context-2d-save-dev><a href=#dom-context-2d-save>save</a></code>()<dd>

    <p>Pushes the current state onto the stack.</p>

   <dt><var>context</var> . <code id=dom-context-2d-restore-dev><a href=#dom-context-2d-restore>restore</a></code>()<dd>

    <p>Pops the top state on the stack, restoring the context to that state.</p>

   </dl>

  

  <p>The <dfn id=dom-context-2d-save><code>save()</code></dfn> method, when invoked, must push
  a copy of the current drawing state onto the drawing state stack.</p>

  <p>The <dfn id=dom-context-2d-restore><code>restore()</code></dfn> method, when invoked,
  must 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>

  <p>When the user agent is to <dfn id=reset-the-rendering-context-to-its-default-state>reset the rendering context to its default state</dfn>, it must
  clear the drawing state stack and everything that <a href=#drawing-state id=the-canvas-state:drawing-state>drawing state</a> consists of to
  initial values.</p>

  

  


  <h6 id=line-styles><span class=secno>4.12.5.1.3</span> Line styles<a href=#line-styles class=self-link></a></h6>

  <dl class=domintro><dt><var>context</var> . <code id=dom-context-2d-linewidth-dev><a href=#dom-context-2d-linewidth>lineWidth</a></code> [ = <var>value</var> ]<dt><var>styles</var> . <code id=line-styles:dom-context-2d-linewidth><a href=#dom-context-2d-linewidth>lineWidth</a></code> [ = <var>value</var> ]<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>

   <dt><var>context</var> . <code id=dom-context-2d-linecap-dev><a href=#dom-context-2d-linecap>lineCap</a></code> [ = <var>value</var> ]<dt><var>styles</var> . <code id=line-styles:dom-context-2d-linecap><a href=#dom-context-2d-linecap>lineCap</a></code> [ = <var>value</var> ]<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>

   <dt><var>context</var> . <code id=dom-context-2d-linejoin-dev><a href=#dom-context-2d-linejoin>lineJoin</a></code> [ = <var>value</var> ]<dt><var>styles</var> . <code id=line-styles:dom-context-2d-linejoin><a href=#dom-context-2d-linejoin>lineJoin</a></code> [ = <var>value</var> ]<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>

   <dt><var>context</var> . <code id=dom-context-2d-miterlimit-dev><a href=#dom-context-2d-miterlimit>miterLimit</a></code> [ = <var>value</var> ]<dt><var>styles</var> . <code id=line-styles:dom-context-2d-miterlimit><a href=#dom-context-2d-miterlimit>miterLimit</a></code> [ = <var>value</var> ]<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>

   <dt><var>context</var> . <code id=dom-context-2d-setlinedash-dev><a href=#dom-context-2d-setlinedash>setLineDash</a></code>(<var>segments</var>)<dt><var>styles</var> . <code id=line-styles:dom-context-2d-setlinedash><a href=#dom-context-2d-setlinedash>setLineDash</a></code>(<var>segments</var>)<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>

   <dt><var>segments</var> = <var>context</var> . <code id=dom-context-2d-getlinedash-dev><a href=#dom-context-2d-getlinedash>getLineDash</a></code>()<dt><var>segments</var> = <var>styles</var> . <code id=line-styles:dom-context-2d-getlinedash><a href=#dom-context-2d-getlinedash>getLineDash</a></code>()<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>

   <dt><var>context</var> . <code id=dom-context-2d-linedashoffset-dev><a href=#dom-context-2d-linedashoffset>lineDashOffset</a></code><dt><var>styles</var> . <code id=line-styles:dom-context-2d-linedashoffset><a href=#dom-context-2d-linedashoffset>lineDashOffset</a></code><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>

   </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>

  <p>The <dfn id=dom-context-2d-linewidth><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>

  <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 id=dom-context-2d-linecap><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>

  <p>On getting, it must return the current value. On setting, the current value must be changed
  to the new value.</p>

  <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 id=dom-context-2d-linejoin><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>

  <p>On getting, it must return the current value. On setting, the current value must be changed
  to the new value.</p>

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

  <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 id=dom-context-2d-miterlimit><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>
  

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

  <p>The <dfn id=dom-context-2d-setlinedash><code>setLineDash()</code></dfn> method, when
  invoked, must run these steps:</p>

  <ol><li><p>Let <var>a</var> be the argument.<li><p>If any value in <var>a</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).<li><p>If the number of elements in <var>a</var> is odd, then let <var>a</var>
   be the concatenation of two copies of <var>a</var>.<li><p>Let the object's <a href=#dash-list id=line-styles:dash-list-2>dash list</a> be <var>a</var>.</ol>

  <p>When the <dfn id=dom-context-2d-getlinedash><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>

  <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 id=dom-context-2d-linedashoffset><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>

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

  <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.<li><p>Prune all zero-length <a href=#line-segments id=line-styles:line-segments>line segments</a> from <var>path</var>.<li><p>Remove from <var>path</var> any subpaths containing no lines (i.e. subpaths with
   just one point).<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.<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><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>.<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><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><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.<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><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>.<li><p>Let <var>position</var> be zero minus <var>offset</var>.<li><p>Let <var>index</var> be 0.<li><p>Let <var>current state</var> be <i>off</i> (the other states being <i>on</i>
     and <i>zero-on</i>).<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.<li><p>Increment <var>position</var> by <var>segment length</var>.<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.<li><p>If <var>segment length</var> is nonzero, then let <var>current state</var> be
     <i>on</i>.<li><p>Increment <var>index</var> by one.<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.<li><p>Let <var>start</var> be the offset <var>position</var> on <var>L</var>.<li><p>Increment <var>position</var> by <var>segment length</var>.<li><p>If <var>position</var> is less than zero, then jump to the step labeled
     <i>post-cut</i>.<li><p>If <var>start</var> is less than zero, then let <var>start</var> be
     zero.<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>.<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><dd>

        <p>Do nothing, just continue to the next step.</p>

       <dt>If <var>current state</var> is <i>off</i><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>

       <dt>Otherwise<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>

       </dl>

     <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>.<li><p>If <var>segment length</var> is greater than zero, then let
     <var>positioned-at-on-dash</var> be false.<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.<li><p>Return to the step labeled <i>dash on</i>.</ol>

   <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><p>Return the newly created path.</ol>



  


  <h6 id=text-styles><span class=secno>4.12.5.1.4</span> Text styles<a href=#text-styles class=self-link></a></h6>

  <dl class=domintro><dt><var>context</var> . <code id=dom-context-2d-font-dev><a href=#dom-context-2d-font>font</a></code> [ = <var>value</var> ]<dt><var>styles</var> . <code id=text-styles:dom-context-2d-font><a href=#dom-context-2d-font>font</a></code> [ = <var>value</var> ]<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.</p>

    <p>Relative keywords and lengths are computed relative to the font of the <code id=text-styles:the-canvas-element><a href=#the-canvas-element>canvas</a></code>
    element.</p>

   <dt><var>context</var> . <code id=dom-context-2d-textalign-dev><a href=#dom-context-2d-textalign>textAlign</a></code> [ = <var>value</var> ]<dt><var>styles</var> . <code id=text-styles:dom-context-2d-textalign><a href=#dom-context-2d-textalign>textAlign</a></code> [ = <var>value</var> ]<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>

   <dt><var>context</var> . <code id=dom-context-2d-textbaseline-dev><a href=#dom-context-2d-textbaseline>textBaseline</a></code> [ = <var>value</var> ]<dt><var>styles</var> . <code id=text-styles:dom-context-2d-textbaseline><a href=#dom-context-2d-textbaseline>textBaseline</a></code> [ = <var>value</var> ]<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>

   <dt><var>context</var> . <code id=dom-context-2d-direction-dev><a href=#dom-context-2d-direction>direction</a></code> [ = <var>value</var> ]<dt><var>styles</var> . <code id=text-styles:dom-context-2d-direction><a href=#dom-context-2d-direction>direction</a></code> [ = <var>value</var> ]<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>

   </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-2><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>

  <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-3><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>.<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>.<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>.<li><p>Assert: <var>global</var> implements <code id=text-styles:workerglobalscope><a href=#workerglobalscope>WorkerGlobalScope</a></code>.<li><p>Return <var>global</var>.</ol>
   </ol>

  <div class=example>
   <p>This is an example of font resolution with a regular <code id=text-styles:the-canvas-element-4><a href=#the-canvas-element>canvas</a></code> element with ID <code>c1</code>.</p>

   <pre><code class='js'><c- kr>const</c-> font <c- o>=</c-> <c- k>new</c-> FontFace<c- p>(</c-><c- u>&quot;MyCanvasFont&quot;</c-><c- p>,</c-> <c- u>&quot;url(mycanvasfont.ttf)&quot;</c-><c- p>);</c->
documents<c- p>.</c->fonts<c- p>.</c->add<c- p>(</c->font<c- p>);</c->

<c- kr>const</c-> context <c- o>=</c-> document<c- p>.</c->getElementById<c- p>(</c-><c- u>&quot;c1&quot;</c-><c- p>).</c->getContext<c- p>(</c-><c- u>&quot;2d&quot;</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>&quot;64px MyCanvasFont&quot;</c-><c- p>;</c->
  context<c- p>.</c->fillText<c- p>(</c-><c- u>&quot;hello&quot;</c-><c- p>,</c-> <c- mi>0</c-><c- p>,</c-> <c- mi>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-5><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- kr>const</c-> offscreenCanvas <c- o>=</c-> document<c- p>.</c->getElementById<c- p>(</c-><c- u>&quot;c2&quot;</c-><c- p>).</c->transferControlToOffscreen<c- p>();</c->
worker<c- p>.</c->postMesage<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- kr>const</c-> transferredCanvas <c- o>=</c-> ev<c- p>.</c->data<c- p>;</c->
  <c- kr>const</c-> context <c- o>=</c-> transferredCanvas<c- p>.</c->getContext<c- p>(</c-><c- u>&quot;2d&quot;</c-><c- p>);</c->
  <c- kr>const</c-> font <c- o>=</c-> <c- k>new</c-> FontFace<c- p>(</c-><c- u>&quot;MyFont&quot;</c-><c- p>,</c-> <c- u>&quot;url(myfont.ttf)&quot;</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>&quot;64px MyFont&quot;</c-><c- p>;</c->
    context<c- p>.</c->fillText<c- p>(</c-><c- u>&quot;hello&quot;</c-><c- p>,</c-> <c- mi>0</c-><c- p>,</c-> <c- mi>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>

  <p>The <dfn id=dom-context-2d-font><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'>
  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/visudet.html#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>

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

  <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/visudet.html#propdef-line-height data-x-internal="'line-height'">'line-height'</a> component). <a href=#refsCSSOM>[CSSOM]</a></p>

  <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>&apos;italic 400 12px/2 Unknown Font, sans-serif&apos;</c-><c- p>;</c-></code></pre>

   <p>...the expression <code>context.font</code> would evaluate to the string "<code>italic 12px "Unknown Font", 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>

  <p>The <dfn id=dom-context-2d-textalign><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>

  <p>The <dfn id=dom-context-2d-textbaseline><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>

  <p>The <dfn id=dom-context-2d-direction><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-6><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>

  

  <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 id=dom-context-2d-textalign-start><code>start</code></dfn>
   <dd><p>Align to the start edge of the text (left side in left-to-right text, right side in
   right-to-left text).<dt><dfn id=dom-context-2d-textalign-end><code>end</code></dfn>
   <dd><p>Align to the end edge of the text (right side in left-to-right text, left side in
   right-to-left text).<dt><dfn id=dom-context-2d-textalign-left><code>left</code></dfn>
   <dd><p>Align to the left.<dt><dfn id=dom-context-2d-textalign-right><code>right</code></dfn>
   <dd><p>Align to the right.<dt><dfn id=dom-context-2d-textalign-center><code>center</code></dfn>
   <dd><p>Align to the center.</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 top of the em square 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 top of the em square and the bottom of the em square, the alphabetic baseline is where characters like Á, ÿ, f, and Ω are anchored, the ideographic baseline is where glyphs like 私 and 達 are anchored, and the bottom of the em square 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 the em square." height=300></p>

  <p>The keywords map to these alignment points as follows:</p>

  <dl><dt><dfn id=dom-context-2d-textbaseline-top><code>top</code></dfn>
   <dd>The top of the em square<dt><dfn id=dom-context-2d-textbaseline-hanging><code>hanging</code></dfn>
   <dd>The hanging baseline<dt><dfn id=dom-context-2d-textbaseline-middle><code>middle</code></dfn>
   <dd>The middle of the em square<dt><dfn id=dom-context-2d-textbaseline-alphabetic><code>alphabetic</code></dfn>
   <dd>The alphabetic baseline<dt><dfn id=dom-context-2d-textbaseline-ideographic><code>ideographic</code></dfn>
   <dd>The ideographic baseline<dt><dfn id=dom-context-2d-textbaseline-bottom><code>bottom</code></dfn>
   <dd>The bottom of the em square</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 id=dom-context-2d-direction-ltr><code>ltr</code></dfn>

   <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.<dt><dfn id=dom-context-2d-direction-rtl><code>rtl</code></dfn>

   <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.<dt><dfn id=dom-context-2d-direction-inherit><code>inherit</code></dfn>

   <dd><p>Default to the directionality of the <code id=text-styles:the-canvas-element-6><a href=#the-canvas-element>canvas</a></code> element or <code id=text-styles:document><a href=#document>Document</a></code>
   as appropriate.</dl>

  <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-7><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/visuren.html#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/visuren.html#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.<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.<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.<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>"<dd>Let <var>direction</var> be '<a href=#concept-ltr id=text-styles:concept-ltr>ltr</a>'.<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>"<dd>Let <var>direction</var> be '<a href=#concept-rtl id=text-styles:concept-rtl>rtl</a>'.<dt>If the <var>target</var> object's <a href=#font-style-source-object id=text-styles:font-style-source-object-11>font style source object</a> is an
     element<dd>Let <var>direction</var> be <a href=#the-directionality id=text-styles:the-directionality>the directionality</a> of the <var>target</var> object's <a href=#font-style-source-object id=text-styles:font-style-source-object-12>font style source object</a>.<dt>If the <var>target</var> object's <a href=#font-style-source-object id=text-styles:font-style-source-object-13>font style source object</a> is a
     <code id=text-styles:document-2><a href=#document>Document</a></code> with a non-null <a id=text-styles:document-element href=https://dom.spec.whatwg.org/#document-element data-x-internal=document-element>document element</a><dd>Let <var>direction</var> be <a href=#the-directionality id=text-styles:the-directionality-2>the directionality</a> of the <var>target</var>
     object's <a href=#font-style-source-object id=text-styles:font-style-source-object-14>font style source object</a>'s <a id=text-styles:document-element-2 href=https://dom.spec.whatwg.org/#document-element data-x-internal=document-element>document element</a>.<dt>Otherwise<dd>Let <var>direction</var> be '<a href=#concept-ltr id=text-styles:concept-ltr-2>ltr</a>'.</dl>

   <li><p>Form a hypothetical infinitely-wide CSS <a id=text-styles:line-box href=https://drafts.csswg.org/css2/visuren.html#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/visuren.html#inline-box data-x-internal=inline-box>inline box</a> containing the text <var>text</var>, with all the properties at their
   initial values except the <a id="text-styles:'font'-2" href=https://drafts.csswg.org/css-fonts/#font-prop data-x-internal="'font'">'font'</a> property of the <a id=text-styles:inline-box-4 href=https://drafts.csswg.org/css2/visuren.html#inline-box data-x-internal=inline-box>inline box</a> set to
   <var>font</var>, the <a id="text-styles:'direction'" href=https://drafts.csswg.org/css-writing-modes/#direction data-x-internal="'direction'">'direction'</a> property of the <a id=text-styles:inline-box-5 href=https://drafts.csswg.org/css2/visuren.html#inline-box data-x-internal=inline-box>inline box</a> set to
   <var>direction</var>, and the <a id="text-styles:'white-space'" href=https://drafts.csswg.org/css-text/#white-space-property data-x-internal="'white-space'">'white-space'</a> property set to 'pre'. <a href=#refsCSS>[CSS]</a><li><p>If <var>maxWidth</var> was provided and the hypothetical width of the
   <a id=text-styles:inline-box-6 href=https://drafts.csswg.org/css2/visuren.html#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/visuren.html#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.<li>

    <p>The <var>anchor point</var> is a point on the <a id=text-styles:inline-box-7 href=https://drafts.csswg.org/css2/visuren.html#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>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>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'<dd>Let the <var>anchor point</var>'s horizontal position be the left edge of the
     <a id=text-styles:inline-box-8 href=https://drafts.csswg.org/css2/visuren.html#inline-box data-x-internal=inline-box>inline box</a>, and let <var>physical alignment</var> be <i>left</i>.<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>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>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'<dd>Let the <var>anchor point</var>'s horizontal position be the right edge of the
     <a id=text-styles:inline-box-9 href=https://drafts.csswg.org/css2/visuren.html#inline-box data-x-internal=inline-box>inline box</a>, and let <var>physical alignment</var> be <i>right</i>.<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><dd>Let the <var>anchor point</var>'s horizontal position be half way between the left
     and right edges of the <a id=text-styles:inline-box-10 href=https://drafts.csswg.org/css2/visuren.html#inline-box data-x-internal=inline-box>inline box</a>, and let <var>physical alignment</var> be
     <i>center</i>.</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><dd>Let the <var>anchor point</var>'s vertical position be the top of the em box of
     the first available font of the <a id=text-styles:inline-box-11 href=https://drafts.csswg.org/css2/visuren.html#inline-box data-x-internal=inline-box>inline box</a>.<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><dd>Let the <var>anchor point</var>'s vertical position be the hanging baseline of the
     first available font of the <a id=text-styles:inline-box-12 href=https://drafts.csswg.org/css2/visuren.html#inline-box data-x-internal=inline-box>inline box</a>.<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><dd>Let the <var>anchor point</var>'s vertical position be half way between the bottom
     and the top of the em box of the first available font of the <a id=text-styles:inline-box-13 href=https://drafts.csswg.org/css2/visuren.html#inline-box data-x-internal=inline-box>inline box</a>.<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><dd>Let the <var>anchor point</var>'s vertical position be the alphabetic baseline of
     the first available font of the <a id=text-styles:inline-box-14 href=https://drafts.csswg.org/css2/visuren.html#inline-box data-x-internal=inline-box>inline box</a>.<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><dd>Let the <var>anchor point</var>'s vertical position be the ideographic baseline of
     the first available font of the <a id=text-styles:inline-box-15 href=https://drafts.csswg.org/css2/visuren.html#inline-box data-x-internal=inline-box>inline box</a>.<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><dd>Let the <var>anchor point</var>'s vertical position be the bottom of the em box of
     the first available font of the <a id=text-styles:inline-box-16 href=https://drafts.csswg.org/css2/visuren.html#inline-box data-x-internal=inline-box>inline box</a>.</dl>

   <li>

    <p>Let <var>result</var> be an array constructed by iterating over each glyph in the
    <a id=text-styles:inline-box-17 href=https://drafts.csswg.org/css2/visuren.html#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-18 href=https://drafts.csswg.org/css2/visuren.html#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 is at the <var>anchor
    point</var>.</p>

   <li><p>Return <var>result</var>, <var>physical alignment</var>, and the inline
   box.</ol>


  <h6 id=building-paths><span class=secno>4.12.5.1.5</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><var>context</var> . <code id=dom-context-2d-moveto-dev><a href=#dom-context-2d-moveto>moveTo</a></code>(<var>x</var>, <var>y</var>)<dt><var>path</var> . <code id=building-paths:dom-context-2d-moveto><a href=#dom-context-2d-moveto>moveTo</a></code>(<var>x</var>, <var>y</var>)<dd>

    <p>Creates a new subpath with the given point.</p>

   <dt><var>context</var> . <code id=dom-context-2d-closepath-dev><a href=#dom-context-2d-closepath>closePath</a></code>()<dt><var>path</var> . <code id=building-paths:dom-context-2d-closepath><a href=#dom-context-2d-closepath>closePath</a></code>()<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>

   <dt><var>context</var> . <code id=dom-context-2d-lineto-dev><a href=#dom-context-2d-lineto>lineTo</a></code>(<var>x</var>, <var>y</var>)<dt><var>path</var> . <code id=building-paths:dom-context-2d-lineto><a href=#dom-context-2d-lineto>lineTo</a></code>(<var>x</var>, <var>y</var>)<dd>

    <p>Adds the given point to the current subpath, connected to the previous one by a straight
    line.</p>

   <dt><var>context</var> . <code id=dom-context-2d-quadraticcurveto-dev><a href=#dom-context-2d-quadraticcurveto>quadraticCurveTo</a></code>(<var>cpx</var>, <var>cpy</var>, <var>x</var>, <var>y</var>)<dt><var>path</var> . <code id=building-paths:dom-context-2d-quadraticcurveto><a href=#dom-context-2d-quadraticcurveto>quadraticCurveTo</a></code>(<var>cpx</var>, <var>cpy</var>, <var>x</var>, <var>y</var>)<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>

   <dt><var>context</var> . <code id=dom-context-2d-beziercurveto-dev><a href=#dom-context-2d-beziercurveto>bezierCurveTo</a></code>(<var>cp1x</var>, <var>cp1y</var>, <var>cp2x</var>, <var>cp2y</var>, <var>x</var>, <var>y</var>)<dt><var>path</var> . <code id=building-paths:dom-context-2d-beziercurveto><a href=#dom-context-2d-beziercurveto>bezierCurveTo</a></code>(<var>cp1x</var>, <var>cp1y</var>, <var>cp2x</var>, <var>cp2y</var>, <var>x</var>, <var>y</var>)<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>

   <dt><var>context</var> . <code id=dom-context-2d-arcto-dev><a href=#dom-context-2d-arcto>arcTo</a></code>(<var>x1</var>, <var>y1</var>, <var>x2</var>, <var>y2</var>, <var>radius</var>)<dt><var>path</var> . <code id=building-paths:dom-context-2d-arcto><a href=#dom-context-2d-arcto>arcTo</a></code>(<var>x1</var>, <var>y1</var>, <var>x2</var>, <var>y2</var>, <var>radius</var>)<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://heycam.github.io/webidl/#indexsizeerror data-x-internal=indexsizeerror>"<code>IndexSizeError</code>"</a> <code id=building-paths:domexception><a data-x-internal=domexception href=https://heycam.github.io/webidl/#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>



   <dt><var>context</var> . <code id=dom-context-2d-arc-dev><a href=#dom-context-2d-arc>arc</a></code>(<var>x</var>, <var>y</var>, <var>radius</var>, <var>startAngle</var>, <var>endAngle</var> [, <var>anticlockwise</var> ] )<dt><var>path</var> . <code id=building-paths:dom-context-2d-arc><a href=#dom-context-2d-arc>arc</a></code>(<var>x</var>, <var>y</var>, <var>radius</var>, <var>startAngle</var>, <var>endAngle</var> [, <var>anticlockwise</var> ] )<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://heycam.github.io/webidl/#indexsizeerror data-x-internal=indexsizeerror>"<code>IndexSizeError</code>"</a> <code id=building-paths:domexception-2><a data-x-internal=domexception href=https://heycam.github.io/webidl/#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>



   <dt><var>context</var> . <code id=dom-context-2d-ellipse-dev><a href=#dom-context-2d-ellipse>ellipse</a></code>(<var>x</var>, <var>y</var>, <var>radiusX</var>, <var>radiusY</var>, <var>rotation</var>, <var>startAngle</var>, <var>endAngle</var> [, <var>anticlockwise</var>] )<dt><var>path</var> . <code id=building-paths:dom-context-2d-ellipse><a href=#dom-context-2d-ellipse>ellipse</a></code>(<var>x</var>, <var>y</var>, <var>radiusX</var>, <var>radiusY</var>, <var>rotation</var>, <var>startAngle</var>, <var>endAngle</var> [, <var>anticlockwise</var>] )<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://heycam.github.io/webidl/#indexsizeerror data-x-internal=indexsizeerror>"<code>IndexSizeError</code>"</a> <code id=building-paths:domexception-3><a data-x-internal=domexception href=https://heycam.github.io/webidl/#dfn-DOMException>DOMException</a></code> if the given
    radius is negative.</p>

   <dt><var>context</var> . <code id=dom-context-2d-rect-dev><a href=#dom-context-2d-rect>rect</a></code>(<var>x</var>, <var>y</var>, <var>w</var>, <var>h</var>)<dt><var>path</var> . <code id=building-paths:dom-context-2d-rect><a href=#dom-context-2d-rect>rect</a></code>(<var>x</var>, <var>y</var>, <var>w</var>, <var>h</var>)<dd>

    <p>Adds a new closed subpath to the path, representing the given rectangle.</p>

   </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>

  <p>The <dfn id=dom-context-2d-moveto><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.<li><p>Create a new subpath with the specified point as its first (and only) point.</ol>

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


  <p>The <dfn id=dom-context-2d-closepath><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>

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

  <p>The <dfn id=dom-context-2d-lineto><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.<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>.<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.</ol>

  <p>The <dfn id=dom-context-2d-quadraticcurveto><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.<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><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><li><p>Add the given point (<var>x</var>, <var>y</var>) to the subpath.</ol>

  <p>The <dfn id=dom-context-2d-beziercurveto><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.<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>.<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><li><p>Add the point (<var>x</var>, <var>y</var>) to the subpath.</ol>

  <hr>

  <p>The <dfn id=dom-context-2d-arcto><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.<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>.<li><p>If <var>radius</var> is negative, then throw an <a id=building-paths:indexsizeerror-4 href=https://heycam.github.io/webidl/#indexsizeerror data-x-internal=indexsizeerror>"<code>IndexSizeError</code>"</a>
   <code id=building-paths:domexception-4><a data-x-internal=domexception href=https://heycam.github.io/webidl/#dfn-DOMException>DOMException</a></code>.<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).<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.<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.<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.</ol>

  <hr>

  <p>The <dfn id=dom-context-2d-arc><code>arc(<var>x</var>, <var>y</var>, <var>radius</var>,
  <var>startAngle</var>, <var>endAngle</var>, <var>anticlockwise</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 this, <var>x</var>, <var>y</var>,
  <var>radius</var>, <var>radius</var>, 0, <var>startAngle</var>, <var>endAngle</var>, and
  <var>anticlockwise</var>.</p>

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

  <p>The <dfn id=dom-context-2d-ellipse><code>ellipse(<var>x</var>, <var>y</var>,
  <var>radiusX</var>, <var>radiusY</var>, <var>rotation</var>, <var>startAngle</var>,
  <var>endAngle</var>, <var>anticlockwise</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 this, <var>x</var>, <var>y</var>, <var>radiusX</var>,
  <var>radiusY</var>, <var>rotation</var>, <var>startAngle</var>, <var>endAngle</var>, and
  <var>anticlockwise</var>.</p>

  <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>anticlockwise</var>, are:

  <ol><li><p>If any of the arguments are infinite or NaN, then return.<li><p>If either <var>radiusX</var> or <var>radiusY</var> are negative, then throw an
   <a id=building-paths:indexsizeerror-5 href=https://heycam.github.io/webidl/#indexsizeerror data-x-internal=indexsizeerror>"<code>IndexSizeError</code>"</a> <code id=building-paths:domexception-5><a data-x-internal=domexception href=https://heycam.github.io/webidl/#dfn-DOMException>DOMException</a></code>.<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.<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>anticlockwise</var> is false and <span><var>endAngle</var>-<var>startAngle</var></span> is equal to or greater than <span>2π</span>, or, if <var>anticlockwise</var> is <em>true</em> and <span><var>startAngle</var>-<var>endAngle</var></span> is equal to or greater than <span>2π</span>, then the arc is the whole circumference of this ellipse, and the point
    at <var>startAngle</var> along this circle's circumference, measured in radians clockwise from
    the ellipse's semi-major axis, acts as both the start point and the end point.</p>

    <p>Otherwise, the points at <var>startAngle</var> and <var>endAngle</var> along this circle's
    circumference, measured in radians clockwise from the ellipse's semi-major axis, are the start
    and end points respectively, and the arc is the path along the circumference of this ellipse
    from the start point to the end point, going anti-clockwise if <var>anticlockwise</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>
   </ol>

  <hr>

  <p>The <dfn id=dom-context-2d-rect><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.<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.<li><p>Mark the subpath as closed.<li><p>Create a new subpath with the point (<var>x</var>, <var>y</var>) as the only point in the
   subpath.</ol>

  

  



  <h6 id=path2d-objects><span class=secno>4.12.5.1.6</span> <code id=path2d-objects:path2d><a href=#path2d>Path2D</a></code> objects<a href=#path2d-objects class=self-link></a></h6><div class=status><input onclick=toggleStatus(this) value=⋰ type=button><p class=support><strong>Support:</strong> path2d<span class="and_chr partial"><span>Chrome for Android (limited)</span> <span>67+</span></span><span class="chrome yes"><span>Chrome</span> <span>68+</span></span><span class="ios_saf yes"><span>iOS Safari</span> <span>9.0+</span></span><span class="and_uc partial"><span>UC Browser for Android (limited)</span> <span>11.8+</span></span><span class="firefox yes"><span>Firefox</span> <span>48+</span></span><span class="ie no"><span>IE</span> <span>None</span></span><span class="op_mini no"><span>Opera Mini</span> <span>None</span></span><span class="safari yes"><span>Safari</span> <span>9.1+</span></span><span class="edge partial"><span>Edge (limited)</span> <span>14+</span></span><span class="samsung partial"><span>Samsung Internet (limited)</span> <span>4+</span></span><span class="opera yes"><span>Opera</span> <span>55+</span></span><span class="android partial"><span>Android Browser (limited)</span> <span>67+</span></span><p class=caniuse>Source: <a href="https://caniuse.com/#feat=path2d">caniuse.com</a></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><var>path</var> = new <code id=dom-path2d-dev><a href=#dom-path2d>Path2D</a></code>()<dd><p>Creates a new empty <code id=path2d-objects:path2d-4><a href=#path2d>Path2D</a></code> object.<dt><var>path</var> = new <code id=path2d-objects:dom-path2d><a href=#dom-path2d>Path2D</a></code>(<var>path</var>)<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>
   <dt><var>path</var> . <code id=dom-path2d-addpath-dev><a href=#dom-path2d-addpath>addPath</a></code>(<var>path</var> [, <var>transform</var> ] )<dd><p>Adds to the path the path given by the argument.</dl>

  

  <p>The <dfn id=dom-path2d><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.<li><p>If <var>path</var> is not given, then return <var>output</var>.<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.)<li>
    <p>Let <var>svgPath</var> be the result of parsing and interpreting <var>path</var> according to
    the SVG specification'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><p>Let (<var>x</var>, <var>y</var>) be the last point in <var>svgPath</var>.<li><p>Add all the subpaths, if any, from <var>svgPath</var> to <var>output</var>.<li><p>Create a new subpath in <var>output</var> with (<var>x</var>, <var>y</var>) as the only
   point in the subpath.<li><p>Return <var>output</var>.</ol>

  <hr>

  <p>The <dfn id=dom-path2d-addpath><code>addPath(<var>b</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>b</var> has no subpaths, then return.<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>.<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.<li><p>Create a copy of all the subpaths in <var>b</var>. Let this copy be known as
   <var>c</var>.<li><p>Transform all the coordinates and lines in <var>c</var> by the transform matrix
   <var>matrix</var>.<li><p>Let (<var>x</var>, <var>y</var>) be the last point in the last subpath
   of <var>c</var>.<li><p>Add all the subpaths in <var>c</var> to <var>a</var>.<li><p>Create a new subpath in <var>a</var> with (<var>x</var>, <var>y</var>) as the only point
   in the subpath.</ol>

  


  <h6 id=transformations><span class=secno>4.12.5.1.7</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><var>context</var> . <code id=dom-context-2d-scale-dev><a href=#dom-context-2d-scale>scale</a></code>(<var>x</var>, <var>y</var>)<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>

   <dt><var>context</var> . <code id=dom-context-2d-rotate-dev><a href=#dom-context-2d-rotate>rotate</a></code>(<var>angle</var>)<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>

   <dt><var>context</var> . <code id=dom-context-2d-translate-dev><a href=#dom-context-2d-translate>translate</a></code>(<var>x</var>, <var>y</var>)<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>

   <dt><var>context</var> . <code id=dom-context-2d-transform-dev><a href=#dom-context-2d-transform>transform</a></code>(<var>a</var>, <var>b</var>, <var>c</var>, <var>d</var>, <var>e</var>, <var>f</var>)<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>

   <dt><var>matrix</var> = <var>context</var> . <code id=dom-context-2d-gettransform-dev><a href=#dom-context-2d-gettransform>getTransform</a></code>()<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>

   <dt><var>context</var> . <code id=dom-context-2d-settransform-dev><a href=#dom-context-2d-settransform>setTransform</a></code>(<var>a</var>, <var>b</var>, <var>c</var>, <var>d</var>, <var>e</var>, <var>f</var>)<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>

   <dt><var>context</var> . <code id=dom-context-2d-settransform-matrix-dev><a href=#dom-context-2d-settransform-matrix>setTransform</a></code>(<var>transform</var>)<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>

   <dt><var>context</var> . <code id=dom-context-2d-resettransform-dev><a href=#dom-context-2d-resettransform>resetTransform</a></code>()<dd>

    <p>Changes the <a href=#current-transformation-matrix id=transformations:current-transformation-matrix-9>current transformation matrix</a> to the identity matrix.</p>

   </dl>

  

  <p>The <dfn id=dom-context-2d-scale><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.<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.</ol>

  <p>The <dfn id=dom-context-2d-rotate><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.<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.</ol>

  <p>The <dfn id=dom-context-2d-translate><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.<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.</ol>

  <p>The <dfn id=dom-context-2d-transform><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.<li><p>Replace the <a href=#current-transformation-matrix id=transformations:current-transformation-matrix-13>current transformation matrix</a> with the result of multiplying the
   current transformation matrix with the matrix described by:</ol>

  

  <table class=matrix><tr><td><var>a</var><td><var>c</var><td><var>e</var><tr><td><var>b</var><td><var>d</var><td><var>f</var><tr><td>0<td>0<td>1</table>

  <p 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>

  

  <p>The <dfn id=dom-context-2d-gettransform><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-14>current transformation matrix</a> matrix of the context.</p>

  <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-15>current transformation matrix</a>, and updating the <a href=#current-transformation-matrix id=transformations:current-transformation-matrix-16>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>

  <p>The <dfn id=dom-context-2d-settransform><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.<li><p>Reset the <a href=#current-transformation-matrix id=transformations:current-transformation-matrix-17>current transformation matrix</a> to the identity matrix.<li><p>Invoke the <code><a href=#dom-context-2d-transform id=transformations:dom-context-2d-transform>transform</a>(<var>a</var>, <var>b</var>, <var>c</var>,
   <var>d</var>, <var>e</var>, <var>f</var>)</code> method with the same arguments.</ol>

  <p>The <dfn id=dom-context-2d-settransform-matrix><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><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.<li><p>Reset the <a href=#current-transformation-matrix id=transformations:current-transformation-matrix-18>current transformation matrix</a> to <var>matrix</var>.</ol>

  <p>The <dfn id=dom-context-2d-resettransform><code>resetTransform()</code></dfn> method,
  when invoked, must reset the <a href=#current-transformation-matrix id=transformations:current-transformation-matrix-19>current transformation matrix</a> to the identity
  matrix.</p>

  



  <h6 id=image-sources-for-2d-rendering-contexts><span class=secno>4.12.5.1.8</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><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><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><code id=image-sources-for-2d-rendering-contexts:imagebitmap><a href=#imagebitmap>ImageBitmap</a></code></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>

  <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><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://heycam.github.io/webidl/#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://heycam.github.io/webidl/#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 an <a href=#intrinsic-width id=image-sources-for-2d-rendering-contexts:intrinsic-width>intrinsic width</a> or <a href=#intrinsic-height id=image-sources-for-2d-rendering-contexts:intrinsic-height>intrinsic height</a>
      (or both) equal to zero, then return <i>bad</i>.</p> 
     <dt><code id=image-sources-for-2d-rendering-contexts:htmlvideoelement-2><a href=#htmlvideoelement>HTMLVideoElement</a></code><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>.<dt><code id=image-sources-for-2d-rendering-contexts:htmlcanvaselement-2><a href=#htmlcanvaselement>HTMLCanvasElement</a></code><dt><code id=image-sources-for-2d-rendering-contexts:offscreencanvas><a href=#offscreencanvas>OffscreenCanvas</a></code><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://heycam.github.io/webidl/#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://heycam.github.io/webidl/#dfn-DOMException>DOMException</a></code>.<dt><code id=image-sources-for-2d-rendering-contexts:imagebitmap-3><a href=#imagebitmap>ImageBitmap</a></code><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://heycam.github.io/webidl/#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://heycam.github.io/webidl/#dfn-DOMException>DOMException</a></code>.</dl>
   <li>
    <p>Return <i>good</i>.</p>
   </ol>

  <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>intrinsic width</a> and <a href=#concept-video-intrinsic-height id=image-sources-for-2d-rendering-contexts:concept-video-intrinsic-height>intrinsic 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>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>:</p>

  <dl class=switch><dt><code id=image-sources-for-2d-rendering-contexts:htmlorsvgimageelement-5><a href=#htmlorsvgimageelement>HTMLOrSVGImageElement</a></code>
   <dt><code id=image-sources-for-2d-rendering-contexts:htmlvideoelement-4><a href=#htmlvideoelement>HTMLVideoElement</a></code>
   <dd><p><var>image</var>'s <a href=#concept-origin id=image-sources-for-2d-rendering-contexts:concept-origin>origin</a> is not <a href=#same-origin id=image-sources-for-2d-rendering-contexts:same-origin>same origin</a> with <a href=#entry-settings-object id=image-sources-for-2d-rendering-contexts:entry-settings-object>entry
   settings object</a>'s <a href=#concept-settings-object-origin id=image-sources-for-2d-rendering-contexts:concept-settings-object-origin>origin</a>.<dt><code id=image-sources-for-2d-rendering-contexts:htmlcanvaselement-4><a href=#htmlcanvaselement>HTMLCanvasElement</a></code>
   <dt><code id=image-sources-for-2d-rendering-contexts:imagebitmap-5><a href=#imagebitmap>ImageBitMap</a></code>
   <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.</dl>



  <h6 id=fill-and-stroke-styles><span class=secno>4.12.5.1.9</span> Fill and stroke styles<a href=#fill-and-stroke-styles class=self-link></a></h6>

  <dl class=domintro><dt><var>context</var> . <code id=dom-context-2d-fillstyle-dev><a href=#dom-context-2d-fillstyle>fillStyle</a></code> [ = <var>value</var> ]<dd>

    <p>Returns the current style used for filling shapes.</p>

    <p>Can be set, to change the fill style.</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>

   <dt><var>context</var> . <code id=dom-context-2d-strokestyle-dev><a href=#dom-context-2d-strokestyle>strokeStyle</a></code> [ = <var>value</var> ]<dd>

    <p>Returns the current style used for stroking shapes.</p>

    <p>Can be set, to change the stroke style.</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>

   </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>The <dfn id=dom-context-2d-fillstyle><code>fillStyle</code></dfn> attribute represents the
  color or style to use inside shapes, and the <dfn id=dom-context-2d-strokestyle><code>strokeStyle</code></dfn> attribute represents the color
  or style to use for the lines around the shapes.</p>

  <p>Both attributes can be either strings, <code id=fill-and-stroke-styles:canvasgradient-3><a href=#canvasgradient>CanvasGradient</a></code>s, or
  <code id=fill-and-stroke-styles:canvaspattern-3><a href=#canvaspattern>CanvasPattern</a></code>s. On setting, strings must be <a href=#parsed-as-a-css-color-value id=fill-and-stroke-styles:parsed-as-a-css-color-value>parsed</a> with this <code id=fill-and-stroke-styles:the-canvas-element><a href=#the-canvas-element>canvas</a></code> element and the color assigned, and
  <code id=fill-and-stroke-styles:canvasgradient-4><a href=#canvasgradient>CanvasGradient</a></code> and <code id=fill-and-stroke-styles:canvaspattern-4><a href=#canvaspattern>CanvasPattern</a></code> objects must be assigned themselves. If
  parsing the value results in failure, then it must be ignored, and the attribute must retain its
  previous value. If the new 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 the
  <code id=fill-and-stroke-styles:canvasrenderingcontext2d><a href=#canvasrenderingcontext2d>CanvasRenderingContext2D</a></code>'s <a href=#concept-canvas-origin-clean id=fill-and-stroke-styles:concept-canvas-origin-clean>origin-clean</a> flag must be set to false.</p>

  <p>When set to a <code id=fill-and-stroke-styles:canvaspattern-6><a href=#canvaspattern>CanvasPattern</a></code> or <code id=fill-and-stroke-styles:canvasgradient-5><a href=#canvasgradient>CanvasGradient</a></code> object, the assignment
  is <a href=#live id=fill-and-stroke-styles:live>live</a>, meaning that changes made to the object after the assignment do affect
  subsequent stroking or filling of shapes.</p>

  <p>On getting, if the value is a color, then the <a href=#serialisation-of-a-color id=fill-and-stroke-styles:serialisation-of-a-color>serialization of the color</a> must be returned. Otherwise, if it is not a color but a
  <code id=fill-and-stroke-styles:canvasgradient-6><a href=#canvasgradient>CanvasGradient</a></code> or <code id=fill-and-stroke-styles:canvaspattern-7><a href=#canvaspattern>CanvasPattern</a></code>, then the respective object must be
  returned. (Such objects are opaque and therefore only useful for assigning to other attributes or
  for comparison to other gradients or patterns.)</p>

  <p>The <dfn id=serialisation-of-a-color>serialization of a color</dfn> for a color
  value is a string, computed as follows: if it has alpha equal to 1.0, then the string is a
  lowercase six-digit hex value, prefixed with a "#" character (U+0023 NUMBER SIGN), with the first
  two digits representing the red component, the next two digits representing the green component,
  and the last two digits representing the blue component, the digits being <a href=https://infra.spec.whatwg.org/#ascii-lower-hex-digit id=fill-and-stroke-styles:lowercase-ascii-hex-digits data-x-internal=lowercase-ascii-hex-digits>ASCII lower hex digits</a>. Otherwise, the color value has alpha less than
  1.0, and the string is the color value in the CSS <code>rgba()</code>
  functional-notation format: the literal string "<code>rgba</code>" (U+0072 U+0067 U+0062
  U+0061) followed by a U+0028 LEFT PARENTHESIS, a base-ten integer in the range 0-255 representing
  the red component (using <a id=fill-and-stroke-styles:ascii-digits href=https://infra.spec.whatwg.org/#ascii-digit data-x-internal=ascii-digits>ASCII digits</a> in the shortest form possible), a literal
  U+002C COMMA and U+0020 SPACE, an integer for the green component, a comma and a space, an integer
  for the blue component, another comma and space, a U+0030 DIGIT ZERO, if the alpha value is
  greater than zero then a U+002E FULL STOP (representing the decimal point), if the alpha value is
  greater than zero then one or more <a id=fill-and-stroke-styles:ascii-digits-2 href=https://infra.spec.whatwg.org/#ascii-digit data-x-internal=ascii-digits>ASCII digits</a> representing the fractional part of
  the alpha, and finally a U+0029
  RIGHT PARENTHESIS. User agents must express the fractional part of the alpha value, if any, with
  the level of precision necessary for the alpha value, when reparsed, to be interpreted as the same
  alpha value.</p>
  

  <p>When the context is created, the <code id=fill-and-stroke-styles:dom-context-2d-fillstyle><a href=#dom-context-2d-fillstyle>fillStyle</a></code> and <code id=fill-and-stroke-styles:dom-context-2d-strokestyle><a href=#dom-context-2d-strokestyle>strokeStyle</a></code> attributes
  must initially have the string value <code>#000000</code>.</p>

  <p>When the value is a color, it must not be affected by the transformation matrix when used to
  draw on bitmaps.</p> 

  

  <hr>

  <p>There are two types of gradients, linear gradients and radial gradients, both represented by
  objects implementing the opaque <code id=fill-and-stroke-styles:canvasgradient-7><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. Between each such stop, the colors and
  the alpha component must be linearly interpolated over the RGBA space 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><var>gradient</var> . <code id=dom-canvasgradient-addcolorstop-dev><a href=#dom-canvasgradient-addcolorstop>addColorStop</a></code>(<var>offset</var>, <var>color</var>)<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://heycam.github.io/webidl/#indexsizeerror data-x-internal=indexsizeerror>"<code>IndexSizeError</code>"</a> <code id=fill-and-stroke-styles:domexception><a data-x-internal=domexception href=https://heycam.github.io/webidl/#dfn-DOMException>DOMException</a></code> if the offset
    is out of range. Throws a <a id=fill-and-stroke-styles:syntaxerror href=https://heycam.github.io/webidl/#syntaxerror data-x-internal=syntaxerror>"<code>SyntaxError</code>"</a> <code id=fill-and-stroke-styles:domexception-2><a data-x-internal=domexception href=https://heycam.github.io/webidl/#dfn-DOMException>DOMException</a></code> if
    the color cannot be parsed.</p>

   <dt><var>gradient</var> = <var>context</var> . <code id=dom-context-2d-createlineargradient-dev><a href=#dom-context-2d-createlineargradient>createLinearGradient</a></code>(<var>x0</var>, <var>y0</var>, <var>x1</var>, <var>y1</var>)<dd>

    <p>Returns a <code id=fill-and-stroke-styles:canvasgradient-8><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>

   <dt><var>gradient</var> = <var>context</var> . <code id=dom-context-2d-createradialgradient-dev><a href=#dom-context-2d-createradialgradient>createRadialGradient</a></code>(<var>x0</var>, <var>y0</var>, <var>r0</var>, <var>x1</var>, <var>y1</var>, <var>r1</var>)<dd>

    <p>Returns a <code id=fill-and-stroke-styles:canvasgradient-9><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://heycam.github.io/webidl/#indexsizeerror data-x-internal=indexsizeerror>"<code>IndexSizeError</code>"</a> <code id=fill-and-stroke-styles:domexception-3><a data-x-internal=domexception href=https://heycam.github.io/webidl/#dfn-DOMException>DOMException</a></code> exception.</p>

   </dl>

  

  <p>The <dfn id=dom-canvasgradient-addcolorstop><code>addColorStop(<var>offset</var>,
  <var>color</var>)</code></dfn> method on the <code id=fill-and-stroke-styles:canvasgradient-10><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://heycam.github.io/webidl/#indexsizeerror data-x-internal=indexsizeerror>"<code>IndexSizeError</code>"</a> <code id=fill-and-stroke-styles:domexception-4><a data-x-internal=domexception href=https://heycam.github.io/webidl/#dfn-DOMException>DOMException</a></code>.<li>
    <p>Let <var>parsed color</var> be the result of <a href=#parsed-as-a-css-color-value id=fill-and-stroke-styles:parsed-as-a-css-color-value-2>parsing</a> <var>color</var>.</p>

    <p class=note>No element is passed to the parser because <code id=fill-and-stroke-styles:canvasgradient-11><a href=#canvasgradient>CanvasGradient</a></code> objects
    are <code id=fill-and-stroke-styles:the-canvas-element-2><a href=#the-canvas-element>canvas</a></code>-neutral — a <code id=fill-and-stroke-styles:canvasgradient-12><a href=#canvasgradient>CanvasGradient</a></code> object created by one
    <code id=fill-and-stroke-styles:the-canvas-element-3><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><p>If <var>parsed color</var> is failure, throw a <a id=fill-and-stroke-styles:syntaxerror-2 href=https://heycam.github.io/webidl/#syntaxerror data-x-internal=syntaxerror>"<code>SyntaxError</code>"</a>
   <code id=fill-and-stroke-styles:domexception-5><a data-x-internal=domexception href=https://heycam.github.io/webidl/#dfn-DOMException>DOMException</a></code>.<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>
   </ol>


  <p>The <dfn id=dom-context-2d-createlineargradient><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-13><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> = <var>x1</var> and <span><var>y0</var> = <var>y1</var></span>, then the linear
  gradient must paint nothing.</p>

  <p>The <dfn id=dom-context-2d-createradialgradient><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://heycam.github.io/webidl/#indexsizeerror data-x-internal=indexsizeerror>"<code>IndexSizeError</code>"</a> <code id=fill-and-stroke-styles:domexception-6><a data-x-internal=domexception href=https://heycam.github.io/webidl/#dfn-DOMException>DOMException</a></code> must be thrown. Otherwise,
  the method, when invoked, must return a radial <code id=fill-and-stroke-styles:canvasgradient-14><a href=#canvasgradient>CanvasGradient</a></code> initialized with the
  two specified circles.</p>

  <p>Radial gradients must be rendered by following these steps:</p>

  <ol><li><p>If <var>x<sub>0</sub></var> = <var>x<sub>1</sub></var> and <var>y<sub>0</sub></var> = <var>y<sub>1</sub></var> and <var>r<sub>0</sub></var> = <var>r<sub>1</sub></var>, then the radial gradient must
   paint nothing. Return.<li>

    <p>Let <span>x(<var>ω</var>) = (<var>x<sub>1</sub></var>-<var>x<sub>0</sub></var>)<var>ω</var> + <var>x<sub>0</sub></var></span></p>

    <p>Let <span>y(<var>ω</var>) = (<var>y<sub>1</sub></var>-<var>y<sub>0</sub></var>)<var>ω</var> + <var>y<sub>0</sub></var></span></p>

    <p>Let <span>r(<var>ω</var>) = (<var>r<sub>1</sub></var>-<var>r<sub>0</sub></var>)<var>ω</var> + <var>r<sub>0</sub></var></span></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><p>For all values of <var>ω</var> where <span>r(<var>ω</var>) > 0</span>, 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 <span>r(<var>ω</var>)</span> at position (<span>x(<var>ω</var>)</span>, <span>y(<var>ω</var>)</span>), 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.</ol>

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

  <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-8><a href=#canvaspattern>CanvasPattern</a></code>
  interface.</p>

  <dl class=domintro><dt><var>pattern</var> = <var>context</var> . <code id=dom-context-2d-createpattern-dev><a href=#dom-context-2d-createpattern>createPattern</a></code>(<var>image</var>, <var>repetition</var>)<dd>

    <p>Returns a <code id=fill-and-stroke-styles:canvaspattern-9><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://heycam.github.io/webidl/#invalidstateerror data-x-internal=invalidstateerror>"<code>InvalidStateError</code>"</a> <code id=fill-and-stroke-styles:domexception-7><a data-x-internal=domexception href=https://heycam.github.io/webidl/#dfn-DOMException>DOMException</a></code>.</p>

   <dt><var>pattern</var> . <code id=dom-canvaspattern-settransform-dev><a href=#dom-canvaspattern-settransform>setTransform</a></code>(<var>transform</var>)<dd>

    <p>Sets the transformation matrix that will be used when rendering the pattern during a fill or
    stroke painting operation.</p>

   </dl>

  

  <p>The <dfn id=dom-context-2d-createpattern><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>.<li><p>If <var>result</var> is <i>bad</i>, then return null.<li><p>Assert: <var>result</var> is <i>good</i>.<li><p>If <var>repetition</var> is the empty string, then set it to "<code>repeat</code>".</p>

   <li><p>If <var>repetition</var> is not a <a href=#case-sensitive id=fill-and-stroke-styles:case-sensitive>case-sensitive</a> match for 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://heycam.github.io/webidl/#syntaxerror data-x-internal=syntaxerror>"<code>SyntaxError</code>"</a> <code id=fill-and-stroke-styles:domexception-8><a data-x-internal=domexception href=https://heycam.github.io/webidl/#dfn-DOMException>DOMException</a></code>.<li><p>Let <var>pattern</var> be a new <code id=fill-and-stroke-styles:canvaspattern-10><a href=#canvaspattern>CanvasPattern</a></code> object with the image
   <var>image</var> and the repetition behavior given by <var>repetition</var>.<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>.<li><p>Return <var>pattern</var>.</ol>

  <p>Modifying the <var>image</var> used when creating a <code id=fill-and-stroke-styles:canvaspattern-11><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-12><a href=#canvaspattern>CanvasPattern</a></code> object.</p>

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

  <p>The <dfn id=dom-canvaspattern-settransform><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><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.<li><p>Reset the pattern's transformation matrix to <var>matrix</var>.</ol>

  <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.<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'" 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><p>Transform the resulting bitmap according to the pattern's transformation matrix.<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>.<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>.<li><p>The resulting bitmap is what is to be rendered, with the same origin and same
   scale.</ol>

  <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.10</span> Drawing rectangles to the bitmap<a href=#drawing-rectangles-to-the-bitmap class=self-link></a></h6>

  <p>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>

  

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

  <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=#dom-context-2d-globalalpha id=drawing-rectangles-to-the-bitmap:dom-context-2d-globalalpha>global alpha</a>, and <a href=#dom-context-2d-globalcompositeoperation id=drawing-rectangles-to-the-bitmap:dom-context-2d-globalcompositeoperation>global composition operators</a>.</p>

  

  <dl class=domintro><dt><var>context</var> . <code id=dom-context-2d-clearrect-dev><a href=#dom-context-2d-clearrect>clearRect</a></code>(<var>x</var>, <var>y</var>, <var>w</var>, <var>h</var>)<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>

   <dt><var>context</var> . <code id=dom-context-2d-fillrect-dev><a href=#dom-context-2d-fillrect>fillRect</a></code>(<var>x</var>, <var>y</var>, <var>w</var>, <var>h</var>)<dd>

    <p>Paints the given rectangle onto the bitmap, using the current fill style.</p>

   <dt><var>context</var> . <code id=dom-context-2d-strokerect-dev><a href=#dom-context-2d-strokerect>strokeRect</a></code>(<var>x</var>, <var>y</var>, <var>w</var>, <var>h</var>)<dd>

    <p>Paints the box that outlines the given rectangle onto the bitmap, using the current stroke
    style.</p>

   </dl>

  

  <p>The <dfn id=dom-context-2d-clearrect><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.<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>.<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.</ol>

  <p class=note>If either height or width are zero, this method has no effect, since the set of
  pixels would be empty.</p>

  <p>The <dfn id=dom-context-2d-fillrect><code>fillRect(<var>x</var>, <var>y</var>,
  <var>w</var>, <var>h</var>)</code></dfn> method, when invoked, must must run these steps:</p>

  <ol><li><p>If any of the arguments are infinite or NaN, then return.<li><p>If either <var>w</var> or <var>h</var> are zero, then return.<li><p>Paint the specified rectangular area using the <code id=drawing-rectangles-to-the-bitmap:dom-context-2d-fillstyle><a href=#dom-context-2d-fillstyle>fillStyle</a></code>.</p>
  </ol>

  <p>The <dfn id=dom-context-2d-strokerect><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.<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 the
   <code id=drawing-rectangles-to-the-bitmap:dom-context-2d-strokestyle><a href=#dom-context-2d-strokestyle>strokeStyle</a></code>.</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>

  



  <h6 id=drawing-text-to-the-bitmap><span class=secno>4.12.5.1.11</span> Drawing text to the bitmap<a href=#drawing-text-to-the-bitmap class=self-link></a></h6><div class=status><input onclick=toggleStatus(this) value=⋰ type=button><p class=support><strong>Support:</strong> canvas-text<span class="and_chr yes"><span>Chrome for Android</span> <span>67+</span></span><span class="chrome yes"><span>Chrome</span> <span>4+</span></span><span class="ios_saf yes"><span>iOS Safari</span> <span>3.2+</span></span><span class="and_uc yes"><span>UC Browser for Android</span> <span>11.8+</span></span><span class="firefox yes"><span>Firefox</span> <span>3.5+</span></span><span class="ie yes"><span>IE</span> <span>9+</span></span><span class="op_mini no"><span>Opera Mini</span> <span>None</span></span><span class="safari yes"><span>Safari</span> <span>4+</span></span><span class="edge yes"><span>Edge</span> <span>12+</span></span><span class="samsung yes"><span>Samsung Internet</span> <span>4+</span></span><span class="opera yes"><span>Opera</span> <span>10.5+</span></span><span class="android yes"><span>Android Browser</span> <span>2.1+</span></span><p class=caniuse>Source: <a href="https://caniuse.com/#feat=canvas-text">caniuse.com</a></div>

  <dl id=text-0 class=domintro><dt><var>context</var> . <code id=dom-context-2d-filltext-dev><a href=#dom-context-2d-filltext>fillText</a></code>(<var>text</var>, <var>x</var>, <var>y</var> [, <var>maxWidth</var> ] )<dt><var>context</var> . <code id=dom-context-2d-stroketext-dev><a href=#dom-context-2d-stroketext>strokeText</a></code>(<var>text</var>, <var>x</var>, <var>y</var> [, <var>maxWidth</var> ] )<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>

   <dt><var>metrics</var> = <var>context</var> . <code id=dom-context-2d-measuretext-dev><a href=#dom-context-2d-measuretext>measureText</a></code>(<var>text</var>)<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>

   <dt><var>metrics</var> . <code id=dom-textmetrics-width-dev><a href=#dom-textmetrics-width>width</a></code><dt><var>metrics</var> . <code id=dom-textmetrics-actualboundingboxleft-dev><a href=#dom-textmetrics-actualboundingboxleft>actualBoundingBoxLeft</a></code><dt><var>metrics</var> . <code id=dom-textmetrics-actualboundingboxright-dev><a href=#dom-textmetrics-actualboundingboxright>actualBoundingBoxRight</a></code><dt><var>metrics</var> . <code id=dom-textmetrics-fontboundingboxascent-dev><a href=#dom-textmetrics-fontboundingboxascent>fontBoundingBoxAscent</a></code><dt><var>metrics</var> . <code id=dom-textmetrics-fontboundingboxdescent-dev><a href=#dom-textmetrics-fontboundingboxdescent>fontBoundingBoxDescent</a></code><dt><var>metrics</var> . <code id=dom-textmetrics-actualboundingboxascent-dev><a href=#dom-textmetrics-actualboundingboxascent>actualBoundingBoxAscent</a></code><dt><var>metrics</var> . <code id=dom-textmetrics-actualboundingboxdescent-dev><a href=#dom-textmetrics-actualboundingboxdescent>actualBoundingBoxDescent</a></code><dt><var>metrics</var> . <code id=dom-textmetrics-emheightascent-dev><a href=#dom-textmetrics-emheightascent>emHeightAscent</a></code><dt><var>metrics</var> . <code id=dom-textmetrics-emheightdescent-dev><a href=#dom-textmetrics-emheightdescent>emHeightDescent</a></code><dt><var>metrics</var> . <code id=dom-textmetrics-hangingbaseline-dev><a href=#dom-textmetrics-hangingbaseline>hangingBaseline</a></code><dt><var>metrics</var> . <code id=dom-textmetrics-alphabeticbaseline-dev><a href=#dom-textmetrics-alphabeticbaseline>alphabeticBaseline</a></code><dt><var>metrics</var> . <code id=dom-textmetrics-ideographicbaseline-dev><a href=#dom-textmetrics-ideographicbaseline>ideographicBaseline</a></code><dd>

    <p>Returns the measurement described below.</p>

   </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>

  <p>The <dfn id=dom-context-2d-filltext><code>fillText()</code></dfn> and <dfn id=dom-context-2d-stroketext><code>strokeText()</code></dfn> methods take three or four arguments,
  <var>text</var>, <var>x</var>, <var>y</var>, and optionally <var>maxWidth</var>, and 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.<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><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>.<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>, <code id=drawing-text-to-the-bitmap:dom-context-2d-fillstyle><a href=#dom-context-2d-fillstyle>fillStyle</a></code> must be applied to the shapes and <code id=drawing-text-to-the-bitmap:dom-context-2d-strokestyle><a href=#dom-context-2d-strokestyle>strokeStyle</a></code> 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: <code id=drawing-text-to-the-bitmap:dom-context-2d-strokestyle-2><a href=#dom-context-2d-strokestyle>strokeStyle</a></code> 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 <code id=drawing-text-to-the-bitmap:dom-context-2d-fillstyle-2><a href=#dom-context-2d-fillstyle>fillStyle</a></code> 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=#dom-context-2d-globalalpha id=drawing-text-to-the-bitmap:dom-context-2d-globalalpha>global
    alpha</a>, the <a href=#clipping-region id=drawing-text-to-the-bitmap:clipping-region>clipping region</a>, and <a href=#dom-context-2d-globalcompositeoperation id=drawing-text-to-the-bitmap:dom-context-2d-globalcompositeoperation>global composition operators</a>.</p>

   </ol>



  <p>The <dfn id=dom-context-2d-measuretext><code>measureText()</code></dfn> method takes one
  argument, <var>text</var>. When the method is invoked, the user agent must 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/visuren.html#inline-box data-x-internal=inline-box>inline box</a> must
  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>
  <a href=#fingerprinting-vector id=drawing-text-to-the-bitmap:fingerprinting-vector class=fingerprint title="There is a potential fingerprinting vector here."><img alt="(This is a fingerprinting vector.)" src=/images/fingerprint.png width=46 height=64></a>
  </p>

  

  <dl><dt><dfn id=dom-textmetrics-width><code>width</code></dfn> attribute<dd><p>The width of that <a id=drawing-text-to-the-bitmap:inline-box-2 href=https://drafts.csswg.org/css2/visuren.html#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.)<dt><dfn id=dom-textmetrics-actualboundingboxleft><code>actualBoundingBoxLeft</code></dfn> attribute<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 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/visuren.html#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>

   <dt><dfn id=dom-textmetrics-actualboundingboxright><code>actualBoundingBoxRight</code></dfn> attribute<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>

   <dt><dfn id=dom-textmetrics-fontboundingboxascent><code>fontBoundingBoxAscent</code></dfn> attribute<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 top of the highest
    bounding rectangle of all the fonts used to render the text, 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>

   <dt><dfn id=dom-textmetrics-fontboundingboxdescent><code>fontBoundingBoxDescent</code></dfn> attribute<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 bottom of the lowest
   bounding rectangle of all the fonts used to render the text, 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.<dt><dfn id=dom-textmetrics-actualboundingboxascent><code>actualBoundingBoxAscent</code></dfn> attribute<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 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 alphabetic baseline 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>

   <dt><dfn id=dom-textmetrics-actualboundingboxdescent><code>actualBoundingBoxDescent</code></dfn> attribute<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.<dt><dfn id=dom-textmetrics-emheightascent><code>emHeightAscent</code></dfn> attribute<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 highest top of the em
   squares in the <a id=drawing-text-to-the-bitmap:line-box href=https://drafts.csswg.org/css2/visuren.html#line-box data-x-internal=line-box>line 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 top of that em square (so this value will usually
   be positive). Zero if the given baseline is the top of that em square; half the font size if the
   given baseline is the middle of that em square.<dt><dfn id=dom-textmetrics-emheightdescent><code>emHeightDescent</code></dfn> attribute<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 lowest bottom of the em
   squares in the <a id=drawing-text-to-the-bitmap:line-box-2 href=https://drafts.csswg.org/css2/visuren.html#line-box data-x-internal=line-box>line 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 bottom of that em square. (Zero if the given baseline
   is the bottom of that em square.)<dt><dfn id=dom-textmetrics-hangingbaseline><code>hangingBaseline</code></dfn> attribute<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 hanging baseline of the
   <a id=drawing-text-to-the-bitmap:line-box-3 href=https://drafts.csswg.org/css2/visuren.html#line-box data-x-internal=line-box>line 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 hanging baseline. (Zero if the given baseline is the hanging
   baseline.)<dt><dfn id=dom-textmetrics-alphabeticbaseline><code>alphabeticBaseline</code></dfn> attribute<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 alphabetic baseline of
   the <a id=drawing-text-to-the-bitmap:line-box-4 href=https://drafts.csswg.org/css2/visuren.html#line-box data-x-internal=line-box>line 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 alphabetic baseline. (Zero if the given baseline is the
   alphabetic baseline.)<dt><dfn id=dom-textmetrics-ideographicbaseline><code>ideographicBaseline</code></dfn> attribute<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 ideographic baseline of
   the <a id=drawing-text-to-the-bitmap:line-box-5 href=https://drafts.csswg.org/css2/visuren.html#line-box data-x-internal=line-box>line 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 ideographic baseline. (Zero if the given baseline is the
   ideographic baseline.)</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 (the em square 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.12</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><var>context</var> . <code id=dom-context-2d-beginpath-dev><a href=#dom-context-2d-beginpath>beginPath</a></code>()<dd>

    <p>Resets the <a href=#current-default-path id=drawing-paths-to-the-canvas:current-default-path-3>current default path</a>.</p>

   <dt><var>context</var> . <code id=dom-context-2d-fill-dev><a href=#dom-context-2d-fill>fill</a></code>( [ <var>fillRule</var> ] )<dt><var>context</var> . <code id=drawing-paths-to-the-canvas:dom-context-2d-fill><a href=#dom-context-2d-fill>fill</a></code>(<var>path</var> [, <var>fillRule</var> ] )<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>

   <dt><var>context</var> . <code id=dom-context-2d-stroke-dev><a href=#dom-context-2d-stroke>stroke</a></code>()<dt><var>context</var> . <code id=drawing-paths-to-the-canvas:dom-context-2d-stroke><a href=#dom-context-2d-stroke>stroke</a></code>(<var>path</var>)<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>

   <dt><var>context</var> . <code id=dom-context-2d-clip-dev><a href=#dom-context-2d-clip>clip</a></code>( [ <var>fillRule</var> ] )<dt><var>context</var> . <code id=drawing-paths-to-the-canvas:dom-context-2d-clip><a href=#dom-context-2d-clip>clip</a></code>(<var>path</var> [, <var>fillRule</var> ] )<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>

   <dt><var>context</var> . <code id=dom-context-2d-ispointinpath-dev><a href=#dom-context-2d-ispointinpath>isPointInPath</a></code>(<var>x</var>, <var>y</var> [, <var>fillRule</var> ] )<dt><var>context</var> . <code id=drawing-paths-to-the-canvas:dom-context-2d-ispointinpath><a href=#dom-context-2d-ispointinpath>isPointInPath</a></code>(<var>path</var>, <var>x</var>, <var>y</var> [, <var>fillRule</var> ] )<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>

   <dt><var>context</var> . <code id=dom-context-2d-ispointinstroke-dev><a href=#dom-context-2d-ispointinstroke>isPointInStroke</a></code>(<var>x</var>, <var>y</var>)<dt><var>context</var> . <code id=drawing-paths-to-the-canvas:dom-context-2d-ispointinstroke><a href=#dom-context-2d-ispointinstroke>isPointInStroke</a></code>(<var>path</var>, <var>x</var>, <var>y</var>)<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>

   </dl>

  

  <p>The <dfn id=dom-context-2d-beginpath><code>beginPath()</code></dfn> method, when invoked,
  must empty the list of subpaths in the context's <a href=#current-default-path id=drawing-paths-to-the-canvas:current-default-path-9>current default path</a> so that the it
  once again has zero subpaths.</p>

  <p>Where the following method definitions use the term <i>intended path</i>, it means the
  <code id=drawing-paths-to-the-canvas:path2d><a href=#path2d>Path2D</a></code> argument, if one was provided, or the <a href=#current-default-path id=drawing-paths-to-the-canvas:current-default-path-10>current default path</a>
  otherwise.</p>

  <p>When the intended path is a <code id=drawing-paths-to-the-canvas:path2d-2><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-3><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>

  <p>The <dfn id=dom-context-2d-fill><code>fill()</code></dfn> method, when invoked, must fill
  all the subpaths of the intended path, using <code id=drawing-paths-to-the-canvas:dom-context-2d-fillstyle><a href=#dom-context-2d-fillstyle>fillStyle</a></code>, and using the <a href=#fill-rule id=drawing-paths-to-the-canvas:fill-rule>fill rule</a> indicated
  by the <var>fillRule</var> argument. Open subpaths must be implicitly closed when being filled
  (without affecting the actual subpaths).</p>

  <p>The <dfn id=dom-context-2d-stroke><code>stroke()</code></dfn> method, when invoked, must
  <a href=#trace-a-path id=drawing-paths-to-the-canvas:trace-a-path>trace</a> the intended path, using this
  <code id=drawing-paths-to-the-canvas:canvaspathdrawingstyles><a href=#canvaspathdrawingstyles>CanvasPathDrawingStyles</a></code> object for the line styles, and then fill the resulting path
  using the <code id=drawing-paths-to-the-canvas:dom-context-2d-strokestyle><a href=#dom-context-2d-strokestyle>strokeStyle</a></code> attribute, 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>

  <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 intended path is the <a href=#current-default-path id=drawing-paths-to-the-canvas:current-default-path-13>current default path</a>.</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-4><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=#dom-context-2d-globalalpha id=drawing-paths-to-the-canvas:dom-context-2d-globalalpha>global
  alpha</a>, the <a href=#clipping-region id=drawing-paths-to-the-canvas:clipping-region>clipping region</a>, and <a href=#dom-context-2d-globalcompositeoperation id=drawing-paths-to-the-canvas:dom-context-2d-globalcompositeoperation>global composition operators</a>. (The effect
  of transformations is described above and varies based on which path is being used.)</p>

  <hr>

  <p>The <dfn id=dom-context-2d-clip><code>clip()</code></dfn> method, when invoked, must
  create a new <dfn id=clipping-region>clipping region</dfn> by calculating the intersection of the current clipping
  region and the area described by the intended path, using the <a href=#fill-rule id=drawing-paths-to-the-canvas:fill-rule-2>fill rule</a> indicated by
  the <var>fillRule</var> argument. 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>

  <p>When the context is initialized, the clipping region must be set to the largest infinite
  surface (i.e. by default, no clipping occurs).</p>

  

  <hr>

  <p>The <dfn id=dom-context-2d-ispointinpath><code>isPointInPath()</code></dfn> method, when
  invoked, must return true if the point given by the <var>x</var> and <var>y</var> coordinates
  passed to the method, when treated as coordinates in the canvas coordinate space unaffected by the
  current transformation, is inside the intended path as determined by the <a href=#fill-rule id=drawing-paths-to-the-canvas:fill-rule-3>fill rule</a>
  indicated by the <var>fillRule</var> argument; and must return false otherwise. 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. If either of the
  arguments are infinite or NaN, then the method must return false.</p>

  <hr>

  <p>The <dfn id=dom-context-2d-ispointinstroke><code>isPointInStroke()</code></dfn> method,
  when invoked, must return true if the point given by the <var>x</var> and <var>y</var> coordinates
  passed to the method, 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 intended path, 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 the
  <code id=drawing-paths-to-the-canvas:canvaspathdrawingstyles-2><a href=#canvaspathdrawingstyles>CanvasPathDrawingStyles</a></code> interface for the line styles; and must return false
  otherwise. Points on the resulting path must be considered to be inside the path. If either of the
  arguments are infinite or NaN, then the method must return false.</p>

  <hr>

  

  <div id=drawCustomFocusRingExample class=example>

   <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>&apos;10px sans-serif&apos;</c-><c- p>;</c->
   context<c- p>.</c->textAlign <c- o>=</c-> <c- t>&apos;left&apos;</c-><c- p>;</c->
   context<c- p>.</c->textBaseline <c- o>=</c-> <c- t>&apos;middle&apos;</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- mi>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>&apos;black&apos;</c-><c- p>;</c->
     context<c- p>.</c->rect<c- p>(</c->x<c- o>-</c-><c- mi>5</c-><c- p>,</c-> y<c- o>-</c-><c- mi>5</c-><c- p>,</c-> <c- mi>10</c-><c- p>,</c-> <c- mi>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>&apos;black&apos;</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- mi>0</c-><c- p>].</c->textContent<c- p>,</c-> x<c- o>+</c-><c- mi>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- mi>7</c-><c- p>,</c-> y<c- o>-</c-><c- mi>7</c-><c- p>,</c-> <c- mi>12</c-> <c- o>+</c-> metrics<c- p>.</c->width<c- o>+</c-><c- mi>2</c-><c- p>,</c-> <c- mi>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>&apos;canvas&apos;</c-><c- p>)[</c-><c- mi>0</c-><c- p>];</c->
   <c- a>var</c-> context <c- o>=</c-> canvas<c- p>.</c->getContext<c- p>(</c-><c- t>&apos;2d&apos;</c-><c- p>);</c->
   context<c- p>.</c->clearRect<c- p>(</c-><c- mi>0</c-><c- p>,</c-> <c- mi>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>&apos;showA&apos;</c-><c- p>),</c-> <c- mi>20</c-><c- p>,</c-> <c- mi>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>&apos;showB&apos;</c-><c- p>),</c-> <c- mi>20</c-><c- p>,</c-> <c- mi>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>&apos;showA&apos;</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>&apos;showB&apos;</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>&apos;canvas&apos;</c-><c- p>)[</c-><c- mi>0</c-><c- p>];</c->
   <c- a>var</c-> context <c- o>=</c-> canvas<c- p>.</c->getContext<c- p>(</c-><c- t>&apos;2d&apos;</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>&apos;showA&apos;</c-><c- p>),</c-> <c- mi>20</c-><c- p>,</c-> <c- mi>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>&apos;showA&apos;</c-><c- p>).</c->checked <c- o>=</c-> <c- o>!</c-><c- p>(</c->document<c- p>.</c->getElementById<c- p>(</c-><c- t>&apos;showA&apos;</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>&apos;showB&apos;</c-><c- p>),</c-> <c- mi>20</c-><c- p>,</c-> <c- mi>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>&apos;showB&apos;</c-><c- p>).</c->checked <c- o>=</c-> <c- o>!</c-><c- p>(</c->document<c- p>.</c->getElementById<c- p>(</c-><c- t>&apos;showB&apos;</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>&apos;canvas&apos;</c-><c- p>)[</c-><c- mi>0</c-><c- p>].</c->addEventListener<c- p>(</c-><c- t>&apos;focus&apos;</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>&apos;canvas&apos;</c-><c- p>)[</c-><c- mi>0</c-><c- p>].</c->addEventListener<c- p>(</c-><c- t>&apos;blur&apos;</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>&apos;canvas&apos;</c-><c- p>)[</c-><c- mi>0</c-><c- p>].</c->addEventListener<c- p>(</c-><c- t>&apos;change&apos;</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>&apos;canvas&apos;</c-><c- p>)[</c-><c- mi>0</c-><c- p>].</c->addEventListener<c- p>(</c-><c- t>&apos;click&apos;</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.13</span> Drawing focus rings and scrolling paths into view<a href=#drawing-focus-rings-and-scrolling-paths-into-view class=self-link></a></h6>

  <dl class=domintro><dt><var>context</var> . <code id=dom-context-2d-drawfocusifneeded-dev><a href=#dom-context-2d-drawfocusifneeded>drawFocusIfNeeded</a></code>(<var>element</var>)<dt><var>context</var> . <code id=drawing-focus-rings-and-scrolling-paths-into-view:dom-context-2d-drawfocusifneeded><a href=#dom-context-2d-drawfocusifneeded>drawFocusIfNeeded</a></code>(<var>path</var>, <var>element</var>)<dd>

    <p>If the given element 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> or the given path, following the platform conventions for focus rings.</p>

   <dt><var>context</var> . <code id=dom-context-2d-scrollpathintoview-dev><a href=#dom-context-2d-scrollpathintoview>scrollPathIntoView</a></code>()<dt><var>context</var> . <code id=drawing-focus-rings-and-scrolling-paths-into-view:dom-context-2d-scrollpathintoview><a href=#dom-context-2d-scrollpathintoview>scrollPathIntoView</a></code>(<var>path</var>)<dd>

    <p>Scrolls the <a href=#current-default-path id=drawing-focus-rings-and-scrolling-paths-into-view:current-default-path-2>current default path</a> or the given path into view. This is especially
    useful on devices with small screens, where the whole canvas might not be visible at once.</p>

   </dl>

  

  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 control drawing focus rings and scrolling paths into view.

  <hr>

  <p id=dom-context-2d-drawosfocusring>The <dfn id=dom-context-2d-drawfocusifneeded><code>drawFocusIfNeeded(<var>element</var>)</code></dfn>
  method, when invoked, must run these steps:</p>

  <ol><li><p>If <var>element</var> is not <a href=#focused id=drawing-focus-rings-and-scrolling-paths-into-view:focused-2>focused</a> or is not a descendant of the element with
   whose context the method is associated, then return.<li>

    <p>Draw a focus ring of the appropriate style along the intended path, 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=#dom-context-2d-globalalpha id=drawing-focus-rings-and-scrolling-paths-into-view:dom-context-2d-globalalpha>global alpha</a>, the <a href=#dom-context-2d-globalcompositeoperation id=drawing-focus-rings-and-scrolling-paths-into-view:dom-context-2d-globalcompositeoperation>global composition operators</a>, or any of
    the members in the <code id=drawing-focus-rings-and-scrolling-paths-into-view:canvasfillstrokestyles><a href=#canvasfillstrokestyles>CanvasFillStrokeStyles</a></code>, <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><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.</ol>

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

  <hr>

  <p>The <dfn id=dom-context-2d-scrollpathintoview><code>scrollPathIntoView()</code></dfn>
  method, when invoked, must run these steps:</p>

  <ol><li><p>Let <var>specifiedRectangle</var> be the rectangle of the bounding box of the intended
   path.<li><p>Let <var>notionalChild</var> be a hypothetical element that is a rendered child of the
   <code id=drawing-focus-rings-and-scrolling-paths-into-view:the-canvas-element><a href=#the-canvas-element>canvas</a></code> element whose dimensions are those of <var>specifiedRectangle</var>.<li><p><a href=https://drafts.csswg.org/cssom-view/#scroll-an-element-into-view id=drawing-focus-rings-and-scrolling-paths-into-view:scroll-an-element-into-view data-x-internal=scroll-an-element-into-view>Scroll <var>notionalChild</var> into
   view</a> with <var>behavior</var> set to "auto", <var>block</var> set to "start", and
   <var>inline</var> set to "nearest".</p>

   <li><p>Optionally, <a href=#inform>inform the user</a> that the caret or selection (or both)
   cover <var>specifiedRectangle</var> of the canvas. The user agent may wait until the next time
   the <a href=#event-loop id=drawing-focus-rings-and-scrolling-paths-into-view:event-loop-2>event loop</a> reaches its <a href=#update-the-rendering id=drawing-focus-rings-and-scrolling-paths-into-view:update-the-rendering-2>update the rendering</a> step to optionally
   inform the user.</ol>

  <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.14</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 id=dom-context-2d-drawimage><code>drawImage</code></dfn> method to draw images.</p>

  

  <p>This method can be invoked with three different sets of arguments:</p>

  <ul class=brief><li><code>drawImage(<var>image</var>, <var>dx</var>, <var>dy</var>)</code>
   <li><code>drawImage(<var>image</var>, <var>dx</var>, <var>dy</var>, <var>dw</var>, <var>dh</var>)</code>
   <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>
  </ul>

  

  <dl class=domintro><dt><var>context</var> . <code id=dom-context-2d-drawimage-dev><a href=#dom-context-2d-drawimage>drawImage</a></code>(<var>image</var>, <var>dx</var>, <var>dy</var>)<dt><var>context</var> . <code id=drawing-images:dom-context-2d-drawimage><a href=#dom-context-2d-drawimage>drawImage</a></code>(<var>image</var>, <var>dx</var>, <var>dy</var>, <var>dw</var>, <var>dh</var>)<dt><var>context</var> . <code id=drawing-images:dom-context-2d-drawimage-2><a href=#dom-context-2d-drawimage>drawImage</a></code>(<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>)<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://heycam.github.io/webidl/#invalidstateerror data-x-internal=invalidstateerror>"<code>InvalidStateError</code>"</a> <code id=drawing-images:domexception><a data-x-internal=domexception href=https://heycam.github.io/webidl/#dfn-DOMException>DOMException</a></code>.</p>

   </dl>

  

  <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.<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>.<li><p>If <var>usability</var> is <i>bad</i>, then return (without drawing anything).<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 href=#intrinsic-width id=drawing-images:intrinsic-width>intrinsic width</a> in image pixels, and the image's
    <a href=#intrinsic-height id=drawing-images:intrinsic-height>intrinsic height</a> in image pixels, respectively. If the image has no <a id=drawing-images:intrinsic-dimensions href=https://drafts.csswg.org/css2/conform.html#intrinsic data-x-internal=intrinsic-dimensions>intrinsic
    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 intrinsic 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><p>If one of the <var>sw</var> or <var>sh</var> arguments is zero, then return. Nothing is
   painted.<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=#dom-context-2d-globalalpha id=drawing-images:dom-context-2d-globalalpha>global
    alpha</a>, the <a href=#clipping-region id=drawing-images:clipping-region>clipping region</a>, and <a href=#dom-context-2d-globalcompositeoperation id=drawing-images:dom-context-2d-globalcompositeoperation>global composition operators</a>.</p>

   <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.</ol>

  


  <h6 id=pixel-manipulation><span class=secno>4.12.5.1.15</span> <dfn>Pixel manipulation</dfn><a href=#pixel-manipulation class=self-link></a></h6>

  <dl class=domintro><dt><var>imagedata</var> = new <code id=dom-imagedata-dev><a href=#dom-imagedata>ImageData</a></code>(<var>sw</var>, <var>sh</var>)<dt><var>imagedata</var> = <var>context</var> . <code id=dom-context-2d-createimagedata-dev><a href=#dom-context-2d-createimagedata>createImageData</a></code>(<var>sw</var>, <var>sh</var>)<dd>
    <p>Returns an <code id=pixel-manipulation:imagedata><a href=#imagedata>ImageData</a></code> object with the given dimensions. 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>

    <p>Throws an <a id=pixel-manipulation:indexsizeerror href=https://heycam.github.io/webidl/#indexsizeerror data-x-internal=indexsizeerror>"<code>IndexSizeError</code>"</a> <code id=pixel-manipulation:domexception><a data-x-internal=domexception href=https://heycam.github.io/webidl/#dfn-DOMException>DOMException</a></code> if either of
    the width or height arguments are zero.</p>
   <dt><var>imagedata</var> = <var>context</var> . <code id=pixel-manipulation:dom-context-2d-createimagedata><a href=#dom-context-2d-createimagedata>createImageData</a></code>(<var>imagedata</var>)<dd><p>Returns an <code id=pixel-manipulation:imagedata-2><a href=#imagedata>ImageData</a></code> object with the same dimensions as the argument. 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>.<dt><var>imagedata</var> = new <code id=pixel-manipulation:dom-imagedata><a href=#dom-imagedata>ImageData</a></code>(<var>data</var>, <var>sw</var> [, <var>sh</var> ] )<dd>
    <p>Returns an <code id=pixel-manipulation:imagedata-3><a href=#imagedata>ImageData</a></code> object using the data provided in the <code id=pixel-manipulation:idl-uint8clampedarray><a data-x-internal=idl-uint8clampedarray href=https://heycam.github.io/webidl/#idl-Uint8ClampedArray>Uint8ClampedArray</a></code> argument, interpreted using the given
    dimensions.</p>

    <p>As each pixel in the data is represented by four numbers, the length of the data needs to be
    a multiple of four times the given width. If the height is provided as well, then the length
    needs to be exactly the width times the height times 4.</p>

    <p>Throws an <a id=pixel-manipulation:indexsizeerror-2 href=https://heycam.github.io/webidl/#indexsizeerror data-x-internal=indexsizeerror>"<code>IndexSizeError</code>"</a> <code id=pixel-manipulation:domexception-2><a data-x-internal=domexception href=https://heycam.github.io/webidl/#dfn-DOMException>DOMException</a></code> if the given
    data and dimensions can't be interpreted consistently, or if either dimension is zero.</p>
   <dt><var>imagedata</var> = <var>context</var> . <code id=dom-context-2d-getimagedata-dev><a href=#dom-context-2d-getimagedata>getImageData</a></code>(<var>sx</var>, <var>sy</var>, <var>sw</var>, <var>sh</var>)<dd>
    <p>Returns an <code id=pixel-manipulation:imagedata-4><a href=#imagedata>ImageData</a></code> object containing the image data for the given rectangle of
    the bitmap.</p>

    <p>Throws an <a id=pixel-manipulation:indexsizeerror-3 href=https://heycam.github.io/webidl/#indexsizeerror data-x-internal=indexsizeerror>"<code>IndexSizeError</code>"</a> <code id=pixel-manipulation:domexception-3><a data-x-internal=domexception href=https://heycam.github.io/webidl/#dfn-DOMException>DOMException</a></code> if the either
    of the width or height arguments are zero.</p>
   <dt><var>imagedata</var> . <code id=dom-imagedata-width-dev><a href=#dom-imagedata-width>width</a></code><dt><var>imagedata</var> . <code id=dom-imagedata-height-dev><a href=#dom-imagedata-height>height</a></code><dd><p>Returns the actual dimensions of the data in the <code id=pixel-manipulation:imagedata-5><a href=#imagedata>ImageData</a></code> object, in
   pixels.<dt><var>imagedata</var> . <code id=dom-imagedata-data-dev><a href=#dom-imagedata-data>data</a></code><dd><p>Returns the one-dimensional array containing the data in RGBA order, as integers in the
   range 0 to 255.<dt><var>context</var> . <code id=dom-context-2d-putimagedata-dev><a href=#dom-context-2d-putimagedata>putImageData</a></code>(<var>imagedata</var>, <var>dx</var>, <var>dy</var> [, <var>dirtyX</var>, <var>dirtyY</var>, <var>dirtyWidth</var>, <var>dirtyHeight</var> ] )<dd>
    <p>Paints the data from the given <code id=pixel-manipulation:imagedata-6><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> attributes, as
    well as the shadow attributes, 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://heycam.github.io/webidl/#invalidstateerror data-x-internal=invalidstateerror>"<code>InvalidStateError</code>"</a> <code id=pixel-manipulation:domexception-4><a data-x-internal=domexception href=https://heycam.github.io/webidl/#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>
   </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>

  <p>The <dfn id=dom-imagedata><code>ImageData()</code></dfn> constructors and the
  <dfn id=dom-context-2d-createimagedata><code>createImageData()</code></dfn> methods are
  used to instantiate new <code id=pixel-manipulation:imagedata-7><a href=#imagedata>ImageData</a></code> objects.</p>

  <p>When the <code id=pixel-manipulation:dom-imagedata-2><a href=#dom-imagedata>ImageData()</a></code> constructor is invoked with two
  numeric arguments <var>sw</var> and <var>sh</var>, it must run these steps:</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-4 href=https://heycam.github.io/webidl/#indexsizeerror data-x-internal=indexsizeerror>"<code>IndexSizeError</code>"</a> <code id=pixel-manipulation:domexception-5><a data-x-internal=domexception href=https://heycam.github.io/webidl/#dfn-DOMException>DOMException</a></code>.<li><p><a href=#create-an-imagedata-object id=pixel-manipulation:create-an-imagedata-object>Create an <code>ImageData</code> object</a> with parameter
   <var>pixelsPerRow</var> set to <var>sw</var>, and <var>rows</var> set to <var>sh</var>.<li><p>Initialize the image data of the newly created <code id=pixel-manipulation:imagedata-8><a href=#imagedata>ImageData</a></code> object 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>.<li><p>Return the newly created <code id=pixel-manipulation:imagedata-9><a href=#imagedata>ImageData</a></code> object.</ol>

  <p>When the <code id=pixel-manipulation:dom-imagedata-3><a href=#dom-imagedata>ImageData()</a></code> constructor is invoked with its first
  argument being an <code id=pixel-manipulation:idl-uint8clampedarray-2><a data-x-internal=idl-uint8clampedarray href=https://heycam.github.io/webidl/#idl-Uint8ClampedArray>Uint8ClampedArray</a></code> <var>source</var>
  and its second and optional third arguments being numeric arguments <var>sw</var> and
  <var>sh</var>, it must run these steps:</p>

  <ol><li><p>Let <var>length</var> be the number of bytes in <var>source</var>.<li><p>If <var>length</var> is not a nonzero integral multiple of four, then throw an
   <a id=pixel-manipulation:invalidstateerror-2 href=https://heycam.github.io/webidl/#invalidstateerror data-x-internal=invalidstateerror>"<code>InvalidStateError</code>"</a> <code id=pixel-manipulation:domexception-6><a data-x-internal=domexception href=https://heycam.github.io/webidl/#dfn-DOMException>DOMException</a></code>.<li><p>Let <var>length</var> be <var>length</var> divided by four.</p>

   <li>

    <p>If <var>length</var> is not an integral multiple of <var>sw</var>, then throw an
    <a id=pixel-manipulation:indexsizeerror-5 href=https://heycam.github.io/webidl/#indexsizeerror data-x-internal=indexsizeerror>"<code>IndexSizeError</code>"</a> <code id=pixel-manipulation:domexception-7><a data-x-internal=domexception href=https://heycam.github.io/webidl/#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><p>Let <var>height</var> be <var>length</var> divided by <var>sw</var>.<li><p>If the <var>sh</var> argument was not omitted, and its value is not equal to
   <var>height</var>, then throw an <a id=pixel-manipulation:indexsizeerror-6 href=https://heycam.github.io/webidl/#indexsizeerror data-x-internal=indexsizeerror>"<code>IndexSizeError</code>"</a>
   <code id=pixel-manipulation:domexception-8><a data-x-internal=domexception href=https://heycam.github.io/webidl/#dfn-DOMException>DOMException</a></code>.<li>

    <p><a href=#create-an-imagedata-object id=pixel-manipulation:create-an-imagedata-object-2>Create an <code>ImageData</code> object</a>, with parameter <var>pixelsPerRow</var>
    set to <var>sw</var>, <var>rows</var> set to <var>sh</var>, and using <var>source</var>.
    Return the newly created <code id=pixel-manipulation:imagedata-10><a href=#imagedata>ImageData</a></code> object.</p>

    <p class=note>The resulting object's data is not a <em>copy</em> of <var>source</var>, it's
    the actual <code id=pixel-manipulation:idl-uint8clampedarray-3><a data-x-internal=idl-uint8clampedarray href=https://heycam.github.io/webidl/#idl-Uint8ClampedArray>Uint8ClampedArray</a></code> object passed as the
    first argument to the constructor.</p>

   </ol>

  <p>When the <code id=pixel-manipulation:dom-context-2d-createimagedata-2><a href=#dom-context-2d-createimagedata>createImageData()</a></code> method is
  invoked with two numeric arguments <var>sw</var> and <var>sh</var>, it must <a href=#create-an-imagedata-object id=pixel-manipulation:create-an-imagedata-object-3>create an
  <code>ImageData</code> object</a>, with parameter <var>pixelsPerRow</var> set to the
  absolute magnitude of <var>sw</var>, and parameter <var>rows</var> set to the absolute magnitude
  of <var>sh</var>. Initialize the image data of the new <code id=pixel-manipulation:imagedata-11><a href=#imagedata>ImageData</a></code> object 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>. If both <var>sw</var> and <var>sh</var> are nonzero, then return
  the new <code id=pixel-manipulation:imagedata-12><a href=#imagedata>ImageData</a></code> object. If one or both of <var>sw</var> and <var>sh</var> are
  zero, then throw an <a id=pixel-manipulation:indexsizeerror-7 href=https://heycam.github.io/webidl/#indexsizeerror data-x-internal=indexsizeerror>"<code>IndexSizeError</code>"</a> <code id=pixel-manipulation:domexception-9><a data-x-internal=domexception href=https://heycam.github.io/webidl/#dfn-DOMException>DOMException</a></code>
  instead.</p>

  <p>When the <code id=pixel-manipulation:dom-context-2d-createimagedata-3><a href=#dom-context-2d-createimagedata>createImageData()</a></code> method is
  invoked with a single <var>imagedata</var> argument, it must <a href=#create-an-imagedata-object id=pixel-manipulation:create-an-imagedata-object-4>create an
  <code>ImageData</code> object</a>, with parameter <var>pixelsPerRow</var> set to the value of
  the <code id=pixel-manipulation:dom-imagedata-width><a href=#dom-imagedata-width>width</a></code> attribute of the <code id=pixel-manipulation:imagedata-13><a href=#imagedata>ImageData</a></code>
  object passed as the argument, and the <var>rows</var> parameter set to the value of the
  <code id=pixel-manipulation:dom-imagedata-height><a href=#dom-imagedata-height>height</a></code> attribute.
  Initialize the image data of the new <code id=pixel-manipulation:imagedata-14><a href=#imagedata>ImageData</a></code> object 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>. Return the newly created <code id=pixel-manipulation:imagedata-15><a href=#imagedata>ImageData</a></code> object.</p>

  <p>The <dfn id=dom-context-2d-getimagedata><code>getImageData(<var>sx</var>,
  <var>sy</var>, <var>sw</var>, <var>sh</var>)</code></dfn> method, when invoked, must,
  if either the <var>sw</var> or <var>sh</var> arguments are zero, throw an
  <a id=pixel-manipulation:indexsizeerror-8 href=https://heycam.github.io/webidl/#indexsizeerror data-x-internal=indexsizeerror>"<code>IndexSizeError</code>"</a> <code id=pixel-manipulation:domexception-10><a data-x-internal=domexception href=https://heycam.github.io/webidl/#dfn-DOMException>DOMException</a></code>; otherwise,
  
  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, it must throw a
  <a id=pixel-manipulation:securityerror href=https://heycam.github.io/webidl/#securityerror data-x-internal=securityerror>"<code>SecurityError</code>"</a> <code id=pixel-manipulation:domexception-11><a data-x-internal=domexception href=https://heycam.github.io/webidl/#dfn-DOMException>DOMException</a></code>;
  
  otherwise, it must <a href=#create-an-imagedata-object id=pixel-manipulation:create-an-imagedata-object-5>create an <code>ImageData</code> object</a>, with parameter
  <var>pixelsPerRow</var> set to <var>sw</var>, and parameter <var>rows</var> set to <var>sh</var>.
  Set the pixel values of the image data of the newly created <code id=pixel-manipulation:imagedata-16><a href=#imagedata>ImageData</a></code> object to
  represent the <a href=#output-bitmap id=pixel-manipulation:output-bitmap>output bitmap</a> for the area of that bitmap denoted by 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>), in the bitmap's coordinate space units.
  Pixels outside the <a href=#output-bitmap id=pixel-manipulation:output-bitmap-2>output bitmap</a> must be set to <a id=pixel-manipulation:transparent-black-6 href=https://drafts.csswg.org/css-color/#transparent-black data-x-internal=transparent-black>transparent black</a>. Pixel
  values must not be premultiplied by alpha.</p>

  <p>When the user agent is required to <dfn id=create-an-imagedata-object>create an <code>ImageData</code> object</dfn>, given a
  positive integer number of rows <var>rows</var>, a positive integer number of pixels per row
  <var>pixelsPerRow</var>, and an optional <code id=pixel-manipulation:idl-uint8clampedarray-4><a data-x-internal=idl-uint8clampedarray href=https://heycam.github.io/webidl/#idl-Uint8ClampedArray>Uint8ClampedArray</a></code> <var>source</var>, it must run these
  steps:</p>

  <ol><li><p>Let <var>imageData</var> be a new uninitialized <code id=pixel-manipulation:imagedata-17><a href=#imagedata>ImageData</a></code> object.<li><p>If <var>source</var> is specified, then assign the <dfn id=dom-imagedata-data><code>data</code></dfn> attribute of <var>imageData</var> to
   <var>source</var>.<li>
    <p>If <var>source</var> is not specified, then initialize the <code id=pixel-manipulation:dom-imagedata-data-2><a href=#dom-imagedata-data>data</a></code> attribute of <var>imageData</var> to a new <code id=pixel-manipulation:idl-uint8clampedarray-5><a data-x-internal=idl-uint8clampedarray href=https://heycam.github.io/webidl/#idl-Uint8ClampedArray>Uint8ClampedArray</a></code> object. The <code id=pixel-manipulation:idl-uint8clampedarray-6><a data-x-internal=idl-uint8clampedarray href=https://heycam.github.io/webidl/#idl-Uint8ClampedArray>Uint8ClampedArray</a></code> object must use a new <a href=#canvas-pixel-arraybuffer id=pixel-manipulation:canvas-pixel-arraybuffer>Canvas
    Pixel <code>ArrayBuffer</code></a> for its storage, and must have a
    zero start offset and a length equal to the length of its storage, in bytes. The <a href=#canvas-pixel-arraybuffer id=pixel-manipulation:canvas-pixel-arraybuffer-2>Canvas
    Pixel <code>ArrayBuffer</code></a> must have the correct size to
    store <var>rows</var> × <var>pixelsPerRow</var> pixels.</p>

    <p>If the <a href=#canvas-pixel-arraybuffer id=pixel-manipulation:canvas-pixel-arraybuffer-3>Canvas Pixel <code>ArrayBuffer</code></a> cannot be
    allocated, then rethrow the <code id=pixel-manipulation:js-rangeerror><a data-x-internal=js-rangeerror href=https://tc39.github.io/ecma262/#sec-native-error-types-used-in-this-standard-rangeerror>RangeError</a></code> thrown by JavaScript,
    and return.</p>
   <li><p>Initialize the <dfn id=dom-imagedata-width><code>width</code></dfn> attribute of
   <var>imageData</var> to <var>pixelsPerRow</var>.<li><p>Initialize the <dfn id=dom-imagedata-height><code>height</code></dfn> attribute of
   <var>imageData</var> to <var>rows</var>.<li><p>Return <var>imageData</var>.</ol>

  <p><code id=pixel-manipulation:imagedata-18><a href=#imagedata>ImageData</a></code> objects are <a href=#serializable-objects id=pixel-manipulation:serializable-objects>serializable objects</a>. Their <a href=#serialization-steps id=pixel-manipulation: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=pixel-manipulation:sub-serialization>sub-serialization</a> of the value of
   <var>value</var>'s <code id=pixel-manipulation:dom-imagedata-data-3><a href=#dom-imagedata-data>data</a></code> attribute.<li><p>Set <var>serialized</var>.[[Width]] to the value of <var>value</var>'s <code id=pixel-manipulation:dom-imagedata-width-2><a href=#dom-imagedata-width>width</a></code> attribute.<li><p>Set <var>serialized</var>.[[Height]] to the value of <var>value</var>'s <code id=pixel-manipulation:dom-imagedata-height-2><a href=#dom-imagedata-height>height</a></code> attribute.</ol>

  <p>Their <a href=#deserialization-steps id=pixel-manipulation:deserialization-steps>deserialization steps</a>, given <var>serialized</var> and <var>value</var>,
  are:</p>

  <ol><li><p>Initialize <var>value</var>'s <code id=pixel-manipulation:dom-imagedata-data-4><a href=#dom-imagedata-data>data</a></code> attribute
   to the <a href=#sub-deserialization id=pixel-manipulation:sub-deserialization>sub-deserialization</a> of <var>serialized</var>.[[Data]].<li><p>Initialize <var>value</var>'s <code id=pixel-manipulation:dom-imagedata-width-3><a href=#dom-imagedata-width>width</a></code> attribute
   to <var>serialized</var>.[[Width]].<li><p>Initialize <var>value</var>'s <code id=pixel-manipulation:dom-imagedata-height-3><a href=#dom-imagedata-height>height</a></code> attribute
   to <var>serialized</var>.[[Height]].</ol>

  <p>A <dfn id=canvas-pixel-arraybuffer>Canvas Pixel <code>ArrayBuffer</code></dfn> is an <code id=pixel-manipulation:idl-arraybuffer><a data-x-internal=idl-arraybuffer href=https://heycam.github.io/webidl/#idl-ArrayBuffer>ArrayBuffer</a></code> whose data is represented in left-to-right order, row
  by row top to bottom, starting with the top left, with each pixel's red, green, blue, and alpha
  components being given in that order for each pixel. Each component of each pixel represented in
  this array must be in the range 0..255, representing the 8 bit value for that component. The
  components must be assigned consecutive indices starting with 0 for the top left pixel's red
  component.</p>

  <p>The <dfn id=dom-context-2d-putimagedata><code>putImageData()</code></dfn> method writes
  data from <code id=pixel-manipulation:imagedata-19><a href=#imagedata>ImageData</a></code> structures back to the rendering context's <a href=#output-bitmap id=pixel-manipulation:output-bitmap-3>output
  bitmap</a>. Its arguments are: <var>imagedata</var>, <var>dx</var>, <var>dy</var>,
  <var>dirtyX</var>, <var>dirtyY</var>, <var>dirtyWidth</var>, and <var>dirtyHeight</var>.</p>

  <p>When the last four arguments to this method are omitted, they must be assumed to have the
  values 0, 0, the <code id=pixel-manipulation:dom-imagedata-width-4><a href=#dom-imagedata-width>width</a></code> member of the <var>imagedata</var> structure, and the <code id=pixel-manipulation:dom-imagedata-height-4><a href=#dom-imagedata-height>height</a></code>
  member of the <var>imagedata</var> structure, respectively.</p>

  <p>The method, when invoked, must act as follows:</p>

  <ol><li><p>Let <var>buffer</var> be <var>imagedata</var>'s <code id=pixel-manipulation:dom-imagedata-data-5><a href=#dom-imagedata-data>data</a></code> attribute value's [[ViewedArrayBuffer]] internal
   slot.<li><p>If <a id=pixel-manipulation:isdetachedbuffer href=https://tc39.github.io/ecma262/#sec-isdetachedbuffer data-x-internal=isdetachedbuffer>IsDetachedBuffer</a>(<var>buffer</var>) is true, then throw an
   <a id=pixel-manipulation:invalidstateerror-3 href=https://heycam.github.io/webidl/#invalidstateerror data-x-internal=invalidstateerror>"<code>InvalidStateError</code>"</a> <code id=pixel-manipulation:domexception-12><a data-x-internal=domexception href=https://heycam.github.io/webidl/#dfn-DOMException>DOMException</a></code>.<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>

    <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 zero.</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 zero.</p>

   <li>

    <p>If <var>dirtyX</var>+<var>dirtyWidth</var> is greater than the <code id=pixel-manipulation:dom-imagedata-width-5><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-6><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-5><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-6><a href=#dom-imagedata-height>height</a></code> attribute, minus the value of <var>dirtyY</var>.</p>

   <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><p>For all integer values of <var>x</var> and <var>y</var> where <span><var>dirtyX</var> ≤ <var>x</var> &lt; <span><var>dirtyX</var>+<var>dirtyWidth</var></span></span> and <span><var>dirtyY</var> ≤ <var>y</var> &lt; <span><var>dirtyY</var>+<var>dirtyHeight</var></span></span>, copy the
   four channels of the pixel with coordinate (<var>x</var>, <var>y</var>) in
   the <var>imagedata</var> data structure's <a href=#canvas-pixel-arraybuffer id=pixel-manipulation:canvas-pixel-arraybuffer-4>Canvas Pixel
   <code>ArrayBuffer</code></a> to the pixel with coordinate (<span><var>dx</var>+<var>x</var></span>, <var>dy</var>+<var>y</var>)
   in the rendering context's <a href=#output-bitmap id=pixel-manipulation:output-bitmap-4>output bitmap</a>.</ol>

  <p class=note>Due to the lossy nature of converting to and from premultiplied alpha 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> 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>shadow attributes</a>, <a href=#dom-context-2d-globalalpha id=pixel-manipulation:dom-context-2d-globalalpha-2>global
  alpha</a>, the <a href=#clipping-region id=pixel-manipulation:clipping-region>clipping region</a>, and <a href=#dom-context-2d-globalcompositeoperation id=pixel-manipulation:dom-context-2d-globalcompositeoperation-2>global composition 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-20><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>&apos;2d&apos;</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>&apos;green&apos;</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- mi>2</c-><c- p>,</c-> data<c- p>.</c->height<c- o>/</c-><c- mi>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- mi>0</c-><c- p>,</c-> <c- mi>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>&quot;en&quot;</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>&quot;image.jpeg&quot;</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>&apos;canvas&apos;</c-><c- p>)[</c-><c- mi>0</c-><c- p>];</c->
     <c- a>var</c-> context <c- o>=</c-> canvas<c- p>.</c->getContext<c- p>(</c-><c- t>&apos;2d&apos;</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- mi>0</c-><c- p>,</c-> <c- mi>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- mi>0</c-><c- p>,</c-> <c- mi>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&apos;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- mi>1</c-><c- p>;</c-> y <c- o>&lt;</c-> h<c- o>-</c-><c- mi>1</c-><c- p>;</c-> y <c- o>+=</c-> <c- mi>1</c-><c- p>)</c-> <c- p>{</c->
       <c- k>for</c-> <c- p>(</c-><c- a>var</c-> x <c- o>=</c-> <c- mi>1</c-><c- p>;</c-> x <c- o>&lt;</c-> w<c- o>-</c-><c- mi>1</c-><c- p>;</c-> x <c- o>+=</c-> <c- mi>1</c-><c- p>)</c-> <c- p>{</c->
         <c- k>for</c-> <c- p>(</c-><c- a>var</c-> c <c- o>=</c-> <c- mi>0</c-><c- p>;</c-> c <c- o>&lt;</c-> <c- mi>3</c-><c- p>;</c-> c <c- o>+=</c-> <c- mi>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- mi>4</c-> <c- o>+</c-> c<c- p>;</c->
           outputData<c- p>[</c->i<c- p>]</c-> <c- o>=</c-> <c- mi>127</c-> <c- o>+</c-> <c- o>-</c->inputData<c- p>[</c->i <c- o>-</c-> w<c- o>*</c-><c- mi>4</c-> <c- o>-</c-> <c- mi>4</c-><c- p>]</c-> <c- o>-</c->   inputData<c- p>[</c->i <c- o>-</c-> w<c- o>*</c-><c- mi>4</c-><c- p>]</c-> <c- o>-</c-> inputData<c- p>[</c->i <c- o>-</c-> w<c- o>*</c-><c- mi>4</c-> <c- o>+</c-> <c- mi>4</c-><c- p>]</c-> <c- o>+</c->
                                 <c- o>-</c->inputData<c- p>[</c->i <c- o>-</c-> <c- mi>4</c-><c- p>]</c->       <c- o>+</c-> <c- mi>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- mi>4</c-><c- p>]</c-> <c- o>+</c->
                                 <c- o>-</c->inputData<c- p>[</c->i <c- o>+</c-> w<c- o>*</c-><c- mi>4</c-> <c- o>-</c-> <c- mi>4</c-><c- p>]</c-> <c- o>-</c->   inputData<c- p>[</c->i <c- o>+</c-> w<c- o>*</c-><c- mi>4</c-><c- p>]</c-> <c- o>-</c-> inputData<c- p>[</c->i <c- o>+</c-> w<c- o>*</c-><c- mi>4</c-> <c- o>+</c-> <c- mi>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- mi>4</c-> <c- o>+</c-> <c- mi>3</c-><c- p>]</c-> <c- o>=</c-> <c- mi>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- mi>0</c-><c- p>,</c-> <c- mi>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>&quot;init()&quot;</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>




  <h6 id=compositing><span class=secno>4.12.5.1.16</span> Compositing<a href=#compositing class=self-link></a></h6>

  <dl class=domintro><dt><var>context</var> . <code id=dom-context-2d-globalalpha-dev><a href=#dom-context-2d-globalalpha>globalAlpha</a></code> [ = <var>value</var> ]<dd>

    <p>Returns the current alpha value applied to rendering operations.</p>

    <p>Can be set, to change the alpha value. Values outside of the range 0.0 .. 1.0 are
    ignored.</p>

   <dt><var>context</var> . <code id=dom-context-2d-globalcompositeoperation-dev><a href=#dom-context-2d-globalcompositeoperation>globalCompositeOperation</a></code> [ = <var>value</var> ]<dd>

    <p>Returns the current composition operation, from the values defined in the Compositing and
    Blending specification. <a href=#refsCOMPOSITE>[COMPOSITE]</a>.</p>

    <p>Can be set, to change the composition operation. Unknown values are ignored.</p>

   </dl>

  

  <p>All drawing operations on an object which implements the <code id=compositing:canvascompositing><a href=#canvascompositing>CanvasCompositing</a></code>
  interface are affected by the global compositing attributes, <code id=compositing:dom-context-2d-globalalpha><a href=#dom-context-2d-globalalpha>globalAlpha</a></code> and <code id=compositing:dom-context-2d-globalcompositeoperation><a href=#dom-context-2d-globalcompositeoperation>globalCompositeOperation</a></code>.</p>

  

  <p>The <dfn id=dom-context-2d-globalalpha><code>globalAlpha</code></dfn> attribute 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 must be in the range from 0.0 (fully transparent) to 1.0 (no additional
  transparency). If an attempt is made to set the attribute to a value outside this range, including
  Infinity and Not-a-Number (NaN) values, then the attribute must retain its previous value. When
  the context is created, the <code id=compositing:dom-context-2d-globalalpha-2><a href=#dom-context-2d-globalalpha>globalAlpha</a></code> attribute
  must initially have the value 1.0.</p>

  <p>The <dfn id=dom-context-2d-globalcompositeoperation><code>globalCompositeOperation</code></dfn> attribute
  sets the <dfn id=current-composition-operator>current composition operator</dfn>, which 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 <code id=compositing:dom-context-2d-globalalpha-3><a href=#dom-context-2d-globalalpha>globalAlpha</a></code> and the current transformation matrix
  applied. The possible values are those defined in the Compositing and Blending specification, and
  include the values <dfn id=gcop-source-over><code>source-over</code></dfn>
  and <dfn id=gcop-copy><code>copy</code></dfn>.
  <a href=#refsCOMPOSITE>[COMPOSITE]</a></p>

  <p>These values are all case-sensitive — they must be used exactly as defined. User agents
  must not recognize values that are not a <a href=#case-sensitive id=compositing:case-sensitive>case-sensitive</a> match for one of the values
  given in the Compositing and Blending specification. <a href=#refsCOMPOSITE>[COMPOSITE]</a></p>

  <p>On setting, if the user agent does not recognize the specified value, it must be ignored,
  leaving the value of <code id=compositing:dom-context-2d-globalcompositeoperation-2><a href=#dom-context-2d-globalcompositeoperation>globalCompositeOperation</a></code> unaffected.
  Otherwise, the attribute must be set to the given new value.</p>

  <p>When the context is created, the <code id=compositing:dom-context-2d-globalcompositeoperation-3><a href=#dom-context-2d-globalcompositeoperation>globalCompositeOperation</a></code> attribute must
  initially have the value <code id=compositing:gcop-source-over><a href=#gcop-source-over>source-over</a></code>.</p>

  



  <h6 id=image-smoothing><span class=secno>4.12.5.1.17</span> Image smoothing<a href=#image-smoothing class=self-link></a></h6>

  <dl class=domintro><dt><var>context</var> . <code id=dom-context-2d-imagesmoothingenabled-dev><a href=#dom-context-2d-imagesmoothingenabled>imageSmoothingEnabled</a></code> [ = <var>value</var> ]<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>

   <dt><var>context</var> . <code id=dom-context-2d-imagesmoothingquality-dev><a href=#dom-context-2d-imagesmoothingquality>imageSmoothingQuality</a></code> [ = <var>value</var> ]<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>

   </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>

  <p>The <dfn id=dom-context-2d-imagesmoothingenabled><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>

  <p>The <dfn id=dom-context-2d-imagesmoothingquality><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>

  


  <h6 id=shadows><span class=secno>4.12.5.1.18</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><var>context</var> . <code id=dom-context-2d-shadowcolor-dev><a href=#dom-context-2d-shadowcolor>shadowColor</a></code> [ = <var>value</var> ]<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>

   <dt><var>context</var> . <code id=dom-context-2d-shadowoffsetx-dev><a href=#dom-context-2d-shadowoffsetx>shadowOffsetX</a></code> [ = <var>value</var> ]<dt><var>context</var> . <code id=dom-context-2d-shadowoffsety-dev><a href=#dom-context-2d-shadowoffsety>shadowOffsetY</a></code> [ = <var>value</var> ]<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>

   <dt><var>context</var> . <code id=dom-context-2d-shadowblur-dev><a href=#dom-context-2d-shadowblur>shadowBlur</a></code> [ = <var>value</var> ]<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>

   </dl>

  

  <p>The <dfn id=dom-context-2d-shadowcolor><code>shadowColor</code></dfn> attribute sets the
  color of the shadow.</p>

  <p>When the context is created, the <code id=shadows:dom-context-2d-shadowcolor><a href=#dom-context-2d-shadowcolor>shadowColor</a></code>
  attribute initially 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>

  <p>On getting, the <a href=#serialisation-of-a-color id=shadows:serialisation-of-a-color>serialization of the color</a>
  must be returned.</p>

  <p>On setting, the new value must be <a href=#parsed-as-a-css-color-value id=shadows:parsed-as-a-css-color-value>parsed</a>
  with this <code id=shadows:the-canvas-element><a href=#the-canvas-element>canvas</a></code> element and the color assigned. If parsing the value results in
  failure then it must be ignored, and the attribute must retain its previous value. <a href=#refsCSSCOLOR>[CSSCOLOR]</a></p>

  <p>The <dfn id=dom-context-2d-shadowoffsetx><code>shadowOffsetX</code></dfn> and <dfn id=dom-context-2d-shadowoffsety><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>

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

  <p>The <dfn id=dom-context-2d-shadowblur><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>

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

  <p><dfn id=when-shadows-are-drawn>Shadows are only drawn if</dfn> the opacity component of
  the alpha component of the color of <code id=shadows:dom-context-2d-shadowcolor-2><a href=#dom-context-2d-shadowcolor>shadowColor</a></code> 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>

  <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.<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>.<li><p>Copy the alpha channel 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.<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>.<li> <p>Perform a 2D Gaussian Blur on <var>B</var>, using <var>σ</var>
     as the standard deviation.</p>  </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><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 color of <code id=shadows:dom-context-2d-shadowcolor-3><a href=#dom-context-2d-shadowcolor>shadowColor</a></code>.<li><p>Multiply the alpha component of every pixel in <var>B</var> by the alpha
   component of the color of <code id=shadows:dom-context-2d-shadowcolor-4><a href=#dom-context-2d-shadowcolor>shadowColor</a></code>.<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.</ol>

  

  <p>If the current composition operation is <code id=shadows:gcop-copy><a href=#gcop-copy>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.19</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 id=dom-context-2d-filter><code>filter</code></dfn>
  attribute.</p>

  <dl class=domintro><dt><var>context</var> . <code id=dom-context-2d-filter-dev><a href=#dom-context-2d-filter>filter</a></code> [ = <var>value</var> ]<dd>

    <p>Returns the current filter.</p>

    <p>Can be set, to change the filter. Values that cannot be parsed as a
    <a id=filters:filter-function-list href=https://drafts.fxtf.org/filter-effects/#typedef-filter-function-list data-x-internal=filter-function-list>&lt;filter-function-list></a> value are ignored.</p>

   </dl>

  

  <p>The <code id=filters:dom-context-2d-filter><a href=#dom-context-2d-filter>filter</a></code> attribute, on getting, must
  return the last value it was successfully set to. The value must not be re-serialized. On setting,
  if the new value is 'none' (not the empty string, null, or undefined), filters must be disabled
  for the context. Otherwise, the value must be parsed as a
  <a id=filters:filter-function-list-2 href=https://drafts.fxtf.org/filter-effects/#typedef-filter-function-list data-x-internal=filter-function-list>&lt;filter-function-list></a> value. If the value cannot be parsed as a
  <a id=filters:filter-function-list-3 href=https://drafts.fxtf.org/filter-effects/#typedef-filter-function-list data-x-internal=filter-function-list>&lt;filter-function-list></a> value, where using property-independent style sheet
  syntax like 'inherit' or 'initial' is considered an invalid value, then it must be ignored, and
  the attribute must retain its previous value. When creating the object implementing the
  <code id=filters:canvasfilters-2><a href=#canvasfilters>CanvasFilters</a></code> interface, the attribute must be set to 'none'.</p>

  <p>A <a id=filters:filter-function-list-4 href=https://drafts.fxtf.org/filter-effects/#typedef-filter-function-list data-x-internal=filter-function-list>&lt;filter-function-list></a> value consists of a sequence of one or more
  filter functions or references to SVG filters. The input to the filter is used as the input
  to the first item in the list. Subsequent items take the output of the previous item as
  their input. <a href=#refsFILTERS>[FILTERS]</a></p>

  <p>Coordinates used in the value of the <code id=filters:dom-context-2d-filter-2><a href=#dom-context-2d-filter>filter</a></code> attribute 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 <code id=filters:dom-context-2d-filter-3><a href=#dom-context-2d-filter>filter</a></code> attribute 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 it is an
  element. 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 <code id=filters:dom-context-2d-filter-4><a href=#dom-context-2d-filter>filter</a></code> attribute refers 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 <code id=filters:dom-context-2d-filter-5><a href=#dom-context-2d-filter>filter</a></code> attribute refers 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.20</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 'none' 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.21</span> <dfn>Drawing model</dfn><a href=#drawing-model class=self-link></a></h6>

  <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.<li><p>When the filter attribute is set to a value other than 'none' 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 <code id=drawing-model:dom-context-2d-filter><a href=#dom-context-2d-filter>filter</a></code>, creating image <var>B</var>. Otherwise, let
   <var>B</var> be an alias for <var>A</var>.<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>.<li><p><a href=#when-shadows-are-drawn id=drawing-model:when-shadows-are-drawn-2>When shadows are drawn</a>, multiply the alpha component of every pixel in <var>C</var> by <code id=drawing-model:dom-context-2d-globalalpha><a href=#dom-context-2d-globalalpha>globalAlpha</a></code>.<li><p><a href=#when-shadows-are-drawn id=drawing-model:when-shadows-are-drawn-3>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-composition-operator id=drawing-model:current-composition-operator>current
   composition operator</a>.<li><p>Multiply the alpha component of every pixel in <var>B</var> by <code id=drawing-model:dom-context-2d-globalalpha-2><a href=#dom-context-2d-globalalpha>globalAlpha</a></code>.<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-composition-operator id=drawing-model:current-composition-operator-2>current composition operator</a>.</ol>

  <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.22</span> Best practices<a href=#best-practices class=self-link></a></h6>

  <p>When a canvas is interactive, authors should include focusable elements in the element's
  fallback content corresponding to each focusable 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>In addition to drawing focus rings, authors should use the <code id=best-practices:dom-context-2d-scrollpathintoview><a href=#dom-context-2d-scrollpathintoview>scrollPathIntoView()</a></code> method when an element in
  the canvas is focused, to make sure it is visible on the screen (if applicable).</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>Keyboard movement of the caret has to be reimplemented (possibly across lines, for multiline
   text input).<li>Scrolling of the text control has to be implemented (horizontally for long lines, vertically
   for multiline input).<li>Native features such as copy-and-paste have to be reimplemented.<li>Native features such as spell-checking have to be reimplemented.<li>Native features such as drag-and-drop have to be reimplemented.<li>Native features such as page-wide text search have to be reimplemented.<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>Bidirectional text editing has to be reimplemented.<li>For multiline text editing, line wrapping has to be implemented for all relevant
   languages.<li>Text selection has to be reimplemented.<li>Dragging of bidirectional text selections has to be reimplemented.<li>Platform-native keyboard shortcuts have to be reimplemented.<li>Platform-native input method editors (IMEs) have to be reimplemented.<li>Undo and redo functionality has to be reimplemented.<li>Accessibility features such as magnification following the caret or selection have to be
   reimplemented.</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.23</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>&quot;800&quot;</c-> <c- e>height</c-><c- o>=</c-><c- s>&quot;450&quot;</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>&apos;canvas&apos;</c-><c- p>)[</c-><c- mi>0</c-><c- p>].</c->getContext<c- p>(</c-><c- t>&apos;2d&apos;</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- mi>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- mi>2</c-><c- p>,</c-> context<c- p>.</c->canvas<c- p>.</c->height<c- o>/</c-><c- mi>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- mi>2</c-><c- p>,</c-> <c- o>-</c->context<c- p>.</c->canvas<c- p>.</c->height<c- o>/</c-><c- mi>2</c-><c- p>);</c->
   context<c- p>.</c->beginPath<c- p>();</c->
   context<c- p>.</c->lineWidth <c- o>=</c-> <c- mi>5</c-> <c- o>+</c-> Math<c- p>.</c->random<c- p>()</c-> <c- o>*</c-> <c- mi>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- mi>10</c-> <c- o>*</c-> Math<c- p>.</c->random<c- p>();</c->
   context<c- p>.</c->strokeStyle <c- o>=</c-> <c- t>&apos;hsl(&apos;</c-> <c- o>+</c-> hue <c- o>+</c-> <c- t>&apos;, 50%, 50%)&apos;</c-><c- p>;</c->
   context<c- p>.</c->shadowColor <c- o>=</c-> <c- t>&apos;white&apos;</c-><c- p>;</c->
   context<c- p>.</c->shadowBlur <c- o>=</c-> <c- mi>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- mi>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>&apos;rgba(0,0,0,0.1)&apos;</c-><c- p>;</c->
   context<c- p>.</c->fillRect<c- p>(</c-><c- mi>0</c-><c- p>,</c-> <c- mi>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- mi>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>meta</c-> <c- e>charset</c-><c- o>=</c-><c- s>&quot;utf-8&quot;</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>&quot;380&quot;</c-> <c- e>height</c-><c- o>=</c-><c- s>&quot;200&quot;</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- mi>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- mi>0</c-><c- p>,</c-> <c- mi>0</c-><c- p>,</c-> <c- mi>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>&apos;rgb(55,121,179)&apos;</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>&apos;rgb(121,194,245)&apos;</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>&apos;rgb(164,200,214)&apos;</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- mi>0</c-><c- p>,</c-> <c- k>this</c-><c- p>.</c->horizon<c- p>,</c-> <c- mi>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>&apos;rgb(81,140,20)&apos;</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>&apos;rgb(123,177,57)&apos;</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- mi>0</c-><c- p>,</c-> <c- mi>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- mi>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- mi>0</c-><c- p>,</c-> <c- mi>0</c-><c- p>);</c->
     context<c- p>.</c->shadowColor <c- o>=</c-> <c- t>&apos;white&apos;</c-><c- p>;</c->
     context<c- p>.</c->shadowOffsetY <c- o>=</c-> <c- mi>30</c-><c- o>+</c-><c- k>this</c-><c- p>.</c->horizon<c- o>/</c-><c- mi>3</c-><c- p>;</c-> <c- c1>// offset down on canvas</c->
     context<c- p>.</c->shadowBlur <c- o>=</c-> <c- t>&apos;5&apos;</c-><c- p>;</c->
     context<c- p>.</c->fillStyle <c- o>=</c-> <c- t>&apos;white&apos;</c-><c- p>;</c->
     context<c- p>.</c->textAlign <c- o>=</c-> <c- t>&apos;left&apos;</c-><c- p>;</c->
     context<c- p>.</c->textBaseline <c- o>=</c-> <c- t>&apos;top&apos;</c-><c- p>;</c->
     context<c- p>.</c->font <c- o>=</c-> <c- t>&apos;20px sans-serif&apos;</c-><c- p>;</c->
     context<c- p>.</c->fillText<c- p>(</c-><c- t>&apos;WHATWG ROCKS&apos;</c-><c- p>,</c-> <c- mi>10</c-><c- p>,</c-> <c- o>-</c-><c- mi>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- mi>30</c-><c- p>,</c-> <c- mi>0</c-><c- p>);</c->
     context<c- p>.</c->beginPath<c- p>();</c->
     context<c- p>.</c->fillStyle <c- o>=</c-> <c- t>&apos;rgb(143,89,2)&apos;</c-><c- p>;</c->
     context<c- p>.</c->lineStyle <c- o>=</c-> <c- t>&apos;rgb(10,10,10)&apos;</c-><c- p>;</c->
     context<c- p>.</c->lineWidth <c- o>=</c-> <c- mi>2</c-><c- p>;</c->
     context<c- p>.</c->rect<c- p>(</c-><c- mi>0</c-><c- p>,</c-> <c- k>this</c-><c- p>.</c->horizon<c- o>+</c-><c- mi>5</c-><c- p>,</c-> <c- mi>10</c-><c- p>,</c-> <c- o>-</c-><c- mi>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>&apos;rgb(78,154,6)&apos;</c-><c- p>;</c->
     context<c- p>.</c->arc<c- p>(</c-><c- mi>5</c-><c- p>,</c-> <c- k>this</c-><c- p>.</c->horizon<c- o>-</c-><c- mi>60</c-><c- p>,</c-> <c- mi>30</c-><c- p>,</c-> <c- mi>0</c-><c- p>,</c-> Math<c- p>.</c->PI<c- o>*</c-><c- mi>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- mi>0</c-><c- p>,</c-> <c- mi>0</c-><c- p>);</c->
     context<c- p>.</c->beginPath<c- p>();</c->
     context<c- p>.</c->rect<c- p>(</c-><c- mi>0</c-><c- p>,</c-> <c- k>this</c-><c- p>.</c->horizon <c- o>-</c-> <c- mi>5</c-><c- p>,</c-> <c- mi>25</c-><c- p>,</c-> <c- mi>25</c-><c- p>);</c->
     context<c- p>.</c->fillStyle <c- o>=</c-> <c- t>&apos;rgb(220,154,94)&apos;</c-><c- p>;</c->
     context<c- p>.</c->lineStyle <c- o>=</c-> <c- t>&apos;rgb(10,10,10)&apos;</c-><c- p>;</c->
     context<c- p>.</c->lineWidth <c- o>=</c-> <c- mi>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>&apos;blue-robot.png&apos;</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>&apos;idle&apos;</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>&apos;walk&apos;</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>&apos;idle&apos;</c-><c- p>;</c->
   <c- p>};</c->
   <c- k>this</c-><c- p>.</c->frameIndex <c- o>=</c-> <c- p>{</c->
     <c- t>&apos;idle&apos;</c-><c- o>:</c-> <c- p>[</c-><c- mi>0</c-><c- p>],</c-> <c- c1>// first cell is the idle frame</c->
     <c- t>&apos;walk&apos;</c-><c- o>:</c-> <c- p>[</c-><c- mi>1</c-><c- p>,</c-><c- mi>2</c-><c- p>,</c-><c- mi>3</c-><c- p>,</c-><c- mi>4</c-><c- p>,</c-><c- mi>5</c-><c- p>,</c-><c- mi>6</c-><c- p>],</c-> <c- c1>// the walking animation is cells 1-6</c->
     <c- t>&apos;stop&apos;</c-><c- o>:</c-> <c- p>[</c-><c- mi>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>&apos;idle&apos;</c-><c- p>;</c->
   <c- k>this</c-><c- p>.</c->frame <c- o>=</c-> <c- mi>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- mi>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&apos;ve reached the end of this animation cycle</c->
       <c- k>this</c-><c- p>.</c->frame <c- o>=</c-> <c- mi>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>&apos;walk&apos;</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>&apos;stop&apos;</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>&apos;stop&apos;</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>&apos;walk&apos;</c-><c- p>)</c->
             <c- k>this</c-><c- p>.</c->mode <c- o>=</c-> <c- t>&apos;walk&apos;</c-><c- p>;</c->
           <c- k>else</c->
             <c- k>this</c-><c- p>.</c->mode <c- o>=</c-> <c- t>&apos;idle&apos;</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>&apos;idle&apos;</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>&apos;walk&apos;</c-><c- p>)</c->
             <c- k>this</c-><c- p>.</c->mode <c- o>=</c-> <c- t>&apos;walk&apos;</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>&apos;walk&apos;</c-><c- p>)</c->
       <c- k>return</c-> <c- mi>8</c-><c- p>;</c->
     <c- k>return</c-> <c- mi>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- mi>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- mi>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>&apos;canvas&apos;</c-><c- p>)[</c-><c- mi>0</c-><c- p>];</c->
 <c- a>var</c-> context <c- o>=</c-> canvas<c- p>.</c->getContext<c- p>(</c-><c- t>&apos;2d&apos;</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- mi>0</c-><c- p>,</c-> <c- mi>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- mi>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&apos;t slow down when we don&apos;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- mi>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>&quot;buttons&quot;</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>&quot;Walk&quot;</c-> <c- e>onclick</c-><c- o>=</c-><c- s>&quot;blueRobot.walk()&quot;</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>&quot;Stop&quot;</c-> <c- e>onclick</c-><c- o>=</c-><c- s>&quot;blueRobot.stop()&quot;</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>&quot;https://johncolburn.deviantart.com/&quot;</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>&quot;license&quot;</c-> <c- e>href</c-><c- o>=</c-><c- s>&quot;https://creativecommons.org/licenses/by-sa/3.0/&quot;</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- kr>const</c-> canvas <c- o>=</c-> document<c- p>.</c->createElement<c- p>(</c-><c- t>&apos;canvas&apos;</c-><c- p>);</c->
  <c- kr>const</c-> context <c- o>=</c-> canvas<c- p>.</c->getContext<c- p>(</c-><c- t>&apos;bitmaprenderer&apos;</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>&apos;image/jpeg&apos;</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>

  <pre><code class='idl'>[<c- g>Exposed</c->=<c- n>Window</c->]
<c- b>interface</c-> <dfn id='imagebitmaprenderingcontext'><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> <a href='#dom-imagebitmaprenderingcontext-canvas' id='the-imagebitmaprenderingcontext-interface:dom-imagebitmaprenderingcontext-canvas'><c- g>canvas</c-></a>;
  <c- b>void</c-> <a href='#dom-imagebitmaprenderingcontext-transferfromimagebitmap' id='the-imagebitmaprenderingcontext-interface:dom-imagebitmaprenderingcontext-transferfromimagebitmap'><c- g>transferFromImageBitmap</c-></a>(<c- n>ImageBitmap</c->? <c- g>bitmap</c->);
};

<c- b>dictionary</c-> <dfn id='imagebitmaprenderingcontextsettings'><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><var>context</var> = <var>canvas</var> . <code id=the-imagebitmaprenderingcontext-interface:dom-canvas-getcontext><a href=#dom-canvas-getcontext>getContext</a></code>('bitmaprenderer' [, { [ <code id=the-imagebitmaprenderingcontext-interface:dom-imagebitmaprenderingcontextsettings-alpha-2><a href=#dom-imagebitmaprenderingcontextsettings-alpha>alpha</a></code>: false ] } ] )<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>

   <dt><var>context</var> . <code id=dom-imagebitmaprenderingcontext-canvas-dev><a href=#dom-imagebitmaprenderingcontext-canvas>canvas</a></code><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>

   <dt><var>context</var> . <code id=dom-imagebitmaprenderingcontext-transferfromimagebitmap-dev><a href=#dom-imagebitmaprenderingcontext-transferfromimagebitmap>transferFromImageBitmap</a></code>(imageBitmap)<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>

   <dt><var>context</var> . <code id=the-imagebitmaprenderingcontext-interface:dom-imagebitmaprenderingcontext-transferfromimagebitmap-2><a href=#dom-imagebitmaprenderingcontext-transferfromimagebitmap>transferFromImageBitmap</a></code>(
   null)<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>

   </dl>

  

  <p>The <dfn id=dom-imagebitmaprenderingcontext-canvas><code>canvas</code></dfn> attribute
  must return the value it was initialized to when the object was created.</p>

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

  <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 source-over composite operation. 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>

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

  <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>.<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.<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 an <a href=#intrinsic-width id=the-imagebitmaprenderingcontext-interface:intrinsic-width>intrinsic 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 an <a href=#intrinsic-height id=the-imagebitmaprenderingcontext-interface:intrinsic-height>intrinsic 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>.<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.</ol>

   <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>.<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>
     </ol>

   </ol>

  <hr>

  <p>The <dfn id=imagebitmaprenderingcontext-creation-algorithm><code>ImageBitmapRenderingContext</code> creation algorithm</dfn>, which is passed a
  <var>target</var> (a <code id=the-imagebitmaprenderingcontext-interface:the-canvas-element-9><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://heycam.github.io/webidl/#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.)<li><p>Let <var>context</var> be a new <code id=the-imagebitmaprenderingcontext-interface:imagebitmaprenderingcontext-8><a href=#imagebitmaprenderingcontext>ImageBitmapRenderingContext</a></code> object.<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>.<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).<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>.<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.

   <li>
    <p>Process each of the members of <var>settings</var> as follows:</p>

    <dl><dt><dfn id=dom-imagebitmaprenderingcontextsettings-alpha><code>alpha</code></dfn><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.</dl>
   <li><p>Return <var>context</var>.</ol>

  <hr>

  <p>The <dfn id=dom-imagebitmaprenderingcontext-transferfromimagebitmap><code>transferFromImageBitmap(<var>imageBitmap</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.<li><p>If <var>imageBitmap</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
   <var>context</var> argument and no <var>bitmap</var> argument, then return.<li><p>If the value of <var>imageBitmap</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://heycam.github.io/webidl/#invalidstateerror data-x-internal=invalidstateerror>"<code>InvalidStateError</code>"</a> <code id=the-imagebitmaprenderingcontext-interface:domexception><a data-x-internal=domexception href=https://heycam.github.io/webidl/#dfn-DOMException>DOMException</a></code>.<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 <var>context</var> argument equal to <var>bitmapContext</var>, and the
   <var>bitmap</var> argument referring to <var>imageBitmap</var>'s underlying <a href=#concept-imagebitmap-bitmap-data id=the-imagebitmaprenderingcontext-interface:concept-imagebitmap-bitmap-data-5>bitmap data</a>.

   <li><p>Set the value of <var>imageBitmap</var>'s <a href=#detached id=the-imagebitmaprenderingcontext-interface:detached-2>[[Detached]]</a> internal slot to
   true.<li><p>Unset <var>imageBitmap's</var> <a href=#concept-imagebitmap-bitmap-data id=the-imagebitmaprenderingcontext-interface:concept-imagebitmap-bitmap-data-6>bitmap
   data</a>.</ol>

  




  <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=status><input onclick=toggleStatus(this) value=⋰ type=button><p class=support><strong>Support:</strong> offscreencanvas<span class="and_chr no"><span>Chrome for Android</span> <span>None</span></span><span class="chrome yes"><span>Chrome</span> <span>69+</span></span><span class="ios_saf no"><span>iOS Safari</span> <span>None</span></span><span class="and_uc no"><span>UC Browser for Android</span> <span>None</span></span><span class="firefox no"><span>Firefox</span> <span>None</span></span><span class="ie no"><span>IE</span> <span>None</span></span><span class="op_mini no"><span>Opera Mini</span> <span>None</span></span><span class="safari no"><span>Safari</span> <span>None</span></span><span class="edge no"><span>Edge</span> <span>None</span></span><span class="samsung no"><span>Samsung Internet</span> <span>None</span></span><span class="opera no"><span>Opera</span> <span>None</span></span><span class="android no"><span>Android Browser</span> <span>None</span></span><p class=caniuse>Source: <a href="https://caniuse.com/#feat=offscreencanvas">caniuse.com</a></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='https://www.khronos.org/registry/webgl/specs/latest/1.0/#WebGLRenderingContext' data-x-internal='webglrenderingcontext' id='the-offscreencanvas-interface:webglrenderingcontext'><c- n>WebGLRenderingContext</c-></a> <c- b>or</c-> <a href='https://www.khronos.org/registry/webgl/specs/latest/2.0/#WebGL2RenderingContext' data-x-internal='webgl2renderingcontext' id='the-offscreencanvas-interface:webgl2renderingcontext'><c- n>WebGL2RenderingContext</c-></a>) <dfn id='offscreenrenderingcontext'><c- g>OffscreenRenderingContext</c-></dfn>;

<c- b>dictionary</c-> <dfn id='imageencodeoptions'><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> = &quot;image/png&quot;;
  <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> = 1.0;
};

<c- b>enum</c-> <dfn id='offscreenrenderingcontextid'><c- g>OffscreenRenderingContextId</c-></dfn> { <c- s>&quot;</c-><a href='#offscreen-context-type-2d' id='the-offscreencanvas-interface:offscreen-context-type-2d'><c- s>2d</c-></a><c- s>&quot;</c->, <c- s>&quot;</c-><a href='#offscreen-context-type-webgl' id='the-offscreencanvas-interface:offscreen-context-type-webgl'><c- s>webgl</c-></a><c- s>&quot;</c->, <c- s>&quot;</c-><a href='#offscreen-context-type-webgl2' id='the-offscreencanvas-interface:offscreen-context-type-webgl2'><c- s>webgl2</c-></a><c- s>&quot;</c-> };

[<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- 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'><c- g>OffscreenCanvas</c-></dfn> : <a href='https://dom.spec.whatwg.org/#interface-eventtarget' data-x-internal='eventtarget' id='the-offscreencanvas-interface:eventtarget'><c- n>EventTarget</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-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>();
  <c- b>Promise</c->&lt;<a href='https://w3c.github.io/FileAPI/#dfn-Blob' data-x-internal='blob' id='the-offscreencanvas-interface: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->);
};</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 that WebGL can
  fire <code>webglcontextlost</code> and <code>webglcontextrestored</code>
  events at it. <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> by
  calling the <dfn id=offscreencontext-commit><code>commit()</code></dfn> method of the
  <code id=the-offscreencanvas-interface:offscreencanvas-7><a href=#offscreencanvas>OffscreenCanvas</a></code> object's rendering context. All rendering context types that
  can be created by an <code id=the-offscreencanvas-interface:offscreencanvas-8><a href=#offscreencanvas>OffscreenCanvas</a></code> object must implement a <code id=the-offscreencanvas-interface:offscreencontext-commit><a href=#offscreencontext-commit>commit()</a></code> method. The exact behavior of the commit
  method (e.g. whether it copies or transfers bitmaps) may vary, as defined by the rendering
  contexts' respective specifications. Only the <a href=#offscreencanvasrenderingcontext2d id=the-offscreencanvas-interface:offscreencanvasrenderingcontext2d-2>2D context for offscreen canvases</a> is defined
  in this specification.</p>

  <dl class=domintro><dt><var>offscreenCanvas</var> = new <code id=dom-offscreencanvas-dev><a href=#dom-offscreencanvas>OffscreenCanvas</a></code>(<var>width</var>,
   <var>height</var>)<dt>
   <dd>
    <p>Returns a new <code id=the-offscreencanvas-interface:offscreencanvas-9><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>
   <dt><var>context</var> = <var>offscreenCanvas</var> . <code id=dom-offscreencanvas-getcontext-dev><a href=#dom-offscreencanvas-getcontext>getContext</a></code>(<var>contextId</var> [,
   <var>options</var> ] )<dd>
    <p>Returns an object that exposes an API for drawing on the <code id=the-offscreencanvas-interface:offscreencanvas-10><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-webgl-2><a href=#offscreen-context-type-webgl>webgl</a></code>", or "<code id=the-offscreencanvas-interface:offscreen-context-type-webgl2-2><a href=#offscreen-context-type-webgl2>webgl2</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. <a href=#refsWEBGL>[WEBGL]</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>
   </dl>

  

  <p>An <code id=the-offscreencanvas-interface:offscreencanvas-11><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-12><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-13><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-14><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-webgl>webgl</dfn>, <dfn id=offscreencanvas-context-webgl2>webgl2</dfn>, or <dfn id=offscreencanvas-context-detached>detached</dfn> by algorithms defined in this
  specification.</p>

  <p>The constructor <dfn id=dom-offscreencanvas><code>OffscreenCanvas(<var>width</var>,
  <var>height</var>)</code></dfn>, when invoked, must create a new <code id=the-offscreencanvas-interface:offscreencanvas-15><a href=#offscreencanvas>OffscreenCanvas</a></code>
  object with its <a href=#offscreencanvas-bitmap id=the-offscreencanvas-interface:offscreencanvas-bitmap-2>bitmap</a> initialized 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>; and its <code id=the-offscreencanvas-interface:dom-offscreencanvas-width-3><a href=#dom-offscreencanvas-width>width</a></code> and <code id=the-offscreencanvas-interface:dom-offscreencanvas-height-3><a href=#dom-offscreencanvas-height>height</a></code> attributes initialized to <var>width</var> and
  <var>height</var> respectively.</p>

  <hr>

  <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://heycam.github.io/webidl/#invalidstateerror data-x-internal=invalidstateerror>"<code>InvalidStateError</code>"</a> <code id=the-offscreencanvas-interface:domexception><a data-x-internal=domexception href=https://heycam.github.io/webidl/#dfn-DOMException>DOMException</a></code>.<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>.<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>.<li><p>Unset <var>value</var>'s <a href=#offscreencanvas-bitmap id=the-offscreencanvas-interface:offscreencanvas-bitmap-4>bitmap</a>.<li><p>Set <var>dataHolder</var>.[[Width]] to <var>width</var> and
   <var>dataHolder</var>.[[Height]] to <var>height</var>.<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.</ol>

  <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]].<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).</ol>

  <hr>

  <p>The <dfn id=dom-offscreencanvas-getcontext><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://heycam.github.io/webidl/#idl-object id=the-offscreencanvas-interface:idl-object data-x-internal=idl-object>object</a>, then set
   <var>options</var> to null.<li><p>Set <var>options</var> to the result of <a href=https://heycam.github.io/webidl/#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.<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>
       <th><a href=#offscreencanvas-context-none id=the-offscreencanvas-interface:offscreencanvas-context-none-2>none</a>
       <th><a href=#offscreencanvas-context-2d id=the-offscreencanvas-interface:offscreencanvas-context-2d>2d</a>
       <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><a href=#offscreencanvas-context-detached id=the-offscreencanvas-interface:offscreencanvas-context-detached-2>detached</a>
     <tbody><tr><th>"<dfn id=offscreen-context-type-2d><code>2d</code></dfn>"
       <td>
        Follow the steps to <a href=#offscreen-2d-context-creation-algorithm id=the-offscreencanvas-interface:offscreen-2d-context-creation-algorithm>create an
        offscreen 2D context</a> defined in the section below, passing it this
        <code id=the-offscreencanvas-interface:offscreencanvas-19><a href=#offscreencanvas>OffscreenCanvas</a></code> object and <var>options</var>, to obtain an
        <code id=the-offscreencanvas-interface:offscreencanvasrenderingcontext2d-3><a href=#offscreencanvasrenderingcontext2d>OffscreenCanvasRenderingContext2D</a></code> object; if this does not throw an exception,
        then set this <code id=the-offscreencanvas-interface:offscreencanvas-20><a href=#offscreencanvas>OffscreenCanvas</a></code> object'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>, and return the new
        <code id=the-offscreencanvas-interface:offscreencanvasrenderingcontext2d-4><a href=#offscreencanvasrenderingcontext2d>OffscreenCanvasRenderingContext2D</a></code> object.
       <td>
        Return the same object as was returned the last time the method was invoked with this same
        first argument.
       <td>
        Return null.
       <td>
        Throw an <a id=the-offscreencanvas-interface:invalidstateerror-2 href=https://heycam.github.io/webidl/#invalidstateerror data-x-internal=invalidstateerror>"<code>InvalidStateError</code>"</a> <code id=the-offscreencanvas-interface:domexception-2><a data-x-internal=domexception href=https://heycam.github.io/webidl/#dfn-DOMException>DOMException</a></code>.
      <tr><th>"<dfn id=offscreen-context-type-webgl><code>webgl</code></dfn>" or "<dfn id=offscreen-context-type-webgl2><code>webgl2</code></dfn>"
       <td>
        Follow the instructions given in the WebGL specifications' <i>Context Creation</i> sections
        to obtain either 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>, <code id=the-offscreencanvas-interface:webgl2renderingcontext-2><a data-x-internal=webgl2renderingcontext href=https://www.khronos.org/registry/webgl/specs/latest/2.0/#WebGL2RenderingContext>WebGL2RenderingContext</a></code>,
        or null; if the returned value is null, then return null; otherwise, set this
        <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-5>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>, and return the
        <code id=the-offscreencanvas-interface:webglrenderingcontext-3><a data-x-internal=webglrenderingcontext href=https://www.khronos.org/registry/webgl/specs/latest/1.0/#WebGLRenderingContext>WebGLRenderingContext</a></code> or <code id=the-offscreencanvas-interface:webgl2renderingcontext-3><a data-x-internal=webgl2renderingcontext href=https://www.khronos.org/registry/webgl/specs/latest/2.0/#WebGL2RenderingContext>WebGL2RenderingContext</a></code> object. <a href=#refsWEBGL>[WEBGL]</a>
       <td>
        Return null.
       <td>
        Return the same value as was returned the last time the method was invoked with this same
        first argument.
       <td>
        Throw an <a id=the-offscreencanvas-interface:invalidstateerror-3 href=https://heycam.github.io/webidl/#invalidstateerror data-x-internal=invalidstateerror>"<code>InvalidStateError</code>"</a> <code id=the-offscreencanvas-interface:domexception-3><a data-x-internal=domexception href=https://heycam.github.io/webidl/#dfn-DOMException>DOMException</a></code>.
    </table>
   </ol>

  <hr>

  

  <dl class=domintro><dt><var>offscreenCanvas</var> . <code id=dom-offscreencanvas-width-dev><a href=#dom-offscreencanvas-width>width</a></code> [
   = <var>value</var> ]<dt><var>offscreenCanvas</var> . <code id=dom-offscreencanvas-height-dev><a href=#dom-offscreencanvas-height>height</a></code> [
   = <var>value</var> ]<dd>
    <p>These attributes return the dimensions of 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-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>
   </dl>

  

  <p>If either the <dfn id=dom-offscreencanvas-width><code>width</code></dfn> or <dfn id=dom-offscreencanvas-height><code>height</code></dfn> attributes of an
  <code id=the-offscreencanvas-interface:offscreencanvas-23><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-24><a href=#offscreencanvas>OffscreenCanvas</a></code> object's <a href=#offscreencanvas-context-mode id=the-offscreencanvas-interface:offscreencanvas-context-mode-6>context
  mode</a> is <a href=#offscreencanvas-context-2d id=the-offscreencanvas-interface:offscreencanvas-context-2d-3>2d</a>, then replace the
  <code id=the-offscreencanvas-interface:offscreencanvas-25><a href=#offscreencanvas>OffscreenCanvas</a></code> object's <a href=#offscreencanvas-bitmap id=the-offscreencanvas-interface:offscreencanvas-bitmap-8>bitmap</a> with a
  new <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> bitmap and <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>. The new bitmap's dimensions are equal 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>

  <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 class=note>If an <code id=the-offscreencanvas-interface:offscreencanvas-26><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/css2/conform.html#intrinsic id=the-offscreencanvas-interface:intrinsic-dimensions data-x-internal=intrinsic-dimensions>intrinsic size</a> will only be updated via the <code id=the-offscreencanvas-interface:offscreencontext-commit-2><a href=#offscreencontext-commit>commit()</a></code> method of the <code id=the-offscreencanvas-interface:offscreencanvas-27><a href=#offscreencanvas>OffscreenCanvas</a></code>
  object's rendering context.</p>

  <dl class=domintro><dt><var>promise</var> = <var>offscreenCanvas</var> . <code id=dom-offscreencanvas-converttoblob-dev><a href=#dom-offscreencanvas-converttoblob>convertToBlob</a></code>( [<var>options</var>] )<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-28><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>
   <dt><var>canvas</var> . <code id=dom-offscreencanvas-transfertoimagebitmap-dev><a href=#dom-offscreencanvas-transfertoimagebitmap>transferToImageBitmap</a></code>()<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-29><a href=#offscreencanvas>OffscreenCanvas</a></code> object. The image in the <code id=the-offscreencanvas-interface:offscreencanvas-30><a href=#offscreencanvas>OffscreenCanvas</a></code> object is
    replaced with a new blank image.</p>
   </dl>

  

  <p>The <dfn id=dom-offscreencanvas-converttoblob><code>convertToBlob(<var>options</var>)</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-31><a href=#offscreencanvas>OffscreenCanvas</a></code> object's <a href=#detached id=the-offscreencanvas-interface:detached>[[Detached]]</a>
   internal slot is set to true, then return a promise rejected with an
   <a id=the-offscreencanvas-interface:invalidstateerror-4 href=https://heycam.github.io/webidl/#invalidstateerror data-x-internal=invalidstateerror>"<code>InvalidStateError</code>"</a> <code id=the-offscreencanvas-interface:domexception-4><a data-x-internal=domexception href=https://heycam.github.io/webidl/#dfn-DOMException>DOMException</a></code>.<li><p>If this <code id=the-offscreencanvas-interface:offscreencanvas-32><a href=#offscreencanvas>OffscreenCanvas</a></code> object's <a href=#offscreencanvas-context-mode id=the-offscreencanvas-interface:offscreencanvas-context-mode-7>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=#offscreencontext2d-bitmap id=the-offscreencanvas-interface:offscreencontext2d-bitmap>bitmap</a>'s <a href=#offscreencontext2d-origin-clean id=the-offscreencanvas-interface:offscreencontext2d-origin-clean>origin-clean</a> flag is set to false, then return a
   promise rejected with a <a id=the-offscreencanvas-interface:securityerror href=https://heycam.github.io/webidl/#securityerror data-x-internal=securityerror>"<code>SecurityError</code>"</a> <code id=the-offscreencanvas-interface:domexception-5><a data-x-internal=domexception href=https://heycam.github.io/webidl/#dfn-DOMException>DOMException</a></code>.</p>

   <li><p>If this <code id=the-offscreencanvas-interface:offscreencanvas-33><a href=#offscreencanvas>OffscreenCanvas</a></code> object'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 promise rejected with an
   <a id=the-offscreencanvas-interface:indexsizeerror href=https://heycam.github.io/webidl/#indexsizeerror data-x-internal=indexsizeerror>"<code>IndexSizeError</code>"</a> <code id=the-offscreencanvas-interface:domexception-6><a data-x-internal=domexception href=https://heycam.github.io/webidl/#dfn-DOMException>DOMException</a></code>.<li><p>Let <var>bitmap</var> be a copy of this <code id=the-offscreencanvas-interface:offscreencanvas-34><a href=#offscreencanvas>OffscreenCanvas</a></code> object's <a href=#offscreencanvas-bitmap id=the-offscreencanvas-interface:offscreencanvas-bitmap-10>bitmap</a>.<li><p>Let <var>result</var> be a new promise object.<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>.<li>
      <p><a href=#queue-a-task id=the-offscreencanvas-interface:queue-a-task>Queue a task</a> 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://heycam.github.io/webidl/#encodingerror data-x-internal=encodingerror>"<code>EncodingError</code>"</a> <code id=the-offscreencanvas-interface:domexception-7><a data-x-internal=domexception href=https://heycam.github.io/webidl/#dfn-DOMException>DOMException</a></code>.<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
       the <a href=#concept-relevant-realm id=the-offscreencanvas-interface:concept-relevant-realm>relevant Realm</a> of this
       <code id=the-offscreencanvas-interface:offscreencanvas-35><a href=#offscreencanvas>OffscreenCanvas</a></code> object, representing <var>file</var>. <a href=#refsFILEAPI>[FILEAPI]</a></ol>

      <p>The <a href=#task-source id=the-offscreencanvas-interface:task-source>task source</a> for this task is the <a href=#canvas-blob-serialisation-task-source id=the-offscreencanvas-interface:canvas-blob-serialisation-task-source>canvas blob serialization task
      source</a>.</p>
     </ol>
   <li><p>Return <var>result</var>.</ol>

  <p>The <dfn id=dom-offscreencanvas-transfertoimagebitmap><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-36><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-5 href=https://heycam.github.io/webidl/#invalidstateerror data-x-internal=invalidstateerror>"<code>InvalidStateError</code>"</a>
   <code id=the-offscreencanvas-interface:domexception-8><a data-x-internal=domexception href=https://heycam.github.io/webidl/#dfn-DOMException>DOMException</a></code>.<li><p>If this <code id=the-offscreencanvas-interface:offscreencanvas-37><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 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-6 href=https://heycam.github.io/webidl/#invalidstateerror data-x-internal=invalidstateerror>"<code>InvalidStateError</code>"</a> <code id=the-offscreencanvas-interface:domexception-9><a data-x-internal=domexception href=https://heycam.github.io/webidl/#dfn-DOMException>DOMException</a></code>.<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-38><a href=#offscreencanvas>OffscreenCanvas</a></code> object's <a href=#offscreencanvas-bitmap id=the-offscreencanvas-interface:offscreencanvas-bitmap-11>bitmap</a>.<li><p>Set this <code id=the-offscreencanvas-interface:offscreencanvas-39><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 as the previous bitmap, and with its pixels initialized to <a id=the-offscreencanvas-interface:transparent-black-6 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=#offscreencontext2d-alpha id=the-offscreencanvas-interface:offscreencontext2d-alpha>alpha</a> flag is set to false.<li><p>Return <var>image</var>.</ol>
  

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

  <pre><code class='idl'>[<c- g>Exposed</c->=(<c- n>Window</c->,<c- n>Worker</c->)]
<c- b>interface</c-> <dfn id='offscreencanvasrenderingcontext2d'><c- g>OffscreenCanvasRenderingContext2D</c-></dfn> {
  <c- b>void</c-> <a href='#offscreencontext2d-commit' id='the-offscreen-2d-rendering-context:offscreencontext2d-commit'><c- g>commit</c-></a>();
  <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='#canvasstate' id='the-offscreen-2d-rendering-context:canvasstate'><c- n>CanvasState</c-></a>;
<a href='#offscreencanvasrenderingcontext2d' id='the-offscreen-2d-rendering-context:offscreencanvasrenderingcontext2d-2'><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-3'><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-4'><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-5'><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-6'><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-7'><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-8'><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-9'><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-10'><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-11'><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-12'><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-13'><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-14'><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-15'><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-16><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;<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;<li><p>it has a <code id=the-offscreen-2d-rendering-context:offscreencontext2d-commit-2><a href=#offscreencontext2d-commit>commit()</a></code> method for pushing the
   rendered image to the context's <code id=the-offscreen-2d-rendering-context:offscreencanvas-4><a href=#offscreencanvas>OffscreenCanvas</a></code> object's <a href=#offscreencanvas-placeholder id=the-offscreen-2d-rendering-context:offscreencanvas-placeholder>placeholder <code>canvas</code> element</a>.</ul>

  <p>An <code id=the-offscreen-2d-rendering-context:offscreencanvasrenderingcontext2d-17><a href=#offscreencanvasrenderingcontext2d>OffscreenCanvasRenderingContext2D</a></code> object has a <dfn id=offscreencontext2d-bitmap>bitmap</dfn> that is initialized when the object is
  created.</p>

  <p>The <a href=#offscreencontext2d-bitmap id=the-offscreen-2d-rendering-context:offscreencontext2d-bitmap>bitmap</a> has an <dfn id=offscreencontext2d-origin-clean>origin-clean</dfn> flag, which can be set to true or
  false. Initially, when one of these bitmaps is created, its <a href=#offscreencontext2d-origin-clean id=the-offscreen-2d-rendering-context:offscreencontext2d-origin-clean>origin-clean</a> flag must be set to true.</p>

  <p>An <code id=the-offscreen-2d-rendering-context:offscreencanvasrenderingcontext2d-18><a href=#offscreencanvasrenderingcontext2d>OffscreenCanvasRenderingContext2D</a></code> object also has an <dfn id=offscreencontext2d-alpha>alpha</dfn> flag, which can be set to true or false. Initially,
  when the context is created, its alpha flag must be set to true. When an
  <code id=the-offscreen-2d-rendering-context:offscreencanvasrenderingcontext2d-19><a href=#offscreencanvasrenderingcontext2d>OffscreenCanvasRenderingContext2D</a></code> object has its <a href=#offscreencontext2d-alpha id=the-offscreen-2d-rendering-context:offscreencontext2d-alpha>alpha</a> flag set to false, then its alpha channel 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>An <code id=the-offscreen-2d-rendering-context:offscreencanvasrenderingcontext2d-20><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-5><a href=#offscreencanvas>OffscreenCanvas</a></code> object
  from which the <code id=the-offscreen-2d-rendering-context:offscreencanvasrenderingcontext2d-21><a href=#offscreencanvasrenderingcontext2d>OffscreenCanvasRenderingContext2D</a></code> object was created.

  <dl class=domintro><dt><var>offscreenCanvasRenderingContext2D</var> . <code id=offscreencontext2d-commit-dev><a href=#offscreencontext2d-commit>commit</a></code>()<dd>
    <p>Copies the rendering context's <a href=#offscreencontext2d-bitmap id=the-offscreen-2d-rendering-context:offscreencontext2d-bitmap-2>bitmap</a> to
    the bitmap of the <a href=#offscreencanvas-placeholder id=the-offscreen-2d-rendering-context:offscreencanvas-placeholder-2>placeholder <code>canvas</code>
    element</a> of the <a href=#associated-offscreencanvas-object id=the-offscreen-2d-rendering-context:associated-offscreencanvas-object>associated <code>OffscreenCanvas</code> object</a>. The copy
    operation is synchronous. Calling this method is not needed for the transfer, since it happens
    automatically during the <a href=#event-loop id=the-offscreen-2d-rendering-context:event-loop>event loop</a> execution.</p>
   <dt><var>offscreenCanvas</var> = <var>offscreenCanvasRenderingContext2D</var> . <code id=offscreencontext2d-canvas-dev><a href=#offscreencontext2d-canvas>canvas</a></code><dd>
    <p>Returns the <a href=#associated-offscreencanvas-object id=the-offscreen-2d-rendering-context:associated-offscreencanvas-object-2>associated <code>OffscreenCanvas</code> object</a>.</p>
   </dl>

  

  <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-6><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.<li><p>Let <var>settings</var> be the result of <a href=https://heycam.github.io/webidl/#es-type-mapping id=the-offscreen-2d-rendering-context:concept-idl-convert data-x-internal=concept-idl-convert>converting</a> <var>options</var> to the dictionary type
   <code id=the-offscreen-2d-rendering-context:canvasrenderingcontext2dsettings><a href=#canvasrenderingcontext2dsettings>CanvasRenderingContext2DSettings</a></code>. (This can throw an exception.).<li><p>Let <var>context</var> be a new <code id=the-offscreen-2d-rendering-context:offscreencanvasrenderingcontext2d-22><a href=#offscreencanvasrenderingcontext2d>OffscreenCanvasRenderingContext2D</a></code>
   object.<li><p>Set <var>context</var>'s <a href=#associated-offscreencanvas-object id=the-offscreen-2d-rendering-context:associated-offscreencanvas-object-3>associated <code>OffscreenCanvas</code> object</a> to
   <var>target</var>.<li><p>Process each of the members of <var>settings</var> as follows:</p>
    <dl><dt><code id=the-offscreen-2d-rendering-context:dom-canvasrenderingcontext2dsettings-alpha><a href=#dom-canvasrenderingcontext2dsettings-alpha>alpha</a></code><dd>If false, set <var>context</var>'s <a href=#offscreencontext2d-alpha id=the-offscreen-2d-rendering-context:offscreencontext2d-alpha-2>alpha</a>
     flag to false.</dl>
   <li><p>Set <var>context</var>'s <a href=#offscreencontext2d-bitmap id=the-offscreen-2d-rendering-context:offscreencontext2d-bitmap-3>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).<li><p>If <var>context</var>'s <a href=#offscreencontext2d-alpha id=the-offscreen-2d-rendering-context:offscreencontext2d-alpha-3>alpha</a> flag is set
   to true, initialize all the pixels of <var>context</var>'s <a href=#offscreencontext2d-bitmap id=the-offscreen-2d-rendering-context:offscreencontext2d-bitmap-4>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>.<li><p>Return <var>context</var>.</ol>

  <p>The <dfn id=offscreencontext2d-commit><code>commit()</code></dfn> method, when invoked,
  must run the following steps:</p>

  <ol><li><p>If this <code id=the-offscreen-2d-rendering-context:offscreencanvasrenderingcontext2d-23><a href=#offscreencanvasrenderingcontext2d>OffscreenCanvasRenderingContext2D</a></code>'s <a href=#associated-offscreencanvas-object id=the-offscreen-2d-rendering-context:associated-offscreencanvas-object-4>associated
    <code>OffscreenCanvas</code> object</a> does not have a <a href=#offscreencanvas-placeholder id=the-offscreen-2d-rendering-context:offscreencanvas-placeholder-3>placeholder <code>canvas</code> element</a>, then
    return.<li><p>Let <var>image</var> be a copy of this <code id=the-offscreen-2d-rendering-context:offscreencanvasrenderingcontext2d-24><a href=#offscreencanvasrenderingcontext2d>OffscreenCanvasRenderingContext2D</a></code>'s
    <a href=#offscreencontext2d-bitmap id=the-offscreen-2d-rendering-context:offscreencontext2d-bitmap-5>bitmap</a>, including the value of its <a href=#offscreencontext2d-origin-clean id=the-offscreen-2d-rendering-context:offscreencontext2d-origin-clean-2>origin-clean</a> flag.<li>
     <p><a href=#queue-a-task id=the-offscreen-2d-rendering-context:queue-a-task>Queue a task</a> in the <a href=#offscreencanvas-placeholder id=the-offscreen-2d-rendering-context:offscreencanvas-placeholder-4>placeholder <code>canvas</code> element</a>'s
     <a href=#relevant-settings-object id=the-offscreen-2d-rendering-context:relevant-settings-object>relevant settings object</a>'s <a href=#responsible-event-loop id=the-offscreen-2d-rendering-context:responsible-event-loop>responsible event loop</a> (which will be a
     <a href=#browsing-context id=the-offscreen-2d-rendering-context:browsing-context>browsing context</a> <a href=#event-loop id=the-offscreen-2d-rendering-context:event-loop-2>event loop</a>) to set the <a href=#offscreencanvas-placeholder id=the-offscreen-2d-rendering-context:offscreencanvas-placeholder-5>placeholder <code>canvas</code> element</a>'s
     <a href=#output-bitmap id=the-offscreen-2d-rendering-context:output-bitmap>output bitmap</a> to be a reference to <var>image</var>.</p>

     <p class=note>If <var>image</var> has different dimensions than the bitmap previously
     referenced as the <a href=#offscreencanvas-placeholder id=the-offscreen-2d-rendering-context:offscreencanvas-placeholder-6>placeholder <code>canvas</code>
     element</a>'s <a href=#output-bitmap id=the-offscreen-2d-rendering-context:output-bitmap-2>output bitmap</a>, then this task will result in a change in
     the <a href=#offscreencanvas-placeholder id=the-offscreen-2d-rendering-context:offscreencanvas-placeholder-7>placeholder <code>canvas</code>
     element</a>'s <a href=https://drafts.csswg.org/css2/conform.html#intrinsic id=the-offscreen-2d-rendering-context:intrinsic-dimensions data-x-internal=intrinsic-dimensions>intrinsic size</a>, which can affect
     document layout.</p>
    </ol>

  <p class=note>Implementations are encouraged to short-circuit the graphics update steps of
  the <a href=#browsing-context id=the-offscreen-2d-rendering-context:browsing-context-2>browsing context</a> <a href=#event-loop id=the-offscreen-2d-rendering-context:event-loop-3>event loop</a> for the purposes of updating the
  contents of a <a href=#offscreencanvas-placeholder id=the-offscreen-2d-rendering-context:offscreencanvas-placeholder-8>placeholder <code>canvas</code>
  element</a> to the display. This could mean, for example, that the <code id=the-offscreen-2d-rendering-context:offscreencontext2d-commit-3><a href=#offscreencontext2d-commit>commit()</a></code> method can copy the bitmap contents 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-9>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:offscreencontext2d-commit-4><a href=#offscreencontext2d-commit>commit()</a></code> method is invoked from a worker
  and the <a href=#event-loop id=the-offscreen-2d-rendering-context:event-loop-4>event loop</a> of the <a href=#offscreencanvas-placeholder id=the-offscreen-2d-rendering-context:offscreencanvas-placeholder-10>placeholder <code>canvas</code> element</a>'s
  <a href=#browsing-context id=the-offscreen-2d-rendering-context:browsing-context-3>browsing context</a> is busy. However, such shortcuts can not 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-11>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>

  <p>The <dfn id=offscreencontext2d-canvas><code>canvas</code></dfn> attribute, on getting,
  must return this <code id=the-offscreen-2d-rendering-context:offscreencanvasrenderingcontext2d-25><a href=#offscreencanvasrenderingcontext2d>OffscreenCanvasRenderingContext2D</a></code>'s <a href=#associated-offscreencanvas-object id=the-offscreen-2d-rendering-context:associated-offscreencanvas-object-5>associated
  <code>OffscreenCanvas</code> object</a>.

  </p>

  

  <h5 id=colour-spaces-and-colour-correction><span class=secno>4.12.5.4</span> Color spaces and color correction<a href=#colour-spaces-and-colour-correction class=self-link></a></h5>

  <p>The <code id=colour-spaces-and-colour-correction:the-canvas-element><a href=#the-canvas-element>canvas</a></code> APIs must perform color correction at only two points: when rendering
  images with their own gamma correction and color space information onto a bitmap, to convert the
  image to the color space used by the bitmaps (e.g. using the 2D Context's <code id=colour-spaces-and-colour-correction:dom-context-2d-drawimage><a href=#dom-context-2d-drawimage>drawImage()</a></code> method with an
  <code id=colour-spaces-and-colour-correction:htmlorsvgimageelement><a href=#htmlorsvgimageelement>HTMLOrSVGImageElement</a></code> object), and when rendering the actual canvas bitmap to the
  output device.</p>

  <p class=note>Thus, in the 2D context, colors used to draw shapes onto the canvas will exactly
  match colors obtained through the <code id=colour-spaces-and-colour-correction:dom-context-2d-getimagedata><a href=#dom-context-2d-getimagedata>getImageData()</a></code> method.</p>

  <p>The <code id=colour-spaces-and-colour-correction:dom-canvas-todataurl><a href=#dom-canvas-todataurl>toDataURL()</a></code> method, when invoked, must not
  include color space information in the resources they return. Where the output format allows it,
  the color of pixels in resources created by <code id=colour-spaces-and-colour-correction:dom-canvas-todataurl-2><a href=#dom-canvas-todataurl>toDataURL()</a></code>
  must match those returned by the <code id=colour-spaces-and-colour-correction:dom-context-2d-getimagedata-2><a href=#dom-context-2d-getimagedata>getImageData()</a></code>
  method.</p>

  <p>In user agents that support CSS, the color space used by a <code id=colour-spaces-and-colour-correction:the-canvas-element-2><a href=#the-canvas-element>canvas</a></code> element must
  match the color space used for processing any colors for that element in CSS.</p>

  <p>The gamma correction and color space information of images must be handled in such a way that
  an image rendered directly using an <code id=colour-spaces-and-colour-correction:the-img-element><a href=#the-img-element>img</a></code> element would use the same colors as one
  painted on a <code id=colour-spaces-and-colour-correction:the-canvas-element-3><a href=#the-canvas-element>canvas</a></code> element that is then itself rendered. Furthermore, the rendering
  of images that have no color correction information (such as those returned by the <code id=colour-spaces-and-colour-correction:dom-canvas-todataurl-3><a href=#dom-canvas-todataurl>toDataURL()</a></code> method) must be rendered with no color
  correction.</p>

  <p class=note>Thus, in the 2D context, calling the <code id=colour-spaces-and-colour-correction:dom-context-2d-drawimage-2><a href=#dom-context-2d-drawimage>drawImage()</a></code> method to render the output of the <code id=colour-spaces-and-colour-correction:dom-canvas-todataurl-4><a href=#dom-canvas-todataurl>toDataURL()</a></code> method to the canvas, given the appropriate
  dimensions, has no visible effect.</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>

  

  <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 an optional <var>type</var> and
  <var>quality</var>, it must create an image file in the format given by <var>type</var>, or if
  <var>type</var> was not supplied, in the PNG format. 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 channel, 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 source-over operator.</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>") and <var>quality</var> is given, then, if <a href=https://tc39.github.io/ecma262/#sec-ecmascript-data-types-and-values id=serialising-bitmaps-to-a-file:js-type data-x-internal=js-type>Type</a>(<var>quality</var>) is Number, and <var>quality</var> is in the range
  0.0 to 1.0 inclusive, the user agent must treat <var>quality</var> as the desired quality level.
  If <a href=https://tc39.github.io/ecma262/#sec-ecmascript-data-types-and-values id=serialising-bitmaps-to-a-file:js-type-2 data-x-internal=js-type>Type</a>(<var>quality</var>) is not Number, or if <var>quality</var>
  is outside that range, 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>

  


  

  <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 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://heycam.github.io/webidl/#securityerror data-x-internal=securityerror>"<code>SecurityError</code>"</a> <code id=security-with-canvas-elements:domexception><a data-x-internal=domexception href=https://heycam.github.io/webidl/#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 <code id=security-with-canvas-elements:the-canvas-element-3><a href=#the-canvas-element>canvas</a></code> element'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-4><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-5><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-6><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>

  

  <h3 id=custom-elements><span class=secno>4.13</span> Custom elements<a href=#custom-elements class=self-link></a></h3><div class=status><input onclick=toggleStatus(this) value=⋰ type=button><p class=support><strong>Support:</strong> custom-elementsv1<span class="and_chr yes"><span>Chrome for Android</span> <span>67+</span></span><span class="chrome yes"><span>Chrome</span> <span>67+</span></span><span class="ios_saf partial"><span>iOS Safari (limited)</span> <span>10.3+</span></span><span class="and_uc yes"><span>UC Browser for Android</span> <span>11.8+</span></span><span class="firefox yes"><span>Firefox</span> <span>63+</span></span><span class="ie no"><span>IE</span> <span>None</span></span><span class="op_mini no"><span>Opera Mini</span> <span>None</span></span><span class="safari partial"><span>Safari (limited)</span> <span>10.1+</span></span><span class="samsung yes"><span>Samsung Internet</span> <span>6.2+</span></span><span class="opera partial"><span>Opera (limited)</span> <span>41+</span></span><span class="android yes"><span>Android Browser</span> <span>67+</span></span><p class=caniuse>Source: <a href="https://caniuse.com/#feat=custom-elementsv1">caniuse.com</a></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>&quot;nl&quot;</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- kr>class</c-> FlagIcon <c- kr>extends</c-> HTMLElement <c- p>{</c->
  constructor<c- p>()</c-> <c- p>{</c->
    <c- kr>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- kr>static</c-> get observedAttributes<c- p>()</c-> <c- p>{</c-> <c- k>return</c-> <c- p>[</c-><c- u>&quot;country&quot;</c-><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 &quot;country&quot; 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>&quot;country&quot;</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&apos;ll probably want to</c->
    <c- c1>// check this.ownerDocument.defaultView to see if we&apos;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>&quot;flag-icon&quot;</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- kr>const</c-> flagIcon <c- o>=</c-> document<c- p>.</c->createElement<c- p>(</c-><c- u>&quot;flag-icon&quot;</c-><c- p>)</c->
flagIcon<c- p>.</c->country <c- o>=</c-> <c- u>&quot;jp&quot;</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- kr>const</c-> flagIcon <c- o>=</c-> <c- k>new</c-> FlagIcon<c- p>()</c->
flagIcon<c- p>.</c->country <c- o>=</c-> <c- u>&quot;jp&quot;</c->
document<c- p>.</c->body<c- p>.</c->appendChild<c- p>(</c->flagIcon<c- p>)</c-></code></pre>

  <h5 id=custom-elements-customized-builtin-example><span class=secno>4.13.1.2</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- kr>class</c-> PlasticButton <c- kr>extends</c-> HTMLButtonElement <c- p>{</c->
  constructor<c- p>()</c-> <c- p>{</c->
    <c- kr>super</c-><c- p>();</c->

    <c- k>this</c-><c- p>.</c->addEventListener<c- p>(</c-><c- u>&quot;click&quot;</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>extends</code>
  option:</p>

  <pre><code class='js'>customElements<c- p>.</c->define<c- p>(</c-><c- u>&quot;plastic-button&quot;</c-><c- p>,</c-> PlasticButton<c- p>,</c-> <c- p>{</c-> <c- kr>extends</c-><c- o>:</c-> <c- u>&quot;button&quot;</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>&quot;plastic-button&quot;</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>Click
  me?&lt;/plastic-button></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- kr>const</c-> plasticButton <c- o>=</c-> document<c- p>.</c->createElement<c- p>(</c-><c- u>&quot;button&quot;</c-><c- p>,</c-> <c- p>{</c-> is<c- o>:</c-> <c- u>&quot;plastic-button&quot;</c-> <c- p>});</c->
plasticButton<c- p>.</c->textContent <c- o>=</c-> <c- u>&quot;Click me!&quot;</c-><c- p>;</c-></code></pre>

  <p>And as before, the constructor will also work:</p>

  <pre><code class='js'><c- kr>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 &quot;button&quot;</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>&quot;is&quot;</c-><c- p>));</c->
console<c- p>.</c->log<c- p>(</c->plasticButton<c- p>.</c->outerHTML<c- p>);</c-> <c- c1>// will output &apos;&lt;button is=&quot;plastic-button&quot;&gt;&lt;/button&gt;&apos;</c-></code></pre>

  <p>Regardless of how it is created, all the 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.3</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=#interactive-content-2 id=custom-elements-autonomous-drawbacks:interactive-content-2>interactive content</a>, thus making it
   <a href=#focusable-area id=custom-elements-autonomous-drawbacks:focusable-area>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.<li><p>The addition of various ARIA attributes helps convey semantics to accessibility
   technology. For example, setting the <code id=custom-elements-autonomous-drawbacks:attr-aria-role><a href=#attr-aria-role>role</a></code> attribute 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/aria/aria.html#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/aria.html#aria-label>aria-label</a></code> attribute is necessary to give the button an
   <a href=https://w3c.github.io/aria/aria/aria.html#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 <code id=custom-elements-autonomous-drawbacks:attr-aria-disabled><a data-x-internal=attr-aria-disabled href=https://w3c.github.io/aria/aria/aria.html#aria-disabled>aria-disabled</a></code> to "<code>true</code>" when the button
   is logically disabled conveys to accessibility technology the button's disabled state.<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.<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>.</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><code class='js'><c- kr>class</c-> TacoButton <c- kr>extends</c-> HTMLElement <c- p>{</c->
  <c- kr>static</c-> get observedAttributes<c- p>()</c-> <c- p>{</c-> <c- k>return</c-> <c- p>[</c-><c- u>&quot;disabled&quot;</c-><c- p>];</c-> <c- p>}</c->

  constructor<c- p>()</c-> <c- p>{</c->
    <c- kr>super</c-><c- p>();</c->

    <c- k>this</c-><c- p>.</c->addEventListener<c- p>(</c-><c- u>&quot;keydown&quot;</c-><c- p>,</c-> e <c- p>=&gt;</c-> <c- p>{</c->
      <c- k>if</c-> <c- p>(</c->e<c- p>.</c->keyCode <c- o>===</c-> <c- mi>32</c-> <c- o>||</c-> e<c- p>.</c->keyCode <c- o>===</c-> <c- mi>13</c-><c- p>)</c-> <c- p>{</c->
        <c- k>this</c-><c- p>.</c->dispatchEvent<c- p>(</c-><c- k>new</c-> MouseEvent<c- p>(</c-><c- u>&quot;click&quot;</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>&quot;click&quot;</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->stopPropagation<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->setAttribute<c- p>(</c-><c- u>&quot;aria-label&quot;</c-><c- p>,</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>&quot;role&quot;</c-><c- p>,</c-> <c- u>&quot;button&quot;</c-><c- p>);</c->
    <c- k>this</c-><c- p>.</c->setAttribute<c- p>(</c-><c- u>&quot;tabindex&quot;</c-><c- p>,</c-> <c- u>&quot;0&quot;</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>&quot;disabled&quot;</c-><c- p>);</c->
  <c- p>}</c->

  set disabled<c- p>(</c->v<c- p>)</c-> <c- p>{</c->
    <c- k>if</c-> <c- p>(</c->v<c- p>)</c-> <c- p>{</c->
      <c- k>this</c-><c- p>.</c->setAttribute<c- p>(</c-><c- u>&quot;disabled&quot;</c-><c- p>,</c-> <c- u>&quot;&quot;</c-><c- p>);</c->
    <c- p>}</c-> <c- k>else</c-> <c- p>{</c->
      <c- k>this</c-><c- p>.</c->removeAttribute<c- p>(</c-><c- u>&quot;disabled&quot;</c-><c- p>);</c->
    <c- p>}</c->
  <c- p>}</c->

  attributeChangedCallback<c- p>()</c-> <c- p>{</c->
    <c- c1>// only is called for the disabled attribute 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>&quot;tabindex&quot;</c-><c- p>);</c->
      <c- k>this</c-><c- p>.</c->setAttribute<c- p>(</c-><c- u>&quot;aria-disabled&quot;</c-><c- p>,</c-> <c- u>&quot;true&quot;</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>&quot;tabindex&quot;</c-><c- p>,</c-> <c- u>&quot;0&quot;</c-><c- p>);</c->
      <c- k>this</c-><c- p>.</c->setAttribute<c- p>(</c-><c- u>&quot;aria-disabled&quot;</c-><c- p>,</c-> <c- u>&quot;false&quot;</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> and
  <code id=custom-elements-autonomous-drawbacks:attr-aria-*><a href=#attr-aria-*>aria-*</a></code> attributes of its own volition. This is because as of now
  there is no way to specify default accessibility semantics or focus behavior for custom elements,
  forcing the use of these attributes to do so (even though they are 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><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.4</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>&quot;en&quot;</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>&quot;Kelvin&quot;</c-><c- p>&gt;</c->
  <c- p>&lt;</c-><c- f>img</c-> <c- e>src</c-><c- o>=</c-><c- s>&quot;images/tree.jpg&quot;</c-> <c- e>alt</c-><c- o>=</c-><c- s>&quot;A beautiful tree towering over an empty savannah&quot;</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>&quot;js/elements/img-viewer.js&quot;</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></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>&quot;en&quot;</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>&quot;use strict&quot;</c-><c- p>;</c->

  <c- kr>const</c-> inDocument <c- o>=</c-> document<c- p>.</c->querySelector<c- p>(</c-><c- u>&quot;example-element&quot;</c-><c- p>);</c->
  <c- kr>const</c-> outOfDocument <c- o>=</c-> document<c- p>.</c->createElement<c- p>(</c-><c- u>&quot;example-element&quot;</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- kr>class</c-> ExampleElement <c- kr>extends</c-> HTMLElement <c- p>{}</c->
  customElements<c- p>.</c->define<c- p>(</c-><c- u>&quot;example-element&quot;</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&apos;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>

  <h4 id=custom-element-conformance><span class=secno>4.13.2</span> Requirements for custom element constructors<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.<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>).<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.<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.<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.<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.<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>.</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>

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

  <ol><li><p>An <dfn id=autonomous-custom-element data-export="">autonomous custom element</dfn>, which is defined with no <code>extends</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>.<li><p>A <dfn id=customized-built-in-element data-export="">customized built-in element</dfn>, which is defined with an <code>extends</code> option. These types of custom elements have a local name equal to the
   value passed in their <code>extends</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 id=attr-is><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>.</ol>

  <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>:<dd><a href=#flow-content-2 id=custom-elements-core-concepts:flow-content-2>Flow content</a>.<dd><a href=#phrasing-content-2 id=custom-elements-core-concepts:phrasing-content-2>Phrasing content</a>.<dd><a href=#palpable-content-2 id=custom-elements-core-concepts:palpable-content-2>Palpable content</a>.<dt><a href=#concept-element-contexts id=custom-elements-core-concepts:concept-element-contexts>Contexts in which this element can be used</a>:<dd>Where <a href=#phrasing-content-2 id=custom-elements-core-concepts:phrasing-content-2-2>phrasing content</a> is expected.<dt><a href=#concept-element-content-model id=custom-elements-core-concepts:concept-element-content-model>Content model</a>:<dd><a href=#transparent id=custom-elements-core-concepts:transparent>Transparent</a>.<dt><a href=#concept-element-attributes id=custom-elements-core-concepts:concept-element-attributes>Content attributes</a>:<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>Any other attribute that has no namespace (see prose).<dt><a href=#concept-element-dom id=custom-elements-core-concepts:concept-element-dom>DOM interface</a>:<dd>Supplied by the element's author (inherits from <code id=custom-elements-core-concepts:htmlelement><a href=#htmlelement>HTMLElement</a></code>)</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 href=#xml-compatible id=custom-elements-core-concepts:xml-compatible>XML-compatible</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>

  <p>A <dfn id=valid-custom-element-name data-export="">valid custom element name</dfn> is a sequence of characters
  <var>name</var> that meets all of the following requirements:</p>

  <ul><li>
    <p><var>name</var> must match the <code id=custom-elements-core-concepts:prod-potentialcustomelementname><a href=#prod-potentialcustomelementname>PotentialCustomElementName</a></code> production:</p>

    <dl><dt><code><dfn id=prod-potentialcustomelementname>PotentialCustomElementName</dfn> ::=</code><dd><code>[a-z] (<a href=#prod-pcenchar id=custom-elements-core-concepts:prod-pcenchar>PCENChar</a>)* '-'
     (<a href=#prod-pcenchar id=custom-elements-core-concepts:prod-pcenchar-2>PCENChar</a>)*</code><dt><code><dfn id=prod-pcenchar>PCENChar</dfn> ::=</code><dd><code>"-" | "." | [0-9] | "_" | [a-z] | #xB7 | [#xC0-#xD6] | [#xD8-#xF6] |
     [#xF8-#x37D] | [#x37F-#x1FFF] | [#x200C-#x200D] | [#x203F-#x2040] | [#x2070-#x218F] |
     [#x2C00-#x2FEF] | [#x3001-#xD7FF] | [#xF900-#xFDCF] | [#xFDF0-#xFFFD] |
     [#x10000-#xEFFFF]</code></dl>

    <p>This uses the <a href=https://www.w3.org/TR/xml/#sec-notation>EBNF notation</a> from the
    <cite>XML</cite> specification. <a href=#refsXML>[XML]</a></p>
   <li>
    <p><var>name</var> must not be any of the following:</p>

    <ul class=brief><li><code>annotation-xml</code><li><code>color-profile</code><li><code>font-face</code><li><code>font-face-src</code><li><code>font-face-uri</code><li><code>font-face-format</code><li><code>font-face-name</code><li><code>missing-glyph</code></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</cite> and <cite>MathML</cite>. <a href=#refsSVG>[SVG]</a> <a href=#refsMATHML>[MATHML]</a></p>
   </ul>

  <div class=note>
   <p>These requirements ensure a number of goals for <a href=#valid-custom-element-name id=custom-elements-core-concepts:valid-custom-element-name-2>valid
   custom element names</a>:</p>

   <ul><li><p>They start with 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>, ensuring that the HTML parser will
    treat them as tags instead of as text.<li><p>They do 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>,
    ensuring that the user agent can always treat HTML elements ASCII-case-insensitively.<li><p>They contain a hyphen, used for namespacing and to ensure forward compatibility (since no
    elements will be added to HTML, SVG, or MathML with hyphen-containing local names in the
    future).<li><p>They can always 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> and <code id=custom-elements-core-concepts:dom-document-createelementns><a data-x-internal=dom-document-createelementns href=https://dom.spec.whatwg.org/#dom-document-createelementns>createElementNS()</a></code>, which have restrictions that go
    beyond the parser's.</ul>

   <p>Apart from these restrictions, a large variety of names is allowed, to give maximum
   flexibility for use cases like <code>&lt;math-α></code> or <code>&lt;emotion-😍></code>.</p>
  </div>

  

  <p>A <dfn id=custom-element-definition>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><dd>A <a href=#valid-custom-element-name id=custom-elements-core-concepts:valid-custom-element-name-3>valid custom element name</a><dt>A <dfn data-dfn-for="custom element definition" id=concept-custom-element-definition-local-name data-export="">local name</dfn><dd>A local name<dt>A <dfn data-dfn-for="custom element definition" id=concept-custom-element-definition-constructor data-export="">constructor</dfn><dd>A Web IDL <code id=custom-elements-core-concepts:idl-function><a data-x-internal=idl-function href=https://heycam.github.io/webidl/#common-Function>Function</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><dt>A list of <dfn id=concept-custom-element-definition-observed-attributes>observed
   attributes</dfn><dd>A <code>sequence&lt;DOMString></code><dt>A collection of <dfn id=concept-custom-element-definition-lifecycle-callbacks>lifecycle callbacks</dfn><dd>A map, whose four keys are the strings "<code>connectedCallback</code>",
   "<code>disconnectedCallback</code>", "<code>adoptedCallback</code>", and
   "<code>attributeChangedCallback</code>". The corresponding values are either a Web IDL
   <code id=custom-elements-core-concepts:idl-function-2><a data-x-internal=idl-function href=https://heycam.github.io/webidl/#common-Function>Function</a></code> callback function type value, or null. By default the
   value of each entry is null.<dt>A <dfn id=concept-custom-element-definition-construction-stack>construction
   stack</dfn><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>.</dl>

  <p>To <dfn id=look-up-a-custom-element-definition data-export="">look up a custom element definition</dfn>, given a <var>document</var>,
  <var>namespace</var>, <var>localName</var>, and <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>custom element definition</a> or null:</p>

  <ol><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>, return null.<li><p>If <var>document</var> does not have a <a href=#concept-document-bc id=custom-elements-core-concepts:concept-document-bc>browsing
   context</a>, return null.<li><p>Let <var>registry</var> be <var>document</var>'s <a href=#concept-relevant-global id=custom-elements-core-concepts:concept-relevant-global>relevant global object</a>'s
   <code id=custom-elements-core-concepts:customelementregistry><a href=#customelementregistry>CustomElementRegistry</a></code> object.<li><p>If there is <a href=#custom-element-definition id=custom-elements-core-concepts:custom-element-definition-2>custom element definition</a> in <var>registry</var> 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>, return that <a href=#custom-element-definition id=custom-elements-core-concepts:custom-element-definition-3>custom element definition</a>.<li><p>If there is a <a href=#custom-element-definition id=custom-elements-core-concepts:custom-element-definition-4>custom element definition</a> in <var>registry</var> 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>, return that <a href=#custom-element-definition id=custom-elements-core-concepts:custom-element-definition-5>custom element definition</a>.<li><p>Return null.</ol>

  

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

  <p>Each <code id=custom-elements-api:window><a href=#window>Window</a></code> object is associated with a unique instance of a
  <code id=custom-elements-api:customelementregistry-2><a href=#customelementregistry>CustomElementRegistry</a></code> object, allocated when the <code id=custom-elements-api:window-2><a href=#window>Window</a></code> object is
  created.</p>

  <p class=note>Custom element registries are associated with <code id=custom-elements-api:window-3><a href=#window>Window</a></code> objects, instead
  of <code id=custom-elements-api:document><a href=#document>Document</a></code> objects, since each <a href=#custom-element-constructor id=custom-elements-api:custom-element-constructor>custom element constructor</a> inherits from
  the <code id=custom-elements-api:htmlelement><a href=#htmlelement>HTMLElement</a></code> interface, and there is exactly one <code id=custom-elements-api:htmlelement-2><a href=#htmlelement>HTMLElement</a></code>
  interface per <code id=custom-elements-api:window-4><a href=#window>Window</a></code> object.</p>

  

  <p>The <dfn id=dom-window-customelements><code>customElements</code></dfn> attribute
  of the <code id=custom-elements-api:window-5><a href=#window>Window</a></code> interface must return the <code id=custom-elements-api:customelementregistry-3><a href=#customelementregistry>CustomElementRegistry</a></code> object for
  that <code id=custom-elements-api:window-6><a href=#window>Window</a></code> object.</p>

  <pre><code class='idl'>[<c- g>Exposed</c->=<c- n>Window</c->]
<c- b>interface</c-> <dfn id='customelementregistry'><c- g>CustomElementRegistry</c-></dfn> {
  [<a href='#cereactions' id='custom-elements-api:cereactions'><c- g>CEReactions</c-></a>] <c- b>void</c-> <a href='#dom-customelementregistry-define' id='custom-elements-api:dom-customelementregistry-define'><c- g>define</c-></a>(<c- b>DOMString</c-> <c- g>name</c->, <a href='#customelementconstructor' id='custom-elements-api:customelementconstructor'><c- n>CustomElementConstructor</c-></a> <c- g>constructor</c->, <c- b>optional</c-> <a href='#elementdefinitionoptions' id='custom-elements-api:elementdefinitionoptions'><c- n>ElementDefinitionOptions</c-></a> <c- g>options</c->);
  <c- b>any</c-> <a href='#dom-customelementregistry-get' id='custom-elements-api:dom-customelementregistry-get'><c- g>get</c-></a>(<c- b>DOMString</c-> <c- g>name</c->);
  <c- b>Promise</c->&lt;<c- b>void</c->&gt; <a href='#dom-customelementregistry-whendefined' id='custom-elements-api:dom-customelementregistry-whendefined'><c- g>whenDefined</c-></a>(<c- b>DOMString</c-> <c- g>name</c->);
  [<a href='#cereactions' id='custom-elements-api:cereactions-2'><c- g>CEReactions</c-></a>] <c- b>void</c-> <a href='#dom-customelementregistry-upgrade' id='custom-elements-api:dom-customelementregistry-upgrade'><c- g>upgrade</c-></a>(<a href='https://dom.spec.whatwg.org/#interface-node' data-x-internal='node' id='custom-elements-api:node'><c- n>Node</c-></a> <c- g>root</c->);
};

<c- b>callback</c-> <dfn id='customelementconstructor'><c- g>CustomElementConstructor</c-></dfn> = <c- b>any</c-> ();

<c- b>dictionary</c-> <dfn id='elementdefinitionoptions'><c- g>ElementDefinitionOptions</c-></dfn> {
  <c- b>DOMString</c-> <c- g>extends</c->;
};</code></pre>

  <p>Every <code id=custom-elements-api:customelementregistry-4><a href=#customelementregistry>CustomElementRegistry</a></code> has a set of <a href=#custom-element-definition id=custom-elements-api:custom-element-definition>custom element definitions</a>, initially empty. In general, algorithms in this
  specification look up elements in the registry by any of <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-5><a href=#customelementregistry>CustomElementRegistry</a></code> also has an <dfn id=element-definition-is-running>element definition is running</dfn>
  flag which is used to prevent reentrant invocations of <a href=#element-definition id=custom-elements-api:element-definition>element definition</a>. It is
  initially unset.</p>

  <p>Every <code id=custom-elements-api:customelementregistry-6><a href=#customelementregistry>CustomElementRegistry</a></code> also has a <dfn id=when-defined-promise-map>when-defined promise map</dfn>,
  mapping <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>

  

  <dl class=domintro><dt><var>window</var> . <code id=custom-elements-api:dom-window-customelements><a href=#dom-window-customelements>customElements</a></code> . <code id=dom-customelementregistry-define-dev><a href=#dom-customelementregistry-define>define</a></code>(<var>name</var>,
   <var>constructor</var>)<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>.<dt><var>window</var> . <code id=custom-elements-api:dom-window-customelements-2><a href=#dom-window-customelements>customElements</a></code> . <code id=custom-elements-api:dom-customelementregistry-define-2><a href=#dom-customelementregistry-define>define</a></code>(<var>name</var>, <var>constructor</var>,
   { extends: <var>baseLocalName</var> })<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://heycam.github.io/webidl/#notsupportederror data-x-internal=notsupportederror>"<code>NotSupportedError</code>"</a>
   <code id=custom-elements-api:domexception><a data-x-internal=domexception href=https://heycam.github.io/webidl/#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.<dt><var>window</var> . <code id=custom-elements-api:dom-window-customelements-3><a href=#dom-window-customelements>customElements</a></code> . <code id=dom-customelementregistry-get-dev><a href=#dom-customelementregistry-get>get</a></code>(<var>name</var>)<dd>Retrieves the <a href=#custom-element-constructor id=custom-elements-api:custom-element-constructor-2>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>.<dt><var>window</var> . <code id=custom-elements-api:dom-window-customelements-4><a href=#dom-window-customelements>customElements</a></code> . <code id=dom-customelementregistry-whendefined-dev><a href=#dom-customelementregistry-whendefined>whenDefined</a></code>(<var>name</var>)<dd>Returns a promise that will be fulfilled when a <a href=#custom-element id=custom-elements-api:custom-element-4>custom element</a> becomes defined
   with the given name. (If such a <a href=#custom-element id=custom-elements-api:custom-element-5>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://heycam.github.io/webidl/#syntaxerror data-x-internal=syntaxerror>"<code>SyntaxError</code>"</a> <code id=custom-elements-api:domexception-2><a data-x-internal=domexception href=https://heycam.github.io/webidl/#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>.<dt><var>window</var> . <code id=custom-elements-api:dom-window-customelements-5><a href=#dom-window-customelements>customElements</a></code> . <code id=dom-customelementregistry-upgrade-dev><a href=#dom-customelementregistry-upgrade>upgrade</a></code>(<var>root</var>)<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>.</dl>

  <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-3>custom element definition</a>
  to the <code id=custom-elements-api:customelementregistry-7><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. When invoked,
  the <dfn id=dom-customelementregistry-define><code>define(<var>name</var>,
  <var>constructor</var>, <var>options</var>)</code></dfn> method must run these steps:</p>

  

  <ol><li><p>If <a id=custom-elements-api:isconstructor href=https://tc39.github.io/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.github.io/ecma262/#sec-native-error-types-used-in-this-standard-typeerror>TypeError</a></code>.<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://heycam.github.io/webidl/#syntaxerror data-x-internal=syntaxerror>"<code>SyntaxError</code>"</a> <code id=custom-elements-api:domexception-3><a data-x-internal=domexception href=https://heycam.github.io/webidl/#dfn-DOMException>DOMException</a></code>.<li><p>If this <code id=custom-elements-api:customelementregistry-8><a href=#customelementregistry>CustomElementRegistry</a></code> contains an entry 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-2 href=https://heycam.github.io/webidl/#notsupportederror data-x-internal=notsupportederror>"<code>NotSupportedError</code>"</a> <code id=custom-elements-api:domexception-4><a data-x-internal=domexception href=https://heycam.github.io/webidl/#dfn-DOMException>DOMException</a></code>.<li><p>If this <code id=custom-elements-api:customelementregistry-9><a href=#customelementregistry>CustomElementRegistry</a></code> contains an entry with <a href=#concept-custom-element-definition-constructor id=custom-elements-api:concept-custom-element-definition-constructor-2>constructor</a> <var>constructor</var>,
   then throw a <a id=custom-elements-api:notsupportederror-3 href=https://heycam.github.io/webidl/#notsupportederror data-x-internal=notsupportederror>"<code>NotSupportedError</code>"</a> <code id=custom-elements-api:domexception-5><a data-x-internal=domexception href=https://heycam.github.io/webidl/#dfn-DOMException>DOMException</a></code>.<li><p>Let <var>localName</var> be <var>name</var>.<li><p>Let <var>extends</var> be the value of the <code>extends</code> member of
   <var>options</var>, or null if no such member exists.<li>
    <p>If <var>extends</var> is not null, then:</p>

    <ol><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-4 href=https://heycam.github.io/webidl/#notsupportederror data-x-internal=notsupportederror>"<code>NotSupportedError</code>"</a> <code id=custom-elements-api:domexception-6><a data-x-internal=domexception href=https://heycam.github.io/webidl/#dfn-DOMException>DOMException</a></code>.<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-5 href=https://heycam.github.io/webidl/#notsupportederror data-x-internal=notsupportederror>"<code>NotSupportedError</code>"</a> <code id=custom-elements-api:domexception-7><a data-x-internal=domexception href=https://heycam.github.io/webidl/#dfn-DOMException>DOMException</a></code>.<li><p>Set <var>localName</var> to <var>extends</var>.</ol>
   <li><p>If this <code id=custom-elements-api:customelementregistry-10><a href=#customelementregistry>CustomElementRegistry</a></code>'s <a href=#element-definition-is-running id=custom-elements-api:element-definition-is-running>element definition is running</a>
   flag is set, then throw a <a id=custom-elements-api:notsupportederror-6 href=https://heycam.github.io/webidl/#notsupportederror data-x-internal=notsupportederror>"<code>NotSupportedError</code>"</a> <code id=custom-elements-api:domexception-8><a data-x-internal=domexception href=https://heycam.github.io/webidl/#dfn-DOMException>DOMException</a></code>.<li><p>Set this <code id=custom-elements-api:customelementregistry-11><a href=#customelementregistry>CustomElementRegistry</a></code>'s <a href=#element-definition-is-running id=custom-elements-api:element-definition-is-running-2>element definition is running</a>
   flag.<li>
    <p>Run the following substeps while catching any exceptions:</p>

    <ol><li><p>Let <var>prototype</var> be <a href=https://tc39.github.io/ecma262/#sec-get-o-p id=custom-elements-api:js-get data-x-internal=js-get>Get</a>(<var>constructor</var>,
     "prototype"). Rethrow any exceptions.<li><p>If <a href=https://tc39.github.io/ecma262/#sec-ecmascript-data-types-and-values id=custom-elements-api:js-type data-x-internal=js-type>Type</a>(<var>prototype</var>) is not Object, then throw a
     <code id=custom-elements-api:typeerror-2><a data-x-internal=typeerror href=https://tc39.github.io/ecma262/#sec-native-error-types-used-in-this-standard-typeerror>TypeError</a></code> exception.<li><p>Let <var>lifecycleCallbacks</var> be a map with the four keys "<code>connectedCallback</code>", "<code>disconnectedCallback</code>", "<code>adoptedCallback</code>", and "<code>attributeChangedCallback</code>", each
     of which belongs to an entry whose value is null.</p>

     <li>
      <p>For each of the four keys <var>callbackName</var> in <var>lifecycleCallbacks</var>, in the
      order listed in the previous step:</p>

      <ol><li><p>Let <var>callbackValue</var> be <a href=https://tc39.github.io/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>). Rethrow any exceptions.</p>

       <li><p>If <var>callbackValue</var> is not undefined, then set the value of the entry in
       <var>lifecycleCallbacks</var> with key <var>callbackName</var> to the result of <a href=https://heycam.github.io/webidl/#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://heycam.github.io/webidl/#common-Function>Function</a></code> callback type. Rethrow any exceptions from the
       conversion.</ol>
     <li><p>Let <var>observedAttributes</var> be an empty <code>sequence&lt;DOMString></code>.<li>
      <p>If the value of the entry in <var>lifecycleCallbacks</var> with key "<code>attributeChangedCallback</code>" is not null, then:</p>

      <ol><li><p>Let <var>observedAttributesIterable</var> be <a href=https://tc39.github.io/ecma262/#sec-get-o-p id=custom-elements-api:js-get-3 data-x-internal=js-get>Get</a>(<var>constructor</var>, "observedAttributes"). Rethrow any
       exceptions.<li><p>If <var>observedAttributesIterable</var> is not undefined, then set
       <var>observedAttributes</var> to the result of <a href=https://heycam.github.io/webidl/#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></code>. Rethrow any exceptions from the
       conversion.</ol>
    </ol>

    <p>Then, perform the following substep, regardless of whether the above steps threw an exception
    or not:</p>

    <ol><li><p>Unset this <code id=custom-elements-api:customelementregistry-12><a href=#customelementregistry>CustomElementRegistry</a></code>'s <a href=#element-definition-is-running id=custom-elements-api:element-definition-is-running-3>element definition is
     running</a> flag.</ol>

    <p>Finally, if the first set of substeps threw an exception, then rethrow that exception (thus
    terminating this algorithm). Otherwise, continue onward.</p>
   <li><p>Let <var>definition</var> be a new <a href=#custom-element-definition id=custom-elements-api:custom-element-definition-4>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-3>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>, and <a href=#concept-custom-element-definition-lifecycle-callbacks id=custom-elements-api:concept-custom-element-definition-lifecycle-callbacks>lifecycle callbacks</a>
   <var>lifecycleCallbacks</var>.<li><p>Add <var>definition</var> to this <code id=custom-elements-api:customelementregistry-13><a href=#customelementregistry>CustomElementRegistry</a></code>.<li><p>Let <var>document</var> be this <code id=custom-elements-api:customelementregistry-14><a href=#customelementregistry>CustomElementRegistry</a></code>'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>associated
   <code>Document</code></a>.<li><p>Let <var>upgrade candidates</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 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>extends</var> is non-null, 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>.<li><p>For each element <var>element</var> in <var>upgrade candidates</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>.<li>
    <p>If this <code id=custom-elements-api:customelementregistry-15><a href=#customelementregistry>CustomElementRegistry</a></code>'s <a href=#when-defined-promise-map id=custom-elements-api:when-defined-promise-map>when-defined promise map</a>
    contains an entry with key <var>name</var>:</p>

    <ol><li><p>Let <var>promise</var> be the value of that entry.<li><p>Resolve <var>promise</var> with undefined.<li><p>Delete the entry with key <var>name</var> from this
     <code id=custom-elements-api:customelementregistry-16><a href=#customelementregistry>CustomElementRegistry</a></code>'s <a href=#when-defined-promise-map id=custom-elements-api:when-defined-promise-map-2>when-defined promise map</a>.</ol>
   </ol>

  <p>When invoked, the <dfn id=dom-customelementregistry-get><code>get(<var>name</var>)</code></dfn> method must run these
  steps:</p>

  <ol><li><p>If this <code id=custom-elements-api:customelementregistry-17><a href=#customelementregistry>CustomElementRegistry</a></code> contains an entry 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
   entry's <a href=#concept-custom-element-definition-constructor id=custom-elements-api:concept-custom-element-definition-constructor-4>constructor</a>.<li><p>Otherwise, return undefined.</ol>

  <p>When invoked, the <dfn id=dom-customelementregistry-whendefined><code>whenDefined(<var>name</var>)</code></dfn> method
  must run these steps:</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 new
   promise rejected with a <a id=custom-elements-api:syntaxerror-3 href=https://heycam.github.io/webidl/#syntaxerror data-x-internal=syntaxerror>"<code>SyntaxError</code>"</a> <code id=custom-elements-api:domexception-9><a data-x-internal=domexception href=https://heycam.github.io/webidl/#dfn-DOMException>DOMException</a></code>.<li><p>If this <code id=custom-elements-api:customelementregistry-18><a href=#customelementregistry>CustomElementRegistry</a></code> contains an entry with <a href=#concept-custom-element-definition-name id=custom-elements-api:concept-custom-element-definition-name-7>name</a> <var>name</var>, then return a new
   promise resolved with undefined.<li><p>Let <var>map</var> be this <code id=custom-elements-api:customelementregistry-19><a href=#customelementregistry>CustomElementRegistry</a></code>'s <a href=#when-defined-promise-map id=custom-elements-api:when-defined-promise-map-3>when-defined
   promise map</a>.<li><p>If <var>map</var> does not contain an entry with key <var>name</var>, create an entry in
   <var>map</var> with key <var>name</var> and whose value is a new promise.<li><p>Let <var>promise</var> be the value of the entry in <var>map</var> with key
   <var>name</var>.<li><p>Return <var>promise</var>.</ol>

  

  <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-6>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>&quot;:not(:defined)&quot;</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>

  

  <p>When invoked, the <dfn id=dom-customelementregistry-upgrade><code>upgrade(<var>root</var>)</code></dfn> method must run
  these steps:</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>.<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>.</ol>

  

  <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- kr>const</c-> el <c- o>=</c-> document<c- p>.</c->createElement<c- p>(</c-><c- u>&quot;spider-man&quot;</c-><c- p>);</c->

<c- kr>class</c-> SpiderMan <c- kr>extends</c-> HTMLElement <c- p>{}</c->
customElements<c- p>.</c->define<c- p>(</c-><c- u>&quot;spider-man&quot;</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>

  

  <h4 id=upgrades><span class=secno>4.13.5</span> <dfn>Upgrades</dfn><a href=#upgrades class=self-link></a></h4>

  <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>
    <p>If <var>element</var> is <a href=https://dom.spec.whatwg.org/#concept-element-custom id=upgrades:concept-element-custom data-x-internal=concept-element-custom>custom</a>, then
    return.</p>

    <div class=example>
     <p>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>&quot;a&quot;</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>&quot;b&quot;</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 &quot;a&quot; and &quot;b&quot;</c->
customElements<c- p>.</c->define<c- p>(</c-><c- u>&quot;x-foo&quot;</c-><c- p>,</c-> <c- kr>class</c-> <c- kr>extends</c-> HTMLElement <c- p>{</c->
  constructor<c- p>()</c-> <c- p>{</c->
    <c- kr>super</c-><c- p>();</c->

    <c- kr>const</c-> b <c- o>=</c-> document<c- p>.</c->querySelector<c- p>(</c-><c- u>&quot;#b&quot;</c-><c- p>);</c->
    b<c- p>.</c->remove<c- p>();</c->

    <c- c1>// While this constructor is running for &quot;a&quot;, &quot;b&quot; is still</c->
    <c- c1>// undefined, and so inserting it into the document will enqueue a</c->
    <c- c1>// second upgrade reaction for &quot;b&quot; 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><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 "<code>failed</code>", then return.<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>.<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 an argument list containing
   <var>attribute</var>'s local name, null, <var>attribute</var>'s value, and <var>attribute</var>'s
   namespace.<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 an empty argument list.<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>.<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>.<li>
    <p>Run the following substeps while catching any exceptions:</p>

    <ol><li>
      <p>Let <var>constructResult</var> be the result of <a href=https://heycam.github.io/webidl/#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>
      <p>If <a id=upgrades:samevalue href=https://tc39.github.io/ecma262/#sec-samevalue data-x-internal=samevalue>SameValue</a>(<var>constructResult</var>, <var>element</var>) is false,
      then throw an <a id=upgrades:invalidstateerror href=https://heycam.github.io/webidl/#invalidstateerror data-x-internal=invalidstateerror>"<code>InvalidStateError</code>"</a> <code id=upgrades:domexception><a data-x-internal=domexception href=https://heycam.github.io/webidl/#dfn-DOMException>DOMException</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 object from the
      constructor.</p>
     </ol>

    <p>Then, perform the following substep, regardless of whether the above steps threw an exception
    or not:</p>

    <ol><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>
     </ol>

    <p>Finally, if the above steps threw an exception, then:</p>

    <ol><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>".<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.<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><p>Rethrow the exception (thus terminating this algorithm).</ol>
   <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>custom</code>".</ol>

  <p>To <dfn id=concept-try-upgrade data-export="">try to upgrade an element</dfn>, given as
  input an element <var>element</var>, run the following steps:</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>looking up a custom element definition</a> given <var>element</var>'s <a id=upgrades:node-document href=https://dom.spec.whatwg.org/#concept-node-document data-x-internal=node-document>node
   document</a>, <var>element</var>'s namespace, <var>element</var>'s local name, 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>.<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>.</ol>

  

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

  <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.<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.<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.<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.<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.)</ul>

  <p>We call these reactions collectively <dfn id=concept-custom-element-reaction>custom
  element reactions</dfn>.</p>

  <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=#unit-of-related-similar-origin-browsing-contexts id=custom-element-reactions:unit-of-related-similar-origin-browsing-contexts>unit of related similar-origin browsing contexts</a> has a <dfn id=custom-element-reactions-stack>custom element
  reactions stack</dfn>, which is initially empty. The <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 the <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 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/execCommand.html#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<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.</ul>

  <p>This is all summarized in the following schematic diagram:</p>

  <p><img 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>

  <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>If the <a href=#custom-element-reactions-stack id=custom-element-reactions:custom-element-reactions-stack-4>custom element reactions stack</a> is empty, then:</p>

    <ol><li><p>Add <var>element</var> to the <a href=#backup-element-queue id=custom-element-reactions:backup-element-queue-3>backup element queue</a>.<li><p>If the <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.<li><p>Set the <a href=#processing-the-backup-element-queue id=custom-element-reactions:processing-the-backup-element-queue-2>processing the backup element queue</a> flag.<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 the <a href=#backup-element-queue id=custom-element-reactions:backup-element-queue-4>backup element
       queue</a>.<li><p>Unset the <a href=#processing-the-backup-element-queue id=custom-element-reactions:processing-the-backup-element-queue-3>processing the backup element queue</a> flag.</ol>
     </ol>
   <li><p>Otherwise, add <var>element</var> to the <a href=#current-element-queue id=custom-element-reactions:current-element-queue>current element queue</a>.</ol>

  <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><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>.<li><p>If <var>callback</var> is null, then return<li>
    <p>If <var>callbackName</var> is "<code>attributeChangedCallback</code>", then:</p>

    <ol><li><p>Let <var>attributeName</var> be the first element of <var>args</var>.<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.</ol>
   <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>.<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>.</ol>

  <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>.<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>.</ol>

  <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>For each <a href=#custom-element id=custom-element-reactions:custom-element-4>custom element</a> <var>element</var> in <var>queue</var>:</p>

    <ol><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>.<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><dd><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>.<dt><a href=#callback-reaction id=custom-element-reactions:callback-reaction-2>callback reaction</a><dd><a href=https://heycam.github.io/webidl/#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 with <var>element</var> as the
         <a href=https://heycam.github.io/webidl/#dfn-callback-this-value id=custom-element-reactions:dfn-callback-this-value data-x-internal=dfn-callback-this-value>callback this value</a>.</dl>

        <p>If this throws an exception, catch it, and <a href=#report-the-exception id=custom-element-reactions:report-the-exception>report the exception</a>.</p>
       </ol>
     </ol>
   </ol>

  <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 data-export=""><code>[CEReactions]</code></dfn> IDL <a id=custom-element-reactions:extended-attribute href=https://heycam.github.io/webidl/#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>

  <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 the
   <a href=#custom-element-reactions-stack id=custom-element-reactions:custom-element-reactions-stack-5>custom element reactions stack</a>.<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.<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 the
   <a href=#custom-element-reactions-stack id=custom-element-reactions:custom-element-reactions-stack-6>custom element reactions stack</a>.<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>.<li><p>If an exception <var>exception</var> was thrown by the original steps, rethrow
   <var>exception</var>.<li><p>If a value <var>value</var> was returned from the original steps, return
   <var>value</var>.</ol>

  <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:htmlelement><a href=#htmlelement>HTMLElement</a></code>'s <code>outerText</code> IDL attribute<li><p><code id=custom-element-reactions:htmlinputelement><a href=#htmlinputelement>HTMLInputElement</a></code>'s <code>webkitdirectory</code> and <code>incremental</code> IDL attributes<li><p><code id=custom-element-reactions:htmllinkelement><a href=#htmllinkelement>HTMLLinkElement</a></code>'s <code>disabled</code> and <code>scope</code> IDL attributes<li><p><code id=custom-element-reactions:shadowroot><a data-x-internal=shadowroot href=https://dom.spec.whatwg.org/#interface-shadowroot>ShadowRoot</a></code>'s <code>innerHTML</code> IDL attribute</ul>
  </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> Bread crumb navigation<a href=#rel-up class=self-link></a></h4>

  <p>This specification does not provide a machine-readable way of describing bread-crumb 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>&quot;/&quot;</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>&quot;/products/&quot;</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>&quot;/products/dishwashers/&quot;</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>&quot;/&quot;</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>&quot;/second-hand/&quot;</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>&quot;tag-cloud&quot;</c-><c- p>&gt;</c->
 <c- p>&lt;</c-><c- f>li</c-> <c- e>class</c-><c- o>=</c-><c- s>&quot;tag-cloud-4&quot;</c-><c- p>&gt;&lt;</c-><c- f>a</c-> <c- e>title</c-><c- o>=</c-><c- s>&quot;28 instances&quot;</c-> <c- e>href</c-><c- o>=</c-><c- s>&quot;/t/apple&quot;</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>&quot;tag-cloud-2&quot;</c-><c- p>&gt;&lt;</c-><c- f>a</c-> <c- e>title</c-><c- o>=</c-><c- s>&quot;6 instances&quot;</c->  <c- e>href</c-><c- o>=</c-><c- s>&quot;/t/kiwi&quot;</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>&quot;tag-cloud-5&quot;</c-><c- p>&gt;&lt;</c-><c- f>a</c-> <c- e>title</c-><c- o>=</c-><c- s>&quot;41 instances&quot;</c-> <c- e>href</c-><c- o>=</c-><c- s>&quot;/t/pear&quot;</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&apos;s playing first?
<c- p>&lt;</c-><c- f>p</c-><c- p>&gt;</c-> Abbott: That&apos;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>&quot;1319898155&quot;</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&apos;m not that nerdy, I&apos;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>&quot;1319898192&quot;</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>&quot;1319898200&quot;</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&apos;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>&quot;1319898228&quot;</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>&quot;1319898260&quot;</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-> &quot;Hello there!&quot;
 <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 &quot;Hello, how may I help you?&quot;; 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-> &quot;I would like to buy a fish.&quot;
   <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-> &quot;Can I borrow your boat?&quot;
   <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 &quot;What are you offering in return?&quot;.
    <c- p>&lt;</c-><c- f>dl</c-><c- p>&gt;</c->
     <c- p>&lt;</c-><c- f>dt</c-><c- p>&gt;</c-> &quot;Five gold.&quot; (if you have enough)
     <c- p>&lt;</c-><c- f>dt</c-><c- p>&gt;</c-> &quot;Ten gold.&quot; (if you have enough)
     <c- p>&lt;</c-><c- f>dt</c-><c- p>&gt;</c-> &quot;Fifteen gold.&quot; (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-> &quot;A fish.&quot; (if you have one)
     <c- p>&lt;</c-><c- f>dt</c-><c- p>&gt;</c-> &quot;A newspaper.&quot; (if you have one)
     <c- p>&lt;</c-><c- f>dt</c-><c- p>&gt;</c-> &quot;A pebble.&quot; (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-> &quot;No thanks&quot;, she replies. Your conversation options
     at this point are the same as they were after asking to borrow
     her boat, minus any options you&apos;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-> &quot;Vote for me in the next election!&quot;
 <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-> &quot;Madam, are you aware that your fish are running away?&quot;
 <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 &quot;Fish cannot run, miss&quot;.
  <c- p>&lt;</c-><c- f>dl</c-><c- p>&gt;</c->
   <c- p>&lt;</c-><c- f>dt</c-><c- p>&gt;</c-> &quot;You got me!&quot;
   <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-> &quot;Only kidding.&quot;
   <c- p>&lt;</c-><c- f>dd</c-><c- p>&gt;</c-> <c- p>&lt;</c-><c- f>p</c-><c- p>&gt;</c-> &quot;Good one!&quot; she retorts. Your conversation options at this
   point are the same as those following &quot;Hello there!&quot; above.
   <c- p>&lt;</c-><c- f>dt</c-><c- p>&gt;</c-> &quot;Oh, then what are they doing?&quot;
   <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&apos;m about to fly out, sorry!
  <c- p>&lt;</c-><c- f>li</c-><c- p>&gt;</c->Sorry, I&apos;m just waiting for flight clearance and then I&apos;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&apos;m about to fly out, sorry!
  <c- p>&lt;</c-><c- f>li</c-><c- p>&gt;</c->Ok, I&apos;m not leaving right now, my plane is being cleaned.
  <c- p>&lt;</c-><c- f>li</c-><c- p>&gt;</c->Ok, it&apos;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&apos;s up to something nefarious again...
  <c- p>&lt;</c-><c- f>li</c-><c- p>&gt;</c->Nice weather we&apos;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&apos;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>&quot;Colloquial pronunciation of &apos;What do you&apos;&quot;</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&apos;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>&quot;This is, of course, a lie.&quot;</c-></strong><c- p>&gt;</c->we&apos;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&apos;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>&quot;#fn1&quot;</c-> <c- e>id</c-><c- o>=</c-><c- s>&quot;r1&quot;</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>&quot;fn1&quot;</c-><c- p>&gt;&lt;</c-><c- f>a</c-> <c- e>href</c-><c- o>=</c-><c- s>&quot;#r1&quot;</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>&quot;speaker&quot;</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>&quot;speaker&quot;</c-><c- p>&gt;</c->Shopkeeper<c- p>&lt;/</c-><c- f>span</c-><c- p>&gt;</c->: I&apos;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>&quot;speaker&quot;</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>&quot;speaker&quot;</c-><c- p>&gt;</c->Shopkeeper<c- p>&lt;/</c-><c- f>span</c-><c- p>&gt;</c->: No no no, this&apos;s&apos;a tobacconist&apos;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>&quot;#fn1&quot;</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>&quot;#fn2&quot;</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>&quot;#fn3&quot;</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>&quot;#fn4&quot;</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>&quot;fn1&quot;</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>&quot;fn2&quot;</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>&quot;fn3&quot;</c-><c- p>&gt;</c->3. Quality described as &quot;well&quot;.<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>&quot;fn4&quot;</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>

  <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>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>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>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>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>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>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></ul>

  <p class=note>This definition is used to determine what elements <a href=#specially-focusable id=disabled-elements:specially-focusable>can be focused</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>The CSS Values and Units specification 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, the comparison is <a href=#case-sensitive id="case-sensitivity-of-the-css-'attr()'-function:case-sensitive">case-sensitive</a>.</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>The Selectors specification 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, the comparison is <a href=#case-sensitive id=case-sensitivity-of-selectors:case-sensitive>case-sensitive</a>.</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 <a href=#case-sensitive id=case-sensitivity-of-selectors:case-sensitive-2>case-sensitive</a>.</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>, with one exception as noted
  <a href=#attribute-selector-case-sensitive>in the rendering section</a>:</p>

  
  
  <ul class=brief><li><code>accept</code>
   <li><code>accept-charset</code>
   <li><code>align</code>
   <li><code>alink</code>
   <li><code>axis</code>
   <li><code>bgcolor</code>
   <li><code>charset</code>
   <li><code>checked</code>
   <li><code>clear</code>
   <li><code>codetype</code>
   <li><code>color</code>
   <li><code>compact</code>
   <li><code>declare</code>
   <li><code>defer</code>
   <li><code>dir</code>
   <li><code>direction</code> 
   <li><code>disabled</code>
   <li><code>enctype</code>
   <li><code>face</code>
   <li><code>frame</code>
   <li><code>hreflang</code>
   <li><code>http-equiv</code>
   <li><code>lang</code>
   <li><code>language</code>
   <li><code>link</code>
   <li><code>media</code>
   <li><code>method</code>
   <li><code>multiple</code>
   <li><code>nohref</code>
   <li><code>noresize</code>
   <li><code>noshade</code>
   <li><code>nowrap</code>
   <li><code>readonly</code>
   <li><code>rel</code>
   <li><code>rev</code>
   <li><code>rules</code>
   <li><code>scope</code>
   <li><code>scrolling</code>
   <li><code>selected</code>
   <li><code>shape</code>
   <li><code>target</code>
   <li><code>text</code>
   <li><code>type</code> (except as specified in the rendering section)
   <li><code>valign</code>
   <li><code>valuetype</code>
   <li><code>vlink</code>
  </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>
  </div>

  <p>All other attribute values and everything else must be treated as entirely
  <a href=#case-sensitive id=case-sensitivity-of-selectors:case-sensitive-3>case-sensitive</a> for the purposes of selector matching. This includes:</p>

  <ul class=brief><li> <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>
   <li> 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>
   <li> 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>
   <li> 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>
   <li> 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>
   <li> the names of attributes that themselves have namespaces
  </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 <a href=#case-sensitive id=case-sensitivity-of-selectors:case-sensitive-4>case-sensitive</a> 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>

  <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-export=""><code>:defined</code></dfn><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>

   <dt><dfn id=selector-link><code>:link</code></dfn><dt><dfn id=selector-visited><code>:visited</code></dfn><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, 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, and all <code id=pseudo-classes:the-link-element><a href=#the-link-element>link</a></code> elements that have
    an <code id=pseudo-classes:attr-link-href><a href=#attr-link-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>

   <dt><dfn id=selector-active><code>:active</code></dfn><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/selectors3/#the-user-action-pseudo-classes-hover-act>while an
    element is <dfn id=concept-selector-active><i>being activated</i></dfn> by the user</q>.</p>

    <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 has a descendant that is currently matching the <code id=pseudo-classes:selector-active-3><a href=#selector-active>:active</a></code> <a id=pseudo-classes:pseudo-class-5 href=https://drafts.csswg.org/selectors/#pseudo-class data-x-internal=pseudo-class>pseudo-class</a><dd><p>The element is <i id=pseudo-classes:concept-selector-active-2><a href=#concept-selector-active>being activated</a></i>.<dt>If the element 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><dd><p>The element is <i id=pseudo-classes:concept-selector-active-3><a href=#concept-selector-active>being activated</a></i>.<dt>If the element is a <code id=pseudo-classes:the-button-element><a href=#the-button-element>button</a></code> element<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<dd>

      <p>The element is <i id=pseudo-classes:concept-selector-active-4><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>
      and it is not <a href=#concept-fe-disabled id=pseudo-classes:concept-fe-disabled>disabled</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-6 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>

     <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>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>If the element is a <code id=pseudo-classes:the-link-element-2><a href=#the-link-element>link</a></code> element that has an <code id=pseudo-classes:attr-link-href-2><a href=#attr-link-href>href</a></code> attribute<dt>If the element has its <a href=#specially-focusable id=pseudo-classes:specially-focusable>tabindex focus flag</a> set<dd><p>The element is <i id=pseudo-classes:concept-selector-active-5><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-2>in a formal activation
     state</a>.<dt>If the element is <a href=#being-actively-pointed-at id=pseudo-classes:being-actively-pointed-at>being actively pointed at</a><dd><p>The element is <i id=pseudo-classes:concept-selector-active-6><a href=#concept-selector-active>being activated</a></i>.</dl>

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

    <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 depressed; for a finger
    in a multitouch environment, while the finger is touching the display surface).</p>

   <dt><dfn id=selector-hover><code>:hover</code></dfn><dd>

    <p>The <code id=pseudo-classes:selector-hover><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> is defined to match
    an element <q cite=https://drafts.csswg.org/selectors3/#the-user-action-pseudo-classes-hover-act>while the
    user <i>designates</i> 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-8 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>designates</i> if it is:</p>

    <ul><li>

      <p>An element that the user indicates using a pointing device.</p>

     <li>

      <p>An element that has a descendant that the user indicates using a pointing device.</p>

     <li>

      <p>An 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-3><a href=#selector-hover>:hover</a></code>.</p>

     </ul>


    <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-4><a href=#selector-hover>:hover</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>. The element with ID "<code>a</code>" matches it from
     condition 1, 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 condition 2
     (one of their descendants is designated), and the element with ID "<code>c</code>"
     matches it through condition 3 (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-5><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-6><a href=#selector-hover>:hover</a></code>: its descendant is not
     designated, even though it matches <code id=pseudo-classes:selector-hover-7><a href=#selector-hover>:hover</a></code>.</p>

    </div>

   <dt><dfn id=selector-focus><code>:focus</code></dfn><dd>

    <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-10 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 its <a href=#top-level-browsing-context id=pseudo-classes:top-level-browsing-context>top-level browsing
    context</a> has the system focus, it is not itself a <a href=#browsing-context-container id=pseudo-classes:browsing-context-container>browsing context container</a>,
    and it is one of the elements listed in the <a href=#focus-chain id=pseudo-classes:focus-chain>focus chain</a> of the <a href=#currently-focused-area-of-a-top-level-browsing-context id=pseudo-classes:currently-focused-area-of-a-top-level-browsing-context>currently focused area of the
    top-level browsing context</a>.</p>

   <dt><dfn id=selector-target><code>:target</code></dfn><dd>

    <p>For the purposes of the CSS <code id=pseudo-classes:selector-focus-2><a href=#selector-focus>:target</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>, 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>

   <dt><dfn id=selector-enabled><code>:enabled</code></dfn><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>, or <code id=pseudo-classes:the-fieldset-element><a href=#the-fieldset-element>fieldset</a></code> element that is not <a href=#concept-element-disabled id=pseudo-classes:concept-element-disabled>actually disabled</a>.</p>

   <dt><dfn id=selector-disabled><code>:disabled</code></dfn><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>

   <dt><dfn id=selector-checked><code>:checked</code></dfn><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><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><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</ul>

   <dt><dfn id=selector-indeterminate><code>:indeterminate</code></dfn><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><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><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</ul>

   <dt><dfn id=selector-default><code>:default</code></dfn><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><code id=pseudo-classes:the-button-element-4><a href=#the-button-element>button</a></code> elements that are their form's <a href=#default-button id=pseudo-classes:default-button>default button</a><li><code id=pseudo-classes:the-input-element-8><a href=#the-input-element>input</a></code> elements whose <code id=pseudo-classes:attr-input-type-6><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)-2">Submit Button</a> or <a href="#image-button-state-(type=image)" id="pseudo-classes:image-button-state-(type=image)-2">Image Button</a> state, and that are their form's
     <a href=#default-button id=pseudo-classes:default-button-2>default button</a><li><code id=pseudo-classes:the-input-element-9><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><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</ul>

   <dt><dfn id=selector-placeholder-shown><code>:placeholder-shown</code></dfn><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-10><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><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.</ul>

   <dt><dfn id=selector-valid><code>:valid</code></dfn><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><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>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><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></ul>

   <dt><dfn id=selector-invalid><code>:invalid</code></dfn><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><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-2>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><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></ul>

   <dt><dfn id=selector-in-range><code>:in-range</code></dfn><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-20 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-7>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>

   <dt><dfn id=selector-out-of-range><code>:out-of-range</code></dfn><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-21 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-8>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>

   <dt><dfn id=selector-required><code>:required</code></dfn><dd>

    <p>The <code id=pseudo-classes:selector-required><a href=#selector-required>:required</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
    any element falling into one of the following categories:</p>

    <ul><li><code id=pseudo-classes:the-input-element-11><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><code id=pseudo-classes:the-select-element-2><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><code id=pseudo-classes:the-textarea-element-3><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</ul>

   <dt><dfn id=selector-optional><code>:optional</code></dfn><dd>

    <p>The <code id=pseudo-classes:selector-optional><a href=#selector-optional>:optional</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
    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 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><code id=pseudo-classes:the-select-element-3><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><code id=pseudo-classes:the-textarea-element-4><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</ul>

   <dt><dfn id=selector-read-only><code>:read-only</code></dfn><dt><dfn id=selector-read-write><code>:read-write</code></dfn><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-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, 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-13><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-2>disabled</a>)<li><code id=pseudo-classes:the-textarea-element-5><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-3>disabled</a><li>elements that are <a href=https://w3c.github.io/editing/execCommand.html#editing-host id=pseudo-classes:editing-host data-x-internal=editing-host>editing hosts</a> or <a id=pseudo-classes:editable href=https://w3c.github.io/editing/execCommand.html#editable data-x-internal=editable>editable</a>
     and are neither <code id=pseudo-classes:the-input-element-14><a href=#the-input-element>input</a></code> elements nor <code id=pseudo-classes:the-textarea-element-6><a href=#the-textarea-element>textarea</a></code> elements</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-25 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>HTML elements</a>.</p>

   <dt><dfn id=selector-ltr><code>:dir(ltr)</code></dfn><dd>

    <p>The <code id=pseudo-classes:selector-ltr><a href=#selector-ltr>:dir(ltr)</a></code> <a id=pseudo-classes:pseudo-class-26 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>

   <dt><dfn id=selector-rtl><code>:dir(rtl)</code></dfn><dd>

    <p>The <code id=pseudo-classes:selector-rtl><a href=#selector-rtl>:dir(rtl)</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 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>

   </dl><div class=status><input onclick=toggleStatus(this) value=⋰ type=button><p class=support><strong>Support:</strong> css-read-only-write<span class="and_chr yes"><span>Chrome for Android</span> <span>67+</span></span><span class="chrome yes"><span>Chrome</span> <span>36+</span></span><span class="ios_saf yes"><span>iOS Safari</span> <span>9.0+</span></span><span class="and_uc yes"><span>UC Browser for Android</span> <span>11.8+</span></span><span class="firefox no"><span>Firefox</span> <span>None</span></span><span class="ie no"><span>IE</span> <span>None</span></span><span class="op_mini no"><span>Opera Mini</span> <span>None</span></span><span class="safari yes"><span>Safari</span> <span>9+</span></span><span class="edge yes"><span>Edge</span> <span>13+</span></span><span class="samsung yes"><span>Samsung Internet</span> <span>4+</span></span><span class="opera yes"><span>Opera</span> <span>23+</span></span><span class="android yes"><span>Android Browser</span> <span>67+</span></span><p class=caniuse>Source: <a href="https://caniuse.com/#feat=css-read-only-write">caniuse.com</a></div>

  <p class=note>This specification does not define when an element matches the <code>:lang()</code> dynamic <a id=pseudo-classes:pseudo-class-28 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 the Selectors specification.
  <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>&quot;name&quot;</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>&quot;name&quot;</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>&quot;name&quot;</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>&quot;name&quot;</c-><c- p>&gt;&lt;</c-><c- f>a</c-> <c- e>href</c-><c- o>=</c-><c- s>&quot;/?user=daniel&quot;</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>&quot;name&quot;</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>&quot;band&quot;</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>&quot;nationality&quot;</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>&quot;image&quot;</c-> <c- e>src</c-><c- o>=</c-><c- s>&quot;google-logo.png&quot;</c-> <c- e>alt</c-><c- o>=</c-><c- s>&quot;Google&quot;</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>&quot;product-id&quot;</c-> <c- e>value</c-><c- o>=</c-><c- s>&quot;9678AOU879&quot;</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>&quot;http://schema.org/Product&quot;</c-><c- p>&gt;</c->
 <c- p>&lt;</c-><c- f>span</c-> <c- e>itemprop</c-><c- o>=</c-><c- s>&quot;name&quot;</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>&quot;panasonic-fridge-60l-white.jpg&quot;</c-> <c- e>alt</c-><c- o>=</c-><c- s>&quot;&quot;</c-><c- p>&gt;</c->
  <c- p>&lt;</c-><c- f>div</c-> <c- e>itemprop</c-><c- o>=</c-><c- s>&quot;aggregateRating&quot;</c->
       <c- e>itemscope</c-> <c- e>itemtype</c-><c- o>=</c-><c- s>&quot;http://schema.org/AggregateRating&quot;</c-><c- p>&gt;</c->
   <c- p>&lt;</c-><c- f>meter</c-> <c- e>itemprop</c-><c- o>=</c-><c- s>&quot;ratingValue&quot;</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>&quot;reviewCount&quot;</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>&quot;birthday&quot;</c-> <c- e>datetime</c-><c- o>=</c-><c- s>&quot;2009-05-10&quot;</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>&quot;name&quot;</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>&quot;band&quot;</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>&quot;name&quot;</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>&quot;size&quot;</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>&quot;amanda&quot;</c-> <c- e>itemref</c-><c- o>=</c-><c- s>&quot;a b&quot;</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>&quot;a&quot;</c-><c- p>&gt;</c->Name: <c- p>&lt;</c-><c- f>span</c-> <c- e>itemprop</c-><c- o>=</c-><c- s>&quot;name&quot;</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>&quot;b&quot;</c-> <c- e>itemprop</c-><c- o>=</c-><c- s>&quot;band&quot;</c-> <c- e>itemscope</c-> <c- e>itemref</c-><c- o>=</c-><c- s>&quot;c&quot;</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>&quot;c&quot;</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>&quot;name&quot;</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>&quot;size&quot;</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>&quot;flavor&quot;</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>&quot;flavor&quot;</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>&quot;favorite-color favorite-fruit&quot;</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>&quot;castle.jpeg&quot;</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>&quot;name&quot;</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>&quot;name&quot;</c-> <c- e>content</c-><c- o>=</c-><c- s>&quot;The Castle&quot;</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>&quot;castle.jpeg&quot;</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>&quot;https://example.org/animals#cat&quot;</c-><c- p>&gt;</c->
 <c- p>&lt;</c-><c- f>h1</c-> <c- e>itemprop</c-><c- o>=</c-><c- s>&quot;name&quot;</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>&quot;desc&quot;</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>&quot;img&quot;</c-> <c- e>src</c-><c- o>=</c-><c- s>&quot;hedral.jpeg&quot;</c-> <c- e>alt</c-><c- o>=</c-><c- s>&quot;&quot;</c-> <c- e>title</c-><c- o>=</c-><c- s>&quot;Hedral, age 18 months&quot;</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>&quot;https://vocab.example.net/book&quot;</c->
    <strong><c- e>itemid</c-><c- o>=</c-><c- s>&quot;urn:isbn:0-330-34032-8&quot;</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>&quot;title&quot;</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>&quot;author&quot;</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>&quot;pubdate&quot;</c-> <c- e>datetime</c-><c- o>=</c-><c- s>&quot;1996-01-26&quot;</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://tools.ietf.org/html/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>&quot;https://example.org/animals#cat&quot;</c-><c- p>&gt;</c->
 <c- p>&lt;</c-><c- f>h1</c-> <c- e>itemprop</c-><c- o>=</c-><c- s>&quot;name https://example.com/fn&quot;</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>&quot;desc&quot;</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>&quot;https://example.com/color&quot;</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>&quot;https://example.com/color&quot;</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>&quot;img&quot;</c-> <c- e>src</c-><c- o>=</c-><c- s>&quot;hedral.jpeg&quot;</c-> <c- e>alt</c-><c- o>=</c-><c- s>&quot;&quot;</c-> <c- e>title</c-><c- o>=</c-><c- s>&quot;Hedral, age 18 months&quot;</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>Value
    <tbody><tr><td>name
      <td>Hedral
     <tr><td>https://example.com/fn
      <td>Hedral
     <tr><td>desc
      <td>Hedral is a male american domestic shorthair, with a fluffy black fur with white paws and belly.
     <tr><td>https://example.com/color
      <td>black
     <tr><td>https://example.com/color
      <td>white
     <tr><td>img
      <td>.../hedral.jpeg
   </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>

  <p>Every <a href=#html-elements id=items:html-elements>HTML element</a> may have an <dfn id=attr-itemscope><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>

  <p>Elements with an <code id=items:attr-itemscope-3><a href=#attr-itemscope>itemscope</a></code> attribute may have an <dfn id=attr-itemtype><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> that are
  <a href=#case-sensitive id=items:case-sensitive>case-sensitive</a>, 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>

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

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

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

  <hr>

  <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 id=attr-itemid><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>

  <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=#parse-a-url id=items:parse-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 resolving it fails, it is said to have no <a href=#global-identifier id=items:global-identifier>global identifier</a>.</p>

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

  <p>Elements with an <code id=items:attr-itemscope-8><a href=#attr-itemscope>itemscope</a></code> attribute may have an <dfn id=attr-itemref><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> that are
  <a href=#case-sensitive id=items:case-sensitive-2>case-sensitive</a>, 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<dd>An integer that names the product in the manufacturer's catalog.<dt>name<dd>A brief description of the product.<dt>scale<dd>One of "HO", "1", or "Z" (potentially with leading or trailing
    whitespace), indicating the scale of the product.<dt>digital<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.<dt>track-type<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.</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<dd>Rolling stock with an engine<dt>https://md.example.com/passengers<dd>Passenger rolling stock<dt>https://md.example.com/track<dd>Track pieces<dt>https://md.example.com/lighting<dd>Equipment with lighting</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>&quot;https://md.example.com/loco</c->
<c- s>                        https://md.example.com/lighting&quot;</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>&quot;name&quot;</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>&quot;product-code&quot;</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>&quot;scale&quot;</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>&quot;digital&quot;</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>&quot;https://md.example.com/track</c->
<c- s>                       https://md.example.com/lighting&quot;</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>&quot;name&quot;</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>&quot;product-code&quot;</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>&quot;track-type&quot;</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>&quot;scale&quot;</c-> <c- e>content</c-><c- o>=</c-><c- s>&quot;HO&quot;</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>&quot;https://md.example.com/passengers&quot;</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>&quot;name&quot;</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>&quot;product-code&quot;</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>&quot;scale&quot;</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><code>itemprop</code></dfn> attribute<a href=#names:-the-itemprop-attribute class=self-link></a></h4>

  <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> that are
  <a href=#case-sensitive id=names:-the-itemprop-attribute:case-sensitive>case-sensitive</a>, 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>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>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>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).</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>

  

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

  <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>&quot;a&quot;</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>&quot;a&quot;</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>&quot;b&quot;</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>&quot;b&quot;</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>&quot;a&quot;</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>&quot;a&quot;</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>&quot;a&quot;</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>&quot;b&quot;</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>&quot;a&quot;</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>&quot;x&quot;</c-><c- p>&gt;</c->
 <c- p>&lt;</c-><c- f>p</c-> <c- e>itemprop</c-><c- o>=</c-><c- s>&quot;a&quot;</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>&quot;x&quot;</c-><c- p>&gt;</c->
 <c- p>&lt;</c-><c- f>p</c-> <c- e>itemprop</c-><c- o>=</c-><c- s>&quot;b&quot;</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>&quot;a&quot;</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>

  <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<dd>

    <p>The value is the <a href=#concept-item id=values:concept-item>item</a> created by the element.</p>

   <dt>If the element is a <code id=values:the-meta-element><a href=#the-meta-element>meta</a></code> element<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>

   <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<dd>

    <p>The value is the <a href=#resulting-url-string id=values:resulting-url-string>resulting URL string</a> that results from <a href=#parse-a-url id=values:parse-a-url>parsing</a> the value of the element's <code>src</code> attribute relative to
    the <a id=values:node-document href=https://dom.spec.whatwg.org/#concept-node-document data-x-internal=node-document>node document</a> of the element at the time the attribute is set, or the empty
    string if there is no such attribute or if <a href=#parse-a-url id=values:parse-a-url-2>parsing</a> it results
    in an error.</p>

   <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<dd>

    <p>The value is the <a href=#resulting-url-string id=values:resulting-url-string-2>resulting URL string</a> that results from <a href=#parse-a-url id=values:parse-a-url-3>parsing</a> the value of the element's <code>href</code> attribute relative to
    the <a id=values:node-document-2 href=https://dom.spec.whatwg.org/#concept-node-document data-x-internal=node-document>node document</a> of the element at the time the attribute is set, or the empty
    string if there is no such attribute or if <a href=#parse-a-url id=values:parse-a-url-4>parsing</a> it results
    in an error.</p>

   <dt>If the element is an <code id=values:the-object-element><a href=#the-object-element>object</a></code> element<dd>

    <p>The value is the <a href=#resulting-url-string id=values:resulting-url-string-3>resulting URL string</a> that results from <a href=#parse-a-url id=values:parse-a-url-5>parsing</a> the value of the element's <code>data</code> attribute relative to
    the <a id=values:node-document-3 href=https://dom.spec.whatwg.org/#concept-node-document data-x-internal=node-document>node document</a> of the element at the time the attribute is set, or the empty
    string if there is no such attribute or if <a href=#parse-a-url id=values:parse-a-url-6>parsing</a> it results
    in an error.</p>

   <dt>If the element is a <code id=values:the-data-element><a href=#the-data-element>data</a></code> element<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>

   <dt>If the element is a <code id=values:the-meter-element><a href=#the-meter-element>meter</a></code> element<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>

   <dt>If the element is a <code id=values:the-time-element><a href=#the-time-element>time</a></code> element<dd>

    <p>The value is the element's <a href=#datetime-value id=values:datetime-value>datetime value</a>.</p>

   <dt>Otherwise<dd>

    <p>The value is the element's <code id=values:textcontent><a data-x-internal=textcontent href=https://dom.spec.whatwg.org/#dom-node-textcontent>textContent</a></code>.</p>

   </dl>

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

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

  <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.<li><p>Add the element <var>root</var> to <var>memory</var>.<li><p>Add the child elements of <var>root</var>, if any, to <var>pending</var>.<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>.<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.<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>; continue.<li><p>Add <var>current</var> to <var>memory</var>.<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>.<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>.</ol>

   <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>.<li><p>Return <var>results</var>.</ol>

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

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



  <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>&quot;en&quot;</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>&quot;http://n.whatwg.org/work&quot;</c-> <c- e>itemref</c-><c- o>=</c-><c- s>&quot;licenses&quot;</c-><c- p>&gt;</c->
   <c- p>&lt;</c-><c- f>img</c-> <c- e>itemprop</c-><c- o>=</c-><c- s>&quot;work&quot;</c-> <c- e>src</c-><c- o>=</c-><c- s>&quot;images/house.jpeg&quot;</c-> <c- e>alt</c-><c- o>=</c-><c- s>&quot;A white house, boarded up, sits in a forest.&quot;</c-><c- p>&gt;</c->
   <c- p>&lt;</c-><c- f>figcaption</c-> <c- e>itemprop</c-><c- o>=</c-><c- s>&quot;title&quot;</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>&quot;http://n.whatwg.org/work&quot;</c-> <c- e>itemref</c-><c- o>=</c-><c- s>&quot;licenses&quot;</c-><c- p>&gt;</c->
   <c- p>&lt;</c-><c- f>img</c-> <c- e>itemprop</c-><c- o>=</c-><c- s>&quot;work&quot;</c-> <c- e>src</c-><c- o>=</c-><c- s>&quot;images/mailbox.jpeg&quot;</c-> <c- e>alt</c-><c- o>=</c-><c- s>&quot;Outside the house is a mailbox. It has a leaflet inside.&quot;</c-><c- p>&gt;</c->
   <c- p>&lt;</c-><c- f>figcaption</c-> <c- e>itemprop</c-><c- o>=</c-><c- s>&quot;title&quot;</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>&quot;licenses&quot;</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>&quot;license&quot;</c->
   <c- e>href</c-><c- o>=</c-><c- s>&quot;http://www.opensource.org/licenses/mit-license.php&quot;</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
    <dd><code>images/house.jpeg</code>
    <dt>title
    <dd>The house I found.
    <dt>license
    <dd><code>http://www.opensource.org/licenses/mit-license.php</code>
   </dl>

   <p>...and one with:</p>

   <dl class=brief><dt>work
    <dd><code>images/mailbox.jpeg</code>
    <dt>title
    <dd>The mailbox.
    <dt>license
    <dd><code>http://www.opensource.org/licenses/mit-license.php</code>
   </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&apos;s just an </c-><a href='https://svgwg.org/svg2-draft/struct.html#SVGElement' data-x-internal='svg-svg' id='microdata-and-other-namespaces: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 the vCard 4.0 specification 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><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, when compared in a
    <a href=#case-sensitive id=vcard:case-sensitive>case-sensitive</a> manner, is equal to 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>

   <dt><dfn id=md-vcard-fn><code>fn</code></dfn><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>

   <dt><dfn id=md-vcard-n><code>n</code></dfn><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>

   <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>)<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>

   <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>)<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>

   <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>)<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>

   <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>)<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>

   <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>)<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>

   <dt><dfn id=md-vcard-nickname><code>nickname</code></dfn><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>

   <dt><dfn id=md-vcard-photo><code>photo</code></dfn><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>

   <dt><dfn id=md-vcard-bday><code>bday</code></dfn><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>

   <dt><dfn id=md-vcard-anniversary><code>anniversary</code></dfn><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>

   <dt><dfn id=md-vcard-sex><code>sex</code></dfn><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>

   <dt><dfn id=md-vcard-gender-identity><code>gender-identity</code></dfn><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>

   <dt><dfn id=md-vcard-adr><code>adr</code></dfn><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>

   <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>)<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, when compared in a
    <a href=#case-sensitive id=vcard:case-sensitive-2>case-sensitive</a> manner, is equal to 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>

   <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>)<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>The vCard specification urges authors not to use this field.</p>

   <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>)<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>The vCard specification urges authors not to use this field.</p>

   <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>)<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>

   <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>)<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>

   <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>)<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>

   <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>)<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>

   <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>)<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>

   <dt><dfn id=md-vcard-tel><code>tel</code></dfn><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>

   <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>)<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, when compared in a
    <a href=#case-sensitive id=vcard:case-sensitive-3>case-sensitive</a> manner, is equal to 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>

   <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>)<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>

   <dt><dfn id=md-vcard-email><code>email</code></dfn><dd>

    <p>Gives the e-mail 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>

   <dt><dfn id=md-vcard-impp><code>impp</code></dfn><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>

   <dt><dfn id=md-vcard-lang><code>lang</code></dfn><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>

   <dt><dfn id=md-vcard-tz><code>tz</code></dfn><dd>

    <p>Gives the time zone of the person or organization.</p>

    <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>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>A U+003A COLON character (:).<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.</ol>

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

   <dt><dfn id=md-vcard-geo><code>geo</code></dfn><dd>

    <p>Gives the geographical position of the person or organization.</p>

    <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>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>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>A U+003B SEMICOLON character (;).<li>Optionally, either a U+002B PLUS SIGN character (+) or a U+002D HYPHEN-MINUS character
     (-).<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>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>.</ol>

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

   <dt><dfn id=md-vcard-title><code>title</code></dfn><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>

   <dt><dfn id=md-vcard-role><code>role</code></dfn><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>

   <dt><dfn id=md-vcard-logo><code>logo</code></dfn><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>

   <dt><dfn id=md-vcard-agent><code>agent</code></dfn><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>

   <dt><dfn id=md-vcard-org><code>org</code></dfn><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>

   <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>)<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>

   <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>)<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>

   <dt><dfn id=md-vcard-member><code>member</code></dfn><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>

   <dt><dfn id=md-vcard-related><code>related</code></dfn><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>

   <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>)<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>

   <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>)<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, when compared in a
    <a href=#case-sensitive id=vcard:case-sensitive-4>case-sensitive</a> manner, is equal to 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>

   <dt><dfn id=md-vcard-categories><code>categories</code></dfn><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>

   <dt><dfn id=md-vcard-note><code>note</code></dfn><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>

   <dt><dfn id=md-vcard-rev><code>rev</code></dfn><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>

   <dt><dfn id=md-vcard-sound><code>sound</code></dfn><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>

   <dt><dfn id=md-vcard-uid><code>uid</code></dfn><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>

   <dt><dfn id=md-vcard-url><code>url</code></dfn><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>

   </dl>

  <p>The <dfn id=kind-strings>kind strings</dfn> are:</p>

  <dl><dt><dfn id=md-vcard-kind-individual><code>individual</code></dfn><dd>
    <p>Indicates a single entity (e.g. a person).</p>
   <dt><dfn id=md-vcard-kind-group><code>group</code></dfn><dd>
    <p>Indicates multiple entities (e.g. a mailing list).</p>
   <dt><dfn id=md-vcard-kind-org><code>org</code></dfn><dd>
    <p>Indicates a single entity that is not a person (e.g. a company).</p>
   <dt><dfn id=md-vcard-kind-location><code>location</code></dfn><dd>
    <p>Indicates a geographical place (e.g. an office building).</p>
   </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><dd>
    <p>Indicates a delivery address for a residence.</p>
   <dt><dfn id=md-vcard-type-adr-work><code>work</code></dfn><dd>
    <p>Indicates a delivery address for a place of work.</p>
   </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><dd>
    <p>Indicates a residential number.</p>
   <dt><dfn id=md-vcard-type-tel-work><code>work</code></dfn><dd>
    <p>Indicates a telephone number for a place of work.</p>
   <dt><dfn id=md-vcard-type-tel-text><code>text</code></dfn><dd>
    <p>Indicates that the telephone number supports text messages (SMS).</p>
   <dt><dfn id=md-vcard-type-tel-voice><code>voice</code></dfn><dd>
    <p>Indicates a voice telephone number.</p>
   <dt><dfn id=md-vcard-type-tel-fax><code>fax</code></dfn><dd>
    <p>Indicates a facsimile telephone number.</p>
   <dt><dfn id=md-vcard-type-tel-cell><code>cell</code></dfn><dd>
    <p>Indicates a cellular telephone number.</p>
   <dt><dfn id=md-vcard-type-tel-video><code>video</code></dfn><dd>
    <p>Indicates a video conferencing telephone number.</p>
   <dt><dfn id=md-vcard-type-tel-pager><code>pager</code></dfn><dd>
    <p>Indicates a paging device telephone number.</p>
   <dt><dfn id=md-vcard-type-tel-textphone><code>textphone</code></dfn><dd>
    <p>Indicates a telecommunication device for people with hearing or speech difficulties.</p>
   </dl>

  <p>The <dfn id=relationship-strings>relationship strings</dfn> are:</p>

  <dl><dt><dfn id=md-vcard-rel-emergency><code>emergency</code></dfn><dd>
    <p>An emergency contact.</p>
   <dt><dfn id=md-vcard-rel-agent><code>agent</code></dfn><dd>
    <p>Another entity that acts on behalf of this entity.</p>
   <dt><dfn id=md-vcard-rel-contact>contact</dfn><dt><dfn id=md-vcard-rel-acquaintance>acquaintance</dfn><dt><dfn id=md-vcard-rel-friend>friend</dfn><dt><dfn id=md-vcard-rel-met>met</dfn><dt><dfn id=md-vcard-rel-co-worker>worker</dfn><dt><dfn id=md-vcard-rel-colleague>colleague</dfn><dt><dfn id=md-vcard-rel-co-resident>resident</dfn><dt><dfn id=md-vcard-rel-neighbor>neighbor</dfn><dt><dfn id=md-vcard-rel-child>child</dfn><dt><dfn id=md-vcard-rel-parent>parent</dfn><dt><dfn id=md-vcard-rel-sibling>sibling</dfn><dt><dfn id=md-vcard-rel-spouse>spouse</dfn><dt><dfn id=md-vcard-rel-kin>kin</dfn><dt><dfn id=md-vcard-rel-muse>muse</dfn><dt><dfn id=md-vcard-rel-crush>crush</dfn><dt><dfn id=md-vcard-rel-date>date</dfn><dt><dfn id=md-vcard-rel-sweetheart>sweetheart</dfn><dt><dfn id=md-vcard-rel-me>me</dfn><dd>
    <p>Has the meaning defined in XFN. <a href=#refsXFN>[XFN]</a></p>
   </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>

  <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.<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>.<li><p>Let <var>output</var> be an empty string.<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>.<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>.<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>.<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>.<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 the <code id=conversion-to-vcard:textcontent><a data-x-internal=textcontent href=https://dom.spec.whatwg.org/#dom-node-textcontent>textContent</a></code> of <a href=#the-title-element-2 id=conversion-to-vcard:the-title-element-2-2>the <code>title</code>
   element</a> as the value to <var>output</var>.<li><p>Let <var>sex</var> be the empty string.<li><p>Let <var>gender-identity</var> be the empty string.<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.<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><dd>

        <ol><li><p>Let <var>value</var> be the empty string.<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>Append a U+003B SEMICOLON character (;) to <var>value</var>.<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>Append a U+003B SEMICOLON character (;) to <var>value</var>.<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>Append a U+003B SEMICOLON character (;) to <var>value</var>.<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>Append a U+003B SEMICOLON character (;) to <var>value</var>.<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>

        </ol>

       <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><dd>

        <ol><li><p>Let <var>value</var> be the empty string.<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>Append a U+003B SEMICOLON character (;) to <var>value</var>.<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>Append a U+003B SEMICOLON character (;) to <var>value</var>.<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>Append a U+003B SEMICOLON character (;) to <var>value</var>.<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>Append a U+003B SEMICOLON character (;) to <var>value</var>.<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>Append a U+003B SEMICOLON character (;) to <var>value</var>.<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>Append a U+003B SEMICOLON character (;) to <var>value</var>.<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><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>.</ol>

       <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><dd>

        <ol><li><p>Let <var>value</var> be the empty string.<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>

          <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.<li><p>Append a U+003B SEMICOLON character (;) to <var>value</var>.<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>.</ol>

         </ol>

       <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><dd>

        <ol><li><p>Let <var>value</var> be the empty string.<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>.<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>.</ol>

       <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<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><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 alphanumeric</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>.</ol>

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

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

       <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>)<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>.<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>.<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>.<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>.<li><p>Prefix every U+005C REVERSE SOLIDUS character (\) in <var>value</var> with
         another U+005C REVERSE SOLIDUS character (\).<li><p>Prefix every U+002C COMMA character (,) in <var>value</var> with a U+005C
         REVERSE SOLIDUS character (\).<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 (\).<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).<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).</ol>

       </dl>

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

     </ol>

   <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>.<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>.</ol>

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

   <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>.<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>.<li><p>Append the parameter's name to <var>line</var>.<li><p>Append a U+003D EQUALS SIGN character (=) to <var>line</var>.<li><p>Append the parameter's value to <var>line</var>.</ol>

   <li><p>Append a U+003A COLON character (:) to <var>line</var>.<li><p>Append <var>value</var> to <var>line</var>.<li><p>Let <var>maximum length</var> be 75.<li>

    <p>While <var>line</var>'s <a href=https://infra.spec.whatwg.org/#string-length id=conversion-to-vcard:string-length data-x-internal=string-length>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>.<li><p>Remove the first <var>maximum length</var> code points from <var>line</var>.<li><p>Append a U+000D CARRIAGE RETURN character (CR) to <var>output</var>.<li><p>Append a U+000A LINE FEED character (LF) to <var>output</var>.<li><p>Append a U+0020 SPACE character to <var>output</var>.<li><p>Let <var>maximum length</var> be 74.</ol>

   <li><p>Append (what remains of) <var>line</var> to <var>output</var>.<li><p>Append a U+000D CARRIAGE RETURN character (CR) to <var>output</var>.<li><p>Append a U+000A LINE FEED character (LF) to <var>output</var>.</ol>

  <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.<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.<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>.<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>.</ol>

   <li><p>Return <var>value</var>.</ol>

  <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.<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.<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>.</ol>

  <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 (\).<li><p>Prefix every U+002C COMMA character (,) in <var>value</var> with a U+005C REVERSE
   SOLIDUS character (\).<li><p>Prefix every U+003B SEMICOLON character (;) in <var>value</var> with a U+005C
   REVERSE SOLIDUS character (\).<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).<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).<li><p>Return the mutated <var>value</var>.</ol>

  <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>&quot;jack&quot;</c-> <c- e>itemscope</c-> <c- e>itemtype</c-><c- o>=</c-><c- s>&quot;http://microformats.org/profile/hcard&quot;</c-><c- p>&gt;</c->
 <c- p>&lt;</c-><c- f>h1</c-> <c- e>itemprop</c-><c- o>=</c-><c- s>&quot;fn&quot;</c-><c- p>&gt;</c->
  <c- p>&lt;</c-><c- f>span</c-> <c- e>itemprop</c-><c- o>=</c-><c- s>&quot;n&quot;</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>&quot;given-name&quot;</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>&quot;family-name&quot;</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>&quot;photo&quot;</c-> <c- e>alt</c-><c- o>=</c-><c- s>&quot;&quot;</c-> <c- e>src</c-><c- o>=</c-><c- s>&quot;jack-bauer.jpg&quot;</c-><c- p>&gt;</c->
 <c- p>&lt;</c-><c- f>p</c-> <c- e>itemprop</c-><c- o>=</c-><c- s>&quot;org&quot;</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>&quot;organization-name&quot;</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>&quot;organization-unit&quot;</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>&quot;adr&quot;</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>&quot;street-address&quot;</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>&quot;locality&quot;</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>&quot;region&quot;</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>&quot;postal-code&quot;</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>&quot;country-name&quot;</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>&quot;geo&quot;</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>&quot;tel&quot;</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>&quot;value&quot;</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>&quot;type&quot;</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>&quot;type&quot;</c-> <c- e>content</c-><c- o>=</c-><c- s>&quot;voice&quot;</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>&quot;url&quot;</c-> <c- e>href</c-><c- o>=</c-><c- s>&quot;https://en.wikipedia.org/wiki/Jack_Bauer&quot;</c-><c- p>&gt;</c->I&apos;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>&quot;url&quot;</c-> <c- e>href</c-><c- o>=</c-><c- s>&quot;http://www.jackbauerfacts.com/&quot;</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>&quot;email&quot;</c-><c- p>&gt;&lt;</c-><c- f>a</c-> <c- e>href</c-><c- o>=</c-><c- s>&quot;mailto:j.bauer@la.ctu.gov.invalid&quot;</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>&quot;tel&quot;</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>&quot;value&quot;</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>&quot;type&quot;</c-> <c- e>content</c-><c- o>=</c-><c- s>&quot;cell&quot;</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>&quot;2008-07-20 21:00:00+01:00&quot;</c-><c- p>&gt;</c->
  <c- p>&lt;</c-><c- f>meta</c-> <c- e>itemprop</c-><c- o>=</c-><c- s>&quot;rev&quot;</c-> <c- e>content</c-><c- o>=</c-><c- s>&quot;2008-07-20 21:00:00+01:00&quot;</c-><c- p>&gt;</c->
  <c- p>&lt;</c-><c- f>p</c-> <c- e>itemprop</c-><c- o>=</c-><c- s>&quot;tel&quot;</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>&quot;type&quot;</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>&quot;value&quot;</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>&quot;http://microformats.org/profile/hcard&quot;</c-><c- p>&gt;</c->
 <c- p>&lt;</c-><c- f>strong</c-> <c- e>itemprop</c-><c- o>=</c-><c- s>&quot;fn&quot;</c-><c- p>&gt;&lt;</c-><c- f>span</c-> <c- e>itemprop</c-><c- o>=</c-><c- s>&quot;n&quot;</c-> <c- e>itemscope</c-><c- p>&gt;&lt;</c-><c- f>span</c-> <c- e>itemprop</c-><c- o>=</c-><c- s>&quot;given-name&quot;</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>&quot;family-name&quot;</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>&quot;adr&quot;</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>&quot;street-address&quot;</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>&quot;street-address&quot;</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>&quot;locality&quot;</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>&quot;region&quot;</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>&quot;postal-code&quot;</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>&quot;http://microformats.org/profile/hcard&quot;</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>&quot;n&quot;</c-> <c- e>itemscope</c-><c- p>&gt;&lt;</c-><c- f>span</c-> <c- e>itemprop</c-><c- o>=</c-><c- s>&quot;given-name&quot;</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>&quot;family-name&quot;</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 the iCalendar specification, 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><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>

   <dt><dfn id=md-vevent-categories><code>categories</code></dfn><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>

   <dt><dfn id=md-vevent-class><code>class</code></dfn><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><code>private</code><li><code>confidential</code></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>

   <dt><dfn id=md-vevent-comment><code>comment</code></dfn><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>

   <dt><dfn id=md-vevent-description><code>description</code></dfn><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>

   <dt><dfn id=md-vevent-geo><code>geo</code></dfn><dd>

    <p>Gives the geographical position of the event.</p>

    <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>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>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>A U+003B SEMICOLON character (;).<li>Optionally, either a U+002B PLUS SIGN character (+) or a U+002D HYPHEN-MINUS character
     (-).<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>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>.</ol>

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

   <dt><dfn id=md-vevent-location><code>location</code></dfn><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>

   <dt><dfn id=md-vevent-resources><code>resources</code></dfn><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>

   <dt><dfn id=md-vevent-status><code>status</code></dfn><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><code>confirmed</code><li><code>cancelled</code></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>

   <dt><dfn id=md-vevent-summary><code>summary</code></dfn><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>

   <dt><dfn id=md-vevent-dtend><code>dtend</code></dfn><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>

   <dt><dfn id=md-vevent-dtstart><code>dtstart</code></dfn><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>

   <dt><dfn id=md-vevent-duration><code>duration</code></dfn><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>

   <dt><dfn id=md-vevent-transp><code>transp</code></dfn><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><code>transparent</code></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>

   <dt><dfn id=md-vevent-contact><code>contact</code></dfn><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>

   <dt><dfn id=md-vevent-url><code>url</code></dfn><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>

   <dt><dfn id=md-vevent-uid><code>uid</code></dfn><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>

   <dt><dfn id=md-vevent-exdate><code>exdate</code></dfn><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>

   <dt><dfn id=md-vevent-rdate><code>rdate</code></dfn><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:

    <ul><li>A <a href=#valid-date-string id=vevent:valid-date-string-5>valid date string</a>.<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>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>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>.</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>

   <dt><dfn id=md-vevent-rrule><code>rrule</code></dfn><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 the iCalendar specification. <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>

   <dt><dfn id=md-vevent-created><code>created</code></dfn><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>

   <dt><dfn id=md-vevent-last-modified><code>last-modified</code></dfn><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>

   <dt><dfn id=md-vevent-sequence><code>sequence</code></dfn><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>

   </dl>

  <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>A U+0050 LATIN CAPITAL LETTER P character (P).<li>One of the following:

    <ul><li> 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. <li> At least one, and possible both in this order, of the following:

      <ol><li> 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. <li> 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:

        <ol><li> 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. <li> 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. <li> 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. </ol>

      </ol>

     </ul>

   </ol>


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

  <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.<li><p>Let <var>output</var> be an empty string.<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>.<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>.<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>.<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>.<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><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><dd>

        <p>Skip the property.</p>

       <dt>If the property is <code id=conversion-to-icalendar:md-vevent-dtend><a href=#md-vevent-dtend>dtend</a></code><dt>If the property is <code id=conversion-to-icalendar:md-vevent-dtstart><a href=#md-vevent-dtstart>dtstart</a></code><dt>If the property is <code id=conversion-to-icalendar:md-vevent-exdate><a href=#md-vevent-exdate>exdate</a></code><dt>If the property is <code id=conversion-to-icalendar:md-vevent-rdate><a href=#md-vevent-rdate>rdate</a></code><dt>If the property is <code id=conversion-to-icalendar:md-vevent-created><a href=#md-vevent-created>created</a></code><dt>If the property is <code id=conversion-to-icalendar:md-vevent-last-modified><a href=#md-vevent-last-modified>last-modified</a></code><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>

       <dt>Otherwise<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>

       </dl>

     <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>.</ol>

   <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>.</ol>

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

    <p>If there is an annotation:</p>

    <ol><li><p>Append a U+003B SEMICOLON character (;) to <var>line</var>.<li><p>Append the annotation to <var>line</var>.</ol>

   <li><p>Append a U+003A COLON character (:) to <var>line</var>.<li><p>Prefix every U+005C REVERSE SOLIDUS character (\) in <var>value</var> with
   another U+005C REVERSE SOLIDUS character (\).<li><p>Prefix every U+002C COMMA character (,) in <var>value</var> with a U+005C REVERSE
   SOLIDUS character (\).<li><p>Prefix every U+003B SEMICOLON character (;) in <var>value</var> with a U+005C
   REVERSE SOLIDUS character (\).<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).<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).<li><p>Append <var>value</var> to <var>line</var>.<li><p>Let <var>maximum length</var> be 75.<li>

    <p>While <var>line</var>'s <a href=https://infra.spec.whatwg.org/#string-length id=conversion-to-icalendar:string-length data-x-internal=string-length>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>.<li><p>Remove the first <var>maximum length</var> code points from <var>line</var>.<li><p>Append a U+000D CARRIAGE RETURN character (CR) to <var>output</var>.<li><p>Append a U+000A LINE FEED character (LF) to <var>output</var>.<li><p>Append a U+0020 SPACE character to <var>output</var>.<li><p>Let <var>maximum length</var> be 74.</ol>

   <li><p>Append (what remains of) <var>line</var> to <var>output</var>.<li><p>Append a U+000D CARRIAGE RETURN character (CR) to <var>output</var>.<li><p>Append a U+000A LINE FEED character (LF) to <var>output</var>.</ol>

  <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>&quot;http://microformats.org/profile/hcalendar#vevent&quot;</c-><c- p>&gt;</c->
 ...
 <c- p>&lt;</c-><c- f>h1</c-> <c- e>itemprop</c-><c- o>=</c-><c- s>&quot;summary&quot;</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>&quot;dtstart&quot;</c-> <c- e>datetime</c-><c- o>=</c-><c- s>&quot;2009-05-05T19:00:00Z&quot;</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>&quot;dtend&quot;</c-> <c- e>datetime</c-><c- o>=</c-><c- s>&quot;2009-05-05T21:00:00Z&quot;</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>&quot;http://livebrum.co.uk/2009/05/05/bluesday-tuesday-money-road&quot;</c->
    <c- e>rel</c-><c- o>=</c-><c- s>&quot;bookmark&quot;</c-> <c- e>itemprop</c-><c- o>=</c-><c- s>&quot;url&quot;</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>&quot;location&quot;</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>&quot;Add to Calendar&quot;</c->
           <c- e>onclick</c-><c- o>=</c-><c- s>&quot;location = getCalendar(this)&quot;</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>&quot;description&quot;</c-> <c- e>content</c-><c- o>=</c-><c- s>&quot;via livebrum.co.uk&quot;</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>&quot;http://microformats.org/profile/hcalendar#vevent&quot;</c-><c- p>&gt;</c->
 <c- p>&lt;</c-><c- f>p</c-><c- p>&gt;</c->I&apos;m going to
 <c- p>&lt;</c-><c- f>strong</c-> <c- e>itemprop</c-><c- o>=</c-><c- s>&quot;summary&quot;</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>&quot;dtstart&quot;</c-> <c- e>datetime</c-><c- o>=</c-><c- s>&quot;2009-05-05T19:00:00Z&quot;</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>&quot;dtend&quot;</c-> <c- e>datetime</c-><c- o>=</c-><c- s>&quot;2009-05-05T21:00:00Z&quot;</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>&quot;location&quot;</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>&quot;http://livebrum.co.uk/2009/05/05/bluesday-tuesday-money-road&quot;</c->
       <c- e>itemprop</c-><c- o>=</c-><c- s>&quot;url&quot;</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>&quot;description&quot;</c-> <c- e>content</c-><c- o>=</c-><c- s>&quot;via livebrum.co.uk&quot;</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><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>

   <dt><dfn id=md-work-title><code>title</code></dfn><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>

   <dt><dfn id=md-work-author><code>author</code></dfn><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>

   <dt><dfn id=md-work-license><code>license</code></dfn><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>

   </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>&quot;http://n.whatwg.org/work&quot;</c-></strong><c- p>&gt;</c->
 <c- p>&lt;</c-><c- f>img</c-> <strong><c- e>itemprop</c-><c- o>=</c-><c- s>&quot;work&quot;</c-></strong> <c- e>src</c-><c- o>=</c-><c- s>&quot;mypond.jpeg&quot;</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>&quot;title&quot;</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>&quot;license&quot;</c-></strong>
  <c- e>href</c-><c- o>=</c-><c- s>&quot;https://creativecommons.org/licenses/by-sa/4.0/&quot;</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>&quot;license&quot;</c-></strong>
  <c- e>href</c-><c- o>=</c-><c- s>&quot;http://www.opensource.org/licenses/mit-license.php&quot;</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>

  <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.<li><p>Let <var>items</var> be an empty array.<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>.<li><p>Add an entry to <var>result</var> called "<code>items</code>" whose
   value is the array <var>items</var>.<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></ol>

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

  <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.<li><p>If no <var>memory</var> was passed to the algorithm, let <var>memory</var> be an empty list.<li><p>Add <var>item</var> to <var>memory</var>.<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><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>.<li><p>Let <var>properties</var> be an empty object.<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>.<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.<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.<li><p>Append <var>value</var> to the entry named <var>name</var> in <var>properties</var>.</ol>

     </ol>

   <li><p>Add an entry to <var>result</var> called "<code>properties</code>" whose
   value is the object <var>properties</var>.<li><p>Return <var>result</var>.</ol>

  <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>&quot;en&quot;</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>&quot;http://schema.org/BlogPosting&quot;</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>&quot;headline&quot;</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>&quot;datePublished&quot;</c-> <c- e>datetime</c-><c- o>=</c-><c- s>&quot;2013-08-29&quot;</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>&quot;url&quot;</c-> <c- e>href</c-><c- o>=</c-><c- s>&quot;?comments=0&quot;</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&apos;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>&quot;comment&quot;</c-> <c- e>itemscope</c-> <c- e>itemtype</c-><c- o>=</c-><c- s>&quot;http://schema.org/UserComments&quot;</c-> <c- e>id</c-><c- o>=</c-><c- s>&quot;c1&quot;</c-><c- p>&gt;</c->
   <c- p>&lt;</c-><c- f>link</c-> <c- e>itemprop</c-><c- o>=</c-><c- s>&quot;url&quot;</c-> <c- e>href</c-><c- o>=</c-><c- s>&quot;#c1&quot;</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>&quot;creator&quot;</c-> <c- e>itemscope</c-> <c- e>itemtype</c-><c- o>=</c-><c- s>&quot;http://schema.org/Person&quot;</c-><c- p>&gt;</c->
     <c- p>&lt;</c-><c- f>span</c-> <c- e>itemprop</c-><c- o>=</c-><c- s>&quot;name&quot;</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>&quot;commentTime&quot;</c-> <c- e>datetime</c-><c- o>=</c-><c- s>&quot;2013-08-29&quot;</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>&quot;comment&quot;</c-> <c- e>itemscope</c-> <c- e>itemtype</c-><c- o>=</c-><c- s>&quot;http://schema.org/UserComments&quot;</c-> <c- e>id</c-><c- o>=</c-><c- s>&quot;c2&quot;</c-><c- p>&gt;</c->
   <c- p>&lt;</c-><c- f>link</c-> <c- e>itemprop</c-><c- o>=</c-><c- s>&quot;url&quot;</c-> <c- e>href</c-><c- o>=</c-><c- s>&quot;#c2&quot;</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>&quot;creator&quot;</c-> <c- e>itemscope</c-> <c- e>itemtype</c-><c- o>=</c-><c- s>&quot;http://schema.org/Person&quot;</c-><c- p>&gt;</c->
     <c- p>&lt;</c-><c- f>span</c-> <c- e>itemprop</c-><c- o>=</c-><c- s>&quot;name&quot;</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>&quot;commentTime&quot;</c-> <c- e>datetime</c-><c- o>=</c-><c- s>&quot;2013-08-29&quot;</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 &quot;we got it down&quot;...<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>&quot;items&quot;</c-><c- o>:</c-> <c- p>[</c->
    <c- p>{</c->
      <c- u>&quot;type&quot;</c-><c- o>:</c-> <c- p>[</c-> <c- u>&quot;http://schema.org/BlogPosting&quot;</c-> <c- p>],</c->
      <c- u>&quot;properties&quot;</c-><c- o>:</c-> <c- p>{</c->
        <c- u>&quot;headline&quot;</c-><c- o>:</c-> <c- p>[</c-> <c- u>&quot;Progress report&quot;</c-> <c- p>],</c->
        <c- u>&quot;datePublished&quot;</c-><c- o>:</c-> <c- p>[</c-> <c- u>&quot;2013-08-29&quot;</c-> <c- p>],</c->
        <c- u>&quot;url&quot;</c-><c- o>:</c-> <c- p>[</c-> <c- u>&quot;https://blog.example.com/progress-report?comments=0&quot;</c-> <c- p>],</c->
        <c- u>&quot;comment&quot;</c-><c- o>:</c-> <c- p>[</c->
          <c- p>{</c->
            <c- u>&quot;type&quot;</c-><c- o>:</c-> <c- p>[</c-> <c- u>&quot;http://schema.org/UserComments&quot;</c-> <c- p>],</c->
            <c- u>&quot;properties&quot;</c-><c- o>:</c-> <c- p>{</c->
              <c- u>&quot;url&quot;</c-><c- o>:</c-> <c- p>[</c-> <c- u>&quot;https://blog.example.com/progress-report#c1&quot;</c-> <c- p>],</c->
              <c- u>&quot;creator&quot;</c-><c- o>:</c-> <c- p>[</c->
                <c- p>{</c->
                  <c- u>&quot;type&quot;</c-><c- o>:</c-> <c- p>[</c-> <c- u>&quot;http://schema.org/Person&quot;</c-> <c- p>],</c->
                  <c- u>&quot;properties&quot;</c-><c- o>:</c-> <c- p>{</c->
                    <c- u>&quot;name&quot;</c-><c- o>:</c-> <c- p>[</c-> <c- u>&quot;Greg&quot;</c-> <c- p>]</c->
                  <c- p>}</c->
                <c- p>}</c->
              <c- p>],</c->
              <c- u>&quot;commentTime&quot;</c-><c- o>:</c-> <c- p>[</c-> <c- u>&quot;2013-08-29&quot;</c-> <c- p>]</c->
            <c- p>}</c->
          <c- p>},</c->
          <c- p>{</c->
            <c- u>&quot;type&quot;</c-><c- o>:</c-> <c- p>[</c-> <c- u>&quot;http://schema.org/UserComments&quot;</c-> <c- p>],</c->
            <c- u>&quot;properties&quot;</c-><c- o>:</c-> <c- p>{</c->
              <c- u>&quot;url&quot;</c-><c- o>:</c-> <c- p>[</c-> <c- u>&quot;https://blog.example.com/progress-report#c2&quot;</c-> <c- p>],</c->
              <c- u>&quot;creator&quot;</c-><c- o>:</c-> <c- p>[</c->
                <c- p>{</c->
                  <c- u>&quot;type&quot;</c-><c- o>:</c-> <c- p>[</c-> <c- u>&quot;http://schema.org/Person&quot;</c-> <c- p>],</c->
                  <c- u>&quot;properties&quot;</c-><c- o>:</c-> <c- p>{</c->
                    <c- u>&quot;name&quot;</c-><c- o>:</c-> <c- p>[</c-> <c- u>&quot;Charlotte&quot;</c-> <c- p>]</c->
                  <c- p>}</c->
                <c- p>}</c->
              <c- p>],</c->
              <c- u>&quot;commentTime&quot;</c-><c- o>:</c-> <c- p>[</c-> <c- u>&quot;2013-08-29&quot;</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 <dfn><code>hidden</code></dfn> attribute<a href=#the-hidden-attribute class=self-link></a></h3><div class=status><input onclick=toggleStatus(this) value=⋰ type=button><p class=support><strong>Support:</strong> hidden<span class="and_chr yes"><span>Chrome for Android</span> <span>67+</span></span><span class="chrome yes"><span>Chrome</span> <span>6+</span></span><span class="ios_saf yes"><span>iOS Safari</span> <span>5.0+</span></span><span class="and_uc yes"><span>UC Browser for Android</span> <span>11.8+</span></span><span class="firefox yes"><span>Firefox</span> <span>4+</span></span><span class="ie yes"><span>IE</span> <span>11+</span></span><span class="op_mini yes"><span>Opera Mini</span> <span>all+</span></span><span class="safari yes"><span>Safari</span> <span>5.1+</span></span><span class="edge yes"><span>Edge</span> <span>12+</span></span><span class="samsung yes"><span>Samsung Internet</span> <span>4+</span></span><span class="opera yes"><span>Opera</span> <span>11.1+</span></span><span class="android yes"><span>Android Browser</span> <span>4+</span></span><p class=caniuse>Source: <a href="https://caniuse.com/#feat=hidden">caniuse.com</a></div>

  <p>All <a href=#html-elements id=the-hidden-attribute:html-elements>HTML elements</a> may have the <code id=the-hidden-attribute:the-hidden-attribute><a href=#the-hidden-attribute>hidden</a></code> content
  attribute set. The <code id=the-hidden-attribute:the-hidden-attribute-2><a href=#the-hidden-attribute>hidden</a></code> attribute is a <a href=#boolean-attribute id=the-hidden-attribute:boolean-attribute>boolean
  attribute</a>. When specified on an element, 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 have the <code id=the-hidden-attribute:the-hidden-attribute-3><a href=#the-hidden-attribute>hidden</a></code> attribute specified. This requirement may be implemented
  indirectly through the style layer. For example, an HTML+CSS user agent could implement these
  requirements <a href=#hiddenCSS>using the rules suggested in the Rendering
  section</a>.</p>

  <p class=note>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 <code id=the-hidden-attribute:the-hidden-attribute-4><a href=#the-hidden-attribute>hidden</a></code> attribute. Authors therefore
  have to take care when writing their style sheets to make sure that the attribute is still styled
  as expected.</p>

  <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>&quot;login&quot;</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&apos;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>&apos;login&apos;</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>&apos;game&apos;</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>&quot;game&quot;</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:the-hidden-attribute-5><a href=#the-hidden-attribute>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:the-hidden-attribute-6><a href=#the-hidden-attribute>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:the-hidden-attribute-7><a href=#the-hidden-attribute>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:the-hidden-attribute-8><a href=#the-hidden-attribute>hidden</a></code> must not
  <a href=#hyperlink id=the-hidden-attribute:hyperlink>hyperlink</a> to elements that are <code id=the-hidden-attribute:the-hidden-attribute-9><a href=#the-hidden-attribute>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:the-hidden-attribute-10><a href=#the-hidden-attribute>hidden</a></code> must similarly not refer to elements that are
  <code id=the-hidden-attribute:the-hidden-attribute-11><a href=#the-hidden-attribute>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:the-hidden-attribute-12><a href=#the-hidden-attribute>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:the-hidden-attribute-13><a href=#the-hidden-attribute>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/aria.html#aria-describedby>aria-describedby</a></code> attribute to refer to descriptions that are
   themselves <code id=the-hidden-attribute:the-hidden-attribute-14><a href=#the-hidden-attribute>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 images 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:the-hidden-attribute-15><a href=#the-hidden-attribute>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:the-hidden-attribute-16><a href=#the-hidden-attribute>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>

  

  <p>The <dfn id=dom-hidden><code>hidden</code></dfn> IDL attribute must <a href=#reflect id=the-hidden-attribute:reflect>reflect</a>
  the content attribute of the same name.</p>

  



  <h3 id=inert-subtrees><span class=secno>6.2</span> Inert subtrees<a href=#inert-subtrees class=self-link></a></h3>

  <p class=note>This section <strong>does not</strong> define or create any content attribute
  named "inert". This section merely defines an abstract <em>concept</em> of
  <a href=#inert id=inert-subtrees:inert>inertness</a>.</p>

  <p>A node (in particular elements and text nodes) can be marked as <dfn id=inert>inert</dfn>. When a node
  is <a href=#inert id=inert-subtrees:inert-2>inert</a>, then the user agent must act as if the node was absent for the purposes of
  targeting user interaction events, may ignore the node for the purposes of text search user
  interfaces (commonly known as "find in page"), and may prevent the user from selecting text in
  that node. User agents should allow the user to override the restrictions on search and text
  selection, however.</p>

  <p class=example>For example, consider a page that consists of just a single <a href=#inert id=inert-subtrees:inert-3>inert</a>
  paragraph positioned in the middle of a <code id=inert-subtrees:the-body-element><a href=#the-body-element>body</a></code>. If a user moves their pointing device
  from the <code id=inert-subtrees:the-body-element-2><a href=#the-body-element>body</a></code> over to the <a href=#inert id=inert-subtrees:inert-4>inert</a> paragraph and clicks on the paragraph,
  no <code id=inert-subtrees:event-mouseover><a data-x-internal=event-mouseover href=https://w3c.github.io/uievents/#event-type-mouseover>mouseover</a></code> event would be fired, and the <code id=inert-subtrees:event-mousemove><a data-x-internal=event-mousemove href=https://w3c.github.io/uievents/#event-type-mousemove>mousemove</a></code> and <code id=inert-subtrees:event-click><a data-x-internal=event-click href=https://w3c.github.io/uievents/#event-type-click>click</a></code> events would
  be fired on the <code id=inert-subtrees:the-body-element-3><a href=#the-body-element>body</a></code> element rather than the paragraph.</p>

  <p class=note>When a node is inert, it generally cannot be focused. Inert nodes that are <a href=#concept-command id=inert-subtrees:concept-command>commands</a> will also get disabled.</p>

  <p>While a <a href=#browsing-context-container id=inert-subtrees:browsing-context-container>browsing context container</a> is marked as <a href=#inert id=inert-subtrees:inert-5>inert</a>, its
  <a href=#nested-browsing-context id=inert-subtrees:nested-browsing-context>nested browsing context</a>'s <a href=#active-document id=inert-subtrees:active-document>active document</a>, and all nodes in that
  <code id=inert-subtrees:document><a href=#document>Document</a></code>, must be marked as <a href=#inert id=inert-subtrees:inert-6>inert</a>.</p>

  <p><span id=expressly-inert-control></span><span id=expressly-inert-dialog></span>An element
  is <dfn id=expressly-inert>expressly inert</dfn> if it is <a href=#inert id=inert-subtrees:inert-7>inert</a> and its <a id=inert-subtrees:node-document href=https://dom.spec.whatwg.org/#concept-node-document data-x-internal=node-document>node document</a> is
  not <a href=#inert id=inert-subtrees:inert-8>inert</a>.</p>

  <p>A <code id=inert-subtrees:document-2><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=inert-subtrees:the-dialog-element><a href=#the-dialog-element>dialog</a></code> element in
  <var>document</var>'s <a id=inert-subtrees:top-layer href=https://fullscreen.spec.whatwg.org/#top-layer data-x-internal=top-layer>top layer</a>. While <var>document</var> is so blocked, every node
  that is <a id=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 href=https://dom.spec.whatwg.org/#concept-shadow-including-descendant id=inert-subtrees:shadow-including-descendant data-x-internal=shadow-including-descendant>shadow-including
  descendants</a>, must be marked <a href=#inert id=inert-subtrees:inert-9>inert</a>. (The elements excepted by this paragraph
  can additionally be marked <a href=#inert id=inert-subtrees:inert-10>inert</a> through other means; being part of a modal dialog
  does not "protect" a node from being marked <a href=#inert id=inert-subtrees:inert-11>inert</a>.)</p>

  <p class=note>The <code id=inert-subtrees:the-dialog-element-2><a href=#the-dialog-element>dialog</a></code> element's <code id=inert-subtrees:dom-dialog-showmodal><a href=#dom-dialog-showmodal>showModal()</a></code> method causes this mechanism to trigger, by <a href=https://fullscreen.spec.whatwg.org/#top-layer-add id=inert-subtrees:top-layer-add data-x-internal=top-layer-add>adding</a> the <code id=inert-subtrees:the-dialog-element-3><a href=#the-dialog-element>dialog</a></code> element to its <a id=inert-subtrees:node-document-2 href=https://dom.spec.whatwg.org/#concept-node-document data-x-internal=node-document>node
  document</a>'s <a id=inert-subtrees:top-layer-2 href=https://fullscreen.spec.whatwg.org/#top-layer data-x-internal=top-layer>top layer</a>.</p>




  <h3 id=activation><span class=secno>6.3</span> Activation<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>
  

  <p id=allowed-to-show-a-popup>An algorithm is <dfn id=triggered-by-user-activation data-export="">triggered by user
  activation</dfn> if any of the following conditions is true:</p>

  <ul><li><p>The <a href=#concept-task id=activation:concept-task>task</a> in which the algorithm is running is currently
   processing an <a id=activation:activation-behaviour-4 href=https://dom.spec.whatwg.org/#eventtarget-activation-behavior data-x-internal=activation-behaviour>activation behavior</a> whose <code id=activation:event-click-2><a data-x-internal=event-click href=https://w3c.github.io/uievents/#event-type-click>click</a></code>
   event's <code id=activation: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.<li>
    <p>The <a href=#concept-task id=activation:concept-task-2>task</a> in which the algorithm is running is currently
    running the event listener for an event whose <code id=activation:dom-event-istrusted-2><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=activation: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 class=brief><li><code id=activation:event-change><a href=#event-change>change</a></code><li><code id=activation:event-click-3><a data-x-internal=event-click href=https://w3c.github.io/uievents/#event-type-click>click</a></code><li><code id=activation:event-contextmenu><a href=#event-contextmenu>contextmenu</a></code><li><code id=activation:event-dblclick><a data-x-internal=event-dblclick href=https://w3c.github.io/uievents/#event-type-dblclick>dblclick</a></code><li><code id=activation:event-mouseup><a data-x-internal=event-mouseup href=https://w3c.github.io/uievents/#event-type-mouseup>mouseup</a></code><li><code id=activation:event-pointerup><a data-x-internal=event-pointerup href=https://w3c.github.io/pointerevents/#the-pointerup-event>pointerup</a></code><li><code id=activation:event-reset><a href=#event-reset>reset</a></code><li><code id=activation:event-submit><a href=#event-submit>submit</a></code><li><code id=activation:event-touchend><a data-x-internal=event-touchend href=https://w3c.github.io/touch-events/#event-touchend>touchend</a></code></ul>

   <li>
    <p>The <a href=#concept-task id=activation:concept-task-3>task</a> in which the algorithm is running was <a href=#queue-a-task id=activation:queue-a-task>queued</a> by an algorithm that was <a href=#triggered-by-user-activation id=activation:triggered-by-user-activation>triggered by user
    activation</a>, and the chain of such algorithms started within a user-agent defined
    timeframe.</p>

    <p class=example>For example, if a user clicked a button, it might be acceptable for a popup
    to result from that after 4 seconds, but it would likely not be acceptable for a popup to result
    from that after 4 hours.</p>
   </ul>

  


  

  <dl class=domintro><dt><var>element</var> . <code id=dom-click-dev><a href=#dom-click>click</a></code>()<dd>

    <p>Acts as if the element was clicked.</p>

   </dl>

  

  <p>Each element has an associated <dfn id=click-in-progress-flag>click in progress flag</dfn>, which is initially unset.</p>

  <p>The <dfn id=dom-click><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.<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.<li><p>Set this element's <a href=#click-in-progress-flag id=activation:click-in-progress-flag-2>click in progress flag</a>.<li><p><a href=#fire-a-synthetic-mouse-event id=activation:fire-a-synthetic-mouse-event>Fire a synthetic mouse event</a> at this element, with the <var>not trusted
   flag</var> set.<li><p>Unset this element's <a href=#click-in-progress-flag id=activation:click-in-progress-flag-3>click in progress flag</a>.</ol>

  



  <h3 id=focus><span class=secno>6.4</span> Focus<a href=#focus class=self-link></a></h3>

  
  
  
  

  

  <h4 id=introduction-8><span class=secno>6.4.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>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.4.2</span> Data model<a href=#data-model class=self-link></a></h4>

  <p>The term <dfn id=focusable-area>focusable area</dfn> is used to refer to regions of the interface that can become
  the target of 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 id=th-fa-dom-rep><a href=#dom-anchor id=data-model:dom-anchor-4>DOM anchor</a>
    <tr><th colspan=2 id=th-fa-examples>Examples

   <tbody><tr><th headers=th-fa-area id=td-fa-1 class=data-header>
     Elements that have their <a href=#specially-focusable id=data-model:specially-focusable>tabindex focus flag</a> set, that are not <a href=#concept-element-disabled id=data-model:concept-element-disabled>actually disabled</a>, that are not <a href=#expressly-inert id=data-model:expressly-inert>expressly
     inert</a>, and that are either <a href=#being-rendered id=data-model:being-rendered>being rendered</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>. 
     <td headers="td-fa-1 th-fa-dom-rep">
     The element itself.
    <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:text-(type=text)-state-and-search-state-(type=search)"><a href="#text-(type=text)-state-and-search-state-(type=search)">&lt;input
     type=text></a></code>, sometimes <code id=data-model:the-a-element><a href=#the-a-element>&lt;a href=""></a></code> (depending on platform
     conventions).

   <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=#expressly-inert id=data-model:expressly-inert-2>expressly
     inert</a>.
     <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.
    <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>&quot;Enter Door&quot;</c-> <c- e>coords</c-><c- o>=</c-><c- s>&quot;10,10,100,200&quot;</c-> <c- e>href</c-><c- o>=</c-><c- s>&quot;door.html&quot;</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>&quot;images/innerwall.jpeg&quot;</c-> <c- e>alt</c-><c- o>=</c-><c- s>&quot;There is a white wall here, with a door.&quot;</c-> <c- e>usemap</c-><c- o>=</c-><c- s>&quot;#wallmap&quot;</c-><c- p>&gt;</c->
...
<c- p>&lt;</c-><c- f>img</c-> <c- e>src</c-><c- o>=</c-><c- s>&quot;images/outerwall.jpeg&quot;</c-> <c- e>alt</c-><c- o>=</c-><c- s>&quot;There is a red wall here, with a door.&quot;</c-> <c- e>usemap</c-><c- o>=</c-><c- s>&quot;#wallmap&quot;</c-><c- p>&gt;</c-></code></pre>
     </div>

   <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=#expressly-inert id=data-model:expressly-inert-3>expressly
     inert</a>.
     <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.
    <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 that is exposed to the user</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></a></code>, the two range control widgets in a <code id="data-model:range-state-(type=range)"><a href="#range-state-(type=range)">&lt;input type=range multiple></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 enabled the element to be opened or closed using
     keyboard input.</p>

   <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=#expressly-inert id=data-model:expressly-inert-4>expressly inert</a>. 
     <td headers="td-fa-4 th-fa-dom-rep">
     The element for which the box that the scrollable region scrolls was created.
    <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>

   <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/visuren.html#viewport data-x-internal=viewport>viewport</a> of a <code id=data-model:document><a href=#document>Document</a></code> that has a <a href=#concept-document-bc id=data-model:concept-document-bc>browsing context</a> and is not <a href=#inert id=data-model:inert>inert</a>.
     <td headers="td-fa-5 th-fa-dom-rep">
     The <code id=data-model:document-2><a href=#document>Document</a></code> for which the <a id=data-model:viewport-2 href=https://drafts.csswg.org/css2/visuren.html#viewport data-x-internal=viewport>viewport</a> was created.
    <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>

   <tbody><tr><th headers=th-fa-area id=td-fa-6 class=data-header>
     Any other element or part of an element, especially to aid with accessibility or to better
     match platform conventions.
     <td headers="td-fa-6 th-fa-dom-rep">
     The element.
    <tr><td colspan=2 headers="td-fa-6 th-fa-examples">
     <p class=example>A user agent could make all list item bullets focusable, 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 focusable, so that their advisory information can
     be accessed.</p>

  </table>

  <p id=bc-focus-ergo-bcc-focus class=note>A <a href=#browsing-context-container id=data-model:browsing-context-container>browsing context 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=#browsing-context-container id=data-model:browsing-context-container-2>browsing context
  container</a> get immediately routed to the <a href=#nested-browsing-context id=data-model:nested-browsing-context>nested browsing context</a>'s <a href=#active-document id=data-model:active-document>active
  document</a>. Similarly, in sequential focus navigation a <a href=#browsing-context-container id=data-model:browsing-context-container-3>browsing context
  container</a> essentially acts merely as a placeholder for its <a href=#nested-browsing-context id=data-model:nested-browsing-context-2>nested browsing
  context</a>'s <a href=#active-document id=data-model:active-document-2>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-3><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><a href=#focusable-area id=data-model:focusable-area-12>Focusable areas</a> in a <code id=data-model:document-4><a href=#document>Document</a></code>
  are ordered relative to the <a id=data-model:tree-order href=https://dom.spec.whatwg.org/#concept-tree-order data-x-internal=tree-order>tree order</a> of their <a href=#dom-anchor id=data-model:dom-anchor-7>DOM
  anchors</a>. <a href=#focusable-area id=data-model:focusable-area-13>Focusable areas</a> with the same <a href=#dom-anchor id=data-model:dom-anchor-8>DOM
  anchor</a> in a <code id=data-model:document-5><a href=#document>Document</a></code> are ordered relative to their CSS boxes' relative
  positions in a pre-order, depth-first traversal of the box tree. <a href=#refsCSS>[CSS]</a></p>

  <hr>

  <p>The <dfn id=currently-focused-area-of-a-top-level-browsing-context>currently focused area of a top-level browsing context</dfn> at any particular time is
  the <a href=#focusable-area id=data-model:focusable-area-14>focusable area</a> returned by this algorithm:</p>

  <ol><li><p>Let <var>candidate</var> be the <code id=data-model:document-6><a href=#document>Document</a></code> of the <a href=#top-level-browsing-context id=data-model:top-level-browsing-context>top-level
   browsing context</a>.<li><p>If the designated <a href=#focused-area-of-the-document id=data-model:focused-area-of-the-document>focused area of the document</a> is a <a href=#browsing-context-container id=data-model:browsing-context-container-4>browsing context
   container</a> with a non-null <a href=#nested-browsing-context id=data-model:nested-browsing-context-3>nested browsing context</a>, then let
   <var>candidate</var> be the <a href=#active-document id=data-model:active-document-3>active document</a> of that <a href=#browsing-context-container id=data-model:browsing-context-container-5>browsing context
   container</a>'s <a href=#nested-browsing-context id=data-model:nested-browsing-context-4>nested browsing context</a>, and redo this step.<li><p>If <var>candidate</var> has a <a href=#focused-area-of-the-document id=data-model:focused-area-of-the-document-2>focused
   area</a>, set <var>candidate</var> to <var>candidate</var>'s <a href=#focused-area-of-the-document id=data-model:focused-area-of-the-document-3>focused area</a>.<li><p>Return <var>candidate</var>.</ol>

  <p>An element that is the <a href=#dom-anchor id=data-model:dom-anchor-9>DOM anchor</a> of a <a href=#focusable-area id=data-model:focusable-area-15>focusable area</a> is said to <dfn id=gains-focus>gain focus</dfn> when that <a href=#focusable-area id=data-model:focusable-area-16>focusable area</a> becomes the <a href=#currently-focused-area-of-a-top-level-browsing-context id=data-model:currently-focused-area-of-a-top-level-browsing-context>currently
  focused area of a top-level browsing context</a>. When an element is the <a href=#dom-anchor id=data-model:dom-anchor-10>DOM anchor</a> of a
  <a href=#focusable-area id=data-model:focusable-area-17>focusable area</a> of the <a href=#currently-focused-area-of-a-top-level-browsing-context id=data-model:currently-focused-area-of-a-top-level-browsing-context-2>currently focused area of a top-level browsing context</a>,
  it is <dfn id=focused>focused</dfn>.</p>

  

  <p>The <dfn id=focus-chain>focus chain</dfn> of a <a href=#focusable-area id=data-model:focusable-area-18>focusable area</a> <var>subject</var> is the ordered
  list constructed as follows:</p>

  <ol><li><p>Let <var>current object</var> be <var>subject</var>.<li><p>Let <var>output</var> be an empty list.<li><p><i>Loop</i>: Append <var>current object</var> to <var>output</var>.<li>

    <p>If <var>current object</var> is an <code id=data-model:the-area-element-3><a href=#the-area-element>area</a></code> element's shape, append
    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>current object</var> is a <a href=#focusable-area id=data-model:focusable-area-19>focusable area</a> whose <a href=#dom-anchor id=data-model:dom-anchor-11>DOM
    anchor</a> is an element that is not <var>current object</var> itself, append that
    <a href=#dom-anchor id=data-model:dom-anchor-12>DOM anchor</a> element to <var>output</var>.</p>

   <li>

    <p>If <var>current object</var> is a <code id=data-model:document-7><a href=#document>Document</a></code> in a <a href=#nested-browsing-context id=data-model:nested-browsing-context-5>nested browsing
    context</a>, let <var>current object</var> be its <a href=#browsing-context-container id=data-model:browsing-context-container-6>browsing context container</a>,
    and return to the step labeled <i>loop</i>.</p>

   <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-browsing-context id=data-model:currently-focused-area-of-a-top-level-browsing-context-3>currently focused area of a top-level browsing
    context</a>) continues up the focus hierarchy up to the <code id=data-model:document-8><a href=#document>Document</a></code> of the
    <a href=#top-level-browsing-context id=data-model:top-level-browsing-context-2>top-level browsing context</a>.</p>

   </ol>

  


  <h4 id=the-tabindex-attribute><span class=secno>6.4.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>

  <p>The <dfn id=attr-tabindex><code>tabindex</code></dfn> content attribute allows authors to
  indicate that an element is supposed to be <a href=#focusable-area id=the-tabindex-attribute:focusable-area>focusable</a>, and
  whether it is supposed to be reachable using <a href=#sequential-focus-navigation id=the-tabindex-attribute:sequential-focus-navigation>sequential focus navigation</a> and, if so,
  what is to be the relative order of the element for the purposes of sequential focus navigation.
  The name "tab index" comes from the common use of the "tab" key to navigate through the focusable
  elements. The term "tabbing" refers to moving forward through the focusable elements that can be
  reached using sequential focus navigation.<div class=status><input onclick=toggleStatus(this) value=⋰ type=button><p class=support><strong>Support:</strong> tabindex-attr<span class="and_chr yes"><span>Chrome for Android</span> <span>67+</span></span><span class="chrome yes"><span>Chrome</span> <span>15+</span></span><span class="ios_saf yes"><span>iOS Safari</span> <span>3.2+</span></span><span class="firefox yes"><span>Firefox</span> <span>4+</span></span><span class="ie yes"><span>IE</span> <span>7+</span></span><span class="safari yes"><span>Safari</span> <span>5.1+</span></span><span class="edge yes"><span>Edge</span> <span>12+</span></span><span class="opera yes"><span>Opera</span> <span>9.5+</span></span><p class=caniuse>Source: <a href="https://caniuse.com/#feat=tabindex-attr">caniuse.com</a></div>

  <p>When the attribute is omitted, the user agent applies defaults. (There is no way to make an
  element that is <a href=#being-rendered id=the-tabindex-attribute:being-rendered>being rendered</a> be not focusable at all without <a href=#concept-element-disabled id=the-tabindex-attribute:concept-element-disabled>disabling</a> it or making it <a href=#inert id=the-tabindex-attribute:inert>inert</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-2>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 to be unreachable by
  <a href=#sequential-focus-navigation id=the-tabindex-attribute:sequential-focus-navigation-2>sequential focus navigation</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>

  

  <p>Each element can have a <dfn id=specially-focusable>tabindex focus flag</dfn> set, as defined
  below. This flag is a factor that contributes towards determining whether an element is a
  <a href=#focusable-area id=the-tabindex-attribute:focusable-area-3>focusable area</a>, as described in the previous section.</p>

  <p>If the <code id=the-tabindex-attribute:attr-tabindex-4><a href=#attr-tabindex>tabindex</a></code> attribute is specified on an element, it
  must be parsed using the <a href=#rules-for-parsing-integers id=the-tabindex-attribute:rules-for-parsing-integers>rules for parsing integers</a>. The attribute's values, or lack
  thereof, must be interpreted as follows:</p>

  <dl><dt>If the attribute is omitted or parsing the value returns an error<dd>

    <p>The user agent should follow platform conventions to determine if the element's
    <a href=#specially-focusable id=the-tabindex-attribute:specially-focusable>tabindex focus flag</a> is set and, if so, whether the element and any <a href=#focusable-area id=the-tabindex-attribute:focusable-area-4>focusable areas</a> that have the element as their <a href=#dom-anchor id=the-tabindex-attribute:dom-anchor>DOM anchor</a> can
    be reached using <a href=#sequential-focus-navigation id=the-tabindex-attribute:sequential-focus-navigation-3>sequential focus navigation</a>, and if so, what their relative
    position in the <a href=#sequential-focus-navigation-order id=the-tabindex-attribute:sequential-focus-navigation-order-2>sequential focus navigation order</a> is to be.</p>

    <p>Modulo platform conventions, it is suggested that for the following elements, the
    <a href=#specially-focusable id=the-tabindex-attribute:specially-focusable-2>tabindex focus flag</a> be set:</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><code id=the-tabindex-attribute:the-link-element><a href=#the-link-element>link</a></code> elements that have an <code id=the-tabindex-attribute:attr-link-href><a href=#attr-link-href>href</a></code> attribute<li><code id=the-tabindex-attribute:the-button-element><a href=#the-button-element>button</a></code> elements<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><code id=the-tabindex-attribute:the-select-element><a href=#the-select-element>select</a></code> elements<li><code id=the-tabindex-attribute:the-textarea-element><a href=#the-textarea-element>textarea</a></code> elements<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>Elements with a <code id=the-tabindex-attribute:the-draggable-attribute><a href=#the-draggable-attribute>draggable</a></code> attribute set, if that would
     enable the user agent to allow the user to begin a drag operations for those elements without
     the use of a pointing device<li><a href=https://w3c.github.io/editing/execCommand.html#editing-host id=the-tabindex-attribute:editing-host data-x-internal=editing-host>Editing hosts</a><li><a href=#browsing-context-container id=the-tabindex-attribute:browsing-context-container>Browsing context containers</a></ul>

   <dt id=negative-tabindex>If the value is a negative integer<dd>

    <p>The user agent must set the element's <a href=#specially-focusable id=the-tabindex-attribute:specially-focusable-3>tabindex focus flag</a>, but should omit the
    element from the <a href=#sequential-focus-navigation-order id=the-tabindex-attribute:sequential-focus-navigation-order-3>sequential focus navigation order</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-5><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>

   <dt>If the value is a zero<dd>

    <p>The user agent must set the element's <a href=#specially-focusable id=the-tabindex-attribute:specially-focusable-4>tabindex focus flag</a>, should allow the
    element and any <a href=#focusable-area id=the-tabindex-attribute:focusable-area-5>focusable areas</a> that have the element as their
    <a href=#dom-anchor id=the-tabindex-attribute:dom-anchor-2>DOM anchor</a> to be reached using <a href=#sequential-focus-navigation id=the-tabindex-attribute:sequential-focus-navigation-4>sequential focus navigation</a>, following
    platform conventions to determine the element's relative position in the <a href=#sequential-focus-navigation-order id=the-tabindex-attribute:sequential-focus-navigation-order-4>sequential focus
    navigation order</a>.</p>

   <dt>If the value is greater than zero<dd>

    <p>The user agent must set the element's <a href=#specially-focusable id=the-tabindex-attribute:specially-focusable-5>tabindex focus flag</a>, should allow 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> to be reached using sequential focus navigation, and should place the element
    — referenced as <var>candidate</var> below — and the aforementioned <a href=#focusable-area id=the-tabindex-attribute:focusable-area-7>focusable areas</a> in the <a href=#sequential-focus-navigation id=the-tabindex-attribute:sequential-focus-navigation-5>sequential focus navigation</a>
    order so that, relative to other <a href=#focusable-area id=the-tabindex-attribute:focusable-area-8>focusable areas</a> in the
    <a href=#sequential-focus-navigation-order id=the-tabindex-attribute:sequential-focus-navigation-order-5>sequential focus navigation order</a>, they are:</p>

    <ul><li>before any <a href=#focusable-area id=the-tabindex-attribute:focusable-area-9>focusable area</a> whose <a href=#dom-anchor id=the-tabindex-attribute:dom-anchor-4>DOM anchor</a> is an element whose <code id=the-tabindex-attribute:attr-tabindex-6><a href=#attr-tabindex>tabindex</a></code> attribute has been omitted or whose value, when parsed,
     returns an error,<li>before any <a href=#focusable-area id=the-tabindex-attribute:focusable-area-10>focusable area</a> whose <a href=#dom-anchor id=the-tabindex-attribute:dom-anchor-5>DOM anchor</a> is an element whose <code id=the-tabindex-attribute:attr-tabindex-7><a href=#attr-tabindex>tabindex</a></code> attribute has a value equal to or less than zero,<li>after any <a href=#focusable-area id=the-tabindex-attribute:focusable-area-11>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-8><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-9><a href=#attr-tabindex>tabindex</a></code> attribute on <var>candidate</var>,<li>after any <a href=#focusable-area id=the-tabindex-attribute:focusable-area-12>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 equal to the value of the <code id=the-tabindex-attribute:attr-tabindex-11><a href=#attr-tabindex>tabindex</a></code> attribute on <var>candidate</var> but that is
     earlier in the document in <a id=the-tabindex-attribute:tree-order href=https://dom.spec.whatwg.org/#concept-tree-order data-x-internal=tree-order>tree order</a> than <var>candidate</var>,<li>before any <a href=#focusable-area id=the-tabindex-attribute:focusable-area-13>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-12><a href=#attr-tabindex>tabindex</a></code> attribute has a value equal to the value of the <code id=the-tabindex-attribute:attr-tabindex-13><a href=#attr-tabindex>tabindex</a></code> attribute on <var>candidate</var> but that is
     later in the document in <a id=the-tabindex-attribute:tree-order-2 href=https://dom.spec.whatwg.org/#concept-tree-order data-x-internal=tree-order>tree order</a> than <var>candidate</var>, and<li>before any <a href=#focusable-area id=the-tabindex-attribute:focusable-area-14>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-14><a href=#attr-tabindex>tabindex</a></code> attribute has a value greater than the value of the
     <code id=the-tabindex-attribute:attr-tabindex-15><a href=#attr-tabindex>tabindex</a></code> attribute on <var>candidate</var>.</ul>

   </dl>

  <p>An element with the <code id=the-tabindex-attribute:attr-tabindex-16><a href=#attr-tabindex>tabindex</a></code> attribute specified is
  <a href=#interactive-content-2 id=the-tabindex-attribute:interactive-content-2>interactive content</a>.</p>

  <p>The <dfn id=dom-tabindex><code>tabIndex</code></dfn> IDL attribute must
  <a href=#reflect id=the-tabindex-attribute:reflect>reflect</a> the value of the <code id=the-tabindex-attribute:attr-tabindex-17><a href=#attr-tabindex>tabindex</a></code> content
  attribute. Its default value is 0 for elements that are focusable and −1 for elements that
  are not focusable.</p>

  


  

  <h4 id=focus-processing-model><span class=secno>6.4.4</span> <span id=processing-model-5></span>Processing model<a href=#focus-processing-model class=self-link></a></h4>

  <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>focusable area</a>, or an element that is not a <a href=#focusable-area id=focus-processing-model:focusable-area-2>focusable area</a>, or
  a <a href=#browsing-context id=focus-processing-model:browsing-context>browsing context</a>, are as follows. They can optionally be run with a <i>fallback
  target</i>.</p>

  <ol><li>

    <p>If <var>new focus target</var> is not a <a href=#focusable-area id=focus-processing-model:focusable-area-3>focusable area</a>, then run the first
    matching set of steps from the following list:</p>

    <dl class=switch><dt>If <var>new 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-4>focusable areas</a><dd>

      <p>Let <var>new focus target</var> be 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>

     <dt>If <var>new focus target</var> is an element with one or more scrollable regions
     that are <a href=#focusable-area id=focus-processing-model:focusable-area-5>focusable areas</a><dd>

      <p>Let <var>new focus target</var> be the element's first scrollable region,
      according to a pre-order, depth-first traversal of the box tree. <a href=#refsCSS>[CSS]</a></p>

     <dt>If <var>new 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><dd>

      <p>Let <var>new focus target</var> be 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/visuren.html#viewport data-x-internal=viewport>viewport</a>.</p>

     <dt>If <var>new focus target</var> is a <a href=#browsing-context id=focus-processing-model:browsing-context-2>browsing context</a><dd>

      <p>Let <var>new focus target</var> be the <a href=#browsing-context id=focus-processing-model:browsing-context-3>browsing context</a>'s
      <a href=#active-document id=focus-processing-model:active-document>active document</a>.</p>

     <dt>If <var>new focus target</var> is a <a href=#browsing-context-container id=focus-processing-model:browsing-context-container>browsing context container</a> with a non-null
     <a href=#nested-browsing-context id=focus-processing-model:nested-browsing-context>nested browsing context</a><dd>

      <p>Let <var>new focus target</var> be the <a href=#browsing-context-container id=focus-processing-model:browsing-context-container-2>browsing context container</a>'s <a href=#nested-browsing-context id=focus-processing-model:nested-browsing-context-2>nested browsing context</a>'s
      <a href=#active-document id=focus-processing-model:active-document-2>active document</a>.</p>

     <dt>Otherwise<dd>

      <p>If no <i>fallback target</i> was specified, abort the <a href=#focusing-steps id=focus-processing-model:focusing-steps>focusing steps</a>.</p>

      <p>Otherwise, let <var>new focus target</var> be the <i>fallback target</i>.</p>

     </dl>

   <li>

    
    <p>If <var>new focus target</var> is a <a href=#browsing-context-container id=focus-processing-model:browsing-context-container-3>browsing context container</a> with
    non-null <a href=#nested-browsing-context id=focus-processing-model:nested-browsing-context-3>nested browsing context</a>, then let <var>new focus target</var> be the
    <a href=#nested-browsing-context id=focus-processing-model:nested-browsing-context-4>nested browsing context</a>'s <a href=#active-document id=focus-processing-model:active-document-3>active document</a>, and redo this step.</p>

   <li><p>If <var>new focus target</var> is a <a href=#focusable-area id=focus-processing-model:focusable-area-6>focusable area</a> and its <a href=#dom-anchor id=focus-processing-model:dom-anchor>DOM
   anchor</a> is <a href=#inert id=focus-processing-model:inert>inert</a>, then return.<li><p>If <var>new focus target</var> is the <a href=#currently-focused-area-of-a-top-level-browsing-context id=focus-processing-model:currently-focused-area-of-a-top-level-browsing-context>currently focused area of a
   top-level browsing context</a>, then return.<li><p>Let <var>old chain</var> be the <a href=#focus-chain id=focus-processing-model:focus-chain>focus chain</a> of the <a href=#currently-focused-area-of-a-top-level-browsing-context id=focus-processing-model:currently-focused-area-of-a-top-level-browsing-context-2>currently focused area of the
   top-level browsing context</a> in which <var>new focus target</var> finds
   itself.<li><p>Let <var>new chain</var> be the <a href=#focus-chain id=focus-processing-model:focus-chain-2>focus chain</a> of <var>new
   focus target</var>.<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.</ol>

  <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-7>focusable area</a> or <a href=#browsing-context id=focus-processing-model:browsing-context-4>browsing context</a> <var>candidate</var> whenever the
  user attempts to move the focus to <var>candidate</var>.</p>

  <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-8>focusable area</a> or an element that is not a <a href=#focusable-area id=focus-processing-model:focusable-area-9>focusable area</a> are as
  follows:</p>

  <ol><li><p>If <var>old focus target</var> is <a href=#inert id=focus-processing-model:inert-2>inert</a>, then return.<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-browsing-context id=focus-processing-model:currently-focused-area-of-a-top-level-browsing-context-3>currently focused area of a top-level browsing context</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-browsing-context id=focus-processing-model:currently-focused-area-of-a-top-level-browsing-context-4>currently focused area of a top-level browsing context</a>, then let <var>old focus
    target</var> be that <a href=#currently-focused-area-of-a-top-level-browsing-context id=focus-processing-model:currently-focused-area-of-a-top-level-browsing-context-5>currently focused area of a top-level browsing context</a>.</p>

   <li><p>Let <var>old chain</var> be the <a href=#focus-chain id=focus-processing-model:focus-chain-3>focus chain</a> of the <a href=#currently-focused-area-of-a-top-level-browsing-context id=focus-processing-model:currently-focused-area-of-a-top-level-browsing-context-6>currently
   focused area of a top-level browsing context</a>.<li><p>If <var>old focus target</var> is not one of the entries in <var>old
   chain</var>, then return.<li>

    <p>If <var>old focus target</var> is a <a href=#focusable-area id=focus-processing-model:focusable-area-10>focusable area</a>, then let <var>new
    focus target</var> be its <code id=focus-processing-model:document-3><a href=#document>Document</a></code>'s <a id=focus-processing-model:viewport-2 href=https://drafts.csswg.org/css2/visuren.html#viewport data-x-internal=viewport>viewport</a>.</p>

    <p>Otherwise, let <var>new focus target</var> be null.</p>

   <li><p>If <var>new focus target</var> is not null, then run the <a href=#focusing-steps id=focus-processing-model:focusing-steps-3>focusing
   steps</a> for <var>new focus target</var>.</ol>

  <p>When the <a href=#currently-focused-area-of-a-top-level-browsing-context id=focus-processing-model:currently-focused-area-of-a-top-level-browsing-context-7>currently focused area of a top-level browsing context</a> is somehow
  unfocused without another element being explicitly focused in its stead, the user agent must
  <a href=#immediately id=focus-processing-model:immediately-2>immediately</a> run the <a href=#unfocusing-steps id=focus-processing-model:unfocusing-steps>unfocusing steps</a> for that object.</p>

  <p class=note>The <a href=#unfocusing-steps id=focus-processing-model:unfocusing-steps-2>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-browsing-context id=focus-processing-model:currently-focused-area-of-a-top-level-browsing-context-8>currently focused area of a top-level browsing context</a>. For
  example, if the <a href=#currently-focused-area-of-a-top-level-browsing-context id=focus-processing-model:currently-focused-area-of-a-top-level-browsing-context-9>currently focused area of a top-level browsing context</a> is a
  <a id=focus-processing-model:viewport-3 href=https://drafts.csswg.org/css2/visuren.html#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-11>focusable area</a> is explicitly focused with the <a href=#focusing-steps id=focus-processing-model:focusing-steps-4>focusing steps</a>.</p>

  <hr>

  <p><dfn id=focus-fixup-rule>Focus fixup rule</dfn>: When the designated <a href=#focused-area-of-the-document id=focus-processing-model:focused-area-of-the-document>focused area of the document</a> is removed from that <code id=focus-processing-model:document-4><a href=#document>Document</a></code> in some
  way (e.g. it stops being a <a href=#focusable-area id=focus-processing-model:focusable-area-12>focusable area</a>, it is removed from the DOM, it becomes
  <a href=#expressly-inert id=focus-processing-model:expressly-inert>expressly inert</a>, etc.), designate the <code id=focus-processing-model:document-5><a href=#document>Document</a></code>'s <a id=focus-processing-model:viewport-4 href=https://drafts.csswg.org/css2/visuren.html#viewport data-x-internal=viewport>viewport</a>
  to be the new <a href=#focused-area-of-the-document id=focus-processing-model:focused-area-of-the-document-2>focused area of the document</a>.</p>

  <p class=example>For example, this might happen because an element is removed from its
  <code id=focus-processing-model:document-6><a href=#document>Document</a></code>, or has a <code id=focus-processing-model:the-hidden-attribute><a href=#the-hidden-attribute>hidden</a></code> attribute added. It might
  also happen to an <code id=focus-processing-model:the-input-element><a href=#the-input-element>input</a></code> element when the element gets <a href=#concept-fe-disabled id=focus-processing-model:concept-fe-disabled>disabled</a>.</p>

  <p class=example>In a <code id=focus-processing-model:document-7><a href=#document>Document</a></code> whose <a href=#focused-area-of-the-document id=focus-processing-model:focused-area-of-the-document-3>focused area</a> is a <code id=focus-processing-model:the-button-element><a href=#the-button-element>button</a></code> element, removing, disabling, or hiding
  that button would cause the page's new <a href=#focused-area-of-the-document id=focus-processing-model:focused-area-of-the-document-4>focused
  area</a> to be the <a id=focus-processing-model:viewport-5 href=https://drafts.csswg.org/css2/visuren.html#viewport data-x-internal=viewport>viewport</a> of the <code id=focus-processing-model:document-8><a href=#document>Document</a></code>. This would, in turn,
  be reflected through the <code id=focus-processing-model:dom-document-activeelement><a href=#dom-document-activeelement>activeElement</a></code> API as
  <a href=#the-body-element-2 id=focus-processing-model:the-body-element-2>the body element</a>.</p>

  <hr>

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

    <p>For each entry <var>entry</var> in <var>old chain</var>, in order, run
    these substeps:</p>

    <ol><li id=unfocus-causes-change-event><p>If <var>entry</var> is an <code id=focus-processing-model:the-input-element-2><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 <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>

      <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-9><a href=#document>Document</a></code> object, let <var>blur event target</var> be
      that <code id=focus-processing-model:document-10><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><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.<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 class=note>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-6 href=https://drafts.csswg.org/css2/visuren.html#viewport data-x-internal=viewport>viewport</a>, no event is fired.</p>

     </ol>

   <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.)<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-13>focusable area</a>: designate <var>entry</var> as the
      <a href=#focused-area-of-the-document id=focus-processing-model:focused-area-of-the-document-5>focused area of the document</a>.</p>

     <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-11><a href=#document>Document</a></code> object, let <var>focus event target</var> be
      that <code id=focus-processing-model:document-12><a href=#document>Document</a></code> object's <a href=#concept-relevant-global id=focus-processing-model:concept-relevant-global-2>relevant global object</a>.</p>

      <p>Otherwise, let <var>focus event target</var> be null.</p>

     <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.<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-7 href=https://drafts.csswg.org/css2/visuren.html#viewport data-x-internal=viewport>viewport</a>, no event is fired.</p>

     </ol>

   </ol>

  <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-3>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>

  <hr>

  <p>When a key event is to be routed in a <a href=#top-level-browsing-context id=focus-processing-model:top-level-browsing-context>top-level browsing context</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-browsing-context id=focus-processing-model:currently-focused-area-of-a-top-level-browsing-context-10>currently focused area of the top-level browsing
   context</a>.<li><p>If <var>target area</var> is a <a href=#focusable-area id=focus-processing-model:focusable-area-14>focusable area</a>, let <var>target
   node</var> be <var>target area</var>'s <a href=#dom-anchor id=focus-processing-model:dom-anchor-2>DOM anchor</a>. Otherwise, <var>target area</var> is a <code id=focus-processing-model:the-dialog-element><a href=#the-dialog-element>dialog</a></code>; let <var>target node</var> be
   <var>target area</var>.<li>

    <p>If <var>target node</var> is a <code id=focus-processing-model:document-13><a href=#document>Document</a></code> that has a <a href=#the-body-element-2 id=focus-processing-model:the-body-element-2-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-3>the body
    element</a> of that <code id=focus-processing-model:document-14><a href=#document>Document</a></code>.</p>

    <p>Otherwise, if <var>target node</var> is a <code id=focus-processing-model:document-15><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>

    <p>If <var>target node</var> is not <a href=#inert id=focus-processing-model:inert-3>inert</a>, then:</p>

    <p class=note>It is possible for the <a href=#currently-focused-area-of-a-top-level-browsing-context id=focus-processing-model:currently-focused-area-of-a-top-level-browsing-context-11>currently focused area of a top-level browsing
    context</a> to be <a href=#inert id=focus-processing-model:inert-4>inert</a>, for example if a <a href=#dom-dialog-showmodal id=focus-processing-model:dom-dialog-showmodal>modal dialog is shown</a>, and then that <code id=focus-processing-model:the-dialog-element-2><a href=#the-dialog-element>dialog</a></code>
    element is made <a href=#inert id=focus-processing-model:inert-5>inert</a>. It is likely to be the result of a logic error in the
    application, though.</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>.<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>.</ol>

   </ol>

  <hr>

  <p>The <dfn id=has-focus-steps data-export="">has focus steps</dfn>, given a <code id=focus-processing-model:document-16><a href=#document>Document</a></code> object
  <var>target</var>, are as follows:</p>

  <ol><li><p>Let <var>candidate</var> be the <code id=focus-processing-model:document-17><a href=#document>Document</a></code> of the <a href=#top-level-browsing-context id=focus-processing-model:top-level-browsing-context-2>top-level browsing
   context</a>.<li>
    <p>While true:</p>

    <ol><li><p>If <var>candidate</var> is <var>target</var>, then return true.<li><p>If the <a href=#focused-area-of-the-document id=focus-processing-model:focused-area-of-the-document-6>focused area</a> of
     <var>candidate</var> is a <a href=#browsing-context-container id=focus-processing-model:browsing-context-container-4>browsing context container</a> with a non-null <a href=#nested-browsing-context id=focus-processing-model:nested-browsing-context-5>nested
     browsing context</a>, then set <var>candidate</var> to the <a href=#active-document id=focus-processing-model:active-document-4>active document</a> of
     that <a href=#browsing-context-container id=focus-processing-model:browsing-context-container-5>browsing context container</a>'s <a href=#nested-browsing-context id=focus-processing-model:nested-browsing-context-6>nested browsing context</a>.<li><p>Otherwise, return false.</ol>
   </ol>



  <h4 id=sequential-focus-navigation><span class=secno>6.4.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. The order in the <a href=#sequential-focus-navigation-order id=sequential-focus-navigation:sequential-focus-navigation-order>sequential focus navigation order</a> does not
  have to be 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> in the <code id=sequential-focus-navigation:document-3><a href=#document>Document</a></code> itself. 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-2>sequential focus navigation order</a>
  of its <code id=sequential-focus-navigation:document-4><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>When the user requests that focus move from the <a href=#currently-focused-area-of-a-top-level-browsing-context id=sequential-focus-navigation:currently-focused-area-of-a-top-level-browsing-context>currently focused area of a top-level
  browsing context</a> to the next or previous <a href=#focusable-area id=sequential-focus-navigation:focusable-area-3>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-browsing-context id=sequential-focus-navigation:top-level-browsing-context>top-level browsing context</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-browsing-context id=sequential-focus-navigation:currently-focused-area-of-a-top-level-browsing-context-2>currently focused area of a top-level
   browsing context</a>, if the user requested to move focus sequentially from there, or else the
   <a href=#top-level-browsing-context id=sequential-focus-navigation:top-level-browsing-context-2>top-level browsing context</a> itself, if the user instead requested to move focus from
   outside the <a href=#top-level-browsing-context id=sequential-focus-navigation:top-level-browsing-context-3>top-level browsing context</a>.<li><p>If there is a <a href=#sequential-focus-navigation-starting-point id=sequential-focus-navigation:sequential-focus-navigation-starting-point>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-2>sequential
   focus navigation starting point</a> instead.<li>

    <p>Let <var>direction</var> be <i>forward</i> if the user requested the <em>next</em>
    control, and <i>backward</i> 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>

    <p><i>Loop</i>: Let <var>selection mechanism</var> be <i>sequential</i> if the <var>starting
    point</var> is a <a href=#browsing-context id=sequential-focus-navigation:browsing-context>browsing context</a> or if <var>starting point</var> is in its
    <code id=sequential-focus-navigation:document-5><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>.</p>

    <p>Otherwise, <var>starting point</var> is not 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-4>sequential focus navigation order</a>; let <var>selection mechanism</var> be
    <i>DOM</i>.</p>

   <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>sequential navigation search
   algorithm</a> with <var>starting point</var>, <var>direction</var>, and <var>selection
   mechanism</var> as the arguments.<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.<li><p>Otherwise, unset the <a href=#sequential-focus-navigation-starting-point id=sequential-focus-navigation:sequential-focus-navigation-starting-point-3>sequential focus navigation starting point</a>.<li>

    <p>If <var>starting point</var> is the <a href=#top-level-browsing-context id=sequential-focus-navigation:top-level-browsing-context-4>top-level browsing context</a>, or a
    <a href=#focusable-area id=sequential-focus-navigation:focusable-area-4>focusable area</a> in the <a href=#top-level-browsing-context id=sequential-focus-navigation:top-level-browsing-context-5>top-level browsing context</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
    focusable control before the browser's rendering area would be the control to focus.</p>

    <p>If the user agent has no focusable 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-browsing-context id=sequential-focus-navigation:top-level-browsing-context-6>top-level browsing context</a> itself.</p>

    

   <li><p>Otherwise, <var>starting point</var> is a <a href=#focusable-area id=sequential-focus-navigation:focusable-area-5>focusable area</a> in a
   <a href=#nested-browsing-context id=sequential-focus-navigation:nested-browsing-context>nested browsing context</a>. Let <var>starting point</var> be that
   <a href=#nested-browsing-context id=sequential-focus-navigation:nested-browsing-context-2>nested browsing context</a>'s <a href=#browsing-context-container id=sequential-focus-navigation:browsing-context-container>browsing context container</a>, and return to the
   step labeled <i>loop</i>.</p>
    
   </ol>


  <p>The <dfn id=sequential-navigation-search-algorithm>sequential navigation search algorithm</dfn> consists of the following steps. This
  algorithm takes three arguments: <var>starting point</var>, <var>direction</var>,
  and <var>selection mechanism</var>.</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> <var>direction</var> is <i>forward</i>
       <th> <var>direction</var> is <i>backward</i>
     <tbody><tr><th><var>starting point</var> is a <a href=#browsing-context id=sequential-focus-navigation:browsing-context-2>browsing context</a>
       <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=#active-document id=sequential-focus-navigation:active-document>active document</a>, if any; or else null
       <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=#active-document id=sequential-focus-navigation:active-document-2>active document</a>, if any; or else null
      <tr><th><var>selection mechanism</var> is <i>DOM</i>
       <td>Let <var>candidate</var> be the first <a href=#suitable-sequentially-focusable-area id=sequential-focus-navigation:suitable-sequentially-focusable-area-3>suitable sequentially focusable area</a>
       in the <a href=#home-document id=sequential-focus-navigation:home-document>home document</a> following <var>starting point</var>, if any; or else null
       <td>Let <var>candidate</var> be the last <a href=#suitable-sequentially-focusable-area id=sequential-focus-navigation:suitable-sequentially-focusable-area-4>suitable sequentially focusable area</a>
       in the <a href=#home-document id=sequential-focus-navigation:home-document-2>home document</a> preceding <var>starting point</var>, if any; or else null
      <tr><th><var>selection mechanism</var> is <i>sequential</i>
       <td>Let <var>candidate</var> be the first <a href=#suitable-sequentially-focusable-area id=sequential-focus-navigation:suitable-sequentially-focusable-area-5>suitable sequentially focusable area</a> in the <a href=#home-sequential-focus-navigation-order id=sequential-focus-navigation:home-sequential-focus-navigation-order>home sequential focus navigation order</a> following <var>starting point</var>, if any; or else null
       <td>Let <var>candidate</var> be the last <a href=#suitable-sequentially-focusable-area id=sequential-focus-navigation:suitable-sequentially-focusable-area-6>suitable sequentially focusable area</a> in the <a href=#home-sequential-focus-navigation-order id=sequential-focus-navigation:home-sequential-focus-navigation-order-2>home sequential focus navigation order</a> preceding <var>starting point</var>, if any; or else null

    </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-6>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 that is 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-5>sequential focus navigation order</a>.</p>

    <p>The <dfn id=home-document>home document</dfn> is the <code id=sequential-focus-navigation:document-8><a href=#document>Document</a></code> to which <var>starting point</var>
    belongs.</p>

    <p>The <dfn id=home-sequential-focus-navigation-order>home sequential focus navigation order</dfn> is the <a href=#sequential-focus-navigation-order id=sequential-focus-navigation:sequential-focus-navigation-order-6>sequential focus
    navigation order</a> to which <var>starting point</var> belongs.</p>

    <p class=note>The <a href=#home-sequential-focus-navigation-order id=sequential-focus-navigation:home-sequential-focus-navigation-order-3>home sequential focus navigation order</a> is the <a href=#home-document id=sequential-focus-navigation:home-document-3>home
    document</a>'s <a href=#sequential-focus-navigation-order id=sequential-focus-navigation:sequential-focus-navigation-order-7>sequential focus navigation order</a>, but is only used when the
    <var>starting point</var> is in that <a href=#sequential-focus-navigation-order id=sequential-focus-navigation:sequential-focus-navigation-order-8>sequential focus navigation order</a>
    (when it's not, <var>selection mechanism</var> will be <i>DOM</i>).</p>

   <li>

    <p>If <var>candidate</var> is a <a href=#browsing-context-container id=sequential-focus-navigation:browsing-context-container-2>browsing context container</a> with a non-null
    <a href=#nested-browsing-context id=sequential-focus-navigation:nested-browsing-context-3>nested browsing context</a>, then let <var>new 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>candidate</var>'s <a href=#nested-browsing-context id=sequential-focus-navigation:nested-browsing-context-4>nested
    browsing context</a> as the first argument, <var>direction</var> as the second, and
    <i>sequential</i>  as the third.</p>

    <p>If <var>new candidate</var> is null, then let <var>starting point</var>
    be <var>candidate</var>, and return to the top of this algorithm. Otherwise, let
    <var>candidate</var> be <var>new candidate</var>.</p>

   <li><p>Return <var>candidate</var>.</ol>

  


  <h4 id=focus-management-apis><span class=secno>6.4.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'><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->;
};</code></pre>

  <dl class=domintro><dt><var>document</var> . <code id=dom-document-activeelement-dev><a href=#dom-document-activeelement>activeElement</a></code><dd>

    <p>Returns the deepest element in the document 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-browsing-context id=focus-management-apis:child-browsing-context>child browsing context</a> is focused, its
    <a href=#browsing-context-container id=focus-management-apis:browsing-context-container>browsing context container</a> is <a href=#bc-focus-ergo-bcc-focus>focused</a> in the
    <a href=#parent-browsing-context id=focus-management-apis:parent-browsing-context>parent browsing context</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-document-activeelement><a href=#dom-document-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>

   <dt><var>document</var> . <code id=dom-document-hasfocus-dev><a href=#dom-document-hasfocus>hasFocus</a></code>()<dd>

    <p>Returns true if key events are being routed through or to the document; otherwise, returns
    false. Roughly speaking, this corresponds to the document, or a document nested inside this
    one, being focused.</p>

   <dt><var>window</var> . <code id=dom-window-focus-dev><a href=#dom-window-focus>focus</a></code>()<dd>

    

    <p>Moves the focus to the window's <a href=#browsing-context id=focus-management-apis:browsing-context>browsing context</a>, if any.</p>

   <dt><var>element</var> . <code id=dom-focus-dev><a href=#dom-focus>focus</a></code>([ { <code id=focus-management-apis:dom-focusoptions-preventscroll-2><a href=#dom-focusoptions-preventscroll>preventScroll</a></code>: true } ])<dd>

    <p>Moves the focus to the element.</p>

    <p>If the element is a <a href=#browsing-context-container id=focus-management-apis:browsing-context-container-2>browsing context container</a>, moves the focus to the
    <a href=#nested-browsing-context id=focus-management-apis:nested-browsing-context>nested browsing context</a> instead.</p>

    <p>By default, this method also scrolls the element 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>

   <dt><var>element</var> . <code id=dom-blur-dev><a href=#dom-blur>blur</a></code>()<dd>

    <p>Moves the focus to the <a id=focus-management-apis:viewport href=https://drafts.csswg.org/css2/visuren.html#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/visuren.html#viewport data-x-internal=viewport>viewport</a>, call the <code id=focus-management-apis:dom-focus><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 a CSS rule 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 links and instead use a yellow background to indicate
     focus, you could use:</p>

     <pre><code class='css'><c- f>:link:focus, :visited:focus </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>

   </dl>

  

  <p>The <dfn id=dom-document-activeelement><code>activeElement</code></dfn> attribute's
  getter must run these steps:</p>

  <ol><li><p>Let <var>candidate</var> be the <a href=#dom-anchor id=focus-management-apis:dom-anchor>DOM anchor</a> of the <a href=#focused-area-of-the-document id=focus-management-apis:focused-area-of-the-document>focused area</a> of this <code id=focus-management-apis:document-2><a href=#document>Document</a></code> object.<li><p>If <var>candidate</var> is not a <code id=focus-management-apis:document-3><a href=#document>Document</a></code> object, then return
   <var>candidate</var>.<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>.<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>.<li><p>Return null.</ol>

  <p>The <dfn id=dom-document-hasfocus><code>hasFocus()</code></dfn> method on the
  <code id=focus-management-apis:document-4><a href=#document>Document</a></code> object, when invoked, must return the result of running the <a href=#has-focus-steps id=focus-management-apis:has-focus-steps>has focus
  steps</a> with the <code id=focus-management-apis:document-5><a href=#document>Document</a></code> object as the argument.</p>

  <p>The <dfn data-dfn-for=Window id=dom-window-focus><code>focus()</code></dfn> method on
  the <code id=focus-management-apis:window><a href=#window>Window</a></code> object, when invoked, must run the <a href=#focusing-steps id=focus-management-apis:focusing-steps>focusing steps</a> with the
  <code id=focus-management-apis:window-2><a href=#window>Window</a></code> object's <a href=#browsing-context id=focus-management-apis:browsing-context-2>browsing context</a>. Additionally, if this <a href=#browsing-context id=focus-management-apis:browsing-context-3>browsing
  context</a> is a <a href=#top-level-browsing-context id=focus-management-apis:top-level-browsing-context>top-level browsing context</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>

  <p>The <dfn data-dfn-for=Window id=dom-window-blur><code>blur()</code></dfn> method on the
  <code id=focus-management-apis:window-3><a href=#window>Window</a></code> object, when invoked, provides a hint to the user agent that the script
  believes the user probably is not currently interested in the contents of the <a href=#browsing-context id=focus-management-apis:browsing-context-4>browsing
  context</a> of the <code id=focus-management-apis:window-4><a href=#window>Window</a></code> object on which the method was invoked, but that the
  contents might become interesting again in the future.</p>

  <p>User agents are encouraged to ignore calls to this <code id=focus-management-apis:dom-window-blur><a href=#dom-window-blur>blur()</a></code>
  method entirely.</p>

  <p class=note>Historically, the <code id=focus-management-apis:dom-window-blur-2><a href=#dom-window-blur>focus()</a></code> and <code id=focus-management-apis:dom-window-blur-3><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=#browsing-context id=focus-management-apis:browsing-context-5>browsing context</a>, but hostile
  sites widely abuse this behavior to the user's detriment.</p>

  <p>The <dfn id=dom-focus><code>focus(<var>options</var>)</code></dfn> method on elements, when
  invoked, must run the following steps:</p>

  <ol><li><p>If the element is marked as <i id=focus-management-apis:locked-for-focus><a href=#locked-for-focus>locked for focus</a></i>, then return.<li><p>Mark the element as <dfn id=locked-for-focus>locked for focus</dfn>.<li><p>Run the <a href=#focusing-steps id=focus-management-apis:focusing-steps-2>focusing steps</a> for the element.<li><p>If the value of the <dfn id=dom-focusoptions-preventscroll><code>preventScroll</code></dfn> dictionary member of
   <var>options</var> is false, then <a href=https://drafts.csswg.org/cssom-view/#scroll-an-element-into-view id=focus-management-apis:scroll-an-element-into-view data-x-internal=scroll-an-element-into-view>scroll the element
   into view</a> with scroll behavior "<code>auto</code>", block flow direction
   position set to a UA-defined value, and inline base direction position set to a UA-defined
   value.<li><p>Unmark the element as <i id=focus-management-apis:locked-for-focus-2><a href=#locked-for-focus>locked for focus</a></i>.</ol>

  <p>The <dfn data-dfn-for=HTMLElement id=dom-blur><code>blur()</code></dfn> method, when
  invoked, should run the <a href=#unfocusing-steps id=focus-management-apis:unfocusing-steps>unfocusing steps</a> for the element on which the method was
  called. User agents may selectively or uniformly ignore calls to this method for usability
  reasons.</p>

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

  




  <h3 id=assigning-keyboard-shortcuts><span class=secno>6.5</span> Assigning keyboard shortcuts<a href=#assigning-keyboard-shortcuts class=self-link></a></h3>

  <h4 id=introduction-9><span class=secno>6.5.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 possibly 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>&quot;collect()&quot;</c->
       <strong><c- e>accesskey</c-><c- o>=</c-><c- s>&quot;C 1&quot;</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 this script 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>&apos;&apos;</c-><c- p>)</c->
    button<c- p>.</c->value <c- o>+=</c-> <c- t>&apos; (&apos;</c-> <c- o>+</c-> button<c- p>.</c->accessKeyLabel <c- o>+</c-> <c- t>&apos;)&apos;</c-><c- p>;</c-></strong>
<c- p>}</c->
addShortcutKeyLabel<c- p>(</c->document<c- p>.</c->getElementById<c- p>(</c-><c- t>&apos;c&apos;</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.5.2</span> The <dfn><code>accesskey</code></dfn> attribute<a href=#the-accesskey-attribute class=self-link></a></h4>

  <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>
  that are <a href=#case-sensitive id=the-accesskey-attribute:case-sensitive>case-sensitive</a>, 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>&quot;Consortium Activities&quot;</c-> <c- e>accesskey</c-><c- o>=</c-><c- s>&quot;A&quot;</c-> <c- e>href</c-><c- o>=</c-><c- s>&quot;/Consortium/activities&quot;</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>&quot;Technical Reports and Recommendations&quot;</c-> <c- e>accesskey</c-><c- o>=</c-><c- s>&quot;T&quot;</c-> <c- e>href</c-><c- o>=</c-><c- s>&quot;/TR/&quot;</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>&quot;Alphabetical Site Index&quot;</c-> <c- e>accesskey</c-><c- o>=</c-><c- s>&quot;S&quot;</c-> <c- e>href</c-><c- o>=</c-><c- s>&quot;/Consortium/siteindex&quot;</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>&quot;About This Site&quot;</c-> <c- e>accesskey</c-><c- o>=</c-><c- s>&quot;B&quot;</c-> <c- e>href</c-><c- o>=</c-><c- s>&quot;/Consortium/&quot;</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>&quot;Contact Consortium&quot;</c-> <c- e>accesskey</c-><c- o>=</c-><c- s>&quot;C&quot;</c-> <c- e>href</c-><c- o>=</c-><c- s>&quot;/Consortium/contact&quot;</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>&quot;/search&quot;</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>&quot;search&quot;</c-> <c- e>name</c-><c- o>=</c-><c- s>&quot;q&quot;</c-> <c- e>accesskey</c-><c- o>=</c-><c- s>&quot;s 0&quot;</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>&quot;submit&quot;</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>&quot;N @ 1&quot;</c-> <c- e>value</c-><c- o>=</c-><c- s>&quot;Compose&quot;</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>&apos; (&apos;</c-> <c- o>+</c-> button<c- p>.</c->accessKeyLabel <c- o>+</c-> <c- t>&apos;)&apos;</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>&apos;input&apos;</c-><c- p>);</c->
 <c- k>for</c-> <c- p>(</c-><c- a>var</c-> i <c- o>=</c-> <c- mi>0</c-><c- p>;</c-> i <c- o>&lt;</c-> inputs<c- p>.</c->length<c- p>;</c-> i <c- o>+=</c-> <c- mi>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>&quot;submit&quot;</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.5.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>

  <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.<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.<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.<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.<li><p>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.
     <a href=#fingerprinting-vector id=keyboard-shortcuts-processing-model:fingerprinting-vector class=fingerprint title="There is a potential fingerprinting vector here."><img alt="(This is a fingerprinting vector.)" src=/images/fingerprint.png width=46 height=64></a>
     </ol>

   <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.<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>.</ol>

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

  <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 <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:the-hidden-attribute><a href=#the-hidden-attribute>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>

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

  <p>The <dfn id=dom-accesskey><code>accessKey</code></dfn> IDL attribute must
  <a href=#reflect id=keyboard-shortcuts-processing-model:reflect>reflect</a> the <code id=keyboard-shortcuts-processing-model:the-accesskey-attribute-6><a href=#the-accesskey-attribute>accesskey</a></code> content attribute.</p>

  <p>The <dfn id=dom-accesskeylabel><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>

  



  <h3 id=editing-2><span class=secno>6.6</span> Editing<a href=#editing-2 class=self-link></a></h3>

  <h4 id=contenteditable><span class=secno>6.6.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=status><input onclick=toggleStatus(this) value=⋰ type=button><p class=support><strong>Support:</strong> contenteditable<span class="and_chr yes"><span>Chrome for Android</span> <span>67+</span></span><span class="chrome yes"><span>Chrome</span> <span>4+</span></span><span class="ios_saf yes"><span>iOS Safari</span> <span>5.0+</span></span><span class="and_uc yes"><span>UC Browser for Android</span> <span>11.8+</span></span><span class="firefox yes"><span>Firefox</span> <span>3.5+</span></span><span class="ie yes"><span>IE</span> <span>5.5+</span></span><span class="op_mini no"><span>Opera Mini</span> <span>None</span></span><span class="safari yes"><span>Safari</span> <span>3.1+</span></span><span class="edge yes"><span>Edge</span> <span>12+</span></span><span class="samsung yes"><span>Samsung Internet</span> <span>4+</span></span><span class="opera yes"><span>Opera</span> <span>9+</span></span><span class="android yes"><span>Android Browser</span> <span>3+</span></span><p class=caniuse>Source: <a href="https://caniuse.com/#feat=contenteditable">caniuse.com</a></div>

  <pre><code class='idl'><c- b>interface</c-> <c- b>mixin</c-> <dfn id='elementcontenteditable'><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>

  <p>The <dfn id=attr-contenteditable><code>contenteditable</code></dfn> content attribute is an
  <a href=#enumerated-attribute id=contenteditable:enumerated-attribute>enumerated attribute</a> whose keywords are the empty string, <code>true</code>,
  and <code>false</code>. The empty string and the <code>true</code> keyword map
  to the <i>true</i> state. The <code>false</code> keyword maps to the <i>false</i> state.
  In addition, there is a third state, the <i>inherit</i> state, which is the <i id=contenteditable:missing-value-default><a href=#missing-value-default>missing value default</a></i> and the <i id=contenteditable:invalid-value-default><a href=#invalid-value-default>invalid value default</a></i>.</p>

  <p>The <i>true</i> state indicates that the element is editable. The <i>inherit</i> state
  indicates that the element is editable if its parent is. The <i>false</i> state indicates that the
  element is not editable.</p>

  <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;&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>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;&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>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>&quot;white-space: pre-wrap&quot;</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>&quot;textarea&quot;</c-><c- p>);</c->
   <c- a>let</c-> div <c- o>=</c-> document<c- p>.</c->getElementById<c- p>(</c-><c- u>&quot;div&quot;</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>&quot;true&quot;</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/execCommand.html#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><var>element</var> . <code id=dom-contenteditable-dev><a href=#dom-contenteditable>contentEditable</a></code> [ = <var>value</var> ]<dd>

    <p>Returns "<code>true</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://heycam.github.io/webidl/#syntaxerror data-x-internal=syntaxerror>"<code>SyntaxError</code>"</a> <code id=contenteditable:domexception><a data-x-internal=domexception href=https://heycam.github.io/webidl/#dfn-DOMException>DOMException</a></code> if the new value
    isn't one of those strings.</p>

   <dt><var>element</var> . <code id=dom-iscontenteditable-dev><a href=#dom-iscontenteditable>isContentEditable</a></code><dd>

    <p>Returns true if the element is editable; otherwise, returns false.</p>

   </dl>

  

  <p>The <dfn id=dom-contenteditable><code>contentEditable</code></dfn> IDL attribute, on
  getting, must return the string "<code>true</code>" if the content attribute is set to
  the true state, "<code>false</code>" if the content attribute is set to the false 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>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://heycam.github.io/webidl/#syntaxerror data-x-internal=syntaxerror>"<code>SyntaxError</code>"</a> <code id=contenteditable:domexception-2><a data-x-internal=domexception href=https://heycam.github.io/webidl/#dfn-DOMException>DOMException</a></code>.</p>

  <p>The <dfn id=dom-iscontenteditable><code>isContentEditable</code></dfn> IDL attribute, on
  getting, must return true if the element is either an <a id=contenteditable:editing-host href=https://w3c.github.io/editing/execCommand.html#editing-host data-x-internal=editing-host>editing host</a> or
  <a id=contenteditable:editable href=https://w3c.github.io/editing/execCommand.html#editable data-x-internal=editable>editable</a>, and false otherwise.</p>

  



  <h4 id=making-entire-documents-editable:-the-designmode-idl-attribute><span class=secno>6.6.2</span> Making entire documents editable: the <code id=making-entire-documents-editable:-the-designmode-idl-attribute:designMode><a href=#designMode>designMode</a></code>
  IDL attribute<a href=#making-entire-documents-editable:-the-designmode-idl-attribute class=self-link></a></h4>

  

  <p>Documents have a <dfn id=designMode><code>designMode</code></dfn>, which can be either enabled or
  disabled.</p>

  

  <dl class=domintro><dt><var>document</var> . <code id=dom-document-designmode-dev><a href=#designMode>designMode</a></code> [ = <var>value</var> ]<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>

   </dl>

  

  <p>The <code id=making-entire-documents-editable:-the-designmode-idl-attribute:designMode-2><a href=#designMode>designMode</a></code> IDL attribute on the
  <code id=making-entire-documents-editable:-the-designmode-idl-attribute:document><a href=#document>Document</a></code> object takes two values, "<code>on</code>" and "<code>off</code>". On setting, the new value must be compared in an <a id=making-entire-documents-editable:-the-designmode-idl-attribute:ascii-case-insensitive href=https://infra.spec.whatwg.org/#ascii-case-insensitive data-x-internal=ascii-case-insensitive>ASCII
  case-insensitive</a> manner to these two values; if it matches the "<code>on</code>"
  value, then <code id=making-entire-documents-editable:-the-designmode-idl-attribute:designMode-3><a href=#designMode>designMode</a></code> must be enabled, and if it
  matches the "<code>off</code>" value, then <code id=making-entire-documents-editable:-the-designmode-idl-attribute:designMode-4><a href=#designMode>designMode</a></code> must be disabled. Other values must be
  ignored.</p>

  <p>On getting, if <code id=making-entire-documents-editable:-the-designmode-idl-attribute:designMode-5><a href=#designMode>designMode</a></code> is enabled, the IDL
  attribute must return the value "<code>on</code>"; otherwise it is disabled, and the
  attribute must return the value "<code>off</code>".</p>

  <p>The last state set must persist until the document is destroyed or the state is changed.
  Initially, documents must have their <code id=making-entire-documents-editable:-the-designmode-idl-attribute:designMode-6><a href=#designMode>designMode</a></code>
  disabled.</p>

  <p>When the <code id=making-entire-documents-editable:-the-designmode-idl-attribute:designMode-7><a href=#designMode>designMode</a></code> changes from being disabled to
  being enabled, the user agent must <a href=#immediately id=making-entire-documents-editable:-the-designmode-idl-attribute:immediately>immediately</a> reset the document's <a id=making-entire-documents-editable:-the-designmode-idl-attribute:active-range href=https://w3c.github.io/editing/execCommand.html#active-range data-x-internal=active-range>active range</a>'s
  start and end boundary points to be at the start of the <code id=making-entire-documents-editable:-the-designmode-idl-attribute:document-2><a href=#document>Document</a></code> and then run the
  <a href=#focusing-steps id=making-entire-documents-editable:-the-designmode-idl-attribute:focusing-steps>focusing steps</a> for the <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> of the <code id=making-entire-documents-editable:-the-designmode-idl-attribute:document-3><a href=#document>Document</a></code>, if
  non-null.</p>

  


  <h4 id=best-practices-for-in-page-editors><span class=secno>6.6.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=https://w3c.github.io/editing/execCommand.html#editing-host id=best-practices-for-in-page-editors:editing-host data-x-internal=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; ball</samp>" or "<samp>yellow &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.6.4</span> Editing APIs<a href=#editing-apis class=self-link></a></h4>

  <p>The definition of the terms
  <dfn id=active-range><a href=https://w3c.github.io/editing/execCommand.html#active-range>active range</a></dfn>,
  <dfn id=editing-host><a href=https://w3c.github.io/editing/execCommand.html#editing-host>editing host</a></dfn>,
  <dfn id=editing-host-of><a href=https://w3c.github.io/editing/execCommand.html#editing-host-of>editing host
  of</a></dfn>, and <dfn id=editable><a href=https://w3c.github.io/editing/execCommand.html#editable>editable</a></dfn>, the user
  interface requirements of elements that are <a href=https://w3c.github.io/editing/execCommand.html#editing-host id=editing-apis:editing-host data-x-internal=editing-host>editing hosts</a> or
  <a id=editing-apis:editable href=https://w3c.github.io/editing/execCommand.html#editable data-x-internal=editable>editable</a>, the

  <dfn id=execCommand><a href=https://w3c.github.io/editing/execCommand.html#execcommand%28%29><code>execCommand()</code></a></dfn>,
  <dfn id=dom-document-querycommandenabled><a href=https://w3c.github.io/editing/execCommand.html#querycommandenabled%28%29><code>queryCommandEnabled()</code></a></dfn>,
  <dfn id=dom-document-querycommandindeterm><a href=https://w3c.github.io/editing/execCommand.html#querycommandindeterm%28%29><code>queryCommandIndeterm()</code></a></dfn>,
  <dfn id=dom-document-querycommandstate><a href=https://w3c.github.io/editing/execCommand.html#querycommandstate%28%29><code>queryCommandState()</code></a></dfn>,
  <dfn id=dom-document-querycommandsupported><a href=https://w3c.github.io/editing/execCommand.html#querycommandsupported%28%29><code>queryCommandSupported()</code></a></dfn>, and
  <dfn id=dom-document-querycommandvalue><a href=https://w3c.github.io/editing/execCommand.html#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/execCommand.html#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.6.5</span> Spelling and grammar checking<a href=#spelling-and-grammar-checking class=self-link></a></h4><div class=status><input onclick=toggleStatus(this) value=⋰ type=button><p class=support><strong>Support:</strong> spellcheck-attribute<span class="and_chr partial"><span>Chrome for Android (limited)</span> <span>67+</span></span><span class="chrome yes"><span>Chrome</span> <span>9+</span></span><span class="ios_saf partial"><span>iOS Safari (limited)</span> <span>3.2+</span></span><span class="and_uc partial"><span>UC Browser for Android (limited)</span> <span>11.8+</span></span><span class="firefox yes"><span>Firefox</span> <span>2+</span></span><span class="ie yes"><span>IE</span> <span>10+</span></span><span class="op_mini partial"><span>Opera Mini (limited)</span> <span>all+</span></span><span class="safari yes"><span>Safari</span> <span>5.1+</span></span><span class="edge yes"><span>Edge</span> <span>12+</span></span><span class="samsung partial"><span>Samsung Internet (limited)</span> <span>4+</span></span><span class="opera yes"><span>Opera</span> <span>10.5+</span></span><span class="android partial"><span>Android Browser (limited)</span> <span>2.1+</span></span><p class=caniuse>Source: <a href="https://caniuse.com/#feat=spellcheck-attribute">caniuse.com</a></div>

  

  <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 id=spelling-and-grammar-checking:editing-host href=https://w3c.github.io/editing/execCommand.html#editing-host data-x-internal=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>

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

   <dt><dfn id=concept-spellcheck-default-false>false-by-default</dfn>

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

   <dt><dfn id=concept-spellcheck-default-inherit>inherit-by-default</dfn>

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

  </dl>

  <hr>

  

  <p>The <dfn id=attr-spellcheck><code>spellcheck</code></dfn> attribute is an <a href=#enumerated-attribute id=spelling-and-grammar-checking:enumerated-attribute>enumerated
  attribute</a> whose keywords are the empty string, <code>true</code> and <code>false</code>. The empty string and the <code>true</code> keyword map to the
  <i>true</i> state. The <code>false</code> keyword maps to the <i>false</i> state. In
  addition, there is a third state, the <i>default</i> state, which is the <i id=spelling-and-grammar-checking:missing-value-default><a href=#missing-value-default>missing value default</a></i> and the <i id=spelling-and-grammar-checking:invalid-value-default><a href=#invalid-value-default>invalid value default</a></i>.</p>

  <p class=note>The <i>true</i> state indicates that the element is to have its spelling and
  grammar checked. The <i>default</i> 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 <i>false</i> state
  indicates that the element is not to be checked.</p>

  

  <hr>

  

  <dl class=domintro><dt><var>element</var> . <code id=dom-spellcheck-dev><a href=#dom-spellcheck>spellcheck</a></code> [ = <var>value</var> ]<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>

   </dl>

  

  <p>The <dfn id=dom-spellcheck><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 <i>true</i> 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 <i>default</i> 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 <i>default</i> 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>

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

  <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 the literal string
  "<code>true</code>", otherwise it must be set to the literal string "<code>false</code>".

  <hr>

  <p>User agents must 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="#e-mail-state-(type=email)" id="spelling-and-grammar-checking:e-mail-state-(type=email)">E-mail</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>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>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=https://w3c.github.io/editing/execCommand.html#editing-host id=spelling-and-grammar-checking:editing-host-2 data-x-internal=editing-host>editing
   hosts</a> or <a id=spelling-and-grammar-checking:editable href=https://w3c.github.io/editing/execCommand.html#editable data-x-internal=editable>editable</a> elements.<li>Text in attributes of <a id=spelling-and-grammar-checking:editable-2 href=https://w3c.github.io/editing/execCommand.html#editable data-x-internal=editable>editable</a> elements.</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>

  <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>Otherwise, if the user has forced the checking for this text to always be enabled, then the
   checking is enabled.<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
   <i>true</i> state, then checking is enabled; otherwise, if that attribute is in the <i>false</i>
   state, then checking is disabled.<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 <i>default</i>
   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 <i>true</i> state, then checking is enabled; otherwise, checking is
   disabled.<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>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>Otherwise, if the element's parent element has <em>its</em> checking enabled, then checking
   is enabled.<li>Otherwise, checking is disabled.</ol>

  <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>&quot;true&quot;</c-><c- p>&gt;</c->
 <c- p>&lt;</c-><c- f>span</c-> <c- e>spellcheck</c-><c- o>=</c-><c- s>&quot;false&quot;</c-> <c- e>id</c-><c- o>=</c-><c- s>&quot;a&quot;</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>&quot;true&quot;</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>&quot; false&quot;</c-> <c- e>id</c-><c- o>=</c-><c- s>&quot;b&quot;</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=autocapitalization><span class=secno>6.6.6</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=https://w3c.github.io/editing/execCommand.html#editing-host id=autocapitalization:editing-host data-x-internal=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-inheriting elements</a>
  associated with the <code id=autocapitalization:the-form-element-2><a href=#the-form-element>form</a></code> element.

  <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="#e-mail-state-(type=email)" id="autocapitalization:e-mail-state-(type=email)">E-mail</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><dd><p>The user agent and input method should use make their own determination of whether or not
   to enable autocapitalization.<dt><dfn id=autocap-hint-none>none</dfn><dd><p>No autocapitalization should be applied (all letters should default to
   lowercase).<dt><dfn id=autocap-hint-sentences>sentences</dfn><dd><p>The first letter of each sentence should default to a capital letter; all other letters
   should default to lowercase.<dt><dfn id=autocap-hint-words>words</dfn><dd><p>The first letter of each word should default to a capital letter; all other letters should
   default to lowercase.<dt><dfn id=autocap-hint-characters>characters</dfn><dd><p>All letters should default to uppercase.</dl>

  <p>The <dfn id=attr-autocapitalize><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> State
   <tbody><tr><td><dfn id=attr-autocapitalize-off><code>off</code></dfn>
     <td rowspan=2><a href=#autocap-hint-none id=autocapitalization:autocap-hint-none>none</a>
    <tr><td><dfn id=attr-autocapitalize-none><code>none</code></dfn>
    <tr><td><dfn id=attr-autocapitalize-on><code>on</code></dfn>
     <td rowspan=2><a href=#autocap-hint-sentences id=autocapitalization:autocap-hint-sentences>sentences</a>
    <tr><td><dfn id=attr-autocapitalize-sentences><code>sentences</code></dfn>
    <tr><td><dfn id=attr-autocapitalize-words><code>words</code></dfn>
     <td><a href=#autocap-hint-words id=autocapitalization:autocap-hint-words>words</a>
    <tr><td><dfn id=attr-autocapitalize-characters><code>characters</code></dfn>
     <td><a href=#autocap-hint-characters id=autocapitalization:autocap-hint-characters>characters</a>
  </table>

  <p>The <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. The <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.</p>

  <dl class=domintro><dt><var>element</var> . <code id=dom-autocapitalize-dev><a href=#dom-autocapitalize>autocapitalize</a></code> [ = <var>value</var> ]<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 id=autocapitalization:editing-host-2 href=https://w3c.github.io/editing/execCommand.html#editing-host data-x-internal=editing-host>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>
   </dl>

  

  <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.<li><p>If <var>element</var> is an <a href=#category-autocapitalize id=autocapitalization:category-autocapitalize-2>autocapitalize-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>.<li><p>Return <a href=#autocap-hint-default id=autocapitalization:autocap-hint-default-2>default</a>.</ol>

  <p>The <dfn id=dom-autocapitalize><code>autocapitalize</code></dfn> IDL attribute, on
  getting, must return the string value corresponding to <a href=#own-autocapitalization-hint id=autocapitalization:own-autocapitalization-hint-2>own autocapitalization hint</a> of
  the element, with the exception that the <a href=#autocap-hint-default id=autocapitalization:autocap-hint-default-3>default</a> state
  maps to the empty string. On setting, it must set the <code id=autocapitalization:attr-autocapitalize-7><a href=#attr-autocapitalize>autocapitalize</a></code> content attribute to the given new value.</p>

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

  <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="#e-mail-state-(type=email)" id="autocapitalization:e-mail-state-(type=email)-2">E-mail</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>.<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>.<li><p>If <var>element</var> is an <a id=autocapitalization:editing-host-3 href=https://w3c.github.io/editing/execCommand.html#editing-host data-x-internal=editing-host>editing host</a> or an <a id=autocapitalization:editable href=https://w3c.github.io/editing/execCommand.html#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/execCommand.html#editing-host-of data-x-internal=editing-host-of>editing host of</a>
   <var>element</var>.<li><p>Assert: this step is never reached, since text input only occurs in elements that meet one
   of the above criteria.</ol>

  


  <h4 id=input-modalities:-the-inputmode-attribute><span class=secno>6.6.7</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><div class=status><input onclick=toggleStatus(this) value=⋰ type=button><p class=support><strong>Support:</strong> input-inputmode<span class="and_chr yes"><span>Chrome for Android</span> <span>67+</span></span><span class="chrome yes"><span>Chrome</span> <span>66+</span></span><span class="ios_saf no"><span>iOS Safari</span> <span>None</span></span><span class="and_uc no"><span>UC Browser for Android</span> <span>None</span></span><span class="firefox no"><span>Firefox</span> <span>None</span></span><span class="ie no"><span>IE</span> <span>None</span></span><span class="op_mini no"><span>Opera Mini</span> <span>None</span></span><span class="safari no"><span>Safari</span> <span>None</span></span><span class="edge no"><span>Edge</span> <span>None</span></span><span class="samsung no"><span>Samsung Internet</span> <span>None</span></span><span class="opera yes"><span>Opera</span> <span>53+</span></span><span class="android yes"><span>Android Browser</span> <span>67+</span></span><p class=caniuse>Source: <a href="https://caniuse.com/#feat=input-inputmode">caniuse.com</a></div>

  <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 id=input-modalities:-the-inputmode-attribute:editing-host href=https://w3c.github.io/editing/execCommand.html#editing-host data-x-internal=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>

  <p>The <dfn id=attr-inputmode><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> Description
   <tbody><tr><td><dfn id=attr-inputmode-keyword-none><code>none</code></dfn>
     <td>The user agent should not display a virtual keyboard. This keyword is useful for content
     that renders its own keyboard control.
    <tr><td><dfn id=attr-inputmode-keyword-text><code>text</code></dfn>
     <td>The user agent should display a virtual keyboard capable of text input in the user's locale.
    <tr><td><dfn id=attr-inputmode-keyword-tel><code>tel</code></dfn>
     <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).
    <tr><td><dfn id=attr-inputmode-keyword-url><code>url</code></dfn>
     <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".
    <tr><td><dfn id=attr-inputmode-keyword-email><code>email</code></dfn>
     <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 e-mail addresses, such as that for the "@" character
     and the "." character.
    <tr><td><dfn id=attr-inputmode-keyword-numeric><code>numeric</code></dfn>
     <td> The user agent should display a virtual keyboard capable of numeric input. This keyword
     is useful for PIN entry.
    <tr><td><dfn id=attr-inputmode-keyword-decimal><code>decimal</code></dfn>
     <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.
    <tr><td><dfn id=attr-inputmode-keyword-search><code>search</code></dfn>
     <td>The user agent should display a virtual keyboard optimized for search.
  </table>

  

  <p>The <dfn id=dom-inputmode><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>

  <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.6.8</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 id=input-modalities:-the-enterkeyhint-attribute:editing-host href=https://w3c.github.io/editing/execCommand.html#editing-host data-x-internal=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>

  <p>The <dfn id=attr-enterkeyhint><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> Description
   <tbody><tr><td><dfn id=attr-enterkeyhint-keyword-enter><code>enter</code></dfn>
     <td>The user agent should present a cue for the operation 'enter', typically
     inserting a new line.
    <tr><td><dfn id=attr-enterkeyhint-keyword-done><code>done</code></dfn>
     <td>The user agent should present a cue for the operation 'done', typically
     meaning there is nothing more to input and the IME will be closed.
    <tr><td><dfn id=attr-enterkeyhint-keyword-go><code>go</code></dfn>
     <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.
    <tr><td><dfn id=attr-enterkeyhint-keyword-next><code>next</code></dfn>
     <td>The user agent should present a cue for the operation 'next', typically
     taking the user to the next field that will accept text.
    <tr><td><dfn id=attr-enterkeyhint-keyword-previous><code>previous</code></dfn>
     <td>The user agent should present a cue for the operation 'previous', typically
     taking the user to the previous field that will accept text.
    <tr><td><dfn id=attr-enterkeyhint-keyword-search><code>search</code></dfn>
     <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.
    <tr><td><dfn id=attr-enterkeyhint-keyword-send><code>send</code></dfn>
     <td> The user agent should present a cue for the operation 'send', typically
     delivering the text to its target.
  </table>

  

  <p>The <dfn id=dom-enterkeyhint><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>

  <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=dnd><span class=secno>6.7</span> <dfn>Drag and drop</dfn><a href=#dnd class=self-link></a></h3><div class=status><input onclick=toggleStatus(this) value=⋰ type=button><p class=support><strong>Support:</strong> dragndrop<span class="and_chr no"><span>Chrome for Android</span> <span>None</span></span><span class="chrome yes"><span>Chrome</span> <span>4+</span></span><span class="ios_saf yes"><span>iOS Safari</span> <span>11.0+</span></span><span class="and_uc no"><span>UC Browser for Android</span> <span>None</span></span><span class="firefox yes"><span>Firefox</span> <span>3.5+</span></span><span class="ie partial"><span>IE (limited)</span> <span>5.5+</span></span><span class="op_mini no"><span>Opera Mini</span> <span>None</span></span><span class="safari yes"><span>Safari</span> <span>3.1+</span></span><span class="edge yes"><span>Edge</span> <span>18+</span></span><span class="samsung no"><span>Samsung Internet</span> <span>None</span></span><span class="opera yes"><span>Opera</span> <span>12+</span></span><span class="android no"><span>Android Browser</span> <span>None</span></span><p class=caniuse>Source: <a href="https://caniuse.com/#feat=dragndrop">caniuse.com</a></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.7.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:the-draggable-attribute><a href=#the-draggable-attribute>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>&quot;dragStartHandler(event)&quot;</c-><c- p>&gt;</c->
 <c- p>&lt;</c-><c- f>li</c-> <c- e>draggable</c-><c- o>=</c-><c- s>&quot;true&quot;</c-> <c- e>data-value</c-><c- o>=</c-><c- s>&quot;fruit-apple&quot;</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>&quot;true&quot;</c-> <c- e>data-value</c-><c- o>=</c-><c- s>&quot;fruit-orange&quot;</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>&quot;true&quot;</c-> <c- e>data-value</c-><c- o>=</c-><c- s>&quot;fruit-pear&quot;</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>&apos;text/x-example&apos;</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&apos;s data-value=&quot;&quot; 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>&apos;move&apos;</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&apos;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>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>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.</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>&quot;dragEnterHandler(event)&quot;</c-> <c- e>ondragover</c-><c- o>=</c-><c- s>&quot;dragOverHandler(event)&quot;</c->
    <c- e>ondrop</c-><c- o>=</c-><c- s>&quot;dropHandler(event)&quot;</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>&apos;text/x-example&apos;</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- mi>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>&apos;string&apos;</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>&apos;move&apos;</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>&apos;li&apos;</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>&apos;fruit-apple&apos;</c-><c- p>)</c-> <c- p>{</c->
      li<c- p>.</c->textContent <c- o>=</c-> <c- t>&apos;Apples&apos;</c-><c- p>;</c->
    <c- p>}</c-> <c- k>else</c-> <c- k>if</c-> <c- p>(</c->data <c- o>==</c-> <c- t>&apos;fruit-orange&apos;</c-><c- p>)</c-> <c- p>{</c->
      li<c- p>.</c->textContent <c- o>=</c-> <c- t>&apos;Oranges&apos;</c-><c- p>;</c->
    <c- p>}</c-> <c- k>else</c-> <c- k>if</c-> <c- p>(</c->data <c- o>==</c-> <c- t>&apos;fruit-pear&apos;</c-><c- p>)</c-> <c- p>{</c->
      li<c- p>.</c->textContent <c- o>=</c-> <c- t>&apos;Pears&apos;</c-><c- p>;</c->
    <c- p>}</c-> <c- k>else</c-> <c- p>{</c->
      li<c- p>.</c->textContent <c- o>=</c-> <c- t>&apos;Unknown Fruit&apos;</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>&quot;dragStartHandler(event)&quot;</c-> <c- e>ondragend</c-><c- o>=</c-><c- s>&quot;dragEndHandler(event)&quot;</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>&apos;move&apos;</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.7.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><dd>

      <p>The kind of data:</p>

      <dl><dt><i>Plain Unicode string</i><dd>
        <p>Text.</p>
       <dt><i>File</i><dd>
        <p>Binary data with a file name.</p>
       </dl>

     <dt><dfn id=the-drag-data-item-type-string>The drag data item type string</dfn><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>Plain Unicode string</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> 

     <dt>The actual data<dd><p>A Unicode or binary string, in some cases with a file name (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>.</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>

    <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>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>.</ul>

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

     <dt><dfn id=concept-dnd-ro>Read-only mode</dfn><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>

     <dt><dfn id=concept-dnd-p>Protected mode</dfn><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>

     </dl>

   <li>

    <p>A <dfn id=drag-data-store-allowed-effects-state>drag data store allowed effects state</dfn>, which is a string.</p>

   </ul>

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


  <h4 id=the-datatransfer-interface><span class=secno>6.7.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>

  <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->,
 <a href='#dom-datatransfer' id='the-datatransfer-interface:dom-datatransfer'><c- g>Constructor</c-></a>]
<c- b>interface</c-> <dfn id='datatransfer'><c- g>DataTransfer</c-></dfn> {
  <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>void</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>void</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>void</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 href='https://w3c.github.io/FileAPI/#filelist-section' data-x-internal='filelist' id='the-datatransfer-interface: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><var>dataTransfer</var> = new <code id=dom-datatransfer-dev><a href=#dom-datatransfer>DataTransfer</a></code>()<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>

   <dt><var>dataTransfer</var> . <code id=dom-datatransfer-dropeffect-dev><a href=#dom-datatransfer-dropeffect>dropEffect</a></code> [ = <var>value</var> ]<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>

   <dt><var>dataTransfer</var> . <code id=dom-datatransfer-effectallowed-dev><a href=#dom-datatransfer-effectallowed>effectAllowed</a></code> [ = <var>value</var> ]<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>

   <dt><var>dataTransfer</var> . <code id=dom-datatransfer-items-dev><a href=#dom-datatransfer-items>items</a></code><dd>

    <p>Returns a <code id=the-datatransfer-interface:datatransferitemlist-2><a href=#datatransferitemlist>DataTransferItemList</a></code> object, with the drag data.</p>

   <dt><var>dataTransfer</var> . <code id=dom-datatransfer-setdragimage-dev><a href=#dom-datatransfer-setdragimage>setDragImage</a></code>(<var>element</var>, <var>x</var>, <var>y</var>)<dd>

    <p>Uses the given element to update the drag feedback, replacing any previously specified
    feedback.</p>

   <dt><var>dataTransfer</var> . <code id=dom-datatransfer-types-dev><a href=#dom-datatransfer-types>types</a></code><dd>

    <p>Returns a <a id=the-datatransfer-interface:frozen-array href=https://heycam.github.io/webidl/#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>

   <dt><var>data</var> = <var>dataTransfer</var> . <code id=dom-datatransfer-getdata-dev><a href=#dom-datatransfer-getdata>getData</a></code>(<var>format</var>)<dd>

    <p>Returns the specified data. If there is no such data, returns the empty string.</p>

   <dt><var>dataTransfer</var> . <code id=dom-datatransfer-setdata-dev><a href=#dom-datatransfer-setdata>setData</a></code>(<var>format</var>, <var>data</var>)<dd>

    <p>Adds the specified data.</p>

   <dt><var>dataTransfer</var> . <code id=dom-datatransfer-cleardata-dev><a href=#dom-datatransfer-cleardata>clearData</a></code>( [ <var>format</var> ] )<dd>

    <p>Removes the data of the specified formats. Removes all data if the argument is omitted.</p>

   <dt><var>dataTransfer</var> . <code id=dom-datatransfer-files-dev><a href=#dom-datatransfer-files>files</a></code><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>

   </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>

  <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://heycam.github.io/webidl/#dfn-frozen-array-type>FrozenArray&lt;DOMString></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.<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>Plain Unicode string</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>.<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.)</ol>
   <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://heycam.github.io/webidl/#dfn-create-frozen-array data-x-internal=creating-a-frozen-array>creating a frozen array</a> from <var>L</var>.</ol>

  <p>The <dfn id=dom-datatransfer><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.<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>.<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".</ol>

  <p>The <dfn id=dom-datatransfer-dropeffect><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>

  <p>The <dfn id=dom-datatransfer-effectallowed><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 <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>

  <p>The <dfn id=dom-datatransfer-items><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>

  <p>The <dfn id=dom-datatransfer-setdragimage><code>setDragImage(<var>element</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.<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.<li><p>If <var>element</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/css2/conform.html#intrinsic id=the-datatransfer-interface:intrinsic-dimensions data-x-internal=intrinsic-dimensions>intrinsic
   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).<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.</ol>

  <p>The <dfn id=dom-datatransfer-types><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>

  <p>The <dfn id=dom-datatransfer-getdata><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.<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.<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>.<li><p>Let <var>convert-to-URL</var> be false.<li><p>If <var>format</var> equals "<code>text</code>", change it to "<code>text/plain</code>".<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.<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>Plain Unicode string</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.<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>.<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><li><p>Return <var>result</var>.</ol>

  <p>The <dfn id=dom-datatransfer-setdata><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.<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.<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>.<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><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>Plain Unicode string</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.<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>Plain Unicode string</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.</ol>

  <p>The <dfn id=dom-datatransfer-cleardata><code>clearData()</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.<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.<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.<li><p>Let <var>format</var> be the first argument, <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>.<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><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>Plain Unicode string</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.</ol>

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

  <p>The <dfn id=dom-datatransfer-files><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>.<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>.<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>.<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>.<li><p>The files found by these steps are those in the list <var>L</var>.</ol>

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

  <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'><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 href='https://w3c.github.io/FileAPI/#dfn-file' data-x-internal='file' id='the-datatransferitemlist-interface:file'><c- n>File</c-></a> <c- g>data</c->);
  <c- b>void</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>void</c-> <a href='#dom-datatransferitemlist-clear' id='the-datatransferitemlist-interface:dom-datatransferitemlist-clear'><c- g>clear</c-></a>();
};</code></pre>

  <dl class=domintro><dt><var>items</var> . <code id=dom-datatransferitemlist-length-dev><a href=#dom-datatransferitemlist-length>length</a></code><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>.<dt><var>items</var>[<var>index</var>]<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>

   <dt><var>items</var> . <code id=dom-datatransferitemlist-remove-dev><a href=#dom-datatransferitemlist-remove>remove</a></code>(<var>index</var>)<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>

   <dt><var>items</var> . <code id=dom-datatransferitemlist-clear-dev><a href=#dom-datatransferitemlist-clear>clear</a></code>()<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>

   <dt><var>items</var> . <code id=dom-datatransferitemlist-add-dev><a href=#dom-datatransferitemlist-add>add</a></code>(<var>data</var>)<dt><var>items</var> . <code id=the-datatransferitemlist-interface:dom-datatransferitemlist-add-3><a href=#dom-datatransferitemlist-add>add</a></code>(<var>data</var>, <var>type</var>)<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>

   </dl>

  

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

  <p>The <dfn id=dom-datatransferitemlist-length><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>

  <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://heycam.github.io/webidl/#dfn-supported-property-indices data-x-internal=supported-property-indices>supported property indices</a> are the numbers in the range

    <span>0 .. <var>n</var>-1</span>,

  where <var>n</var> is the number of items in 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>

  <p id=dom-datatransferitemlist-item>To <a id=the-datatransferitemlist-interface:determine-the-value-of-an-indexed-property href=https://heycam.github.io/webidl/#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>

  <p>The <dfn id=dom-datatransferitemlist-add><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.<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<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>Plain Unicode string</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://heycam.github.io/webidl/#notsupportederror data-x-internal=notsupportederror>"<code>NotSupportedError</code>"</a> <code id=the-datatransferitemlist-interface:domexception><a data-x-internal=domexception href=https://heycam.github.io/webidl/#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>Plain Unicode string</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>

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

     </dl>

   <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).</ol>

  <p>The <dfn id=dom-datatransferitemlist-remove><code>remove()</code></dfn> method, when
  invoked with the argument <var>i</var>, 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://heycam.github.io/webidl/#invalidstateerror data-x-internal=invalidstateerror>"<code>InvalidStateError</code>"</a> <code id=the-datatransferitemlist-interface:domexception-2><a data-x-internal=domexception href=https://heycam.github.io/webidl/#dfn-DOMException>DOMException</a></code>.<li><p>Remove the <var>i</var>th item from the <a href=#drag-data-store id=the-datatransferitemlist-interface:drag-data-store-11>drag data store</a>.</ol>

  <p>The <dfn id=dom-datatransferitemlist-clear><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-12>drag data store</a>. Otherwise, it must do
  nothing.</p>

  


  <h5 id=the-datatransferitem-interface><span class=secno>6.7.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>

  <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'><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>void</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 href='https://w3c.github.io/FileAPI/#dfn-file' data-x-internal='file' id='the-datatransferitem-interface: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'><c- g>FunctionStringCallback</c-></dfn> = <c- b>void</c-> (<c- b>DOMString</c-> <c- g>data</c->);</code></pre>

  <dl class=domintro><dt><var>item</var> . <code id=dom-datatransferitem-kind-dev><a href=#dom-datatransferitem-kind>kind</a></code><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>

   <dt><var>item</var> . <code id=dom-datatransferitem-type-dev><a href=#dom-datatransferitem-type>type</a></code><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>

   <dt><var>item</var> . <code id=dom-datatransferitem-getasstring-dev><a href=#dom-datatransferitem-getasstring>getAsString</a></code>(<var>callback</var>)<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>Plain Unicode string</i>.</p>

   <dt><var>file</var> = <var>item</var> . <code id=dom-datatransferitem-getasfile-dev><a href=#dom-datatransferitem-getasfile>getAsFile</a></code>()<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>

   </dl>

  

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

  <p>The <dfn id=dom-datatransferitem-kind><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> String
   <tbody><tr><td> <i>Plain Unicode string</i> <td> "<code>string</code>"

    <tr><td> <i>File</i> <td> "<code>file</code>"

  </table>

  <p>The <dfn id=dom-datatransferitem-type><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>

  <p>The <dfn id=dom-datatransferitem-getasstring><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.<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.<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>Plain Unicode string</i>, then return.
   The callback is never invoked.<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.</ol>



  <p>The <dfn id=dom-datatransferitem-getasfile><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.<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.<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>

  </ol>



  



  <h4 id=the-dragevent-interface><span class=secno>6.7.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>

  <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- 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>interface</c-> <dfn id='dragevent'><c- g>DragEvent</c-></dfn> : <a href='https://w3c.github.io/uievents/#mouseevent' data-x-internal='mouseevent' id='the-dragevent-interface:mouseevent'><c- n>MouseEvent</c-></a> {
  <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'><c- g>DragEventInit</c-></dfn> : <a href='https://w3c.github.io/uievents/#dictdef-mouseeventinit' data-x-internal='mouseeventinit' id='the-dragevent-interface: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><var>event</var> . <code id=dom-dragevent-datatransfer-dev><a href=#dom-dragevent-datatransfer>dataTransfer</a></code><dd>

    <p>Returns the <code id=the-dragevent-interface:datatransfer-3><a href=#datatransfer>DataTransfer</a></code> object for the event.</p>

   </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>

  

  <p>The <dfn id=dom-dragevent-datatransfer><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>

  

  

  <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><p>If no specific <var>related target</var> was provided, set <var>related target</var> to
   null.<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.<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><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>.<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>.<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>, <code id=the-dragevent-interface:event-dnd-dragexit><a href=#event-dnd-dragexit>dragexit</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><code id=the-dragevent-interface:dom-datatransfer-dropeffect-2><a href=#dom-datatransfer-dropeffect>dropEffect</a></code><tbody><tr><td>"<code id=the-dragevent-interface:dom-datatransfer-effectallowed-none><a href=#dom-datatransfer-effectallowed-none>none</a></code>"<td>"<code id=the-dragevent-interface:dom-datatransfer-dropeffect-none-2><a href=#dom-datatransfer-dropeffect-none>none</a></code>"<tr><td>"<code id=the-dragevent-interface:dom-datatransfer-effectallowed-copy><a href=#dom-datatransfer-effectallowed-copy>copy</a></code>"<td>"<code id=the-dragevent-interface:dom-datatransfer-dropeffect-copy><a href=#dom-datatransfer-dropeffect-copy>copy</a></code>"<tr><td>"<code id=the-dragevent-interface:dom-datatransfer-effectallowed-copylink><a href=#dom-datatransfer-effectallowed-copylink>copyLink</a></code>"<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>"<tr><td>"<code id=the-dragevent-interface:dom-datatransfer-effectallowed-copymove><a href=#dom-datatransfer-effectallowed-copymove>copyMove</a></code>"<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>"<tr><td>"<code id=the-dragevent-interface:dom-datatransfer-effectallowed-all><a href=#dom-datatransfer-effectallowed-all>all</a></code>"<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>"<tr><td>"<code id=the-dragevent-interface:dom-datatransfer-effectallowed-link><a href=#dom-datatransfer-effectallowed-link>link</a></code>"<td>"<code id=the-dragevent-interface:dom-datatransfer-dropeffect-link-3><a href=#dom-datatransfer-dropeffect-link>link</a></code>"<tr><td>"<code id=the-dragevent-interface:dom-datatransfer-effectallowed-linkmove><a href=#dom-datatransfer-effectallowed-linkmove>linkMove</a></code>"<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>"<tr><td>"<code id=the-dragevent-interface:dom-datatransfer-effectallowed-move><a href=#dom-datatransfer-effectallowed-move>move</a></code>"<td>"<code id=the-dragevent-interface:dom-datatransfer-dropeffect-move-4><a href=#dom-datatransfer-dropeffect-move>move</a></code>"<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>"<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>"<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>"<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>"<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>"<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>"<tr><td>Any other case<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>"</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><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>.<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>.<li><p>If <var>e</var> is not <code id=the-dragevent-interface:event-dnd-dragexit-2><a href=#event-dnd-dragexit>dragexit</a></code>, <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.<li>
    <p>Initialize <var>event</var>'s mouse and key attributes initialized 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>clientX</code>, <code>clientY</code>, and <code>button</code> attributes to 0.</p>
   <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.<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>.)<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>.<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>.</ol>

  


  

  <h4 id=drag-and-drop-processing-model><span class=secno>6.7.5</span> Processing model<a href=#drag-and-drop-processing-model class=self-link></a></h4>

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

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

    <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>
     <dd>"<code id=drag-and-drop-processing-model:text/plain><a data-x-internal=text/plain href=https://tools.ietf.org/html/rfc2046#section-4.1.3>text/plain</a></code>"<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>
     <dd><i>Plain Unicode string</i><dt>The actual data<dd>The text of the selection</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>
     <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://tools.ietf.org/html/rfc2046#section-4.5.1>application/octet-stream</a></code>" otherwise.<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>
     <dd><i>File</i><dt>The actual data<dd>The file's contents and name.</dl>

    <p class=note>Dragging files can currently only happen from outside a <a href=#browsing-context id=drag-and-drop-processing-model:browsing-context>browsing
    context</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>

    <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>
     <dd><code id=drag-and-drop-processing-model:application/microdata+json><a href=#application/microdata+json>application/microdata+json</a></code><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>
     <dd><i>Plain Unicode string</i><dt>The actual data<dd>The resulting JSON string.</dl>

   <li>

    <p>Run the following substeps:</p>

    <ol><li><p>Let <var>urls</var> be an empty list of <a href=https://url.spec.whatwg.org/#syntax-url-absolute id=drag-and-drop-processing-model:absolute-url data-x-internal=absolute-url>absolute
     URLs</a>.<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<dd>Add to <var>urls</var> the result of <a href=#parse-a-url id=drag-and-drop-processing-model:parse-a-url>parsing</a> the
       element's <code id=drag-and-drop-processing-model:attr-hyperlink-href-3><a href=#attr-hyperlink-href>href</a></code> content attribute 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>.<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<dd>Add to <var>urls</var> the result of <a href=#parse-a-url id=drag-and-drop-processing-model:parse-a-url-2>parsing</a> the
       element's <code id=drag-and-drop-processing-model:attr-img-src-2><a href=#attr-img-src>src</a></code> content attribute 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>.</dl>

     <li><p>If <var>urls</var> is still empty, then return.<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).<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>
       <dd><code id=drag-and-drop-processing-model:text/uri-list><a href=#text/uri-list>text/uri-list</a></code><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>
       <dd><i>Plain Unicode string</i><dt>The actual data<dd><var>url string</var></dl>

     </ol>

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

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

    <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>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>.</ol>

   </ol>

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

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

    <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-9>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>

    <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 <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-dragexit><a href=#event-dnd-dragexit>dragexit</a></code> at the <a href=#current-target-element id=drag-and-drop-processing-model:current-target-element-5>current
      target element</a>, and then update the <a href=#current-target-element id=drag-and-drop-processing-model:current-target-element-6>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<dd><p>Set the <a href=#current-target-element id=drag-and-drop-processing-model:current-target-element-7>current target element</a> to null also.<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<dd><p>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-9>immediate user
       selection</a>.<dt>Otherwise<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><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-9>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 id=drag-and-drop-processing-model:editing-host href=https://w3c.github.io/editing/execCommand.html#editing-host data-x-internal=editing-host>editing host</a> or
         <a id=drag-and-drop-processing-model:editable href=https://w3c.github.io/editing/execCommand.html#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://tools.ietf.org/html/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>Plain Unicode string</i><dd><p>Set the <a href=#current-target-element id=drag-and-drop-processing-model:current-target-element-10>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.<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><dd><p>Leave the <a href=#current-target-element id=drag-and-drop-processing-model:current-target-element-11>current target element</a> unchanged.<dt>Otherwise<dd>

          <p><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-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-12>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>

         </dl>

       </dl>

     <li>

      <p>If the previous step caused the <a href=#current-target-element id=drag-and-drop-processing-model:current-target-element-13>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-6>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-14>current target element</a> as the specific <var>related
      target</var>.</p>

     <li>

      <p>If the <a href=#current-target-element id=drag-and-drop-processing-model:current-target-element-15>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-7>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-16>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-17>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 id=drag-and-drop-processing-model:editing-host-2 href=https://w3c.github.io/editing/execCommand.html#editing-host data-x-internal=editing-host>editing host</a> or
       <a id=drag-and-drop-processing-model:editable-2 href=https://w3c.github.io/editing/execCommand.html#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://tools.ietf.org/html/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>Plain Unicode string</i><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.<dt>Otherwise<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>".</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><code id=drag-and-drop-processing-model:dom-datatransfer-dropeffect-2><a href=#dom-datatransfer-dropeffect>dropEffect</a></code><th>Drag operation<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>"<code id=drag-and-drop-processing-model:dom-datatransfer-dropeffect-copy><a href=#dom-datatransfer-dropeffect-copy>copy</a></code>"<td>"<code id=drag-and-drop-processing-model:concept-current-drag-operation-copy-2><a href=#concept-current-drag-operation-copy>copy</a></code>"<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>"<code id=drag-and-drop-processing-model:dom-datatransfer-dropeffect-link><a href=#dom-datatransfer-dropeffect-link>link</a></code>"<td>"<code id=drag-and-drop-processing-model:concept-current-drag-operation-link><a href=#concept-current-drag-operation-link>link</a></code>"<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>"<code id=drag-and-drop-processing-model:dom-datatransfer-dropeffect-move><a href=#dom-datatransfer-dropeffect-move>move</a></code>"<td>"<code id=drag-and-drop-processing-model:concept-current-drag-operation-move-2><a href=#concept-current-drag-operation-move>move</a></code>"<tr><td colspan=2>Any other case<td>"<code id=drag-and-drop-processing-model:concept-current-drag-operation-none-4><a href=#concept-current-drag-operation-none>none</a></code>"</table>

     <li>

      <p>Otherwise, if the <a href=#current-target-element id=drag-and-drop-processing-model:current-target-element-18>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>

      <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>Feedback<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>Data will be copied if dropped here.<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>Data will be linked if dropped here.<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>Data will be moved if dropped here.<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>No operation allowed, dropping here will cancel the drag-and-drop operation.</table>

     </ol>

   <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-19>current target element</a> is null, then the drag operation failed. Run
      these substeps:</p>

      <ol><li><p>Let <var>dropped</var> be false.<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-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.<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>".</ol>

      <p>Otherwise, the drag operation might be a success; run these substeps:</p>

      <ol><li><p>Let <var>dropped</var> be true.<li><p>If the <a href=#current-target-element id=drag-and-drop-processing-model:current-target-element-21>current target element</a> is a DOM element, <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-drop><a href=#event-dnd-drop>drop</a></code> at it; otherwise, use
       platform-specific conventions for indicating a drop.<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-22>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 id=drag-and-drop-processing-model:editing-host-3 href=https://w3c.github.io/editing/execCommand.html#editing-host data-x-internal=editing-host>editing host</a> or
         <a id=drag-and-drop-processing-model:editable-3 href=https://w3c.github.io/editing/execCommand.html#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://tools.ietf.org/html/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>Plain Unicode string</i><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://tools.ietf.org/html/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>Plain Unicode string</i> into the text control or
         <a id=drag-and-drop-processing-model:editing-host-4 href=https://w3c.github.io/editing/execCommand.html#editing-host data-x-internal=editing-host>editing host</a> or <a id=drag-and-drop-processing-model:editable-4 href=https://w3c.github.io/editing/execCommand.html#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).<dt>Otherwise<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>".</dl>

       </ol>

     <li>

      <p><a href=#fire-a-dnd-event id=drag-and-drop-processing-model:fire-a-dnd-event-10>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-10>source node</a>.</p>

     <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-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-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 id=drag-and-drop-processing-model:editing-host-5 href=https://w3c.github.io/editing/execCommand.html#editing-host data-x-internal=editing-host>editing host</a><dd><p><a id=drag-and-drop-processing-model:delete-the-selection href=https://w3c.github.io/editing/execCommand.html#delete-the-selection data-x-internal=delete-the-selection>Delete the selection</a>.<dt>If <var>dropped</var> is true, the <a href=#current-target-element id=drag-and-drop-processing-model:current-target-element-24>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<dd><p>The user agent should delete the dragged selection from the relevant text
       control.<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>"<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.<dt>Otherwise<dd><p>The event has no default action.</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="#e-mail-state-(type=email)" id="drag-and-drop-processing-model:e-mail-state-(type=email)">E-mail</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>


     </ol>

   </ol>

  <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/visuren.html#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.7.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> Target <th> Cancelable? <th> <a href=#drag-data-store-mode id=dndevents:drag-data-store-mode>Drag data store mode</a> <th> <code id=dndevents:dom-datatransfer-dropeffect><a href=#dom-datatransfer-dropeffect>dropEffect</a></code> <th> Default Action <tbody><tr><td><dfn id=event-dnd-dragstart><code>dragstart</code></dfn><td><a href=#source-node id=dndevents:source-node>Source node</a><td>✓ Cancelable<td><a href=#concept-dnd-rw id=dndevents:concept-dnd-rw>Read/write mode</a>
     <td>"<code id=dndevents:dom-datatransfer-dropeffect-none><a href=#dom-datatransfer-dropeffect-none>none</a></code>"<td>Initiate the drag-and-drop operation<tr><td><dfn id=event-dnd-drag><code>drag</code></dfn><td><a href=#source-node id=dndevents:source-node-2>Source node</a><td>✓ Cancelable<td><a href=#concept-dnd-p id=dndevents:concept-dnd-p>Protected mode</a>
     <td>"<code id=dndevents:dom-datatransfer-dropeffect-none-2><a href=#dom-datatransfer-dropeffect-none>none</a></code>"<td>Continue the drag-and-drop operation<tr><td><dfn id=event-dnd-dragenter><code>dragenter</code></dfn><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>✓ Cancelable<td><a href=#concept-dnd-p id=dndevents:concept-dnd-p-2>Protected mode</a>
     <td><a href=#dropEffect-initialisation>Based on <code>effectAllowed</code> value</a><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><tr><td><dfn id=event-dnd-dragexit><code>dragexit</code></dfn><td><a href=#current-target-element id=dndevents:current-target-element-2>Previous target element</a><td>—<td><a href=#concept-dnd-p id=dndevents:concept-dnd-p-3>Protected mode</a>
     <td>"<code id=dndevents:dom-datatransfer-dropeffect-none-3><a href=#dom-datatransfer-dropeffect-none>none</a></code>"<td>None<tr><td><dfn id=event-dnd-dragleave><code>dragleave</code></dfn><td><a href=#current-target-element id=dndevents:current-target-element-3>Previous target element</a><td>—<td><a href=#concept-dnd-p id=dndevents:concept-dnd-p-4>Protected mode</a>
     <td>"<code id=dndevents:dom-datatransfer-dropeffect-none-4><a href=#dom-datatransfer-dropeffect-none>none</a></code>"<td>None<tr><td><dfn id=event-dnd-dragover><code>dragover</code></dfn><td><a href=#current-target-element id=dndevents:current-target-element-4>Current target element</a><td>✓ Cancelable<td><a href=#concept-dnd-p id=dndevents:concept-dnd-p-5>Protected mode</a>
     <td><a href=#dropEffect-initialisation>Based on <code>effectAllowed</code> value</a><td>Reset the <a href=#current-drag-operation id=dndevents:current-drag-operation>current drag operation</a> to "none"<tr><td><dfn id=event-dnd-drop><code>drop</code></dfn><td><a href=#current-target-element id=dndevents:current-target-element-5>Current target element</a><td>✓ Cancelable<td><a href=#concept-dnd-ro id=dndevents:concept-dnd-ro>Read-only mode</a>
     <td><a href=#current-drag-operation id=dndevents:current-drag-operation-2>Current drag operation</a><td>Varies<tr><td><dfn id=event-dnd-dragend><code>dragend</code></dfn><td><a href=#source-node id=dndevents:source-node-3>Source node</a><td>—<td><a href=#concept-dnd-p id=dndevents:concept-dnd-p-6>Protected mode</a>
     
     <td><a href=#current-drag-operation id=dndevents:current-drag-operation-3>Current drag operation</a><td>Varies</table>

  <p>Not shown in the above table: all 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.7.7</span> The <dfn><code>draggable</code></dfn> attribute<a href=#the-draggable-attribute class=self-link></a></h4>

  <p>All <a href=#html-elements id=the-draggable-attribute:html-elements>HTML elements</a> may have the <code id=the-draggable-attribute:the-draggable-attribute><a href=#the-draggable-attribute>draggable</a></code>
  content attribute set. The <code id=the-draggable-attribute:the-draggable-attribute-2><a href=#the-draggable-attribute>draggable</a></code> attribute is an
  <a href=#enumerated-attribute id=the-draggable-attribute:enumerated-attribute>enumerated attribute</a>. It has three states. The first state is <i>true</i> and it has
  the keyword <code>true</code>. The second state is <i>false</i> and it has the keyword
  <code>false</code>. The third state is <i>auto</i>; it has no keywords but it is the
  <i id=the-draggable-attribute:missing-value-default><a href=#missing-value-default>missing value default</a></i> and the <i id=the-draggable-attribute:invalid-value-default><a href=#invalid-value-default>invalid value default</a></i>.</p>

  <p>The <i>true</i> state means the element is draggable; the <i>false</i> state means that it is
  not. The <i>auto</i> state uses the default behavior of the user agent.</p>

  <p>An element with a <code id=the-draggable-attribute:the-draggable-attribute-3><a href=#the-draggable-attribute>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><var>element</var> . <code id=dom-draggable-dev><a href=#dom-draggable>draggable</a></code> [ = <var>value</var> ]<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:the-draggable-attribute-4><a href=#the-draggable-attribute>draggable</a></code>
    content attribute.</p>

   </dl>

  

  <p>The <dfn id=dom-draggable><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>

  <p>If an element's <code id=the-draggable-attribute:the-draggable-attribute-5><a href=#the-draggable-attribute>draggable</a></code> content attribute has the state
  <i>true</i>, 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:the-draggable-attribute-6><a href=#the-draggable-attribute>draggable</a></code> content attribute has
  the state <i>false</i>, 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:the-draggable-attribute-7><a href=#the-draggable-attribute>draggable</a></code> content attribute has
  the state <i>auto</i>. 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>

  <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:the-draggable-attribute-8><a href=#the-draggable-attribute>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:the-draggable-attribute-9><a href=#the-draggable-attribute>draggable</a></code> content
  attribute must be set to the literal value "<code>true</code>".</p>

  






  

  <h4 id=security-risks-in-the-drag-and-drop-model><span class=secno>6.7.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>

  




  <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=windows><span class=secno>7.1</span> Browsing contexts<a href=#windows class=self-link></a></h3>

  <p>A <dfn id=browsing-context data-export="">browsing context</dfn> is an environment in which <code id=windows:document><a href=#document>Document</a></code>
  objects are presented to the user.</p>

  <p class=note>A tab or window in a Web browser typically contains a <a href=#browsing-context id=windows:browsing-context>browsing
  context</a>, as does an <code id=windows:the-iframe-element><a href=#the-iframe-element>iframe</a></code> or <code id=windows:frame><a href=#frame>frame</a></code>s in a
  <code id=windows:frameset><a href=#frameset>frameset</a></code>.</p>

  <p>A <a href=#browsing-context id=windows:browsing-context-2>browsing context</a> has a corresponding <code id=windows:windowproxy><a href=#windowproxy>WindowProxy</a></code> object.</p>

  <p>A <a href=#browsing-context id=windows:browsing-context-3>browsing context</a> has a <a href=#session-history id=windows:session-history>session history</a>, which lists the
  <code id=windows:document-2><a href=#document>Document</a></code> objects that the <a href=#browsing-context id=windows:browsing-context-4>browsing context</a> has presented, is presenting,
  or will present. A <a href=#browsing-context id=windows:browsing-context-5>browsing context</a>'s <dfn id=active-document data-export="">active document</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's <a href=#concept-document-window id=windows:concept-document-window>associated
  <code>Document</code></a>. A <dfn data-dfn-for=Document id=concept-document-bc data-lt="browsing context" data-export=""><code>Document</code>'s browsing context</dfn> is the
  <a href=#browsing-context id=windows:browsing-context-6>browsing context</a> whose <a href=#session-history id=windows:session-history-2>session history</a> contains the
  <code id=windows:document-3><a href=#document>Document</a></code>, if any such browsing context exists and has not been <a href=#a-browsing-context-is-discarded id=windows:a-browsing-context-is-discarded>discarded</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-4><a href=#document>Document</a></code> object, as long as the <code id=windows:document-5><a href=#document>Document</a></code> object has a <a href=#concept-document-bc id=windows:concept-document-bc>browsing context</a>. There is one exceptions. 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-6><a href=#document>Document</a></code> in the
  same <a href=#browsing-context id=windows:browsing-context-7>browsing context</a>, such that the mapping is then 1-to-2. This occurs when a
  <a href=#browsing-context id=windows:browsing-context-8>browsing context</a> is <a href=#navigate id=windows:navigate>navigated</a> from the initial
  <code id=windows:about:blank><a href=#about:blank>about:blank</a></code> <code id=windows:document-7><a href=#document>Document</a></code> to another, with <a href=#replacement-enabled id=windows:replacement-enabled>replacement enabled</a>.

  <p class=note>A <code id=windows:document-8><a href=#document>Document</a></code> does not necessarily have a <a href=#concept-document-bc id=windows:concept-document-bc-2>browsing context</a> associated with it. In particular, data
  mining tools are likely to never instantiate browsing contexts. A <code id=windows:document-9><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 <a href=#concept-document-bc id=windows:concept-document-bc-3>browsing context</a>. And the
  <code id=windows:document-10><a href=#document>Document</a></code> originally created for an <code id=windows:the-iframe-element-2><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=#a-browsing-context-is-discarded id=windows:a-browsing-context-is-discarded-2>discarded</a>.</p>

  <p>To <dfn id=set-the-active-document>set the active document</dfn> of a <a href=#browsing-context id=windows:browsing-context-9>browsing context</a>
  <var>browsingContext</var> to a <code id=windows:document-11><a href=#document>Document</a></code> object <var>document</var>, run these
  steps:</p>

  <ol><li>
    <p>Let <var>window</var> be <var>document</var>'s <a href=#concept-relevant-global id=windows:concept-relevant-global>relevant global object</a>.</p>

    <p class=XXX>Per this standard <var>document</var> can be created before
    <var>window</var>, which does not make much sense. See <a href=https://github.com/whatwg/html/issues/2688>issue #2688</a>.</p>
   <li><p>Set <var>browsingContext</var>'s <code id=windows:windowproxy-3><a href=#windowproxy>WindowProxy</a></code> object's <a href=#concept-windowproxy-window id=windows:concept-windowproxy-window-2>[[Window]]</a> internal slot value to
   <var>window</var>.<li><p>Set <var>window</var>'s <a href=#concept-document-window id=windows:concept-document-window-2>associated
   <code>Document</code></a> to <var>document</var>.<li><p>Set <var>window</var>'s <a href=#relevant-settings-object id=windows:relevant-settings-object>relevant settings object</a>'s <a href=#concept-environment-execution-ready-flag id=windows:concept-environment-execution-ready-flag>execution ready flag</a>.</ol>

  <hr>

  <p>A <a href=#browsing-context id=windows:browsing-context-10>browsing context</a> can have a <dfn id=creator-browsing-context data-export="">creator browsing context</dfn>,
  the <a href=#browsing-context id=windows:browsing-context-11>browsing context</a> that was responsible for its creation. If a <a href=#browsing-context id=windows:browsing-context-12>browsing
  context</a> has a <a href=#parent-browsing-context id=windows:parent-browsing-context>parent browsing context</a>, then that is its <a href=#creator-browsing-context id=windows:creator-browsing-context>creator browsing
  context</a>. Otherwise, if the <a href=#browsing-context id=windows:browsing-context-13>browsing context</a> has an <a href=#opener-browsing-context id=windows:opener-browsing-context>opener browsing
  context</a>, then <em>that</em> is its <a href=#creator-browsing-context id=windows:creator-browsing-context-2>creator browsing context</a>. Otherwise, the
  <a href=#browsing-context id=windows:browsing-context-14>browsing context</a> has no <a href=#creator-browsing-context id=windows:creator-browsing-context-3>creator browsing context</a>.</p>

  <p>If a <a href=#browsing-context id=windows:browsing-context-15>browsing context</a> <var>context</var> has a <a href=#creator-browsing-context id=windows:creator-browsing-context-4>creator browsing
  context</a> <var>creator</var>, it also has the following properties. In what follows, let
  <var>creator document</var> be <var>creator</var>'s <a href=#active-document id=windows:active-document>active document</a> at the time
  <var>context</var> is created:</p>

  <dl><dt><dfn id=creator-origin>creator origin</dfn><dd><var>creator document</var>'s <a href=#concept-origin id=windows:concept-origin>origin</a><dt><dfn id=creator-url>creator URL</dfn><dd><var>creator document</var>'s <a href=https://dom.spec.whatwg.org/#concept-document-url id="windows:the-document's-address" data-x-internal="the-document's-address">URL</a><dt><dfn id=creator-base-url>creator base URL</dfn><dd><var>creator document</var>'s <a href=#document-base-url id=windows:document-base-url>base URL</a><dt><dfn id=creator-referrer-policy>creator referrer policy</dfn><dd><var>creator document</var>'s <a href=#concept-document-referrer-policy id=windows:concept-document-referrer-policy>referrer
   policy</a></dl>

  

  <p>To <dfn id=creating-a-new-browsing-context>create a new browsing context</dfn>,
  optionally given <var>noopener</var>:</p>

  <ol><li><p>If <var>noopener</var> was not given, let it be false.<li><p>Let <var>browsingContext</var> be a new <a href=#browsing-context id=windows:browsing-context-16>browsing context</a>.<li>
    <p>Let <var>realm execution context</var> be the result of <a href=#creating-a-new-javascript-realm id=windows:creating-a-new-javascript-realm>creating a new JavaScript
    realm</a> with the following customizations:</p>

    <ul><li><p>For the global object, create a new <code id=windows:window-3><a href=#window>Window</a></code> object.<li><p>For the global <b>this</b> binding, use <var>browsingContext</var>'s
     <code id=windows:windowproxy-4><a href=#windowproxy>WindowProxy</a></code> object.</ul>
   <li><p><a href=#set-up-a-window-environment-settings-object id=windows:set-up-a-window-environment-settings-object>Set up a window environment settings object</a> with <var>realm execution
   context</var>, and let <var>settingsObject</var> be the result.<li><p>Let <var>document</var> be a new <code id=windows:document-12><a href=#document>Document</a></code>, marked as an <a href=https://dom.spec.whatwg.org/#html-document id=windows:html-documents data-x-internal=html-documents>HTML document</a> in <a id=windows:quirks-mode href=https://dom.spec.whatwg.org/#concept-document-quirks data-x-internal=quirks-mode>quirks mode</a>, whose <a href=https://dom.spec.whatwg.org/#concept-document-content-type id=windows:concept-document-content-type data-x-internal=concept-document-content-type>content type</a> is "<code>text/html</code>",
   and which is both <a href=#ready-for-post-load-tasks id=windows:ready-for-post-load-tasks>ready for post-load tasks</a> and <a href=#completely-loaded id=windows:completely-loaded>completely loaded</a>
   immediately.<li><p>Ensure that <var>document</var> has a single child <code id=windows:the-html-element><a href=#the-html-element>html</a></code> node, which itself
   has two empty child nodes: a <code id=windows:the-head-element><a href=#the-head-element>head</a></code> element, and a <code id=windows:the-body-element><a href=#the-body-element>body</a></code> element.<li><p><a href=#set-the-active-document id=windows:set-the-active-document>Set the active document</a> of <var>browsingContext</var> to
   <var>document</var>.<li>
    <p id=about-blank-origin>Set the <a href=#concept-origin id=windows:concept-origin-2>origin</a> of <var>document</var>:</p>

    <ul><li><p>If <var>browsingContext</var> has a <a href=#creator-browsing-context id=windows:creator-browsing-context-5>creator browsing context</a>, then the
     <a href=#concept-origin id=windows:concept-origin-3>origin</a> of <var>document</var> is the <a href=#creator-origin id=windows:creator-origin>creator origin</a>.<li><p>Otherwise, the <a href=#concept-origin id=windows:concept-origin-4>origin</a> of <var>document</var> is a unique <a href=#concept-origin-opaque id=windows:concept-origin-opaque>opaque origin</a>.</ul>
   <li><p>If <var>browsingContext</var> has a <a href=#creator-browsing-context id=windows:creator-browsing-context-6>creator browsing context</a>, then set
   <var>document</var>'s <a href="#the-document's-referrer" id="windows:the-document's-referrer">referrer</a> to the <a href=https://url.spec.whatwg.org/#concept-url-serializer id=windows:concept-url-serializer data-x-internal=concept-url-serializer>serialization</a> of <a href=#creator-url id=windows:creator-url>creator URL</a>.<li><p>If <var>browsingContext</var> has a <a href=#creator-browsing-context id=windows:creator-browsing-context-7>creator browsing context</a>, then set
   <var>document</var>'s <a href=#concept-document-referrer-policy id=windows:concept-document-referrer-policy-2>referrer policy</a> to
   the <a href=#creator-referrer-policy id=windows:creator-referrer-policy>creator referrer policy</a>.<li><p><a href=#implement-the-sandboxing id=windows:implement-the-sandboxing>Implement the sandboxing</a> for <var>document</var>.<li><p>Execute the <a id=windows:initialize-document’s-feature-policy href=https://wicg.github.io/feature-policy/#initialize-for-document data-x-internal=initialize-document’s-feature-policy>Initialize document’s Feature Policy</a> algorithm on
   <var>document</var>. <a href=#refsFEATUREPOLICY>[FEATUREPOLICY]</a><li><p>Add <var>document</var> to <var>browsingContext</var>'s <a href=#session-history id=windows:session-history-3>session
   history</a>.<li id=copy-session-storage><p>If <var>noopener</var> is false, <var>browsingContext</var> is a
   <a href=#top-level-browsing-context id=windows:top-level-browsing-context>top-level browsing context</a>, and <a href=#creator-origin id=windows:creator-origin-2>creator origin</a> is <a href=#same-origin id=windows:same-origin>same
   origin</a> with <var>document</var>'s <a href=#concept-origin id=windows:concept-origin-5>origin</a>, then copy the <code id=windows:dom-sessionstorage><a href=#dom-sessionstorage>sessionStorage</a></code> storage area of the <a href=#creator-origin id=windows:creator-origin-3>creator origin</a>
   from the <a href=#creator-browsing-context id=windows:creator-browsing-context-8>creator browsing context</a> into <var>browsingContext</var>'s set of session
   storage areas. These areas must be considered separate, not affecting each other in any
   way.<li><p>Return <var>browsingContext</var>.</ol>

  


  <h4 id=nested-browsing-contexts><span class=secno>7.1.1</span> Nested browsing contexts<a href=#nested-browsing-contexts class=self-link></a></h4>

  <p>Certain elements (for example, <code id=nested-browsing-contexts:the-iframe-element><a href=#the-iframe-element>iframe</a></code> elements) can instantiate further <a href=#browsing-context id=nested-browsing-contexts:browsing-context>browsing contexts</a>. These elements are called <dfn id=browsing-context-container data-lt="browsing context container" data-export="">browsing
  context containers</dfn>.</p>

  <p>Each <a href=#browsing-context-container id=nested-browsing-contexts:browsing-context-container>browsing context container</a> has a <dfn id=nested-browsing-context data-export="">nested browsing
  context</dfn>, which is either a <a href=#browsing-context id=nested-browsing-contexts:browsing-context-2>browsing context</a> or null.</p>

  <p>If a <a href=#browsing-context id=nested-browsing-contexts:browsing-context-3>browsing context</a> is the <a href=#nested-browsing-context id=nested-browsing-contexts:nested-browsing-context>nested browsing context</a> of a
  <a href=#browsing-context-container id=nested-browsing-contexts:browsing-context-container-2>browsing context container</a>, then the browsing context is said to be <dfn id=browsing-context-nested-through data-export="">nested through</dfn> the <a href=#browsing-context-container id=nested-browsing-contexts:browsing-context-container-3>browsing
  context container</a>'s <a id=nested-browsing-contexts:node-document href=https://dom.spec.whatwg.org/#concept-node-document data-x-internal=node-document>node document</a>.</p>

  <p>A <a href=#browsing-context id=nested-browsing-contexts:browsing-context-4>browsing context</a> <var>child</var> is said to be a <dfn id=child-browsing-context data-export="">child
  browsing context</dfn> of another <a href=#browsing-context id=nested-browsing-contexts:browsing-context-5>browsing context</a> <var>parent</var>, if all of the
  following conditions hold:</p>

  <ul><li><p><var>child</var> is a <a href=#nested-browsing-context id=nested-browsing-contexts:nested-browsing-context-2>nested browsing context</a> of a <a href=#browsing-context-container id=nested-browsing-contexts:browsing-context-container-4>browsing context
   container</a> <var>element</var><li><p><var>element</var> is <a id=nested-browsing-contexts:connected href=https://dom.spec.whatwg.org/#connected data-x-internal=connected>connected</a><li><p><var>element</var>'s <a id=nested-browsing-contexts:shadow-including-root 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=nested-browsing-contexts:concept-document-bc>browsing context</a> is <var>parent</var></ul>

  <p>A <a href=#browsing-context id=nested-browsing-contexts:browsing-context-6>browsing context</a> <var>child</var> is then a <dfn id=document-tree-child-browsing-context>document-tree child browsing
  context</dfn> of <var>parent</var> if it is a <a href=#child-browsing-context id=nested-browsing-contexts:child-browsing-context>child browsing context</a> and its
  <a href=#browsing-context-container id=nested-browsing-contexts:browsing-context-container-5>browsing context container</a> is not just <a id=nested-browsing-contexts:connected-2 href=https://dom.spec.whatwg.org/#connected data-x-internal=connected>connected</a>, but also <a id=nested-browsing-contexts: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>.</p>

  <p>A <a href=#browsing-context id=nested-browsing-contexts:browsing-context-7>browsing context</a> <var>child</var> may have a <dfn id=parent-browsing-context data-export="">parent browsing
  context</dfn>. This is the unique <a href=#browsing-context id=nested-browsing-contexts:browsing-context-8>browsing context</a> that has <var>child</var> as a
  <a href=#child-browsing-context id=nested-browsing-contexts:child-browsing-context-2>child browsing context</a>, if any such browsing context exists. Otherwise, the
  <a href=#browsing-context id=nested-browsing-contexts:browsing-context-9>browsing context</a> has no <a href=#parent-browsing-context id=nested-browsing-contexts:parent-browsing-context>parent browsing context</a>.</p>

  <p>A <a href=#browsing-context id=nested-browsing-contexts:browsing-context-10>browsing context</a> <var>A</var> is said to be an <dfn id=ancestor-browsing-context data-lt="ancestor browsing context" data-export="">ancestor</dfn> of a browsing context
  <var>B</var> if there exists a browsing context <var>A'</var> that is a <a href=#child-browsing-context id=nested-browsing-contexts:child-browsing-context-3>child browsing
  context</a> of <var>A</var> and that is itself an <a href=#ancestor-browsing-context id=nested-browsing-contexts:ancestor-browsing-context>ancestor</a> of <var>B</var>, or if the browsing context <var>A</var> is the
  <a href=#parent-browsing-context id=nested-browsing-contexts:parent-browsing-context-2>parent browsing context</a> of <var>B</var>.</p>

  <p>A <a href=#browsing-context id=nested-browsing-contexts:browsing-context-11>browsing context</a> that is not a <a href=#nested-browsing-context id=nested-browsing-contexts:nested-browsing-context-3>nested browsing context</a> has no
  <a href=#parent-browsing-context id=nested-browsing-contexts:parent-browsing-context-3>parent browsing context</a>, and is the <dfn id=top-level-browsing-context data-export="">top-level browsing
  context</dfn> of all the browsing contexts for which it is an <a href=#ancestor-browsing-context id=nested-browsing-contexts:ancestor-browsing-context-2>ancestor browsing
  context</a>.</p>

  <p>The transitive closure of <a href=#parent-browsing-context id=nested-browsing-contexts:parent-browsing-context-4>parent browsing contexts</a>
  for a <a href=#browsing-context id=nested-browsing-contexts:browsing-context-12>browsing context</a> that is a <a href=#nested-browsing-context id=nested-browsing-contexts:nested-browsing-context-4>nested browsing context</a> gives the list
  of <a href=#ancestor-browsing-context id=nested-browsing-contexts:ancestor-browsing-context-3>ancestor browsing contexts</a>.</p>

  <p>The <dfn id=list-of-the-descendant-browsing-contexts>list of the descendant browsing contexts</dfn> of a <code id=nested-browsing-contexts:document><a href=#document>Document</a></code> <var>d</var>
  is the (ordered) list returned by the following algorithm:</p>

  <ol><li><p>Let <var>list</var> be an empty list.<li>

    <p>For each <a href=#child-browsing-context id=nested-browsing-contexts:child-browsing-context-4>child browsing context</a> of <var>d</var> that is <a href=#browsing-context-nested-through id=nested-browsing-contexts:browsing-context-nested-through>nested through</a> an element that is <a href=https://dom.spec.whatwg.org/#in-a-document id=nested-browsing-contexts:in-a-document data-x-internal=in-a-document>in
    the <code>Document</code></a> <var>d</var>, in the <a id=nested-browsing-contexts:tree-order href=https://dom.spec.whatwg.org/#concept-tree-order data-x-internal=tree-order>tree order</a> of the elements
    nesting those <a href=#browsing-context id=nested-browsing-contexts:browsing-context-13>browsing contexts</a>, run these substeps:</p>

    <ol><li><p>Append that <a href=#child-browsing-context id=nested-browsing-contexts:child-browsing-context-5>child browsing context</a> to the list <var>list</var>.</p>

     <li><p>Append the <a href=#list-of-the-descendant-browsing-contexts id=nested-browsing-contexts:list-of-the-descendant-browsing-contexts>list of the descendant browsing contexts</a> of the <a href=#active-document id=nested-browsing-contexts:active-document>active
     document</a> of that <a href=#child-browsing-context id=nested-browsing-contexts:child-browsing-context-6>child browsing context</a> to the list <var>list</var>.</ol>

   <li><p>Return the constructed <var>list</var>.</ol>

  <p>A <code id=nested-browsing-contexts:document-2><a href=#document>Document</a></code> is said to be <dfn data-dfn-for=Document id=fully-active data-export="">fully
  active</dfn> when it has a <a href=#concept-document-bc id=nested-browsing-contexts:concept-document-bc-2>browsing context</a> and it is
  the <a href=#active-document id=nested-browsing-contexts:active-document-2>active document</a> of that <a href=#browsing-context id=nested-browsing-contexts:browsing-context-14>browsing context</a>, and either its browsing
  context is a <a href=#top-level-browsing-context id=nested-browsing-contexts:top-level-browsing-context>top-level browsing context</a>, or it has a <a href=#parent-browsing-context id=nested-browsing-contexts:parent-browsing-context-5>parent browsing
  context</a> and the <code id=nested-browsing-contexts:document-3><a href=#document>Document</a></code> <a href=#browsing-context-nested-through id=nested-browsing-contexts:browsing-context-nested-through-2>through which</a> it is <a href=#nested-browsing-context id=nested-browsing-contexts:nested-browsing-context-5>nested</a> is itself
  <a href=#fully-active id=nested-browsing-contexts:fully-active>fully active</a>.</p>

  <p>Because they are associated with an element, <a href=#child-browsing-context id=nested-browsing-contexts:child-browsing-context-7>child
  browsing contexts</a> are always tied to a specific <code id=nested-browsing-contexts:document-4><a href=#document>Document</a></code> in their <a href=#parent-browsing-context id=nested-browsing-contexts:parent-browsing-context-6>parent
  browsing context</a>. User agents must not allow the user to interact with <a href=#child-browsing-context id=nested-browsing-contexts:child-browsing-context-8>child browsing contexts</a> of elements that are in <code id=nested-browsing-contexts:document-5><a href=#document>Document</a></code>s
  that are not themselves <a href=#fully-active id=nested-browsing-contexts:fully-active-2>fully active</a>.</p>

  <div class=example>
   <p>The following example illustrates the differences between <a href=#active-document id=nested-browsing-contexts:active-document-3>active</a> and <a href=#fully-active id=nested-browsing-contexts:fully-active-3>fully active</a> <code id=nested-browsing-contexts:document-6><a href=#document>Document</a></code> objects. Here <code>a.html</code> is loaded into a browser window, <code>b-1.html</code> starts
   out loaded into an <code id=nested-browsing-contexts:the-iframe-element-2><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>&quot;en&quot;</c-><c- p>&gt;</c->
<c- p>&lt;</c-><c- f>title</c-><c- p>&gt;</c->Browsing context 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>&quot;b-1.html&quot;</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>&quot;frames[0].location.href = &apos;b-2.html&apos;&quot;</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>&quot;en&quot;</c-><c- p>&gt;</c->
<c- p>&lt;</c-><c- f>title</c-><c- p>&gt;</c->Browsing context 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>&quot;c.html&quot;</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=#active-document id=nested-browsing-contexts:active-document-4>active documents</a> of their respective <a href=#concept-document-bc id=nested-browsing-contexts:concept-document-bc-3>browsing
   contexts</a>. They are also all <a href=#fully-active id=nested-browsing-contexts:fully-active-4>fully active</a>.</p>

   <p>After clicking on the <code id=nested-browsing-contexts:the-button-element><a href=#the-button-element>button</a></code>, and thus loading a new <code id=nested-browsing-contexts:document-7><a href=#document>Document</a></code> from
   <code>b-2.html</code> into browsing context B, we have the following results:</p>

   <ul><li><p>The <code>a.html</code> <code id=nested-browsing-contexts:document-8><a href=#document>Document</a></code> remains both the <a href=#active-document id=nested-browsing-contexts:active-document-5>active
    document</a> of browsing context A, and <a href=#fully-active id=nested-browsing-contexts:fully-active-5>fully active</a>.<li><p>The <code>b-1.html</code> <code id=nested-browsing-contexts:document-9><a href=#document>Document</a></code> is now <em>not</em> the
    <a href=#active-document id=nested-browsing-contexts:active-document-6>active document</a> of browsing context B. As such it is also not <a href=#fully-active id=nested-browsing-contexts:fully-active-6>fully
    active</a>.<li><p>The new <code>b-2.html</code> <code id=nested-browsing-contexts:document-10><a href=#document>Document</a></code> is now the <a href=#active-document id=nested-browsing-contexts:active-document-7>active
    document</a> of browsing context B, and is also <a href=#fully-active id=nested-browsing-contexts:fully-active-7>fully active</a>.<li><p>The <code>c.html</code> <code id=nested-browsing-contexts:document-11><a href=#document>Document</a></code> is still the <a href=#active-document id=nested-browsing-contexts:active-document-8>active
    document</a> of browsing context C. However, since it is <a href=#browsing-context-nested-through id=nested-browsing-contexts:browsing-context-nested-through-3>nested through</a> the <code>b-1.html</code> <code id=nested-browsing-contexts:document-12><a href=#document>Document</a></code>,
    which is itself not <a href=#fully-active id=nested-browsing-contexts:fully-active-8>fully active</a>, this means the <code>c.html</code>
    <code id=nested-browsing-contexts:document-13><a href=#document>Document</a></code> is now not <a href=#fully-active id=nested-browsing-contexts:fully-active-9>fully active</a> (even though it is <a href=#active-document id=nested-browsing-contexts:active-document-9>active</a>).</ul>

   <p>For more explorations of the complexities involved here, especially as it impacts <a href=#history>the session history</a>, see <cite>A Model of Navigation History</cite>. <a href=#refsNAVMODEL>[NAVMODEL]</a></p>
  </div>

  <p>A <a href=#browsing-context id=nested-browsing-contexts:browsing-context-15>browsing context</a> that is a <a href=#nested-browsing-context id=nested-browsing-contexts:nested-browsing-context-6>nested browsing context</a> can be put into
  a <dfn id=delaying-load-events-mode>delaying <code>load</code> events mode</dfn>. This is used when it is
  <a href=#navigate id=nested-browsing-contexts:navigate>navigated</a>, to <a href=#delay-the-load-event id=nested-browsing-contexts:delay-the-load-event>delay the load event</a> of its
  <a href=#browsing-context-container id=nested-browsing-contexts:browsing-context-container-6>browsing context container</a> before the new <code id=nested-browsing-contexts:document-14><a href=#document>Document</a></code> is created.</p>



  <p>The <dfn id=document-family>document family</dfn> of a <a href=#browsing-context id=nested-browsing-contexts:browsing-context-16>browsing context</a> consists of the union of all
  the <code id=nested-browsing-contexts:document-15><a href=#document>Document</a></code> objects in that <a href=#browsing-context id=nested-browsing-contexts:browsing-context-17>browsing context</a>'s <a href=#session-history id=nested-browsing-contexts:session-history>session
  history</a> and the <a href=#document-family id=nested-browsing-contexts:document-family>document families</a> of all those
  <code id=nested-browsing-contexts:document-16><a href=#document>Document</a></code> objects. The <a href=#document-family id=nested-browsing-contexts:document-family-2>document family</a> of a <code id=nested-browsing-contexts:document-17><a href=#document>Document</a></code> object
  consists of the union of all the <a href=#document-family id=nested-browsing-contexts:document-family-3>document families</a> of the
  <a href=#browsing-context id=nested-browsing-contexts:browsing-context-18>browsing contexts</a> that are <a href=#browsing-context-nested-through id=nested-browsing-contexts:browsing-context-nested-through-4>nested through</a> the <code id=nested-browsing-contexts:document-18><a href=#document>Document</a></code> object.</p>

  <p>The <dfn id=concept-bcc-content-document>content document</dfn> of a <a href=#browsing-context-container id=nested-browsing-contexts:browsing-context-container-7>browsing
  context container</a> <var>container</var> is the result of the following algorithm:</p>

  <ol><li><p>If <var>container</var>'s <a href=#nested-browsing-context id=nested-browsing-contexts:nested-browsing-context-7>nested browsing context</a> is null, then return
   null.<li><p>Let <var>context</var> be <var>container</var>'s <a href=#nested-browsing-context id=nested-browsing-contexts:nested-browsing-context-8>nested browsing
   context</a>.<li><p>Let <var>document</var> be <var>context</var>'s <a href=#active-document id=nested-browsing-contexts:active-document-10>active document</a>.<li><p>If <var>document</var>'s <a href=#concept-origin id=nested-browsing-contexts:concept-origin>origin</a> and the <a href=#concept-settings-object-origin id=nested-browsing-contexts:concept-settings-object-origin>origin</a> specified by the <a href=#current-settings-object id=nested-browsing-contexts:current-settings-object>current settings
   object</a> are not <a href=#same-origin-domain id=nested-browsing-contexts:same-origin-domain>same origin-domain</a>, then return null.<li><p>Return <var>document</var>.</ol>


  <h5 id=navigating-nested-browsing-contexts-in-the-dom><span class=secno>7.1.1.1</span> Navigating nested browsing contexts in the DOM<a href=#navigating-nested-browsing-contexts-in-the-dom class=self-link></a></h5>

  <dl class=domintro><dt><var>window</var> . <code id=dom-top-dev><a href=#dom-top>top</a></code><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-browsing-context id=navigating-nested-browsing-contexts-in-the-dom:top-level-browsing-context>top-level browsing context</a>.</p>

   <dt><var>window</var> . <code id=dom-parent-dev><a href=#dom-parent>parent</a></code><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=#parent-browsing-context id=navigating-nested-browsing-contexts-in-the-dom:parent-browsing-context>parent browsing context</a>.</p>

   <dt><var>window</var> . <code id=dom-frameelement-dev><a href=#dom-frameelement>frameElement</a></code><dd>

    <p>Returns the <code id=navigating-nested-browsing-contexts-in-the-dom:element><a data-x-internal=element href=https://dom.spec.whatwg.org/#interface-element>Element</a></code> for the <a href=#browsing-context-container id=navigating-nested-browsing-contexts-in-the-dom:browsing-context-container>browsing context container</a>.</p>

    <p>Returns null if there isn't one, and in cross-origin situations.</p>

   </dl>

  

  <p>The <dfn id=dom-top><code>top</code></dfn> IDL attribute, on getting, must run the
  following algorithm:</p>

  <ol><li><p>Let <var>windowProxy</var> be this <code id=navigating-nested-browsing-contexts-in-the-dom:window><a href=#window>Window</a></code> object's <code id=navigating-nested-browsing-contexts-in-the-dom:windowproxy-3><a href=#windowproxy>WindowProxy</a></code>
   object.<li><p>If there is no <a href=#browsing-context id=navigating-nested-browsing-contexts-in-the-dom:browsing-context>browsing context</a> with <var>windowProxy</var> as its
   <code id=navigating-nested-browsing-contexts-in-the-dom:windowproxy-4><a href=#windowproxy>WindowProxy</a></code> object, then return null.</p>

   <li><p>Let <var>context</var> be that <a href=#browsing-context id=navigating-nested-browsing-contexts-in-the-dom:browsing-context-2>browsing context</a>.<li><p>If <var>context</var> is a <a href=#top-level-browsing-context id=navigating-nested-browsing-contexts-in-the-dom:top-level-browsing-context-2>top-level browsing context</a>, then return
   <var>context</var>'s <code id=navigating-nested-browsing-contexts-in-the-dom:windowproxy-5><a href=#windowproxy>WindowProxy</a></code> object.<li><p>Otherwise, <var>context</var> must have a <a href=#top-level-browsing-context id=navigating-nested-browsing-contexts-in-the-dom:top-level-browsing-context-3>top-level browsing context</a> (i.e. an
   <a href=#ancestor-browsing-context id=navigating-nested-browsing-contexts-in-the-dom:ancestor-browsing-context>ancestor browsing context</a> with no <a href=#parent-browsing-context id=navigating-nested-browsing-contexts-in-the-dom:parent-browsing-context-2>parent browsing context</a>). Return that
   <a href=#top-level-browsing-context id=navigating-nested-browsing-contexts-in-the-dom:top-level-browsing-context-4>top-level browsing context</a>'s <code id=navigating-nested-browsing-contexts-in-the-dom:windowproxy-6><a href=#windowproxy>WindowProxy</a></code> object.</ol>

  <p>The <dfn id=dom-parent><code>parent</code></dfn> IDL attribute, on getting, must run the
  following algorithm:</p>

  <ol><li><p>Let <var>windowProxy</var> be this <code id=navigating-nested-browsing-contexts-in-the-dom:window-2><a href=#window>Window</a></code> object's <code id=navigating-nested-browsing-contexts-in-the-dom:windowproxy-7><a href=#windowproxy>WindowProxy</a></code>
   object.<li><p>If there is no <a href=#browsing-context id=navigating-nested-browsing-contexts-in-the-dom:browsing-context-3>browsing context</a> with <var>windowProxy</var> as its
   <code id=navigating-nested-browsing-contexts-in-the-dom:windowproxy-8><a href=#windowproxy>WindowProxy</a></code> object, then return null.</p>

   <li><p>Let <var>context</var> be that <a href=#browsing-context id=navigating-nested-browsing-contexts-in-the-dom:browsing-context-4>browsing context</a>.<li><p>If <var>context</var> is a <a href=#child-browsing-context id=navigating-nested-browsing-contexts-in-the-dom:child-browsing-context>child browsing context</a> of another <a href=#browsing-context id=navigating-nested-browsing-contexts-in-the-dom:browsing-context-5>browsing
   context</a> <var>parent</var>, then return <var>parent</var>'s <code id=navigating-nested-browsing-contexts-in-the-dom:windowproxy-9><a href=#windowproxy>WindowProxy</a></code>
   object.<li><p>Otherwise, <var>context</var> must be a <a href=#top-level-browsing-context id=navigating-nested-browsing-contexts-in-the-dom:top-level-browsing-context-5>top-level browsing context</a>. Return
   <var>context</var>'s <code id=navigating-nested-browsing-contexts-in-the-dom:windowproxy-10><a href=#windowproxy>WindowProxy</a></code> object.</ol>

  <p>The <dfn id=dom-frameelement><code>frameElement</code></dfn> IDL attribute, on getting,
  must run the following algorithm:</p>

  <ol><li><p>Let <var>windowProxy</var> be this <code id=navigating-nested-browsing-contexts-in-the-dom:window-3><a href=#window>Window</a></code> object's <code id=navigating-nested-browsing-contexts-in-the-dom:windowproxy-11><a href=#windowproxy>WindowProxy</a></code>
   object.<li><p>If there is no <a href=#browsing-context id=navigating-nested-browsing-contexts-in-the-dom:browsing-context-6>browsing context</a> with <var>windowProxy</var> as its
   <code id=navigating-nested-browsing-contexts-in-the-dom:windowproxy-12><a href=#windowproxy>WindowProxy</a></code> object, then return null.</p>

   <li><p>Let <var>context</var> be that <a href=#browsing-context id=navigating-nested-browsing-contexts-in-the-dom:browsing-context-7>browsing context</a>.<li><p>If <var>context</var> is not a <a href=#nested-browsing-context id=navigating-nested-browsing-contexts-in-the-dom:nested-browsing-context>nested browsing context</a>, then return
   null.<li><p>Let <var>container</var> be <var>context</var>'s <a href=#browsing-context-container id=navigating-nested-browsing-contexts-in-the-dom:browsing-context-container-2>browsing context
   container</a>.<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=#concept-origin id=navigating-nested-browsing-contexts-in-the-dom:concept-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.<li><p>Return <var>container</var>.</ol>

  <div class=example>
   <p>An example of when these IDL attributes 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>&quot;use strict&quot;</c-><c- p>;</c->
<c- kr>const</c-> element <c- o>=</c-> document<c- p>.</c->querySelector<c- p>(</c-><c- u>&quot;iframe&quot;</c-><c- p>);</c->
<c- kr>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-8>browsing context</a> corresponding to <code>iframeWindow</code>
   was <a href=#a-browsing-context-is-discarded id=navigating-nested-browsing-contexts-in-the-dom:a-browsing-context-is-discarded>discarded</a> when <code>element</code> was removed from the document.</p>
  </div>

  



  <h4 id=auxiliary-browsing-contexts><span class=secno>7.1.2</span> Auxiliary browsing contexts<a href=#auxiliary-browsing-contexts class=self-link></a></h4>

  <p>It is possible to create new browsing contexts that are related to a <a href=#top-level-browsing-context id=auxiliary-browsing-contexts:top-level-browsing-context>top-level browsing
  context</a> without being nested through an element. Such browsing contexts are called <dfn id=auxiliary-browsing-context data-lt="auxiliary browsing context" data-export="">auxiliary
  browsing contexts</dfn>. Auxiliary browsing contexts are always <a href=#top-level-browsing-context id=auxiliary-browsing-contexts:top-level-browsing-context-2 data-lt="top-level browsing context" data-export="">top-level browsing
  contexts</a>.</p>

  <p>An <a href=#auxiliary-browsing-context id=auxiliary-browsing-contexts:auxiliary-browsing-context>auxiliary browsing context</a> has an <dfn id=opener-browsing-context data-export="">opener browsing
  context</dfn>, which is the <a href=#browsing-context id=auxiliary-browsing-contexts:browsing-context>browsing context</a> from which the <a href=#auxiliary-browsing-context id=auxiliary-browsing-contexts:auxiliary-browsing-context-2>auxiliary browsing
  context</a> was created.</p>


  <h5 id=navigating-auxiliary-browsing-contexts-in-the-dom><span class=secno>7.1.2.1</span> Navigating auxiliary browsing contexts in the DOM<a href=#navigating-auxiliary-browsing-contexts-in-the-dom class=self-link></a></h5>

  <p>An <a href=#auxiliary-browsing-context id=navigating-auxiliary-browsing-contexts-in-the-dom:auxiliary-browsing-context>auxiliary browsing context</a> can be <dfn id=disowned-its-opener>disowned</dfn>.</p>

  <p>The <dfn id=dom-opener><code>opener</code></dfn> attribute's getter must run these
  steps:</p>

  <ol><li><p>If the current <a href=#browsing-context id=navigating-auxiliary-browsing-contexts-in-the-dom:browsing-context>browsing context</a> is <a href=#disowned-its-opener id=navigating-auxiliary-browsing-contexts-in-the-dom:disowned-its-opener>disowned</a>, then return
   null.<li><p>If the current <a href=#browsing-context id=navigating-auxiliary-browsing-contexts-in-the-dom:browsing-context-2>browsing context</a> has no <a href=#opener-browsing-context id=navigating-auxiliary-browsing-contexts-in-the-dom:opener-browsing-context>opener browsing context</a>,
   then return null.<li><p>Return the current <a href=#browsing-context id=navigating-auxiliary-browsing-contexts-in-the-dom:browsing-context-3>browsing context</a>'s <a href=#opener-browsing-context id=navigating-auxiliary-browsing-contexts-in-the-dom:opener-browsing-context-2>opener browsing context</a>'s
   <code id=navigating-auxiliary-browsing-contexts-in-the-dom:windowproxy><a href=#windowproxy>WindowProxy</a></code> object.</ol>

  <p>The <code id=navigating-auxiliary-browsing-contexts-in-the-dom:dom-opener><a href=#dom-opener>opener</a></code> attribute's setter, must run these steps:</p>

  <ol><li><p>If the given value is null, then <a href=#disowned-its-opener id=navigating-auxiliary-browsing-contexts-in-the-dom:disowned-its-opener-2>disown</a> the current
   <a href=#browsing-context id=navigating-auxiliary-browsing-contexts-in-the-dom:browsing-context-4>browsing context</a> and return.<li><p>Perform <a id=navigating-auxiliary-browsing-contexts-in-the-dom:ordinarydefineownproperty href=https://tc39.github.io/ecma262/#sec-ordinarydefineownproperty data-x-internal=ordinarydefineownproperty>OrdinaryDefineOwnProperty</a>(this <code id=navigating-auxiliary-browsing-contexts-in-the-dom:window><a href=#window>Window</a></code> object, "<code>opener</code>", { [[Value]]: the given value, [[Writable]]: true, [[Enumerable]]: true,
   [[Configurable]]: true }). Rethrow any exceptions.</ol>

  <div class=note>
   <p>If a <a href=#browsing-context id=navigating-auxiliary-browsing-contexts-in-the-dom:browsing-context-5>browsing context</a> is <a href=#disowned-its-opener id=navigating-auxiliary-browsing-contexts-in-the-dom:disowned-its-opener-3>disowned</a>, its <code id=navigating-auxiliary-browsing-contexts-in-the-dom:dom-opener-2><a href=#dom-opener>window.opener</a></code> attribute is null. That prevents scripts in the
   <a href=#browsing-context id=navigating-auxiliary-browsing-contexts-in-the-dom:browsing-context-6>browsing context</a> from changing any properties of its <a href=#opener-browsing-context id=navigating-auxiliary-browsing-contexts-in-the-dom:opener-browsing-context-3>opener browsing
   context</a>'s <code id=navigating-auxiliary-browsing-contexts-in-the-dom:window-2><a href=#window>Window</a></code> object (i.e., the <code id=navigating-auxiliary-browsing-contexts-in-the-dom:window-3><a href=#window>Window</a></code> object from which the
   <a href=#browsing-context id=navigating-auxiliary-browsing-contexts-in-the-dom:browsing-context-7>browsing context</a> was created).</p>

   <p>Otherwise, if a <a href=#browsing-context id=navigating-auxiliary-browsing-contexts-in-the-dom:browsing-context-8>browsing context</a> is not <a href=#disowned-its-opener id=navigating-auxiliary-browsing-contexts-in-the-dom:disowned-its-opener-4>disowned</a>, then scripts in
   that <a href=#browsing-context id=navigating-auxiliary-browsing-contexts-in-the-dom:browsing-context-9>browsing context</a> can use <code id=navigating-auxiliary-browsing-contexts-in-the-dom:dom-opener-3><a href=#dom-opener>window.opener</a></code> to
   change properties of its <a href=#opener-browsing-context id=navigating-auxiliary-browsing-contexts-in-the-dom:opener-browsing-context-4>opener browsing context</a>'s <code id=navigating-auxiliary-browsing-contexts-in-the-dom:window-4><a href=#window>Window</a></code> object. For
   example, a script running in the <a href=#browsing-context id=navigating-auxiliary-browsing-contexts-in-the-dom:browsing-context-10>browsing context</a> can change the value of <code>window.opener.location</code>, causing the <a href=#opener-browsing-context id=navigating-auxiliary-browsing-contexts-in-the-dom:opener-browsing-context-5>opener browsing context</a> to
   navigate to a completely different document.</p>
  </div>



  

  <h4 id=security-nav><span class=secno>7.1.3</span> Security<a href=#security-nav class=self-link></a></h4>

  <p id=security-1>A <a href=#browsing-context id=security-nav:browsing-context>browsing context</a> <var>A</var> is <dfn id=familiar-with>familiar
  with</dfn> a second <a href=#browsing-context id=security-nav:browsing-context-2>browsing context</a> <var>B</var> if one of the following
  conditions is true:</p>

  <ul><li>Either the <a href=#concept-origin id=security-nav:concept-origin>origin</a> of the <a href=#active-document id=security-nav:active-document>active document</a> of <var>A</var>
   is the <a href=#same-origin id=security-nav:same-origin>same</a> as the <a href=#concept-origin id=security-nav:concept-origin-2>origin</a> of the <a href=#active-document id=security-nav:active-document-2>active
   document</a> of <var>B</var>, or<li>The browsing context <var>A</var> is a <a href=#nested-browsing-context id=security-nav:nested-browsing-context>nested browsing context</a> with a
   <a href=#top-level-browsing-context id=security-nav:top-level-browsing-context>top-level browsing context</a>, and its <a href=#top-level-browsing-context id=security-nav:top-level-browsing-context-2>top-level browsing context</a> is <var>B</var>, or<li>The browsing context <var>B</var> is an <a href=#auxiliary-browsing-context id=security-nav:auxiliary-browsing-context>auxiliary browsing context</a> and
   <var>A</var> is <a href=#familiar-with id=security-nav:familiar-with>familiar with</a> <var>B</var>'s <a href=#opener-browsing-context id=security-nav:opener-browsing-context>opener
   browsing context</a>, or<li>The browsing context <var>B</var> is not a <a href=#top-level-browsing-context id=security-nav:top-level-browsing-context-3>top-level browsing context</a>,
   but there exists an <a href=#ancestor-browsing-context id=security-nav:ancestor-browsing-context>ancestor browsing context</a> of <var>B</var> whose
   <a href=#active-document id=security-nav:active-document-3>active document</a> has the <a href=#same-origin id=security-nav:same-origin-2>same</a> <a href=#concept-origin id=security-nav:concept-origin-3>origin</a> as
   the <a href=#active-document id=security-nav:active-document-4>active document</a> of <var>A</var> (possibly in fact being <var>A</var> itself).</ul>

  <hr>

  <p>A <a href=#browsing-context id=security-nav:browsing-context-3>browsing context</a> <var>A</var> is <dfn id=allowed-to-navigate>allowed to navigate</dfn> a
  second <a href=#browsing-context id=security-nav:browsing-context-4>browsing context</a> <var>B</var> if the following algorithm returns true:</p>

  <ol><li><p>If <var>A</var> is not the same <a href=#browsing-context id=security-nav:browsing-context-5>browsing context</a> as <var>B</var>, and
   <var>A</var> is not one of the <a href=#ancestor-browsing-context id=security-nav:ancestor-browsing-context-2>ancestor browsing
   contexts</a> of <var>B</var>, and <var>B</var> is not a <a href=#top-level-browsing-context id=security-nav:top-level-browsing-context-4>top-level browsing
   context</a>, and <var>A</var>'s <a href=#active-document id=security-nav:active-document-5>active document</a>'s <a href=#active-sandboxing-flag-set id=security-nav:active-sandboxing-flag-set>active sandboxing flag
   set</a> has its <a href=#sandboxed-navigation-browsing-context-flag id=security-nav:sandboxed-navigation-browsing-context-flag>sandboxed navigation browsing context flag</a> set, then return
   false.<li>
    <p>Otherwise, if <var>B</var> is a <a href=#top-level-browsing-context id=security-nav:top-level-browsing-context-5>top-level browsing context</a>, and is one of the
    <a href=#ancestor-browsing-context id=security-nav:ancestor-browsing-context-3>ancestor browsing contexts</a> of <var>A</var>,
    then:</p>

    <ol><li><p>If this algorithm is <a href=#triggered-by-user-activation id=security-nav:triggered-by-user-activation>triggered by user activation</a> and <var>A</var>'s
     <a href=#active-document id=security-nav:active-document-6>active document</a>'s <a href=#active-sandboxing-flag-set id=security-nav:active-sandboxing-flag-set-2>active sandboxing flag set</a> has its <a href=#sandboxed-top-level-navigation-with-user-activation-browsing-context-flag id=security-nav:sandboxed-top-level-navigation-with-user-activation-browsing-context-flag>sandboxed
     top-level navigation with user activation browsing context flag</a> set, then return
     false.<li><p>Otherwise, if this algorithm is not <a href=#triggered-by-user-activation id=security-nav:triggered-by-user-activation-2>triggered by user activation</a> and
     <var>A</var>'s <a href=#active-document id=security-nav:active-document-7>active document</a>'s <a href=#active-sandboxing-flag-set id=security-nav:active-sandboxing-flag-set-3>active sandboxing flag set</a> has its
     <a href=#sandboxed-top-level-navigation-without-user-activation-browsing-context-flag id=security-nav:sandboxed-top-level-navigation-without-user-activation-browsing-context-flag>sandboxed top-level navigation without user activation browsing context flag</a> set,
     then return false.</ol>
   <li><p>Otherwise, if <var>B</var> is a <a href=#top-level-browsing-context id=security-nav:top-level-browsing-context-6>top-level browsing context</a>, and is
   neither <var>A</var> nor one of the <a href=#ancestor-browsing-context id=security-nav:ancestor-browsing-context-4>ancestor
   browsing contexts</a> of <var>A</var>, and <var>A</var>'s
   <code id=security-nav:document><a href=#document>Document</a></code>'s <a href=#active-sandboxing-flag-set id=security-nav:active-sandboxing-flag-set-4>active sandboxing flag set</a> has its <a href=#sandboxed-navigation-browsing-context-flag id=security-nav:sandboxed-navigation-browsing-context-flag-2>sandboxed
   navigation browsing context flag</a> set, and <var>A</var> is not the <a href=#one-permitted-sandboxed-navigator id=security-nav:one-permitted-sandboxed-navigator>one
   permitted sandboxed navigator</a> of <var>B</var>, then return false.<li><p>Return true.</ol>

  <hr>

  <p>An element has a <dfn id=browsing-context-scope-origin>browsing context scope origin</dfn> if its <code id=security-nav:document-2><a href=#document>Document</a></code>'s
  <a href=#concept-document-bc id=security-nav:concept-document-bc>browsing context</a> is a <a href=#top-level-browsing-context id=security-nav:top-level-browsing-context-7>top-level browsing
  context</a> or if all of its <code id=security-nav:document-3><a href=#document>Document</a></code>'s <a href=#ancestor-browsing-context id=security-nav:ancestor-browsing-context-5>ancestor browsing contexts</a> all have <a href=#active-document id=security-nav:active-document-8>active
  documents</a> whose <a href=#concept-origin id=security-nav:concept-origin-4>origin</a> are the <a href=#same-origin id=security-nav:same-origin-3>same origin</a> as the element's
  <a id=security-nav:node-document href=https://dom.spec.whatwg.org/#concept-node-document data-x-internal=node-document>node document</a>'s <a href=#concept-origin id=security-nav:concept-origin-5>origin</a>. If an element has a <a href=#browsing-context-scope-origin id=security-nav:browsing-context-scope-origin>browsing context scope
  origin</a>, then its value is the <a href=#concept-origin id=security-nav:concept-origin-6>origin</a> of the element's <a id=security-nav:node-document-2 href=https://dom.spec.whatwg.org/#concept-node-document data-x-internal=node-document>node
  document</a>.</p>

  


  

  <h4 id=groupings-of-browsing-contexts><span class=secno>7.1.4</span> Groupings of browsing contexts<a href=#groupings-of-browsing-contexts class=self-link></a></h4>

  <p>Each <a href=#browsing-context id=groupings-of-browsing-contexts:browsing-context>browsing context</a> is defined as having a list of one or more <dfn id=directly-reachable-browsing-contexts>directly
  reachable browsing contexts</dfn>. These are:</p>

  <ul><li>The <a href=#browsing-context id=groupings-of-browsing-contexts:browsing-context-2>browsing context</a> itself.<li>All the <a href=#browsing-context id=groupings-of-browsing-contexts:browsing-context-3>browsing context</a>'s <a href=#child-browsing-context id=groupings-of-browsing-contexts:child-browsing-context>child browsing
   contexts</a>.<li>The <a href=#browsing-context id=groupings-of-browsing-contexts:browsing-context-4>browsing context</a>'s <a href=#parent-browsing-context id=groupings-of-browsing-contexts:parent-browsing-context>parent browsing context</a>.<li>All the <a href=#browsing-context id=groupings-of-browsing-contexts:browsing-context-5>browsing contexts</a> that have the <a href=#browsing-context id=groupings-of-browsing-contexts:browsing-context-6>browsing
   context</a> as their <a href=#opener-browsing-context id=groupings-of-browsing-contexts:opener-browsing-context>opener browsing context</a>.<li>The <a href=#browsing-context id=groupings-of-browsing-contexts:browsing-context-7>browsing context</a>'s <a href=#opener-browsing-context id=groupings-of-browsing-contexts:opener-browsing-context-2>opener browsing context</a>.</ul>

  <p>The transitive closure of all the <a href=#browsing-context id=groupings-of-browsing-contexts:browsing-context-8>browsing contexts</a> that
  are <a href=#directly-reachable-browsing-contexts id=groupings-of-browsing-contexts:directly-reachable-browsing-contexts>directly reachable browsing contexts</a> forms a <dfn id=unit-of-related-browsing-contexts>unit of related browsing
  contexts</dfn>.</p>

  <p>Each <a href=#unit-of-related-browsing-contexts id=groupings-of-browsing-contexts:unit-of-related-browsing-contexts>unit of related browsing contexts</a> is then further divided into the smallest
  number of groups such that every member of each group has an <a href=#active-document id=groupings-of-browsing-contexts:active-document>active document</a> with an
  <a href=#concept-origin id=groupings-of-browsing-contexts:concept-origin>origin</a> that, through appropriate manipulation of the <code id=groupings-of-browsing-contexts:dom-document-domain><a href=#dom-document-domain>document.domain</a></code> attribute, could be made to be <a href=#same-origin-domain id=groupings-of-browsing-contexts:same-origin-domain>same
  origin-domain</a> with other members of the group, but could not be made the same as members of
  any other group. Each such group is a <dfn id=unit-of-related-similar-origin-browsing-contexts data-export="">unit of related similar-origin browsing
  contexts</dfn>.</p>

  <p class=note>There is also at most one <a href=#event-loop id=groupings-of-browsing-contexts:event-loop>event loop</a> per <a href=#unit-of-related-similar-origin-browsing-contexts id=groupings-of-browsing-contexts:unit-of-related-similar-origin-browsing-contexts>unit of related
  similar-origin browsing contexts</a> (though several <a href=#unit-of-related-similar-origin-browsing-contexts id=groupings-of-browsing-contexts:unit-of-related-similar-origin-browsing-contexts-2>units of related similar-origin browsing contexts</a> can
  have a shared <a href=#event-loop id=groupings-of-browsing-contexts:event-loop-2>event loop</a>).</p>

  



  <h4 id=browsing-context-names><span class=secno>7.1.5</span> Browsing context names<a href=#browsing-context-names class=self-link></a></h4>

  <p>Browsing contexts can have a <dfn id=browsing-context-name>browsing context name</dfn>. Unless stated otherwise, it is
  the empty string.</p>

  <p>A <dfn id=valid-browsing-context-name>valid browsing context name</dfn> is any string with at least one character that does
  not start with a U+005F LOW LINE character. (Names starting with an underscore are reserved for
  special keywords.)</p>

  <p>A <dfn id=valid-browsing-context-name-or-keyword>valid browsing context name or keyword</dfn> is any string that is either a <a href=#valid-browsing-context-name id=browsing-context-names:valid-browsing-context-name>valid
  browsing context name</a> or that is an <a id=browsing-context-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>

  <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=#browsing-context id=browsing-context-names:browsing-context>browsing context</a> that the link or script is in, "parent" means the <a href=#parent-browsing-context id=browsing-context-names:parent-browsing-context>parent
  browsing context</a> of the one the link or script is in, "top" means the <a href=#top-level-browsing-context id=browsing-context-names:top-level-browsing-context>top-level
  browsing context</a> of the one the link or script is in, "new" means a new <a href=#top-level-browsing-context id=browsing-context-names:top-level-browsing-context-2>top-level
  browsing context</a> or <a href=#auxiliary-browsing-context id=browsing-context-names:auxiliary-browsing-context>auxiliary browsing context</a> is to be created, 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=browsing-context-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=browsing-context-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 rowspan=2>Ordinary effect
     <th colspan=2>Effect in an <code id=browsing-context-names:the-iframe-element><a href=#the-iframe-element>iframe</a></code> with...
    <tr><th><code>sandbox=""</code>
     <th><code>sandbox="allow-top-navigation"</code>

   <tbody><tr><td>none specified, for links and form submissions 
     <td>current
     <td>current
     <td>current

    <tr><td>empty string
     <td>current
     <td>current
     <td>current

    <tr><td><code>_blank</code>
     <td>new
     <td>maybe new
     <td>maybe new

    <tr><td><code>_self</code>
     <td>current
     <td>current
     <td>current

    <tr><td><code>_parent</code> if there isn't a parent
     <td>current
     <td>current
     <td>current

    <tr><td><code>_parent</code> if parent is also top
     <td>parent/top
     <td>none
     <td>parent/top

    <tr><td><code>_parent</code> if there is one and it's not top
     <td>parent
     <td>none
     <td>none

    <tr><td><code>_top</code> if top is current
     <td>current
     <td>current
     <td>current

    <tr><td><code>_top</code> if top is not current
     <td>top
     <td>none
     <td>top

    <tr><td>name that doesn't exist
     <td>new
     <td>maybe new
     <td>maybe new

    <tr><td>name that exists and is a descendant
     <td>specified descendant
     <td>specified descendant
     <td>specified descendant

    <tr><td>name that exists and is current
     <td>current
     <td>current
     <td>current

    <tr><td>name that exists and is an ancestor that is top
     <td>specified ancestor
     <td>none
     <td>specified ancestor/top

    <tr><td>name that exists and is an ancestor that is not top
     <td>specified ancestor
     <td>none
     <td>none

    <tr><td>other name that exists with common top
     <td>specified
     <td>none
     <td>none

    <tr><td>name that exists with different top, if <a href=#familiar-with id=browsing-context-names:familiar-with>familiar</a> and <a href=#one-permitted-sandboxed-navigator id=browsing-context-names:one-permitted-sandboxed-navigator>one permitted sandboxed navigator</a>
     <td>specified
     <td>specified
     <td>specified

    <tr><td>name that exists with different top, if <a href=#familiar-with id=browsing-context-names:familiar-with-2>familiar</a> but not <a href=#one-permitted-sandboxed-navigator id=browsing-context-names:one-permitted-sandboxed-navigator-2>one permitted sandboxed navigator</a>
     <td>specified
     <td>none
     <td>none

    <tr><td>name that exists with different top, not <a href=#familiar-with id=browsing-context-names:familiar-with-3>familiar</a>
     <td>new
     <td>maybe new
     <td>maybe new

  </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=browsing-context-names:navigate>navigation</a> algorithm, not <a href=#the-rules-for-choosing-a-browsing-context-given-a-browsing-context-name id=browsing-context-names:the-rules-for-choosing-a-browsing-context-given-a-browsing-context-name>the
  rules for choosing a browsing context</a> given below.</small></p>

  

  <hr>

  <p><dfn id=the-rules-for-choosing-a-browsing-context-given-a-browsing-context-name>The rules for
  choosing a browsing context</dfn>, given a <a href=#browsing-context-name id=browsing-context-names:browsing-context-name>browsing context name</a> <var>name</var>, a
  <a href=#browsing-context id=browsing-context-names:browsing-context-2>browsing context</a> <var>current</var>, and a boolean <var>noopener</var> are as
  follows:</p>

  <ol><li><p>Let <var>chosen</var> be null.<li><p>Let <var>new</var> be false.<li><p>If <var>name</var> is the empty string or an <a id=browsing-context-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>current</var>.<li><p>If <var>name</var> is an <a id=browsing-context-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>", then set <var>chosen</var> to <var>current</var>'s <a href=#parent-browsing-context id=browsing-context-names:parent-browsing-context-2>parent
   browsing context</a>, if any, and <var>current</var> otherwise.<li><p>If <var>name</var> is an <a id=browsing-context-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>", then set <var>chosen</var> to <var>current</var>'s <a href=#top-level-browsing-context id=browsing-context-names:top-level-browsing-context-3>top-level
   browsing context</a>, if any, and <var>current</var> otherwise.<li>
    <p>If <var>name</var> is not an <a id=browsing-context-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 there exists a browsing context whose <a href=#browsing-context-name id=browsing-context-names:browsing-context-name-2>name</a> is the same as <var>name</var>, and <var>current</var> is
    <a href=#familiar-with id=browsing-context-names:familiar-with-4>familiar with</a> that browsing context, and the user agent determines that the two
    browsing contexts are related enough that it is ok if they reach each other, then set
    <var>chosen</var> to that browsing context. If there are multiple matching browsing contexts,
    the user agent should set <var>chosen</var> to one in some arbitrary consistent manner, such as
    the most recently opened, most recently focused, or more closely related.</p>

    <p class=XXX>This will be made more precise in <a href=https://github.com/whatwg/html/issues/1440>issue #1440</a>.</p>
   <li>
    <p>Otherwise, a new browsing context 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 the algorithm is not <a href=#triggered-by-user-activation id=browsing-context-names:triggered-by-user-activation>triggered by user activation</a> and
     the user agent has been configured to not show popups (i.e. the user agent has a "popup
     blocker" enabled)<dd><p>The user agent may inform the user that a popup has been blocked.<dt id=sandboxWindowOpen>If <var>current</var>'s <a href=#active-document id=browsing-context-names:active-document>active document</a>'s <a href=#active-sandboxing-flag-set id=browsing-context-names:active-sandboxing-flag-set>active
     sandboxing flag set</a> has the <a href=#sandboxed-auxiliary-navigation-browsing-context-flag id=browsing-context-names:sandboxed-auxiliary-navigation-browsing-context-flag>sandboxed auxiliary navigation browsing context
     flag</a> set.<dd>
      <p>The user agent may offer the user one of:

      <ol><li><p>Set <var>chosen</var> to a <a href=#creating-a-new-browsing-context id=browsing-context-names:creating-a-new-browsing-context>new</a>
       <a href=#top-level-browsing-context id=browsing-context-names:top-level-browsing-context-4>top-level browsing context</a> given <var>noopener</var>, and set <var>new</var> to
       true.<li><p>Set <var>chosen</var> to an existing <a href=#top-level-browsing-context id=browsing-context-names:top-level-browsing-context-5>top-level browsing context</a>.</p>
      </ol>

      <p class=warning>If this case occurs, it means that an author has explicitly sandboxed the
      document that is trying to open a link.</p>

      <p class=note>If the user declines or the user agent doesn't offer the above, the variables
      remain unchanged.</p>
     <dt id=noopener>If the user agent has been configured such that in this instance it will
     create a new browsing context:<dd>
      <p>Set <var>chosen</var> to a <a href=#creating-a-new-browsing-context id=browsing-context-names:creating-a-new-browsing-context-2>new</a>
      <a href=#auxiliary-browsing-context id=browsing-context-names:auxiliary-browsing-context-2>auxiliary browsing context</a> given <var>noopener</var> with the <a href=#opener-browsing-context id=browsing-context-names:opener-browsing-context>opener
      browsing context</a> being <var>current</var>, and set <var>new</var> to true. If
      <var>name</var> is not an <a id=browsing-context-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 <var>chosen</var>'s <a href=#browsing-context-name id=browsing-context-names:browsing-context-name-3>name</a> must be set to <var>name</var>.</p>

      <p class=note>If the newly created <a href=#browsing-context id=browsing-context-names:browsing-context-3>browsing context</a> is immediately <a href=#navigate id=browsing-context-names:navigate-2>navigated</a>, then the navigation will be done with <a href=#replacement-enabled id=browsing-context-names:replacement-enabled>replacement
      enabled</a>.</p>
     <dt>If the user agent has been configured such that in this instance it will reuse
     <var>current</var><dd><p>Set <var>chosen</var> to <var>current</var>.<dt>If the user agent has been configured such that in this instance it will not find a
     browsing context<dd><p>Do nothing.</dl>

    <p class=note>User agents are encouraged to provide a way for users to configure the user
    agent to always reuse <var>current</var>.</p>
   <li>
    <p>If <var>new</var> is true, then:</p>

    <ol><li><p>Let <var>flagSet</var> be <var>current</var>'s <a href=#active-document id=browsing-context-names:active-document-2>active document</a>'s
     <a href=#active-sandboxing-flag-set id=browsing-context-names:active-sandboxing-flag-set-2>active sandboxing flag set</a>.<li><p>If <var>flagSet</var>'s <a href=#sandboxed-navigation-browsing-context-flag id=browsing-context-names:sandboxed-navigation-browsing-context-flag>sandboxed navigation browsing context flag</a> is set,
     then <var>current</var> must be set as <var>chosen</var>'s <a href=#one-permitted-sandboxed-navigator id=browsing-context-names:one-permitted-sandboxed-navigator-3>one permitted sandboxed
     navigator</a>.<li><p>If <var>flagSet</var>'s <a href=#sandbox-propagates-to-auxiliary-browsing-contexts-flag id=browsing-context-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>flagSet</var> must be set in
     <var>chosen</var>'s <a href=#popup-sandboxing-flag-set id=browsing-context-names:popup-sandboxing-flag-set>popup sandboxing flag set</a>.</ol>
   <li><p>Return <var>chosen</var> and <var>new</var>.</ol>


  <h3 id=cross-origin-objects><span class=secno>7.2</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></h3>

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


  <h4 id=integration-with-idl><span class=secno>7.2.1</span> Integration with IDL<a href=#integration-with-idl class=self-link></a></h4>

  <p>When <a id=integration-with-idl:perform-a-security-check href=https://heycam.github.io/webidl/#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 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:</p>

    <ol><li>
      <p>Repeat for each <var>e</var> that is an element 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.github.io/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.<li><p>Otherwise, if <var>type</var> is "<code>getter</code>" and
         <var>e</var>.[[NeedsGet]] is true, then return.<li><p>Otherwise, if <var>type</var> is "<code>setter</code>" and
         <var>e</var>.[[NeedsSet]] is true, then return.</ol>
       </ol>
     </ol>
   <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://heycam.github.io/webidl/#securityerror data-x-internal=securityerror>"<code>SecurityError</code>"</a> <code id=integration-with-idl:domexception><a data-x-internal=domexception href=https://heycam.github.io/webidl/#dfn-DOMException>DOMException</a></code>.</ol>


  <h4 id=shared-internal-slot:-crossoriginpropertydescriptormap><span class=secno>7.2.2</span> Shared internal slot: [[CrossOriginPropertyDescriptorMap]]<a href=#shared-internal-slot:-crossoriginpropertydescriptormap class=self-link></a></h4>

  <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 class=note>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>

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


  <h4 id=shared-abstract-operations><span class=secno>7.2.3</span> Shared abstract operations<a href=#shared-abstract-operations class=self-link></a></h4>

  <h5 id=crossoriginproperties-(-o-)><span class=secno>7.2.3.1</span> <dfn>CrossOriginProperties</dfn> ( <var>O</var> )<a href=#crossoriginproperties-(-o-) class=self-link></a></h5>

  <ol><li><p>Assert: <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.<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>" } ».<li><p>Let <var>crossOriginWindowProperties</var> be «
   { [[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>" } ».<li>
    <p>Repeat for each <var>e</var> that is an element of <var>O</var>'s <a href=#document-tree-child-browsing-context-name-property-set id=crossoriginproperties-(-o-):document-tree-child-browsing-context-name-property-set>document-tree child
    browsing context name property set</a>:</p>

    <ol><li><p>Add { [[Property]]: <var>e</var>, [[HideFromKeys]]: true } as the last element of
     <var>crossOriginWindowProperties</var>.</ol>
   <li><p>Return <var>crossOriginWindowProperties</var>.</ol>

  <p class=note>Indexed properties do not need to be safelisted as they are handled directly by
  the <code id=crossoriginproperties-(-o-):windowproxy><a href=#windowproxy>WindowProxy</a></code> object.</p>

  <h5 id=isplatformobjectsameorigin-(-o-)><span class=secno>7.2.3.2</span> <dfn>IsPlatformObjectSameOrigin</dfn> ( <var>O</var> )<a href=#isplatformobjectsameorigin-(-o-) class=self-link></a></h5>

  <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.</ol>

  <h5 id=crossorigingetownpropertyhelper-(-o,-p-)><span class=secno>7.2.3.3</span> <dfn>CrossOriginGetOwnPropertyHelper</dfn> ( <var>O</var>, <var>P</var> )<a href=#crossorigingetownpropertyhelper-(-o,-p-) class=self-link></a></h5>

  <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://heycam.github.io/webidl/#securityerror data-x-internal=securityerror>"<code>SecurityError</code>"</a> <code id=crossorigingetownpropertyhelper-(-o,-p-):domexception><a data-x-internal=domexception href=https://heycam.github.io/webidl/#dfn-DOMException>DOMException</a></code>.</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>.<li>
    <p>Repeat for each <var>e</var> that is an element 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.github.io/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.<li><p>Let <var>originalDesc</var> be <a id=crossorigingetownpropertyhelper-(-o,-p-):ordinarygetownproperty href=https://tc39.github.io/ecma262/#sec-ordinarygetownproperty data-x-internal=ordinarygetownproperty>OrdinaryGetOwnProperty</a>(<var>O</var>,
       <var>P</var>).<li><p>Let <var>crossOriginDesc</var> be undefined.<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]].<li><p>If ! <a id=crossorigingetownpropertyhelper-(-o,-p-):iscallable href=https://tc39.github.io/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-record href=https://tc39.github.io/ecma262/#current-realm data-x-internal=current-realm-record>current Realm Record</a>, that
         performs the same steps as the IDL operation <var>P</var> on object <var>O</var>.<li><p>Set <var>crossOriginDesc</var> to <a id=crossorigingetownpropertyhelper-(-o,-p-):propertydescriptor href=https://tc39.github.io/ecma262/#sec-property-descriptor-specification-type data-x-internal=propertydescriptor>PropertyDescriptor</a>{
         [[Value]]: <var>value</var>,
         [[Enumerable]]: false,
         [[Writable]]: false,
         [[Configurable]]: true }.</ol>
       <li>
        <p>Otherwise:</p>

        <ol><li><p>Let <var>crossOriginGet</var> be undefined.<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-record-2 href=https://tc39.github.io/ecma262/#current-realm data-x-internal=current-realm-record>current Realm Record</a>, that
         performs the same steps as the getter of the IDL attribute <var>P</var> on object
         <var>O</var>.<li><p>Let <var>crossOriginSet</var> be undefined.<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-record-3 href=https://tc39.github.io/ecma262/#current-realm data-x-internal=current-realm-record>current Realm Record</a>, that
         performs the same steps as the setter of the IDL attribute <var>P</var> on object
         <var>O</var>.<li><p>Set <var>crossOriginDesc</var> to <a id=crossorigingetownpropertyhelper-(-o,-p-):propertydescriptor-2 href=https://tc39.github.io/ecma262/#sec-property-descriptor-specification-type data-x-internal=propertydescriptor>PropertyDescriptor</a>{
         [[Get]]: <var>crossOriginGet</var>,
         [[Set]]: <var>crossOriginSet</var>,
         [[Enumerable]]: false,
         [[Configurable]]: true }.</ol>
       <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>.<li><p>Return <var>crossOriginDesc</var>.</ol>
     </ol>
   <li><p>If <var>P</var> is "<code>then</code>", <a href=#@@tostringtag id=crossorigingetownpropertyhelper-(-o,-p-):@@tostringtag>@@toStringTag</a>,
   <a href=#@@hasinstance id=crossorigingetownpropertyhelper-(-o,-p-):@@hasinstance>@@hasInstance</a>, or <a href=#@@isconcatspreadable id=crossorigingetownpropertyhelper-(-o,-p-):@@isconcatspreadable>@@isConcatSpreadable</a>, then return
   <a id=crossorigingetownpropertyhelper-(-o,-p-):propertydescriptor-3 href=https://tc39.github.io/ecma262/#sec-property-descriptor-specification-type data-x-internal=propertydescriptor>PropertyDescriptor</a>{
   [[Value]]: undefined,
   [[Writable]]: false,
   [[Enumerable]]: false,
   [[Configurable]]: true }.<li><p>Return undefined.</ol>

  <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.github.io/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>

  <h5 id=crossoriginget-(-o,-p,-receiver-)><span class=secno>7.2.3.4</span> <dfn>CrossOriginGet</dfn> ( <var>O</var>, <var>P</var>, <var>Receiver</var> )<a href=#crossoriginget-(-o,-p,-receiver-) class=self-link></a></h5>

  <ol><li><p>Let <var>desc</var> be ? <var>O</var>.[[GetOwnProperty]](<var>P</var>).<li><p>Assert: <var>desc</var> is not undefined.<li><p>If ! <a id=crossoriginget-(-o,-p,-receiver-):isdatadescriptor href=https://tc39.github.io/ecma262/#sec-isdatadescriptor data-x-internal=isdatadescriptor>IsDataDescriptor</a>(<var>desc</var>) is true, then return
   <var>desc</var>.[[Value]].<li><p>Assert: <a id=crossoriginget-(-o,-p,-receiver-):isaccessordescriptor href=https://tc39.github.io/ecma262/#sec-isaccessordescriptor data-x-internal=isaccessordescriptor>IsAccessorDescriptor</a>(<var>desc</var>) is true.<li><p>Let <var>getter</var> be <var>desc</var>.[[Get]].<li><p>If <var>getter</var> is undefined, then throw a <a id=crossoriginget-(-o,-p,-receiver-):securityerror href=https://heycam.github.io/webidl/#securityerror data-x-internal=securityerror>"<code>SecurityError</code>"</a>
   <code id=crossoriginget-(-o,-p,-receiver-):domexception><a data-x-internal=domexception href=https://heycam.github.io/webidl/#dfn-DOMException>DOMException</a></code>.<li><p>Return ? <a id=crossoriginget-(-o,-p,-receiver-):call href=https://tc39.github.io/ecma262/#sec-call data-x-internal=call>Call</a>(<var>getter</var>, <var>Receiver</var>).</ol>

  <h5 id=crossoriginset-(-o,-p,-v,-receiver-)><span class=secno>7.2.3.5</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></h5>

  <ol><li><p>Let <var>desc</var> be ? <var>O</var>.[[GetOwnProperty]](<var>P</var>).<li><p>Assert: <var>desc</var> is not undefined.<li>
    <p>If <var>desc</var>.[[Set]] is present and its value is not undefined, then:

    <ol><li><p>Perform ? <a id=crossoriginset-(-o,-p,-v,-receiver-):call href=https://tc39.github.io/ecma262/#sec-call data-x-internal=call>Call</a>(<var>setter</var>, <var>Receiver</var>,
     «<var>V</var>»).<li><p>Return true.</ol>
   <li><p>Throw a <a id=crossoriginset-(-o,-p,-v,-receiver-):securityerror href=https://heycam.github.io/webidl/#securityerror data-x-internal=securityerror>"<code>SecurityError</code>"</a> <code id=crossoriginset-(-o,-p,-v,-receiver-):domexception><a data-x-internal=domexception href=https://heycam.github.io/webidl/#dfn-DOMException>DOMException</a></code>.</ol>

  <h5 id=crossoriginownpropertykeys-(-o-)><span class=secno>7.2.3.6</span> <dfn>CrossOriginOwnPropertyKeys</dfn> ( <var>O</var> )<a href=#crossoriginownpropertykeys-(-o-) class=self-link></a></h5>

  <ol><li><p>Let <var>keys</var> be a new empty <a href=https://tc39.github.io/ecma262/#sec-list-and-record-specification-type id=crossoriginownpropertykeys-(-o-):js-list data-x-internal=js-list>List</a>.<li>
    <p>Repeat for each <var>e</var> that is an element of !
    <a href=#crossoriginproperties-(-o-) id=crossoriginownpropertykeys-(-o-):crossoriginproperties-(-o-)>CrossOriginProperties</a>(<var>O</var>):</p>

    <ol><li><p>If <var>e</var>.[[HideFromKeys]] is not true, <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>.</ol>
   <li><p>If <var>keys</var> <a href=https://infra.spec.whatwg.org/#list-contain id=crossoriginownpropertykeys-(-o-):list-contains data-x-internal=list-contains>does not contain</a> "<code>then</code>", then <a href=https://infra.spec.whatwg.org/#list-append id=crossoriginownpropertykeys-(-o-):list-append-2 data-x-internal=list-append>append</a> "<code>then</code>" to <var>keys</var>.<li><p>Return the concatenation of <var>keys</var> and « <a href=#@@tostringtag id=crossoriginownpropertykeys-(-o-):@@tostringtag>@@toStringTag</a>,
   <a href=#@@hasinstance id=crossoriginownpropertykeys-(-o-):@@hasinstance>@@hasInstance</a>, <a href=#@@isconcatspreadable id=crossoriginownpropertykeys-(-o-):@@isconcatspreadable>@@isConcatSpreadable</a> ».</ol>

  



  <h3 id=the-window-object><span class=secno>7.3</span> The <code id=the-window-object:window><a href=#window>Window</a></code> object<a href=#the-window-object class=self-link></a></h3>

  <pre><code class='idl'>[<c- g>Global</c->=<c- n>Window</c->,
 <c- g>Exposed</c->=<c- n>Window</c->,
 <c- g>LegacyUnenumerableNamedProperties</c->]
<c- b>interface</c-> <dfn data-dfn-type='interface' data-export id='window'><c- g>Window</c-></dfn> : <a href='https://dom.spec.whatwg.org/#interface-eventtarget' data-x-internal='eventtarget' id='the-window-object:eventtarget'><c- n>EventTarget</c-></a> {
  // the current browsing context
  [<c- g>Unforgeable</c->] <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>;
  [<c- g>Unforgeable</c->] <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>, <c- g>Unforgeable</c->] <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- 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>void</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>void</c-> <a href='#dom-window-stop' id='the-window-object:dom-window-stop'><c- g>stop</c-></a>();
  <c- b>void</c-> <a href='#dom-window-focus' id='the-window-object:dom-window-focus'><c- g>focus</c-></a>();
  <c- b>void</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>;
  [<c- g>Unforgeable</c->] <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 href='https://dom.spec.whatwg.org/#interface-element' data-x-internal='element' id='the-window-object: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-> = &quot;about:blank&quot;, <c- b>optional</c-> <c- b>DOMString</c-> <c- g>target</c-> = &quot;_blank&quot;, <c- b>optional</c-> [<c- g>TreatNullAs</c->=<c- n>EmptyString</c->] <c- b>DOMString</c-> <c- g>features</c-> = &quot;&quot;);
  <a href='#dom-window-nameditem'><c- b>getter</c-></a> <a href='https://heycam.github.io/webidl/#idl-object' data-x-internal='idl-object' id='the-window-object:idl-object'><c- b>object</c-></a> (<c- b>DOMString</c-> <c- g>name</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.

  // 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- b>readonly</c-> <c- b>attribute</c-> <a href='#applicationcache' id='the-window-object:applicationcache'><c- n>ApplicationCache</c-></a> <a href='#dom-applicationcache' id='the-window-object:dom-applicationcache'><c- g>applicationCache</c-></a>;

  // user prompts
  <c- b>void</c-> <a href='#dom-alert' id='the-window-object:dom-alert'><c- g>alert</c-></a>();
  <c- b>void</c-> <a href='#dom-alert' id='the-window-object:dom-alert-2'><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-> = &quot;&quot;);
  <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-> = &quot;&quot;, <c- b>optional</c-> <c- b>DOMString</c-> <c- g>default</c-> = &quot;&quot;);
  <c- b>void</c-> <a href='#dom-print' id='the-window-object:dom-print'><c- g>print</c-></a>();

  <c- b>void</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://heycam.github.io/webidl/#idl-object' data-x-internal='idl-object' id='the-window-object:idl-object-2'><c- b>object</c-></a>&gt; <c- g>transfer</c-> = []);
};
<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>;</code></pre>



  <dl class=domintro><dt><var>window</var> . <code id=dom-window-dev><a href=#dom-window>window</a></code><dt><var>window</var> . <code id=dom-frames-dev><a href=#dom-frames>frames</a></code><dt><var>window</var> . <code id=dom-self-dev><a href=#dom-self>self</a></code><dd>

    <p>These attributes all return <var>window</var>.</p>

   <dt><var>window</var> . <code id=dom-document-dev><a href=#dom-document-2>document</a></code><dd>

    <p>Returns the <code id=the-window-object:document-2><a href=#document>Document</a></code> associated with <var>window</var>.</p>

   <dt><var>document</var> . <code id=dom-document-defaultview-dev><a href=#dom-document-defaultview>defaultView</a></code><dd>

    <p>Returns the <code id=the-window-object:window-4><a href=#window>Window</a></code> object of the <a href=#active-document id=the-window-object:active-document>active document</a>.</p>

   </dl>

  

  <p>The <code id=the-window-object:window-5><a href=#window>Window</a></code> 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 initial <code id=the-window-object:about:blank><a href=#about:blank>about:blank</a></code>
  <code id=the-window-object:document-4><a href=#document>Document</a></code>.</p>

  <p>The <dfn id=dom-window><code>window</code></dfn>, <dfn id=dom-frames><code>frames</code></dfn>, and <dfn id=dom-self><code>self</code></dfn> IDL
  attributes, on getting, must all return this <code id=the-window-object:window-7><a href=#window>Window</a></code> object's <a href=#browsing-context id=the-window-object:browsing-context>browsing
  context</a>'s <code id=the-window-object:windowproxy-8><a href=#windowproxy>WindowProxy</a></code> object.</p>

  <p>The <dfn id=dom-document-2><code>document</code></dfn> IDL attribute, on getting, must
  return this <code id=the-window-object:window-8><a href=#window>Window</a></code> object's <a href=#concept-document-window id=the-window-object:concept-document-window>associated
  <code>Document</code></a>.</p>

  <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-9><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>initializes 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-10><a href=#window>Window</a></code> object of the
  original <code id=the-window-object:about:blank-2><a href=#about:blank>about:blank</a></code> page is reused and gets a new <code id=the-window-object:document-6><a href=#document>Document</a></code> object.</p>

  <p>The <dfn id=dom-document-defaultview><code>defaultView</code></dfn> IDL attribute of the
  <code id=the-window-object:document-7><a href=#document>Document</a></code> interface, on getting, must return this <code id=the-window-object:document-8><a href=#document>Document</a></code>'s <a href=#concept-document-bc id=the-window-object:concept-document-bc>browsing context</a>'s <code id=the-window-object:windowproxy-9><a href=#windowproxy>WindowProxy</a></code> object, if this
  <code id=the-window-object:document-9><a href=#document>Document</a></code> has an associated browsing context, or null otherwise.</p>

  <hr>

  <p>For historical reasons, <code id=the-window-object:window-11><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-10><a href=#document>Document</a></code> <a id=the-window-object:interface-object href=https://heycam.github.io/webidl/#dfn-interface-object data-x-internal=interface-object>interface object</a>.</p>

  


  <h4 id=apis-for-creating-and-navigating-browsing-contexts-by-name><span class=secno>7.3.1</span> APIs for creating and navigating browsing contexts by name<a href=#apis-for-creating-and-navigating-browsing-contexts-by-name class=self-link></a></h4>

  <dl class=domintro><dt><var>window</var> = <var>window</var> . <code id=dom-open-dev><a href=#dom-open>open</a></code>( [ <var>url</var> [, <var>target</var> [, <var>features</var> ] ] ] )<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.
    The <var>target</var> argument gives the name of the new window. If a window exists with that
    name already, it is reused. The <var>features</var> argument can be used to influence the
    rendering of the new window.</p>

   <dt><var>window</var> . <code id=dom-name-dev><a href=#dom-name>name</a></code> [ = <var>value</var> ]<dd>

    <p>Returns the name of the window.</p>

    <p>Can be set, to change the name.</p>

   <dt><var>window</var> . <code id=dom-window-close-dev><a href=#dom-window-close>close</a></code>()<dd>

    <p>Closes the window.</p>

   <dt><var>window</var> . <code id=dom-window-closed-dev><a href=#dom-window-closed>closed</a></code><dd>

    <p>Returns true if the window has been closed, false otherwise.</p>

   <dt><var>window</var> . <code id=dom-window-stop-dev><a href=#dom-window-stop>stop</a></code>()<dd>

    <p>Cancels the document load.</p>

   </dl>

  

  <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>Let <var>entry settings</var> be the <a href=#entry-settings-object id=apis-for-creating-and-navigating-browsing-contexts-by-name:entry-settings-object>entry settings object</a>.<li><p>Let <var>source browsing context</var> be the <a href=#responsible-browsing-context id=apis-for-creating-and-navigating-browsing-contexts-by-name:responsible-browsing-context>responsible browsing context</a>
   specified by <var>entry settings</var>.<li><p>If <var>target</var> is the empty string, then set <var>target</var> to "<code>_blank</code>".<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>.<li><p>Let <var>noopener</var> be true if <var>tokenizedFeatures</var> <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>contains</a> an entry with the key "<code>noopener</code>"<li>
    <p>Let <var>target browsing context</var> and <var>new</var> be the result of applying <a href=#the-rules-for-choosing-a-browsing-context-given-a-browsing-context-name id=apis-for-creating-and-navigating-browsing-contexts-by-name:the-rules-for-choosing-a-browsing-context-given-a-browsing-context-name>the
    rules for choosing a browsing context</a> given <var>target</var>, <var>source browsing
    context</var>, and <var>noopener</var>.

    <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><p>If <var>target browsing context</var> is null, then return null.<li><p>If <var>new</var> is true, then <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>target browsing context</var> given <var>tokenizedFeatures</var>. <a href=#refsCSSOMVIEW>[CSSOMVIEW]</a><li><p>Let <var>resource</var> be the <a id=apis-for-creating-and-navigating-browsing-contexts-by-name:url href=https://url.spec.whatwg.org/#concept-url data-x-internal=url>URL</a> "<code id=apis-for-creating-and-navigating-browsing-contexts-by-name:about:blank-2><a href=#about:blank>about:blank</a></code>".<li>
    <p>If <var>url</var> is not the empty string or <var>new</var> is true, then:

    <ol><li><p>If <var>url</var> is not the empty string, then <a href=#parse-a-url id=apis-for-creating-and-navigating-browsing-contexts-by-name:parse-a-url>parse</a>
     <var>url</var> relative to <var>entry settings</var>, and set <var>resource</var> to the
     <a href=#resulting-url-record id=apis-for-creating-and-navigating-browsing-contexts-by-name:resulting-url-record>resulting URL record</a>, if any. If the <a href=#parse-a-url id=apis-for-creating-and-navigating-browsing-contexts-by-name:parse-a-url-2>parse a URL</a> algorithm failed,
     then throw a <a id=apis-for-creating-and-navigating-browsing-contexts-by-name:syntaxerror href=https://heycam.github.io/webidl/#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://heycam.github.io/webidl/#dfn-DOMException>DOMException</a></code>.<li><p>If <var>resource</var> is "<code id=apis-for-creating-and-navigating-browsing-contexts-by-name:about:blank-3><a href=#about:blank>about:blank</a></code>" and <var>new</var> is true, then
     <a href=#queue-a-task id=apis-for-creating-and-navigating-browsing-contexts-by-name:queue-a-task>queue a task</a> to <a href=https://dom.spec.whatwg.org/#concept-event-fire id=apis-for-creating-and-navigating-browsing-contexts-by-name:concept-event-fire data-x-internal=concept-event-fire>fire an event</a> named <code id=apis-for-creating-and-navigating-browsing-contexts-by-name:event-load><a href=#event-load>load</a></code> at <var>target browsing context</var>'s <code id=apis-for-creating-and-navigating-browsing-contexts-by-name:window><a href=#window>Window</a></code>
     object, with the <var>legacy target override flag</var> set.</p>

     <li><p>Otherwise, <a href=#navigate id=apis-for-creating-and-navigating-browsing-contexts-by-name:navigate>navigate</a> <var>target browsing
     context</var> to <var>resource</var>, with the <var><a href=#exceptions-enabled id=apis-for-creating-and-navigating-browsing-contexts-by-name:exceptions-enabled>exceptions enabled flag</a></var>
     set. If <var>new</var> is true, then <a href=#replacement-enabled id=apis-for-creating-and-navigating-browsing-contexts-by-name:replacement-enabled>replacement must be
     enabled</a>. The <a href=#source-browsing-context id=apis-for-creating-and-navigating-browsing-contexts-by-name:source-browsing-context>source browsing context</a> is <var>source browsing context</var>.
     Rethrow any exceptions.</ol>
   <li><p>If <var>noopener</var> is true, then <a href=#disowned-its-opener id=apis-for-creating-and-navigating-browsing-contexts-by-name:disowned-its-opener>disown</a> <var>target
   browsing context</var> and return null.<li><p>Return <var>target browsing context</var>'s <code id=apis-for-creating-and-navigating-browsing-contexts-by-name:windowproxy><a href=#windowproxy>WindowProxy</a></code> object.</ol>

  <p>The <dfn data-dfn-for=Window id=dom-open data-dfn-type=operation data-lt="open()|open(url, target, features)" data-export=""><code>open(<var>url</var>,
  <var>target</var>, <var>features</var>)</code></dfn> method on <code id=apis-for-creating-and-navigating-browsing-contexts-by-name:window-2><a href=#window>Window</a></code> objects
  provides a mechanism for <a href=#navigate id=apis-for-creating-and-navigating-browsing-contexts-by-name:navigate-2>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>

  <p>When the method is invoked, the user agent must 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>

  <hr>

  <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 href=https://infra.spec.whatwg.org/#ordered-map data-x-internal=ordered-map>ordered map</a>.<li><p>Let <var>position</var> point at the first code point of <var>features</var>.<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.<li><p>Let <var>value</var> be the empty string.<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.<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>.<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>.<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>.<li><p>Advance <var>position</var> by 1.</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>
      <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>.<li><p>Advance <var>position</var> by 1.</ol>

        <p class=note>This skips to the first non-separator but does not skip past a U+002C
        (,).</p>
       <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>.</ol>
     <li><p>If <var>name</var> is not the empty string, then set
     <var>tokenizedFeatures</var>[<var>name</var>] to <var>value</var>.</ol>
   <li><p>Return <var>tokenizedFeatures</var>.</ol>

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

  <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>"
   <dd>Return "<code>left</code>".
   <dt>"<code>screeny</code>"
   <dd>Return "<code>top</code>".
   <dt>"<code>innerwidth</code>"
   <dd>Return "<code>width</code>".
   <dt>"<code>innerheight</code>"
   <dd>Return "<code>height</code>".
   <dt>Anything else
   <dd>Return <var>name</var>.
  </dl>

  <hr>

  <p>The <dfn id=dom-name><code>name</code></dfn> attribute of the <code id=apis-for-creating-and-navigating-browsing-contexts-by-name:window-3><a href=#window>Window</a></code> object
  must, on getting, return the current <a href=#browsing-context-name id=apis-for-creating-and-navigating-browsing-contexts-by-name:browsing-context-name>name</a> of the
  <a href=#browsing-context id=apis-for-creating-and-navigating-browsing-contexts-by-name:browsing-context-2>browsing context</a>; and, on setting, set the <a href=#browsing-context-name id=apis-for-creating-and-navigating-browsing-contexts-by-name:browsing-context-name-2>name</a> of the <a href=#browsing-context id=apis-for-creating-and-navigating-browsing-contexts-by-name:browsing-context-3>browsing context</a> to the new value.</p>

  <p class=note>The name <a href=#resetBCName>gets reset</a> when the browsing context is
  <a href=#navigate id=apis-for-creating-and-navigating-browsing-contexts-by-name:navigate-3>navigated</a> to another <a href=#concept-origin id=apis-for-creating-and-navigating-browsing-contexts-by-name:concept-origin>origin</a>.</p>

  <hr>

  <p>The <dfn id=dom-window-close><code>close()</code></dfn> method on <code id=apis-for-creating-and-navigating-browsing-contexts-by-name:window-4><a href=#window>Window</a></code>
  objects should, if all the following conditions are met, <a href=#close-a-browsing-context id=apis-for-creating-and-navigating-browsing-contexts-by-name:close-a-browsing-context>close</a> the <a href=#browsing-context id=apis-for-creating-and-navigating-browsing-contexts-by-name:browsing-context-4>browsing context</a> <var>A</var>:

  <ul class=brief><li>The corresponding <a href=#browsing-context id=apis-for-creating-and-navigating-browsing-contexts-by-name:browsing-context-5>browsing context</a> <var>A</var> is
   <a href=#script-closable id=apis-for-creating-and-navigating-browsing-contexts-by-name:script-closable>script-closable</a>.<li>The <a href=#responsible-browsing-context id=apis-for-creating-and-navigating-browsing-contexts-by-name:responsible-browsing-context-2>responsible browsing context</a> specified by the <a href=#incumbent-settings-object id=apis-for-creating-and-navigating-browsing-contexts-by-name:incumbent-settings-object>incumbent settings
   object</a> is <a href=#familiar-with id=apis-for-creating-and-navigating-browsing-contexts-by-name:familiar-with>familiar with</a> the <a href=#browsing-context id=apis-for-creating-and-navigating-browsing-contexts-by-name:browsing-context-6>browsing context</a> <var>A</var>.<li id=sandboxClose>The <a href=#responsible-browsing-context id=apis-for-creating-and-navigating-browsing-contexts-by-name:responsible-browsing-context-3>responsible browsing context</a> specified by the
   <a href=#incumbent-settings-object id=apis-for-creating-and-navigating-browsing-contexts-by-name:incumbent-settings-object-2>incumbent settings object</a> is <a href=#allowed-to-navigate id=apis-for-creating-and-navigating-browsing-contexts-by-name:allowed-to-navigate>allowed to navigate</a> the <a href=#browsing-context id=apis-for-creating-and-navigating-browsing-contexts-by-name:browsing-context-7>browsing
   context</a> <var>A</var>.</ul>

  <p>A <a href=#browsing-context id=apis-for-creating-and-navigating-browsing-contexts-by-name:browsing-context-8>browsing context</a> is <dfn id=script-closable>script-closable</dfn> if it is an <a href=#auxiliary-browsing-context id=apis-for-creating-and-navigating-browsing-contexts-by-name:auxiliary-browsing-context-2>auxiliary
  browsing context</a> that was created by a script (as opposed to by an action of the user), or
  if it is a <a href=#top-level-browsing-context id=apis-for-creating-and-navigating-browsing-contexts-by-name:top-level-browsing-context>top-level browsing context</a> whose <a href=#session-history id=apis-for-creating-and-navigating-browsing-contexts-by-name:session-history>session history</a> contains
  only one <code id=apis-for-creating-and-navigating-browsing-contexts-by-name:document><a href=#document>Document</a></code>.</p>

  <p>The <dfn id=dom-window-closed><code>closed</code></dfn> attribute on <code id=apis-for-creating-and-navigating-browsing-contexts-by-name:window-5><a href=#window>Window</a></code>
  objects must return true if the <code id=apis-for-creating-and-navigating-browsing-contexts-by-name:window-6><a href=#window>Window</a></code> object's <a href=#browsing-context id=apis-for-creating-and-navigating-browsing-contexts-by-name:browsing-context-9>browsing context</a> has
  been <a href=#a-browsing-context-is-discarded id=apis-for-creating-and-navigating-browsing-contexts-by-name:a-browsing-context-is-discarded>discarded</a>, and false otherwise.</p>

  <p>The <dfn id=dom-window-stop><code>stop()</code></dfn> method on <code id=apis-for-creating-and-navigating-browsing-contexts-by-name:window-7><a href=#window>Window</a></code>
  objects must <a href=#stop-document-loading id=apis-for-creating-and-navigating-browsing-contexts-by-name:stop-document-loading>stop document loading</a> given this <code id=apis-for-creating-and-navigating-browsing-contexts-by-name:window-8><a href=#window>Window</a></code> object'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>

  


  <h4 id=accessing-other-browsing-contexts><span class=secno>7.3.2</span> Accessing other browsing contexts<a href=#accessing-other-browsing-contexts class=self-link></a></h4>

  <dl class=domintro><dt><var>window</var> . <code id=dom-length-dev><a href=#dom-length>length</a></code><dd>

    <p>Returns the number of <a href=#document-tree-child-browsing-context id=accessing-other-browsing-contexts:document-tree-child-browsing-context>document-tree child browsing contexts</a>.</p>

   <dt><var>window</var>[<var>index</var>]<dd>

    <p>Returns the indicated <a href=#document-tree-child-browsing-context id=accessing-other-browsing-contexts:document-tree-child-browsing-context-2>document-tree child browsing context</a>.</p>

   </dl>

  

  <p id=number-of-child-browsing-contexts>The <dfn id=number-of-document-tree-child-browsing-contexts>number of document-tree child browsing
  contexts</dfn> of a <code id=accessing-other-browsing-contexts:window><a href=#window>Window</a></code> object <var>W</var> is the number of <a href=#document-tree-child-browsing-context id=accessing-other-browsing-contexts:document-tree-child-browsing-context-3>document-tree child browsing contexts</a> of
  <var>W</var>'s <a href=#concept-document-window id=accessing-other-browsing-contexts:concept-document-window>associated <code>Document</code></a>'s
  <a href=#concept-document-bc id=accessing-other-browsing-contexts:concept-document-bc>browsing context</a>.</p>

  <p>The <dfn id=dom-length><code>length</code></dfn> IDL attribute's getter must return the
  <a href=#number-of-document-tree-child-browsing-contexts id=accessing-other-browsing-contexts:number-of-document-tree-child-browsing-contexts>number of document-tree child browsing contexts</a> of this <code id=accessing-other-browsing-contexts:window-2><a href=#window>Window</a></code>
  object.</p>

  <p class=note>Indexed access to <a href=#document-tree-child-browsing-context id=accessing-other-browsing-contexts:document-tree-child-browsing-context-4>document-tree child browsing contexts</a> is defined through the <a href=#windowproxy-getownproperty>[[GetOwnProperty]]</a> internal method of the
  <code id=accessing-other-browsing-contexts:windowproxy><a href=#windowproxy>WindowProxy</a></code> object.</p>

  



  <h4 id=named-access-on-the-window-object><span class=secno>7.3.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></h4>

  <dl class=domintro><dt><var>window</var>[<var>name</var>]<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>

   </dl>

  

  <p id=child-browsing-context-name-property-set>The <dfn id=document-tree-child-browsing-context-name-property-set>document-tree child browsing context
  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>activeDocument</var> be <var>window</var>'s <a href=#browsing-context id=named-access-on-the-window-object:browsing-context>browsing context</a>'s
   <a href=#active-document id=named-access-on-the-window-object:active-document>active document</a>.<li><p>Let <var>childBrowsingContexts</var> be all <a href=#document-tree-child-browsing-context id=named-access-on-the-window-object:document-tree-child-browsing-context>document-tree child browsing contexts</a> of <var>activeDocument</var>'s <a href=#concept-document-bc id=named-access-on-the-window-object:concept-document-bc>browsing context</a> whose <a href=#browsing-context-name id=named-access-on-the-window-object:browsing-context-name>browsing context name</a> is
   not the empty string, in order, and including only the first <a href=#document-tree-child-browsing-context id=named-access-on-the-window-object:document-tree-child-browsing-context-2>document-tree child browsing
   context</a> with a given <a href=#browsing-context-name id=named-access-on-the-window-object:browsing-context-name-2>name</a> if multiple <a href=#document-tree-child-browsing-context id=named-access-on-the-window-object:document-tree-child-browsing-context-3>document-tree child browsing contexts</a> have
   the same one.<li><p>Remove each <a href=#browsing-context id=named-access-on-the-window-object:browsing-context-2>browsing context</a> from <var>childBrowsingContexts</var> whose
   <a href=#active-document id=named-access-on-the-window-object:active-document-2>active document</a>'s <a href=#concept-origin id=named-access-on-the-window-object:concept-origin>origin</a> is not <a href=#same-origin id=named-access-on-the-window-object:same-origin>same origin</a> with
   <var>activeDocument</var>'s <a href=#concept-origin id=named-access-on-the-window-object:concept-origin-2>origin</a> and whose <a href=#browsing-context-name id=named-access-on-the-window-object:browsing-context-name-3>browsing context name</a> does
   not match the name of its <a href=#browsing-context-container id=named-access-on-the-window-object:browsing-context-container>browsing context container</a>'s <code>name</code>
   content attribute value.<li><p>Return the <a href=#browsing-context-name id=named-access-on-the-window-object:browsing-context-name-4>browsing context names</a> of
   <var>childBrowsingContexts</var>, in the same order.</ol>

  <div class=example>
   <p>This means 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>

  <p>The <code id=named-access-on-the-window-object:window-3><a href=#window>Window</a></code> object <a href=https://heycam.github.io/webidl/#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://heycam.github.io/webidl/#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-browsing-context-name-property-set id=named-access-on-the-window-object:document-tree-child-browsing-context-name-property-set>document-tree child browsing context name property
   set</a>;<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:frameset><a href=#frameset>frameset</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=#browsing-context id=named-access-on-the-window-object:browsing-context-3>browsing context</a>'s <a href=#active-document id=named-access-on-the-window-object:active-document-3>active document</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<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=#browsing-context id=named-access-on-the-window-object:browsing-context-4>browsing context</a>'s
   <a href=#active-document id=named-access-on-the-window-object:active-document-4>active document</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>.</ul>

  <p id=dom-window-nameditem>To <a id=named-access-on-the-window-object:determine-the-value-of-a-named-property href=https://heycam.github.io/webidl/#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>, 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> with the name <var>name</var>.</p>

    <p class=note>There will be at least one such object, by definition.</p>

   <li>

    <p>If <var>objects</var> contains a <a href=#nested-browsing-context id=named-access-on-the-window-object:nested-browsing-context>nested browsing context</a>, then return
    the <code id=named-access-on-the-window-object:windowproxy><a href=#windowproxy>WindowProxy</a></code> object of the <a href=#nested-browsing-context id=named-access-on-the-window-object:nested-browsing-context-2>nested browsing context</a> corresponding to
    the first <a href=#browsing-context-container id=named-access-on-the-window-object:browsing-context-container-2>browsing context container</a> in <a id=named-access-on-the-window-object:tree-order-2 href=https://dom.spec.whatwg.org/#concept-tree-order data-x-internal=tree-order>tree order</a> whose
    <a href=#nested-browsing-context id=named-access-on-the-window-object:nested-browsing-context-3>nested browsing context</a> is in <var>objects</var>.</p>

   <li>

    <p>Otherwise, if <var>objects</var> has only one element, return that element.</p>

   <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 the <code id=named-access-on-the-window-object:document><a href=#document>Document</a></code> node,
    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> with
    the name <var>name</var>. (By definition, these will all be elements.)</p> 

   </ol>

  <p><dfn id=dom-window-nameditem-filter>Named objects</dfn> 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-browsing-context id=named-access-on-the-window-object:document-tree-child-browsing-context-4>document-tree child browsing
   contexts</a> of the <a href=#active-document id=named-access-on-the-window-object:active-document-5>active document</a> whose name is <var>name</var>;<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:frameset-2><a href=#frameset>frameset</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 the <a href=#active-document id=named-access-on-the-window-object:active-document-6>active
   document</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<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 the <a href=#active-document id=named-access-on-the-window-object:active-document-7>active
   document</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>.</ul>

  


  

  <h4 id=garbage-collection-and-browsing-contexts><span class=secno>7.3.4</span> Garbage collection and browsing contexts<a href=#garbage-collection-and-browsing-contexts class=self-link></a></h4>

  <p>A <a href=#browsing-context id=garbage-collection-and-browsing-contexts:browsing-context>browsing context</a> has a strong reference to each of its <code id=garbage-collection-and-browsing-contexts:document><a href=#document>Document</a></code>s
  and its <code id=garbage-collection-and-browsing-contexts:windowproxy><a href=#windowproxy>WindowProxy</a></code> object, and the user agent itself has a strong reference to its
  <a href=#top-level-browsing-context id=garbage-collection-and-browsing-contexts:top-level-browsing-context>top-level browsing contexts</a>.</p>

  <p>A <code id=garbage-collection-and-browsing-contexts:document-2><a href=#document>Document</a></code> has a strong reference to its <code id=garbage-collection-and-browsing-contexts:window><a href=#window>Window</a></code> object.</p>

  <p class=note>A <code id=garbage-collection-and-browsing-contexts:window-2><a href=#window>Window</a></code> object <a href=#implied-strong-reference id=garbage-collection-and-browsing-contexts:implied-strong-reference>has a strong
  reference</a> to its <code id=garbage-collection-and-browsing-contexts:document-3><a href=#document>Document</a></code> object through its <code id=garbage-collection-and-browsing-contexts:dom-document-2><a href=#dom-document-2>document</a></code> attribute. Thus, references from other scripts to either of
  those objects will keep both alive. Similarly, both <code id=garbage-collection-and-browsing-contexts:document-4><a href=#document>Document</a></code> and <code id=garbage-collection-and-browsing-contexts:window-3><a href=#window>Window</a></code>
  objects have <a href=#implied-strong-reference id=garbage-collection-and-browsing-contexts:implied-strong-reference-2>implied strong references</a> to the
  <code id=garbage-collection-and-browsing-contexts:windowproxy-2><a href=#windowproxy>WindowProxy</a></code> object.</p>

  <p>Each <a href=#concept-script id=garbage-collection-and-browsing-contexts:concept-script>script</a> has a strong reference to its <a href=#settings-object id=garbage-collection-and-browsing-contexts:settings-object>settings
  object</a>, and each <a href=#environment-settings-object id=garbage-collection-and-browsing-contexts:environment-settings-object>environment settings object</a> has strong references to its
  <a href=#concept-settings-object-global id=garbage-collection-and-browsing-contexts:concept-settings-object-global>global object</a>, <a href=#responsible-browsing-context id=garbage-collection-and-browsing-contexts:responsible-browsing-context>responsible browsing
  context</a>, and <a href=#responsible-document id=garbage-collection-and-browsing-contexts:responsible-document>responsible document</a> (if any).</p>

  <p>To <dfn id=discard-a-document data-lt="discard a document" data-export="">discard</dfn> a
  <code id=garbage-collection-and-browsing-contexts:document-5><a href=#document>Document</a></code> <var>document</var>:</p>

  <ol><li><p>Set <var>document</var>'s <i id=garbage-collection-and-browsing-contexts:concept-document-salvageable><a href=#concept-document-salvageable>salvageable</a></i> state
   to false.<li><p>Run any <a href=#unloading-document-cleanup-steps id=garbage-collection-and-browsing-contexts: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=garbage-collection-and-browsing-contexts:other-applicable-specifications>other applicable specifications</a>.<li><p><a href=#abort-a-document id=garbage-collection-and-browsing-contexts:abort-a-document>Abort</a> <var>document</var>.<li><p>Remove any <a href=#concept-task id=garbage-collection-and-browsing-contexts:concept-task>tasks</a> associated with
   <var>document</var> in any <a href=#task-source id=garbage-collection-and-browsing-contexts:task-source>task source</a>, without running those tasks.<li><p><a href=#a-browsing-context-is-discarded id=garbage-collection-and-browsing-contexts:a-browsing-context-is-discarded>Discard</a> all the <a href=#child-browsing-context id=garbage-collection-and-browsing-contexts:child-browsing-context>child browsing contexts</a> of <var>document</var>.<li><p>Lose the strong reference from <var>document</var>'s <a href=#concept-document-bc id=garbage-collection-and-browsing-contexts:concept-document-bc>browsing context</a> to <var>document</var>.<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> <var>document</var> from the
   <a href=#concept-WorkerGlobalScope-owner-set id=garbage-collection-and-browsing-contexts:concept-WorkerGlobalScope-owner-set>owner set</a> of each <code id=garbage-collection-and-browsing-contexts:workerglobalscope><a href=#workerglobalscope>WorkerGlobalScope</a></code> object whose set <a href=https://infra.spec.whatwg.org/#list-contain id=garbage-collection-and-browsing-contexts:list-contains data-x-internal=list-contains>contains</a> <var>document</var>.</ol>

  <p>When <dfn id=a-browsing-context-is-discarded data-export="">a <em>browsing context</em> is discarded</dfn>, the strong reference
  from the user agent itself to the <a href=#browsing-context id=garbage-collection-and-browsing-contexts:browsing-context-2>browsing context</a> must be severed, and all the
  <code id=garbage-collection-and-browsing-contexts:document-6><a href=#document>Document</a></code> objects for all the entries in the <a href=#browsing-context id=garbage-collection-and-browsing-contexts:browsing-context-3>browsing context</a>'s session
  history must be <a href=#discard-a-document id=garbage-collection-and-browsing-contexts:discard-a-document>discarded</a> as well.</p>

  <p>User agents may <a href=#a-browsing-context-is-discarded id=garbage-collection-and-browsing-contexts:a-browsing-context-is-discarded-2>discard</a> <a href=#top-level-browsing-context id=garbage-collection-and-browsing-contexts:top-level-browsing-context-2>top-level browsing contexts</a> at any time (typically, in
  response to user requests, e.g. when a user force-closes a window containing one or more <a href=#top-level-browsing-context id=garbage-collection-and-browsing-contexts:top-level-browsing-context-3>top-level browsing contexts</a>). Other <a href=#browsing-context id=garbage-collection-and-browsing-contexts:browsing-context-4>browsing contexts</a> must be discarded once their
  <code id=garbage-collection-and-browsing-contexts:windowproxy-3><a href=#windowproxy>WindowProxy</a></code> object is eligible for garbage collection, in addition to the other
  places where this specification requires them to be discarded.</p>

  <p>A <code id=garbage-collection-and-browsing-contexts:windowproxy-4><a href=#windowproxy>WindowProxy</a></code> does <em>not</em> have a strong reference to the <a href=#browsing-context id=garbage-collection-and-browsing-contexts:browsing-context-5>browsing
  context</a> it was created alongside. In particular, it is possible for a <a href=#nested-browsing-context id=garbage-collection-and-browsing-contexts:nested-browsing-context>nested
  browsing context</a> to be <a href=#a-browsing-context-is-discarded id=garbage-collection-and-browsing-contexts:a-browsing-context-is-discarded-3>discarded</a> even
  if JavaScript code holds a reference to its <code id=garbage-collection-and-browsing-contexts:windowproxy-5><a href=#windowproxy>WindowProxy</a></code> object.</p>

  


  <h4 id=closing-browsing-contexts><span class=secno>7.3.5</span> Closing browsing contexts<a href=#closing-browsing-contexts class=self-link></a></h4>

  <p>To <dfn id=close-a-browsing-context>close a browsing context</dfn> <var>browsingContext</var>, run these steps:</p>

  <ol><li><p><a href=#prompt-to-unload-a-document id=closing-browsing-contexts:prompt-to-unload-a-document>Prompt to unload</a> <var>browsingContext</var>'s <a href=#active-document id=closing-browsing-contexts:active-document>active document</a>.
   If the user <a href=#refused-to-allow-the-document-to-be-unloaded id=closing-browsing-contexts:refused-to-allow-the-document-to-be-unloaded>refused to allow the document to be unloaded</a>, then return.<li><p><a href=#unload-a-document id=closing-browsing-contexts:unload-a-document>Unload</a> <var>browsingContext</var>'s <a href=#active-document id=closing-browsing-contexts:active-document-2>active
   document</a>.<li><p>Remove <var>browsingContext</var> from the user interface (e.g., close or hide its tab in
   a tabbed browser).<li><p><a href=#a-browsing-context-is-discarded id=closing-browsing-contexts:a-browsing-context-is-discarded>Discard</a>
   <var>browsingContext</var>.</ol>

  <p>User agents should offer users the ability to arbitrarily <a href=#close-a-browsing-context id=closing-browsing-contexts:close-a-browsing-context>close</a> any <a href=#top-level-browsing-context id=closing-browsing-contexts:top-level-browsing-context>top-level browsing context</a>.</p>



  <h4 id=browser-interface-elements><span class=secno>7.3.6</span> Browser interface elements<a href=#browser-interface-elements class=self-link></a></h4>

  <p>To allow Web pages to integrate with Web browsers, certain Web browser interface elements are
  exposed in a limited way to scripts in Web pages.</p>

  <p>Each interface element is represented by a <code id=browser-interface-elements:barprop><a href=#barprop>BarProp</a></code> object:</p>

  <pre><code class='idl'>[<c- g>Exposed</c->=<c- n>Window</c->]
<c- b>interface</c-> <dfn id='barprop'><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><var>window</var> . <code id=dom-window-locationbar-dev><a href=#dom-window-locationbar>locationbar</a></code> . <code id=dom-barprop-visible-dev><a href=#dom-barprop-visible>visible</a></code><dd>
    <p>Returns true if the location bar is visible; otherwise, returns false.</p>
   <dt><var>window</var> . <code id=dom-window-menubar-dev><a href=#dom-window-menubar>menubar</a></code> . <code id=browser-interface-elements:dom-barprop-visible-2><a href=#dom-barprop-visible>visible</a></code><dd>
    <p>Returns true if the menu bar is visible; otherwise, returns false.</p>
   <dt><var>window</var> . <code id=dom-window-personalbar-dev><a href=#dom-window-personalbar>personalbar</a></code> . <code id=browser-interface-elements:dom-barprop-visible-3><a href=#dom-barprop-visible>visible</a></code><dd>
    <p>Returns true if the personal bar is visible; otherwise, returns false.</p>
   <dt><var>window</var> . <code id=dom-window-scrollbars-dev><a href=#dom-window-scrollbars>scrollbars</a></code> . <code id=browser-interface-elements:dom-barprop-visible-4><a href=#dom-barprop-visible>visible</a></code><dd>
    <p>Returns true if the scroll bars are visible; otherwise, returns false.</p>
   <dt><var>window</var> . <code id=dom-window-statusbar-dev><a href=#dom-window-statusbar>statusbar</a></code> . <code id=browser-interface-elements:dom-barprop-visible-5><a href=#dom-barprop-visible>visible</a></code><dd>
    <p>Returns true if the status bar is visible; otherwise, returns false.</p>
   <dt><var>window</var> . <code id=dom-window-toolbar-dev><a href=#dom-window-toolbar>toolbar</a></code> . <code id=browser-interface-elements:dom-barprop-visible-6><a href=#dom-barprop-visible>visible</a></code><dd>
    <p>Returns true if the toolbar is visible; otherwise, returns false.</p>
   </dl>

  

  <p>The <dfn id=dom-barprop-visible>visible</dfn> attribute, on getting, must return either
  true or a value determined by the user agent to most accurately represent the visibility state of
  the user interface element that the object represents, as described below.</p>

  <p>The following <code id=browser-interface-elements:barprop-2><a href=#barprop>BarProp</a></code> objects exist for each <code id=browser-interface-elements:document><a href=#document>Document</a></code> object in a
  <a href=#browsing-context id=browser-interface-elements:browsing-context>browsing context</a>. Some of the user interface elements represented by these objects
  might have no equivalent in some user agents; for those user agents, except when otherwise
  specified, the object must act as if it was present and visible (i.e. its <code id=browser-interface-elements:dom-barprop-visible-7><a href=#dom-barprop-visible>visible</a></code> attribute must return true).</p>

  <dl><dt><dfn id=the-location-bar-barprop-object>The location bar <code>BarProp</code> object</dfn><dd>Represents the user interface element that contains a control that displays the
   <a id=browser-interface-elements:url href=https://url.spec.whatwg.org/#concept-url data-x-internal=url>URL</a> of the <a href=#active-document id=browser-interface-elements:active-document>active document</a>, or some similar interface concept.<dt><dfn id=the-menu-bar-barprop-object>The menu bar <code>BarProp</code> object</dfn><dd>Represents the user interface element that contains a list of commands in menu form, or some
   similar interface concept.<dt><dfn id=the-personal-bar-barprop-object>The personal bar <code>BarProp</code> object</dfn><dd>Represents the user interface element that contains links to the user's favorite pages, or
   some similar interface concept.<dt><dfn id=the-scrollbar-barprop-object>The scrollbar <code>BarProp</code> object</dfn><dd>Represents the user interface element that contains a scrolling mechanism, or some similar
   interface concept.<dt><dfn id=the-status-bar-barprop-object>The status bar <code>BarProp</code> object</dfn><dd>Represents 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 current indicating. If
   the user agent has no such user interface element, then the object may act as if the
   corresponding user interface element was absent (i.e. its <code id=browser-interface-elements:dom-barprop-visible-8><a href=#dom-barprop-visible>visible</a></code> attribute may return false).<dt><dfn id=the-toolbar-barprop-object>The toolbar <code>BarProp</code> object</dfn><dd>Represents the user interface element found immediately above or before the document, as
   appropriate for the user's media, which typically provides <a href=#session-history id=browser-interface-elements:session-history>session history</a> traversal
   controls (back and forward buttons, reload buttons, etc). If the user agent has no such user
   interface element, then the object may act as if the corresponding user interface element was
   absent (i.e. its <code id=browser-interface-elements:dom-barprop-visible-9><a href=#dom-barprop-visible>visible</a></code> attribute may return
   false).</dl>

  <p>The <dfn id=dom-window-locationbar><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>

  <p>The <dfn id=dom-window-menubar><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>

  <p>The <dfn id=dom-window-personalbar><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>

  <p>The <dfn id=dom-window-scrollbars><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>

  <p>The <dfn id=dom-window-statusbar><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>

  <p>The <dfn id=dom-window-toolbar><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>



  <hr>

  <p>For historical reasons, the <dfn id=dom-window-status><code>status</code></dfn> attribute
  on the <code id=browser-interface-elements:window><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-2><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>


  <h4 id=script-settings-for-window-objects><span class=secno>7.3.7</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></h4>

  <p>When the user agent is required 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:javascript-execution-context href=https://tc39.github.io/ecma262/#sec-execution-contexts data-x-internal=javascript-execution-context>JavaScript execution context</a> <var>execution context</var> and an optional
  <a href=#environment id=script-settings-for-window-objects:environment>environment</a> <var>reserved environment</var>, it must run the following steps:</p>

  <ol><li><p>Let <var>realm</var> be the value of <var>execution context</var>'s Realm
   component.<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>.<li><p>Let <var>url</var> be a copy of the <a href=https://dom.spec.whatwg.org/#concept-document-url id="script-settings-for-window-objects:the-document's-address" data-x-internal="the-document's-address">URL</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>.<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><dd>

      <p>Return <var>execution context</var>.</p>

     <dt>The <a href=#concept-settings-object-module-map id=script-settings-for-window-objects:concept-settings-object-module-map>module map</a><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-2>associated
      <code>Document</code></a>.</p>

     <dt>The <a href=#responsible-browsing-context id=script-settings-for-window-objects:responsible-browsing-context>responsible browsing context</a><dd>

      <p>Return the <a href=#browsing-context id=script-settings-for-window-objects:browsing-context>browsing context</a> with which <var>window</var> is associated.</p>

     <dt>The <a href=#responsible-event-loop id=script-settings-for-window-objects:responsible-event-loop>responsible event loop</a><dd>

      <p>Return the <a href=#event-loop id=script-settings-for-window-objects:event-loop>event loop</a> that is associated with the <a href=#unit-of-related-similar-origin-browsing-contexts id=script-settings-for-window-objects:unit-of-related-similar-origin-browsing-contexts>unit of related
      similar-origin browsing contexts</a> to which <var>window</var>'s <a href=#browsing-context id=script-settings-for-window-objects:browsing-context-2>browsing
      context</a> belongs.</p>

     <dt>The <a href=#responsible-document id=script-settings-for-window-objects:responsible-document>responsible document</a><dd>

      <p>Return <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>

     <dt>The <a href=#api-url-character-encoding id=script-settings-for-window-objects:api-url-character-encoding>API URL character encoding</a><dd>

      <p>Return the current <a href=https://dom.spec.whatwg.org/#concept-document-encoding id="script-settings-for-window-objects:document's-character-encoding" data-x-internal="document's-character-encoding">character encoding</a>
      of <var>window</var>'s <a href=#concept-document-window id=script-settings-for-window-objects:concept-document-window-4>associated
      <code>Document</code></a>.</p>

     <dt>The <a href=#api-base-url id=script-settings-for-window-objects:api-base-url>API base URL</a><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-5>associated <code>Document</code></a>.</p>

     <dt>The <a href=#concept-settings-object-origin id=script-settings-for-window-objects:concept-settings-object-origin>origin</a><dd>

      <p>Return the <a href=#concept-origin id=script-settings-for-window-objects:concept-origin>origin</a> of <var>window</var>'s <a href=#concept-document-window id=script-settings-for-window-objects:concept-document-window-6>associated <code>Document</code></a>.</p>

     <dt>The <a href=#https-state id=script-settings-for-window-objects:https-state>HTTPS state</a><dd>

      <p>Return the <a href=#concept-document-https-state id=script-settings-for-window-objects:concept-document-https-state>HTTPS state</a> of
      <var>window</var>'s <a href=#concept-document-window id=script-settings-for-window-objects:concept-document-window-7>associated
      <code>Document</code></a>.</p>

     <dt>The <a href=#concept-settings-object-referrer-policy id=script-settings-for-window-objects:concept-settings-object-referrer-policy>referrer policy</a><dd>

      <ol><li><p>Let <var>document</var> be the <code id=script-settings-for-window-objects:document><a href=#document>Document</a></code> with which <var>window</var> is
       currently associated.<li><p>While <var>document</var> is <a href=#an-iframe-srcdoc-document id=script-settings-for-window-objects:an-iframe-srcdoc-document>an <code>iframe</code>
       <code>srcdoc</code> document</a> and <var>document</var>'s
       <a href=#concept-document-referrer-policy id=script-settings-for-window-objects:concept-document-referrer-policy>referrer policy</a> is the empty
       string, set <var>document</var> to <var>document</var>'s
       <a href=#concept-document-bc id=script-settings-for-window-objects:concept-document-bc>browsing context</a>'s
       <a href=#browsing-context-container id=script-settings-for-window-objects:browsing-context-container>browsing context container</a>'s <a id=script-settings-for-window-objects:node-document href=https://dom.spec.whatwg.org/#concept-node-document data-x-internal=node-document>node document</a>.<li><p>Return <var>document</var>'s <a href=#concept-document-referrer-policy id=script-settings-for-window-objects:concept-document-referrer-policy-2>referrer
       policy</a>.</ol>

    </dl>
   <li>
    <p>If <var>reserved environment</var> is given, 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>reserved environment</var>'s <a href=#concept-environment-id id=script-settings-for-window-objects:concept-environment-id-2>id</a>,
     <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>reserved environment</var>'s <a href=#concept-environment-creation-url id=script-settings-for-window-objects:concept-environment-creation-url-2>creation URL</a>, <var>settings object</var>'s
     <a href=#concept-environment-target-browsing-context id=script-settings-for-window-objects:concept-environment-target-browsing-context>target browsing context</a> to
     <var>reserved environment</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
     <var>settings object</var>'s <a href=#concept-environment-active-service-worker id=script-settings-for-window-objects:concept-environment-active-service-worker>active
     service worker</a> to <var>reserved environment</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>.<li>
      <p>Set <var>reserved environment</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>
     </ol>
   <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-creation-url id=script-settings-for-window-objects:concept-environment-creation-url-3>creation URL</a> to
   <var>url</var>, <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.<li><p>Set <var>realm</var>'s [[HostDefined]] field to <var>settings object</var>.<li><p>Return <var>settings object</var>.</ol>

  


  

  <h3 id=the-windowproxy-exotic-object><span class=secno>7.4</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></h3>

  <p>A <dfn id=windowproxy data-dfn-type=interface data-export=""><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>There is no <code id=the-windowproxy-exotic-object:windowproxy-4><a href=#windowproxy>WindowProxy</a></code> <a id=the-windowproxy-exotic-object:interface-object href=https://heycam.github.io/webidl/#dfn-interface-object data-x-internal=interface-object>interface object</a>.</p>

  <p>Every <code id=the-windowproxy-exotic-object:windowproxy-5><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>The <code id=the-windowproxy-exotic-object:windowproxy-6><a href=#windowproxy>WindowProxy</a></code> object internal methods are described in the subsections
  below.</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>

  <h4 id=windowproxy-getprototypeof><span class=secno>7.4.1</span> [[GetPrototypeOf]] ( )<a href=#windowproxy-getprototypeof class=self-link></a></h4>

  <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>.<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.github.io/ecma262/#sec-ordinarygetprototypeof data-x-internal=ordinarygetprototypeof>OrdinaryGetPrototypeOf</a>(<var>W</var>).<li><p>Return null.</ol>

  <h4 id=windowproxy-setprototypeof><span class=secno>7.4.2</span> [[SetPrototypeOf]] ( <var>V</var> )<a href=#windowproxy-setprototypeof class=self-link></a></h4>

  <ol><li><p>Return ! <a id=windowproxy-setprototypeof:setimmutableprototype href=https://tc39.github.io/ecma262/#sec-set-immutable-prototype data-x-internal=setimmutableprototype>SetImmutablePrototype</a>(<b>this</b>, <var>V</var>).</ol>

  <h4 id=windowproxy-isextensible><span class=secno>7.4.3</span> [[IsExtensible]] ( )<a href=#windowproxy-isextensible class=self-link></a></h4>

  <ol><li><p>Return true.</ol>

  <h4 id=windowproxy-preventextensions><span class=secno>7.4.4</span> [[PreventExtensions]] ( )<a href=#windowproxy-preventextensions class=self-link></a></h4>

  <ol><li><p>Return false.</ol>

  <h4 id=windowproxy-getownproperty><span class=secno>7.4.5</span> [[GetOwnProperty]] ( <var>P</var> )<a href=#windowproxy-getownproperty class=self-link></a></h4>

  <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>.<li>
    <p>If <var>P</var> is an <a id=windowproxy-getownproperty:array-index-property-name href=https://heycam.github.io/webidl/#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.github.io/ecma262/#sec-touint32 data-x-internal=touint32>ToUint32</a>(<var>P</var>).<li><p>Let <var>maxProperties</var> be the <a href=#number-of-document-tree-child-browsing-contexts id=windowproxy-getownproperty:number-of-document-tree-child-browsing-contexts>number of document-tree child browsing
     contexts</a> of <var>W</var>.<li><p>Let <var>value</var> be undefined.<li>
      <p>If <var>maxProperties</var> is greater than 0 and <var>index</var> is less than
      <var>maxProperties</var>, then:</p>

      <ol><li><p>Let <var>document</var> be <var>W</var>'s <a href=#concept-document-window id=windowproxy-getownproperty:concept-document-window>associated <code>Document</code></a>.<li><p>Set <var>value</var> to the <code id=windowproxy-getownproperty:windowproxy><a href=#windowproxy>WindowProxy</a></code> object of the <var>index</var>th
       <a href=#document-tree-child-browsing-context id=windowproxy-getownproperty:document-tree-child-browsing-context>document-tree child browsing context</a> of <var>document</var>'s <a href=#concept-document-bc id=windowproxy-getownproperty:concept-document-bc>browsing context</a>, sorted in the order
       that their <a href=#browsing-context-container id=windowproxy-getownproperty:browsing-context-container>browsing context container</a>
       elements were most recently inserted into <var>document</var>, the
       <code id=windowproxy-getownproperty:windowproxy-2><a href=#windowproxy>WindowProxy</a></code> object of the most recently inserted <a href=#browsing-context-container id=windowproxy-getownproperty:browsing-context-container-2>browsing context
       container</a>'s <a href=#nested-browsing-context id=windowproxy-getownproperty:nested-browsing-context>nested browsing context</a> being last.</ol>

     <li><p>If <var>value</var> is undefined, then return undefined.<li><p>Return <a id=windowproxy-getownproperty:propertydescriptor href=https://tc39.github.io/ecma262/#sec-property-descriptor-specification-type data-x-internal=propertydescriptor>PropertyDescriptor</a>{
     [[Value]]: <var>value</var>,
     [[Writable]]: false,
     [[Enumerable]]: true,
     [[Configurable]]: true }.</ol>
   <li>
    <p>If ! <a href=#isplatformobjectsameorigin-(-o-) id=windowproxy-getownproperty:isplatformobjectsameorigin-(-o-)>IsPlatformObjectSameOrigin</a>(<var>W</var>) is true, then return !
    <a id=windowproxy-getownproperty:ordinarygetownproperty href=https://tc39.github.io/ecma262/#sec-ordinarygetownproperty data-x-internal=ordinarygetownproperty>OrdinaryGetOwnProperty</a>(<var>W</var>, <var>P</var>).</p>

    <p class=note>This is a <a href=#willful-violation id=windowproxy-getownproperty:willful-violation>willful violation</a> of the JavaScript specification's
    <a id=windowproxy-getownproperty:invariants-of-the-essential-internal-methods href=https://tc39.github.io/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><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>).<li><p>If <var>property</var> is not undefined, then return <var>property</var>.<li>
    <p>If <var>property</var> is undefined and <var>P</var> is in <var>W</var>'s <a href=#document-tree-child-browsing-context-name-property-set id=windowproxy-getownproperty:document-tree-child-browsing-context-name-property-set>document-tree
    child browsing context name property set</a>, then:</p>

    <ol><li><p>Let <var>value</var> be the <code id=windowproxy-getownproperty:windowproxy-3><a href=#windowproxy>WindowProxy</a></code> object of the
     <a href=#dom-window-nameditem-filter id=windowproxy-getownproperty:dom-window-nameditem-filter>named object</a> with the name <var>P</var>.

     <li>
      <p>Return <a id=windowproxy-getownproperty:propertydescriptor-2 href=https://tc39.github.io/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>
     </ol>

   <li><p>Throw a <a id=windowproxy-getownproperty:securityerror href=https://heycam.github.io/webidl/#securityerror data-x-internal=securityerror>"<code>SecurityError</code>"</a> <code id=windowproxy-getownproperty:domexception><a data-x-internal=domexception href=https://heycam.github.io/webidl/#dfn-DOMException>DOMException</a></code>.</ol>

  <h4 id=windowproxy-defineownproperty><span class=secno>7.4.6</span> [[DefineOwnProperty]] ( <var>P</var>, <var>Desc</var>
  )<a href=#windowproxy-defineownproperty class=self-link></a></h4>

  <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>.<li>
    <p>If ! <a href=#isplatformobjectsameorigin-(-o-) id=windowproxy-defineownproperty:isplatformobjectsameorigin-(-o-)>IsPlatformObjectSameOrigin</a>(<var>W</var>) is true, then:

    <ol><li><p>If <var>P</var> is an <a id=windowproxy-defineownproperty:array-index-property-name href=https://heycam.github.io/webidl/#dfn-array-index-property-name data-x-internal=array-index-property-name>array index property name</a>, return false.<li>
      <p>Return ? <a id=windowproxy-defineownproperty:ordinarydefineownproperty href=https://tc39.github.io/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 href=#willful-violation id=windowproxy-defineownproperty:willful-violation>willful violation</a> of the JavaScript specification's
      <a id=windowproxy-defineownproperty:invariants-of-the-essential-internal-methods href=https://tc39.github.io/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>
     </ol>

   <li><p>Throw a <a id=windowproxy-defineownproperty:securityerror href=https://heycam.github.io/webidl/#securityerror data-x-internal=securityerror>"<code>SecurityError</code>"</a> <code id=windowproxy-defineownproperty:domexception><a data-x-internal=domexception href=https://heycam.github.io/webidl/#dfn-DOMException>DOMException</a></code>.</ol>

  <h4 id=windowproxy-get><span class=secno>7.4.7</span> [[Get]] ( <var>P</var>, <var>Receiver</var> )<a href=#windowproxy-get class=self-link></a></h4>

  <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>.<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.github.io/ecma262/#sec-ordinaryget data-x-internal=ordinaryget>OrdinaryGet</a>(<b>this</b>, <var>P</var>, <var>Receiver</var>).<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>).</ol>

  <h4 id=windowproxy-set><span class=secno>7.4.8</span> [[Set]] ( <var>P</var>, <var>V</var>, <var>Receiver</var> )<a href=#windowproxy-set class=self-link></a></h4>

  <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>.<li><p>If ! <a href=#isplatformobjectsameorigin-(-o-) id=windowproxy-set:isplatformobjectsameorigin-(-o-)>IsPlatformObjectSameOrigin</a>(<var>W</var>) is true, then return ?
   <a id=windowproxy-set:ordinaryset href=https://tc39.github.io/ecma262/#sec-ordinaryset data-x-internal=ordinaryset>OrdinarySet</a>(<var>W</var>, <b>this</b>, <var>Receiver</var>).<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>).</ol>

  <h4 id=windowproxy-delete><span class=secno>7.4.9</span> [[Delete]] ( <var>P</var> )<a href=#windowproxy-delete class=self-link></a></h4>

  <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>.<li>
    <p>If ! <a href=#isplatformobjectsameorigin-(-o-) id=windowproxy-delete:isplatformobjectsameorigin-(-o-)>IsPlatformObjectSameOrigin</a>(<var>W</var>) is true, then:

    <ol><li>
      <p>If <var>P</var> is an <a id=windowproxy-delete:array-index-property-name href=https://heycam.github.io/webidl/#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>).<li><p>If <var>desc</var> is undefined, then return true.<li><p>Return false.</ol>
     <li><p>Return ? <a id=windowproxy-delete:ordinarydelete href=https://tc39.github.io/ecma262/#sec-ordinarydelete data-x-internal=ordinarydelete>OrdinaryDelete</a>(<var>W</var>, <var>P</var>).</ol>

   <li><p>Throw a <a id=windowproxy-delete:securityerror href=https://heycam.github.io/webidl/#securityerror data-x-internal=securityerror>"<code>SecurityError</code>"</a> <code id=windowproxy-delete:domexception><a data-x-internal=domexception href=https://heycam.github.io/webidl/#dfn-DOMException>DOMException</a></code>.</ol>

  <h4 id=windowproxy-ownpropertykeys><span class=secno>7.4.10</span> [[OwnPropertyKeys]] ( )<a href=#windowproxy-ownpropertykeys class=self-link></a></h4>

  <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>.<li><p>Let <var>keys</var> be a new empty <a href=https://tc39.github.io/ecma262/#sec-list-and-record-specification-type id=windowproxy-ownpropertykeys:js-list data-x-internal=js-list>List</a>.<li><p>Let <var>maxProperties</var> be the <a href=#number-of-document-tree-child-browsing-contexts id=windowproxy-ownpropertykeys:number-of-document-tree-child-browsing-contexts>number of document-tree child browsing
   contexts</a> of <var>W</var>.<li><p>Let <var>index</var> be 0.<li>
    <p>Repeat while <var>index</var> &lt; <var>maxProperties</var>,

    <ol><li><p>Add ! <a id=windowproxy-ownpropertykeys:tostring href=https://tc39.github.io/ecma262/#sec-tostring data-x-internal=tostring>ToString</a>(<var>index</var>) as the last element of
     <var>keys</var>.<li><p>Increment <var>index</var> by 1.</ol>
   <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.github.io/ecma262/#sec-ordinaryownpropertykeys data-x-internal=ordinaryownpropertykeys>OrdinaryOwnPropertyKeys</a>(<var>W</var>).<li><p>Return the concatenation of <var>keys</var> and !
   <a href=#crossoriginownpropertykeys-(-o-) id=windowproxy-ownpropertykeys:crossoriginownpropertykeys-(-o-)>CrossOriginOwnPropertyKeys</a>(<var>W</var>).</ol>

  



  <h3 id=origin><span class=secno>7.5</span> Origin<a href=#origin class=self-link></a></h3>
  

  <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://heycam.github.io/webidl/#securityerror data-x-internal=securityerror>"<code>SecurityError</code>"</a>
  <code id=origin:domexception><a data-x-internal=domexception href=https://heycam.github.io/webidl/#dfn-DOMException>DOMException</a></code> will be raised.</p>

  <hr>

  <p id=origin-2>An <dfn data-export="" id=concept-origin>origin</dfn> is
  one of the following:</p>

  <dl><dt>An <dfn id=concept-origin-opaque data-export="">opaque origin</dfn><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.<dt>A <dfn id=concept-origin-tuple data-export="">tuple origin</dfn><dd>
    <p>A <a href=#concept-origin-tuple id=origin:concept-origin-tuple>tuple</a> consists of:

    <ul class=brief><li>A <dfn data-dfn-for=origin id=concept-origin-scheme data-export="">scheme</dfn> (a
     <a href=https://url.spec.whatwg.org/#concept-url-scheme id=origin:concept-url-scheme data-x-internal=concept-url-scheme>scheme</a>).<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>A <dfn data-dfn-for=origin id=concept-origin-port data-export="">port</dfn> (a
     <a href=https://url.spec.whatwg.org/#concept-url-port id=origin:concept-url-port data-x-internal=concept-url-port>port</a>).<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.</ul>
   </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-2>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>

  <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.<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>.<li><p>Return <var>origin</var>'s <a href=#concept-origin-host id=origin:concept-origin-host>host</a>.</ol>

  

  <p>Various specification objects are defined to have an <a href=#concept-origin id=origin:concept-origin-4>origin</a>. These <a href=#concept-origin id=origin:concept-origin-5>origins</a> are determined as follows:</p>

  <dl><dt>For <code id=origin:document-2><a href=#document>Document</a></code> objects<dd>

    <dl class=switch><dt id=sandboxOrigin>If the <code id=origin:document-3><a href=#document>Document</a></code>'s <a href=#active-sandboxing-flag-set id=origin:active-sandboxing-flag-set>active sandboxing flag set</a>
     has its <a href=#sandboxed-origin-browsing-context-flag id=origin:sandboxed-origin-browsing-context-flag>sandboxed origin browsing context flag</a> set<dt>If the <code id=origin:document-4><a href=#document>Document</a></code> was generated from a <a href=https://tools.ietf.org/html/rfc2397#section-2 id=origin:data-protocol data-x-internal=data-protocol><code>data:</code> URL</a><dd><p>A unique <a href=#concept-origin-opaque id=origin:concept-origin-opaque-2>opaque origin</a> assigned when the
     <code id=origin:document-5><a href=#document>Document</a></code> is created.<dt>If the <code id=origin:document-6><a href=#document>Document</a></code>'s <a href=https://dom.spec.whatwg.org/#concept-document-url id="origin: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=origin:concept-url-scheme-2 data-x-internal=concept-url-scheme>scheme</a> is a <a id=origin:network-scheme href=https://fetch.spec.whatwg.org/#network-scheme data-x-internal=network-scheme>network scheme</a><dd>
      <p>A copy of the <code id=origin:document-7><a href=#document>Document</a></code>'s <a href=https://dom.spec.whatwg.org/#concept-document-url id="origin:the-document's-address-2" data-x-internal="the-document's-address">URL</a>'s
      <a href=https://url.spec.whatwg.org/#concept-url-origin id=origin:concept-url-origin data-x-internal=concept-url-origin>origin</a> assigned when the <code id=origin:document-8><a href=#document>Document</a></code> is
      created.</p>

      <p class=note>The <code id=origin:dom-document-open><a href=#dom-document-open>document.open()</a></code> method can change
      the <code id=origin:document-9><a href=#document>Document</a></code>'s <a href=https://dom.spec.whatwg.org/#concept-document-url id="origin:the-document's-address-3" data-x-internal="the-document's-address">URL</a> to
      "<code id=origin:about:blank><a href=#about:blank>about:blank</a></code>". Therefore the <a href=#concept-origin id=origin:concept-origin-6>origin</a> is assigned when the
      <code id=origin:document-10><a href=#document>Document</a></code> is created.</p>
     <dt>If the <code id=origin:document-11><a href=#document>Document</a></code> is the initial "<code id=origin:about:blank-2><a href=#about:blank>about:blank</a></code>" document<dd><p><a href=#about-blank-origin>The one it was assigned when its browsing context was
     created</a>.<dt>If the <code id=origin:document-12><a href=#document>Document</a></code> is a non-initial "<code id=origin:about:blank-3><a href=#about:blank>about:blank</a></code>" document<dd><p>The <a href=#concept-settings-object-origin id=origin:concept-settings-object-origin>origin</a> of the <a href=#incumbent-settings-object id=origin:incumbent-settings-object>incumbent
     settings object</a> when the <a href=#navigate id=origin:navigate>navigate</a> algorithm was invoked, or, if no <a href=#concept-script id=origin:concept-script>script</a> was involved, the <a href=#concept-origin id=origin:concept-origin-7>origin</a> of the <a id=origin:node-document href=https://dom.spec.whatwg.org/#concept-node-document data-x-internal=node-document>node
     document</a> of the element that initiated the <a href=#navigate id=origin:navigate-2>navigation</a> to
     that <a id=origin:url href=https://url.spec.whatwg.org/#concept-url data-x-internal=url>URL</a>.<dt>If the <code id=origin:document-13><a href=#document>Document</a></code> was created as part of the processing for <a href=#javascript-protocol id=origin:javascript-protocol><code>javascript:</code> URLs</a><dd><p>The <a href=#concept-origin id=origin:concept-origin-8>origin</a> of the <a href=#active-document id=origin:active-document>active document</a> of the <a href=#browsing-context id=origin:browsing-context>browsing
     context</a> being navigated when the <a href=#navigate id=origin:navigate-3>navigate</a> algorithm was invoked.<dt>If the <code id=origin:document-14><a href=#document>Document</a></code> is <a href=#an-iframe-srcdoc-document id=origin:an-iframe-srcdoc-document>an <code>iframe</code> <code>srcdoc</code> document</a><dd><p>The <a href=#concept-origin id=origin:concept-origin-9>origin</a> of the <code id=origin:document-15><a href=#document>Document</a></code>'s <a href=#concept-document-bc id=origin:concept-document-bc>browsing context</a>'s <a href=#browsing-context-container id=origin:browsing-context-container>browsing context
     container</a>'s <a id=origin:node-document-2 href=https://dom.spec.whatwg.org/#concept-node-document data-x-internal=node-document>node document</a>.<dt>If the <code id=origin:document-16><a href=#document>Document</a></code> was obtained in some other manner (e.g. a <code id=origin:document-17><a href=#document>Document</a></code>
     created using the <code id=origin:dom-domimplementation-createdocument><a data-x-internal=dom-domimplementation-createdocument href=https://dom.spec.whatwg.org/#dom-domimplementation-createdocument>createDocument()</a></code>
     API, etc)<dd>
      <p>The default behavior as defined in the WHATWG DOM standard applies. <a href=#refsDOM>[DOM]</a>.</p>

      <p class=note>The <a href=#concept-origin id=origin:concept-origin-10>origin</a> is a unique <a href=#concept-origin-opaque id=origin:concept-origin-opaque-3>opaque origin</a> assigned when the <code id=origin:document-18><a href=#document>Document</a></code> is
      created.</p>
     </dl>

   <dt>For images of <code id=origin:the-img-element><a href=#the-img-element>img</a></code> elements<dd>

    <dl class=switch><dt>If the <a href=#img-req-data id=origin:img-req-data>image data</a> is <a href=#cors-cross-origin id=origin:cors-cross-origin>CORS-cross-origin</a><dd><p>A unique <a href=#concept-origin-opaque id=origin:concept-origin-opaque-4>opaque origin</a> assigned when the
     image is created.<dt>If the <a href=#img-req-data id=origin:img-req-data-2>image data</a> is <a href=#cors-same-origin id=origin:cors-same-origin>CORS-same-origin</a><dd><p>The <code id=origin:the-img-element-2><a href=#the-img-element>img</a></code> element's <a id=origin:node-document-3 href=https://dom.spec.whatwg.org/#concept-node-document data-x-internal=node-document>node document</a>'s
     <a href=#concept-origin id=origin:concept-origin-11>origin</a>.</dl>

   <dt>For <code id=origin:the-audio-element><a href=#the-audio-element>audio</a></code> and <code id=origin:the-video-element><a href=#the-video-element>video</a></code> elements<dd>

    <dl class=switch><dt>If the <a href=#media-data id=origin:media-data>media data</a> is <a href=#cors-cross-origin id=origin:cors-cross-origin-2>CORS-cross-origin</a><dd><p>A unique <a href=#concept-origin-opaque id=origin:concept-origin-opaque-5>opaque origin</a> assigned when the
     <a href=#media-data id=origin:media-data-2>media data</a> is fetched.<dt>If the <a href=#media-data id=origin:media-data-3>media data</a> is <a href=#cors-same-origin id=origin:cors-same-origin-2>CORS-same-origin</a><dd><p>The <a href=#media-element id=origin:media-element>media element</a>'s <a id=origin:node-document-4 href=https://dom.spec.whatwg.org/#concept-node-document data-x-internal=node-document>node document</a>'s
     <a href=#concept-origin id=origin:concept-origin-12>origin</a>.</dl>

   </dl>

  <p>Other specifications can override the above definitions by themselves specifying the origin of
  a particular <code id=origin:document-19><a href=#document>Document</a></code> object, image, or <a href=#media-element id=origin:media-element-2>media element</a>.</p>

  <hr>

  <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-13>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-6>opaque origin</a>, then
   return "<code>null</code>".<li><p>Otherwise, let <var>result</var> be <var>origin</var>'s <a href=#concept-origin-scheme id=origin:concept-origin-scheme>scheme</a>.<li><p>Append "<code>://</code>" to <var>result</var>.<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>.<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>.<li><p>Return <var>result</var>.</ol>

  <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>There used to also be a
  <i>Unicode serialization of an origin</i>. However, it was never widely adopted.</p>

  <hr>

  <p>Two <a href=#concept-origin id=origin:concept-origin-14>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-7>opaque
   origin</a>, then return true.<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> 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.<li><p>Return false.</ol>

  <p>Two <a href=#concept-origin id=origin:concept-origin-15>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-8>opaque
   origin</a>, then return true.<li>
    <p>If <var>A</var> and <var>B</var> are both <a href=#concept-origin-tuple id=origin:concept-origin-tuple-4>tuple
    origins</a>, run these substeps:</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.<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 identical and null, then return
     true.</ol>

   <li><p>Return false.</ol>

  <div class=example>
   <table><tr><th><var>A</var>
     <th><var>B</var>
     <th><a href=#same-origin id=origin:same-origin-2>same origin</a>
     <th><a href=#same-origin-domain id=origin:same-origin-domain>same origin-domain</a>
    <tr><td>("<code>https</code>", "<code>example.org</code>", null, null)
     <td>("<code>https</code>", "<code>example.org</code>", null, null)
     <td>✅
     <td>✅
    <tr><td>("<code>https</code>", "<code>example.org</code>", 314, null)
     <td>("<code>https</code>", "<code>example.org</code>", 420, null)
     <td>❌
     <td>❌
    <tr><td>("<code>https</code>", "<code>example.org</code>", 314, "<code>example.org</code>")
     <td>("<code>https</code>", "<code>example.org</code>", 420, "<code>example.org</code>")
     <td>❌
     <td>✅
    <tr><td>("<code>https</code>", "<code>example.org</code>", null, null)
     <td>("<code>https</code>", "<code>example.org</code>", null, "<code>example.org</code>")
     <td>✅
     <td>❌
    <tr><td>("<code>https</code>", "<code>example.org</code>", null, "<code>example.org</code>")
     <td>("<code>http</code>", "<code>example.org</code>", null, "<code>example.org</code>")
     <td>❌
     <td>❌
   </table>
  </div>

  


  <h4 id=relaxing-the-same-origin-restriction><span class=secno>7.5.1</span> Relaxing the same-origin restriction<a href=#relaxing-the-same-origin-restriction class=self-link></a></h4>

  <dl class=domintro><dt><var>document</var> . <code id=dom-document-domain-dev><a href=#dom-document-domain>domain</a></code> [ = <var>domain</var> ]<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. (Can't be set in sandboxed
    <code id=relaxing-the-same-origin-restriction:the-iframe-element><a href=#the-iframe-element>iframe</a></code>s.)</p>

   </dl>

  

  <p>To determine if a string <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>, run these steps:</p>
  

  <ol><li><p>If <var>hostSuffixString</var> is the empty string, then return false.<li><p>Let <var>host</var> be 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>
   <var>hostSuffixString</var>.<li><p>If <var>host</var> is failure, then return false.<li>
    <p>If <var>host</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>host</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 an <a id=relaxing-the-same-origin-restriction:ipv4-address href=https://url.spec.whatwg.org/#concept-ipv4 data-x-internal=ipv4-address>IPv4
      address</a> or an <a id=relaxing-the-same-origin-restriction:ipv6-address href=https://url.spec.whatwg.org/#concept-ipv6 data-x-internal=ipv6-address>IPv6 address</a>.</p>
     <li><p>If <var>host</var>, prefixed by a U+002E FULL STOP (.), does not exactly match the end
     of <var>originalHost</var>, then return false.<li><p>If <var>host</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>host</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>, then return false. <a href=#refsURL>[URL]</a></ol>
   <li><p>Return true.</ol>

  <p>The <dfn id=dom-document-domain><code>domain</code></dfn> attribute's getter must run
  these steps:</p>

  <ol><li><p>Let <var>effectiveDomain</var> be this <code id=relaxing-the-same-origin-restriction:document><a href=#document>Document</a></code> object's
   <a href=#concept-origin id=relaxing-the-same-origin-restriction:concept-origin-2>origin</a>'s <a href=#concept-origin-effective-domain id=relaxing-the-same-origin-restriction:concept-origin-effective-domain>effective domain</a>.

   <li><p>If <var>effectiveDomain</var> is null, then return the empty string.<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>.</ol>

  <p>The <code id=relaxing-the-same-origin-restriction:dom-document-domain><a href=#dom-document-domain>domain</a></code> attribute's setter must run these
  steps:</p>

  <ol><li><p>If this <code id=relaxing-the-same-origin-restriction:document-2><a href=#document>Document</a></code> object has no <a href=#concept-document-bc id=relaxing-the-same-origin-restriction:concept-document-bc>browsing
   context</a>, then throw a <a id=relaxing-the-same-origin-restriction:securityerror href=https://heycam.github.io/webidl/#securityerror data-x-internal=securityerror>"<code>SecurityError</code>"</a>
   <code id=relaxing-the-same-origin-restriction:domexception><a data-x-internal=domexception href=https://heycam.github.io/webidl/#dfn-DOMException>DOMException</a></code>.<li><p>If this <code id=relaxing-the-same-origin-restriction:document-3><a href=#document>Document</a></code> object'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-2 href=https://heycam.github.io/webidl/#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://heycam.github.io/webidl/#dfn-DOMException>DOMException</a></code>.<li><p>Let <var>effectiveDomain</var> be this <code id=relaxing-the-same-origin-restriction:document-4><a href=#document>Document</a></code> object's
   <a href=#concept-origin id=relaxing-the-same-origin-restriction:concept-origin-3>origin</a>'s <a href=#concept-origin-effective-domain id=relaxing-the-same-origin-restriction:concept-origin-effective-domain-2>effective domain</a>.

   <li><p>If <var>effectiveDomain</var> is null, then throw a
   <a id=relaxing-the-same-origin-restriction:securityerror-3 href=https://heycam.github.io/webidl/#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://heycam.github.io/webidl/#dfn-DOMException>DOMException</a></code>.<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-4 href=https://heycam.github.io/webidl/#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://heycam.github.io/webidl/#dfn-DOMException>DOMException</a></code>.<li><p>Set this <code id=relaxing-the-same-origin-restriction:document-5><a href=#document>Document</a></code> object's <a href=#concept-origin id=relaxing-the-same-origin-restriction:concept-origin-4>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-2 data-x-internal=host-parser>parsing</a> the given value.</ol>

  

  <p class=note>The <code id=relaxing-the-same-origin-restriction:dom-document-domain-2><a href=#dom-document-domain>document.domain</a></code> attribute is used to
  enable pages on different hosts of a domain to access each other's DOMs.</p>

  <p class=warning>Do not use the <code id=relaxing-the-same-origin-restriction:dom-document-domain-3><a href=#dom-document-domain>document.domain</a></code>
  attribute when using shared hosting. 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-4><a href=#dom-document-domain>document.domain</a></code> attribute has been
  used.</p>




  <h3 id=sandboxing><span class=secno>7.6</span> Sandboxing<a href=#sandboxing class=self-link></a></h3>

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

   <dt>The <dfn id=sandboxed-auxiliary-navigation-browsing-context-flag data-export="">sandboxed auxiliary navigation browsing context flag</dfn><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>

   <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><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 from algorithms that are
    <em>not</em> <a href=#triggered-by-user-activation id=sandboxing:triggered-by-user-activation>triggered by user 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>

   <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><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 from algorithms that
    <em>are</em> <a href=#triggered-by-user-activation id=sandboxing:triggered-by-user-activation-2>triggered by user 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>

   <dt>The <dfn id=sandboxed-plugins-browsing-context-flag data-export="">sandboxed plugins browsing context flag</dfn><dd>

    <p>This flag prevents content from instantiating <a href=#plugin id=sandboxing:plugin>plugins</a>, whether
    using <a href=#sandboxPluginEmbed>the <code>embed</code> element</a>, <a href=#sandboxPluginObject>the <code>object</code> element</a>, or through <a href=#sandboxPluginNavigate>navigation</a> of a <a href=#nested-browsing-context id=sandboxing:nested-browsing-context>nested browsing context</a>, unless
    those <a href=#plugin id=sandboxing:plugin-2>plugins</a> can be <a href=#concept-plugin-secure id=sandboxing:concept-plugin-secure>secured</a>.</p>

   <dt>The <dfn id=sandboxed-origin-browsing-context-flag data-export="">sandboxed origin browsing context flag</dfn><dd>

    <p>This flag <a href=#sandboxOrigin>forces content into a unique 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>

   <dt>The <dfn id=sandboxed-forms-browsing-context-flag data-export="">sandboxed forms browsing context flag</dfn><dd>

    <p>This flag <a href=#sandboxSubmitBlocked>blocks form submission</a>.</p>

   <dt>The <dfn id=sandboxed-pointer-lock-browsing-context-flag data-export="">sandboxed pointer lock browsing context flag</dfn><dd>

    <p>This flag disables the Pointer Lock API. <a href=#refsPOINTERLOCK>[POINTERLOCK]</a></p>

   <dt>The <dfn id=sandboxed-scripts-browsing-context-flag data-export="">sandboxed scripts browsing context flag</dfn><dd>

    <p>This flag <a href=#sandboxScriptBlocked>blocks script execution</a>.</p>

   <dt>The <dfn id=sandboxed-automatic-features-browsing-context-flag data-export="">sandboxed automatic features browsing context flag</dfn><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>

   <dt>The <dfn id=sandboxed-storage-area-urls-flag data-export="">sandboxed storage area URLs flag</dfn><dd>

    <p>This flag prevents URL schemes that use storage areas from being able to access the origin's
    data.</p>

   <dt>The <dfn id=sandboxed-document.domain-browsing-context-flag data-export="">sandboxed <code>document.domain</code>
   browsing context flag</dfn><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>

   <dt>The <dfn id=sandbox-propagates-to-auxiliary-browsing-contexts-flag data-export="">sandbox propagates to auxiliary browsing contexts flag</dfn><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>

   <dt>The <dfn id=sandboxed-modals-flag data-export="">sandboxed modals flag</dfn><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><code id=sandboxing:dom-confirm><a href=#dom-confirm>window.confirm()</a></code><li><code id=sandboxing:dom-print><a href=#dom-print>window.print()</a></code><li><code id=sandboxing:dom-prompt><a href=#dom-prompt>window.prompt()</a></code><li>the <code id=sandboxing:event-beforeunload><a href=#event-beforeunload>beforeunload</a></code> event</ul>

   <dt>The <dfn id=sandboxed-orientation-lock-browsing-context-flag data-export="">sandboxed orientation lock browsing context flag</dfn><dd>

    <p>This flag disables the ability to lock the screen orientation. <a href=#refsSCREENORIENTATION>[SCREENORIENTATION]</a></p>

   <dt>The <dfn id=sandboxed-presentation-browsing-context-flag data-export="">sandboxed presentation browsing context flag</dfn><dd>

    <p>This flag disables the Presentation API. <a href=#refsPRESENTATION>[PRESENTATION]</a></p>

   </dl>

  <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>, 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>.<li><p>Let <var>output</var> be empty.<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>.<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 id=attr-iframe-sandbox-allow-popups><code>allow-popups</code></dfn> keyword.<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 id=attr-iframe-sandbox-allow-top-navigation><code>allow-top-navigation</code></dfn> keyword.<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 id=attr-iframe-sandbox-allow-top-navigation-by-user-activation><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><p>The <a href=#sandboxed-plugins-browsing-context-flag id=sandboxing:sandboxed-plugins-browsing-context-flag>sandboxed plugins browsing context flag</a>.<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 id=attr-iframe-sandbox-allow-same-origin><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 pop-up windows, etc, without preventing the embedded page from
       communicating back to its originating site, using the database APIs to store data, etc.</p>

      </div>

     <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 id=attr-iframe-sandbox-allow-forms><code>allow-forms</code></dfn> keyword.<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 id=attr-iframe-sandbox-allow-pointer-lock><code>allow-pointer-lock</code></dfn>
     keyword.<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 id=attr-iframe-sandbox-allow-scripts><code>allow-scripts</code></dfn> keyword.<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><p>The <a href=#sandboxed-storage-area-urls-flag id=sandboxing:sandboxed-storage-area-urls-flag>sandboxed storage area URLs flag</a>.<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>.<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 id=attr-iframe-sandbox-allow-popups-to-escape-sandbox><code>allow-popups-to-escape-sandbox</code></dfn>
     keyword.<li><p>The <a href=#sandboxed-modals-flag id=sandboxing:sandboxed-modals-flag>sandboxed modals flag</a>, unless <var>tokens</var> contains the <dfn id=attr-iframe-sandbox-allow-modals><code>allow-modals</code></dfn> keyword.<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 id=attr-iframe-sandbox-allow-orientation-lock><code>allow-orientation-lock</code></dfn>
     keyword.<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 id=attr-iframe-sandbox-allow-presentation><code>allow-presentation</code></dfn>
     keyword.</ul>

   </ol>

  <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-browsing-context-given-a-browsing-context-name id=sandboxing:the-rules-for-choosing-a-browsing-context-given-a-browsing-context-name>the rules for
  choosing a browsing context</a>.</p>

  <p>Every <a href=#browsing-context id=sandboxing:browsing-context-6>browsing context</a> that is a <a href=#nested-browsing-context id=sandboxing:nested-browsing-context-2>nested browsing context</a> 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 a <a href=#nested-browsing-context id=sandboxing:nested-browsing-context-3>nested browsing context</a>'s <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><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 id=active-sandboxing-flag-set>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>

  <p>Every resource that is obtained by the <a href=#navigate id=sandboxing:navigate-2>navigation algorithm</a> has
  a <dfn id=forced-sandboxing-flag-set data-export="">forced sandboxing flag set</dfn>, which is a <a href=#sandboxing-flag-set id=sandboxing:sandboxing-flag-set-5>sandboxing flag
  set</a>. A resource by default has no flags set in its <a href=#forced-sandboxing-flag-set id=sandboxing:forced-sandboxing-flag-set>forced sandboxing flag set</a>,
  but other specifications can define that certain flags are set.</p>

  <p class=note>In particular, the <a href=#forced-sandboxing-flag-set id=sandboxing:forced-sandboxing-flag-set-2>forced sandboxing flag set</a> is used by
  <cite>Content Security Policy</cite>. <a href=#refsCSP>[CSP]</a></p>

  <hr>

  <p>To <dfn id=implement-the-sandboxing>implement the sandboxing</dfn> for a <code id=sandboxing:document-3><a href=#document>Document</a></code> object <var>document</var>,
  populate <var>document</var>'s <a href=#active-sandboxing-flag-set id=sandboxing:active-sandboxing-flag-set-3>active sandboxing flag set</a> with the union of the flags
  that are present in the following <a href=#sandboxing-flag-set id=sandboxing:sandboxing-flag-set-6>sandboxing flag
  sets</a>:</p>

  <ul><li><p>If <var>document</var>'s <a href=#concept-document-bc id=sandboxing:concept-document-bc>browsing context</a> is a
   <a href=#top-level-browsing-context id=sandboxing:top-level-browsing-context-6>top-level browsing context</a>, then: the flags set on the <a href=#browsing-context id=sandboxing:browsing-context-7>browsing
   context</a>'s <a href=#popup-sandboxing-flag-set id=sandboxing:popup-sandboxing-flag-set-2>popup sandboxing flag set</a>.<li><p>If <var>document</var>'s <a href=#concept-document-bc id=sandboxing:concept-document-bc-2>browsing context</a> is a
   <a href=#nested-browsing-context id=sandboxing:nested-browsing-context-4>nested browsing context</a>, then: the flags set on the <a href=#browsing-context id=sandboxing:browsing-context-8>browsing context</a>'s
   <a href=#iframe-sandboxing-flag-set id=sandboxing:iframe-sandboxing-flag-set-2><code>iframe</code> sandboxing flag set</a>.<li><p>If <var>document</var>'s <a href=#concept-document-bc id=sandboxing:concept-document-bc-3>browsing context</a> is a
   <a href=#nested-browsing-context id=sandboxing:nested-browsing-context-5>nested browsing context</a>, then: the flags set on the <a href=#browsing-context id=sandboxing:browsing-context-9>browsing context</a>'s
   <a href=#parent-browsing-context id=sandboxing:parent-browsing-context>parent browsing context</a>'s <a href=#active-document id=sandboxing:active-document>active document</a>'s <a href=#active-sandboxing-flag-set id=sandboxing:active-sandboxing-flag-set-4>active sandboxing
   flag set</a>.<li><p>The flags set on <var>document</var>'s resource's <a href=#forced-sandboxing-flag-set id=sandboxing:forced-sandboxing-flag-set-3>forced sandboxing flag set</a>,
   if it has one.</ul>



  <h3 id=history><span class=secno>7.7</span> Session history and navigation<a href=#history class=self-link></a></h3>

  <h4 id=the-session-history-of-browsing-contexts><span class=secno>7.7.1</span> The session history of browsing contexts<a href=#the-session-history-of-browsing-contexts class=self-link></a></h4>

  <p>The sequence of <code id=the-session-history-of-browsing-contexts:document><a href=#document>Document</a></code>s in a <a href=#browsing-context id=the-session-history-of-browsing-contexts:browsing-context>browsing context</a> is its <dfn id=session-history>session
  history</dfn>. Each <a href=#browsing-context id=the-session-history-of-browsing-contexts:browsing-context-2>browsing context</a>, including <a href=#nested-browsing-context id=the-session-history-of-browsing-contexts:nested-browsing-context>nested browsing contexts</a>, has a distinct session history. A <a href=#browsing-context id=the-session-history-of-browsing-contexts:browsing-context-3>browsing
  context</a>'s session history consists of a flat list of <a href=#session-history-entry id=the-session-history-of-browsing-contexts:session-history-entry>session history entries</a>. Each <dfn id=session-history-entry>session history entry</dfn> consists, at a
  minimum, of a <a id=the-session-history-of-browsing-contexts:url href=https://url.spec.whatwg.org/#concept-url data-x-internal=url>URL</a>, and each entry may in addition have <a href=#serialized-state id=the-session-history-of-browsing-contexts:serialized-state>serialized state</a>,
  a title, a <code id=the-session-history-of-browsing-contexts:document-2><a href=#document>Document</a></code> object, form data, a <a href=#scroll-restoration-mode id=the-session-history-of-browsing-contexts:scroll-restoration-mode>scroll restoration mode</a>, a
  scroll position, a <a href=#browsing-context-name id=the-session-history-of-browsing-contexts:browsing-context-name>browsing context name</a>, and other information associated with
  it.</p>

  <p class=note>Each entry, when first created, has a <code id=the-session-history-of-browsing-contexts:document-3><a href=#document>Document</a></code>. However, when a
  <code id=the-session-history-of-browsing-contexts:document-4><a href=#document>Document</a></code> is not <a href=#fully-active id=the-session-history-of-browsing-contexts:fully-active>active</a>, it's possible for it to be
  <a href=#discard-a-document id=the-session-history-of-browsing-contexts:discard-a-document>discarded</a> to free resources. The <a id=the-session-history-of-browsing-contexts:url-2 href=https://url.spec.whatwg.org/#concept-url data-x-internal=url>URL</a> and
  other data in a <a href=#session-history-entry id=the-session-history-of-browsing-contexts:session-history-entry-2>session history entry</a> is then used to bring a new
  <code id=the-session-history-of-browsing-contexts:document-5><a href=#document>Document</a></code> into being to take the place of the original, in case the user agent finds
  itself having to reactivate that <code id=the-session-history-of-browsing-contexts:document-6><a href=#document>Document</a></code>.</p>

  <p class=note>Titles associated with <a href=#session-history-entry id=the-session-history-of-browsing-contexts:session-history-entry-3>session history
  entries</a> need not have any relation with the current <code id=the-session-history-of-browsing-contexts:the-title-element><a href=#the-title-element>title</a></code> of the
  <code id=the-session-history-of-browsing-contexts:document-7><a href=#document>Document</a></code>. The title of a <a href=#session-history-entry id=the-session-history-of-browsing-contexts:session-history-entry-4>session history entry</a> is intended to explain
  the state of the document at that point, so that the user can navigate the document's history.</p>

  <p>URLs without associated <a href=#serialized-state id=the-session-history-of-browsing-contexts:serialized-state-2>serialized state</a> are added to the session history as the
  user (or script) navigates from page to page.</p>

  <hr>

  <p>Each <code id=the-session-history-of-browsing-contexts:document-8><a href=#document>Document</a></code> object in a <a href=#browsing-context id=the-session-history-of-browsing-contexts:browsing-context-4>browsing context</a>'s <a href=#session-history id=the-session-history-of-browsing-contexts:session-history>session
  history</a> is associated with a unique <code id=the-session-history-of-browsing-contexts:history-3><a href=#history-3>History</a></code> object which must all model the
  same underlying <a href=#session-history id=the-session-history-of-browsing-contexts:session-history-2>session history</a>.</p>

  

  <p>The <dfn id=dom-history><code>history</code></dfn> attribute of the <code id=the-session-history-of-browsing-contexts:window><a href=#window>Window</a></code>
  interface must return the object implementing the <code id=the-session-history-of-browsing-contexts:history-3-2><a href=#history-3>History</a></code> interface for this
  <code id=the-session-history-of-browsing-contexts:window-2><a href=#window>Window</a></code> object's <a href=#concept-document-window id=the-session-history-of-browsing-contexts:concept-document-window>associated
  <code>Document</code></a>.</p>

  

  <hr>

  <p id=state-object><dfn id=serialized-state>Serialized state</dfn> is a serialization (via
  <a href=#structuredserializeforstorage id=the-session-history-of-browsing-contexts:structuredserializeforstorage>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=the-session-history-of-browsing-contexts:structureddeserialize>StructuredDeserialize</a>) serialized state.</p>

  <p>Pages can <a href=#dom-history-pushstate id=the-session-history-of-browsing-contexts:dom-history-pushstate>add</a> <a href=#serialized-state id=the-session-history-of-browsing-contexts:serialized-state-3>serialized state</a> to the
  session history. These are then <a href=#structureddeserialize id=the-session-history-of-browsing-contexts:structureddeserialize-2>deserialized</a> and <a href=#event-popstate id=the-session-history-of-browsing-contexts: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=the-session-history-of-browsing-contexts: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=the-session-history-of-browsing-contexts:url-3 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=the-session-history-of-browsing-contexts:url-4 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=the-session-history-of-browsing-contexts:document-9><a href=#document>Document</a></code> instance and it would have to be reconstructed if a new
   <code id=the-session-history-of-browsing-contexts:document-10><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 pop-up <code id=the-session-history-of-browsing-contexts: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=the-session-history-of-browsing-contexts:url-5 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>At any point, one of the entries in the session history is the <dfn id=current-entry>current entry</dfn>. This
  is the entry representing the <a href=#active-document id=the-session-history-of-browsing-contexts:active-document>active document</a> of the <a href=#browsing-context id=the-session-history-of-browsing-contexts:browsing-context-5>browsing context</a>.
  Which entry is the <a href=#current-entry id=the-session-history-of-browsing-contexts:current-entry>current entry</a> is changed by the algorithms defined in this
  specification, e.g. during <a href=#traverse-the-history id=the-session-history-of-browsing-contexts:traverse-the-history>session history
  traversal</a>.</p>

  <p class=note>The <a href=#current-entry id=the-session-history-of-browsing-contexts:current-entry-2>current entry</a> is usually an entry for the <a href=https://dom.spec.whatwg.org/#concept-document-url id="the-session-history-of-browsing-contexts:the-document's-address" data-x-internal="the-document's-address">URL</a> of the <code id=the-session-history-of-browsing-contexts:document-11><a href=#document>Document</a></code>. However, it can also be one
  of the entries for <a href=#serialized-state id=the-session-history-of-browsing-contexts:serialized-state-5>serialized state</a> added to the history by that document.</p>

  <p><dfn id=an-entry-with-persisted-user-state>An entry with persisted user state</dfn> is one that also has user-agent defined state.
  This specification does not specify what kind of state can be stored.</p>

  <p class=example>For example, some user agents might want to persist the scroll position, or 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=the-session-history-of-browsing-contexts:the-dir-attribute><a href=#the-dir-attribute>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>

  <p>An entry's <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 it. The scroll restoration
  mode may be one of the following:</p>

  <dl><dt>"<dfn id=dom-scrollrestoration-auto><code>auto</code></dfn>"<dd>The user agent is responsible for restoring the scroll position upon navigation.<dt>"<dfn id=dom-scrollrestoration-manual><code>manual</code></dfn>"<dd>The page is responsible for restoring the scroll position and the user agent does not
   attempt to do so automatically</dl>

  <p>If unspecified, the <a href=#scroll-restoration-mode id=the-session-history-of-browsing-contexts:scroll-restoration-mode-2>scroll restoration mode</a> of a new entry must be set to
  "<code id=the-session-history-of-browsing-contexts:dom-scrollrestoration-auto><a href=#dom-scrollrestoration-auto>auto</a></code>".</p>

  <p>Entries that contain <a href=#serialized-state id=the-session-history-of-browsing-contexts:serialized-state-6>serialized state</a> share the same <code id=the-session-history-of-browsing-contexts:document-12><a href=#document>Document</a></code> as the
  entry for the page that was active when they were added.</p>

  <p>Contiguous entries that differ just by their <a href=https://url.spec.whatwg.org/#concept-url id=the-session-history-of-browsing-contexts:url-6 data-x-internal=url>URLs</a>' <a href=https://url.spec.whatwg.org/#concept-url-fragment id=the-session-history-of-browsing-contexts:concept-url-fragment data-x-internal=concept-url-fragment>fragments</a> also share the same <code id=the-session-history-of-browsing-contexts:document-13><a href=#document>Document</a></code>.</p>

  <p class=note>All entries that share the same <code id=the-session-history-of-browsing-contexts:document-14><a href=#document>Document</a></code> (and that are therefore
  merely different states of one particular document) are contiguous by definition.</p>

  <p>Each <code id=the-session-history-of-browsing-contexts:document-15><a href=#document>Document</a></code> in a <a href=#browsing-context id=the-session-history-of-browsing-contexts:browsing-context-6>browsing context</a> can also have a <dfn id=latest-entry>latest
  entry</dfn>. This is the entry for that <code id=the-session-history-of-browsing-contexts:document-16><a href=#document>Document</a></code> to which the <a href=#browsing-context id=the-session-history-of-browsing-contexts:browsing-context-7>browsing
  context</a>'s <a href=#session-history id=the-session-history-of-browsing-contexts:session-history-3>session history</a> was most recently traversed. When a
  <code id=the-session-history-of-browsing-contexts:document-17><a href=#document>Document</a></code> is created, it initially has no <a href=#latest-entry id=the-session-history-of-browsing-contexts:latest-entry>latest entry</a>.</p>

  

  <p>User agents may <a href=#discard-a-document id=the-session-history-of-browsing-contexts:discard-a-document-2>discard</a> the <code id=the-session-history-of-browsing-contexts:document-18><a href=#document>Document</a></code>
  objects of entries other than the <a href=#current-entry id=the-session-history-of-browsing-contexts:current-entry-3>current entry</a> that are not referenced from any
  script, reloading the pages afresh when the user or script navigates back to such pages. This
  specification does not specify when user agents should discard <code id=the-session-history-of-browsing-contexts:document-19><a href=#document>Document</a></code> objects and
  when they should cache them.</p>

  <p>Entries that have had their <code id=the-session-history-of-browsing-contexts:document-20><a href=#document>Document</a></code> objects discarded must, for the purposes of
  the algorithms given below, act as if they had not. When the user or script navigates back or
  forwards to a page which has no in-memory DOM objects, any other entries that shared the same
  <code id=the-session-history-of-browsing-contexts:document-21><a href=#document>Document</a></code> object with it must share the new object as well.</p>

  



  <h4 id=the-history-interface><span class=secno>7.7.2</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>

  <pre><code class='idl'><c- b>enum</c-> <dfn id='scrollrestoration'><c- g>ScrollRestoration</c-></dfn> { <c- s>&quot;</c-><a href='#dom-scrollrestoration-auto' id='the-history-interface:dom-scrollrestoration-auto'><c- s>auto</c-></a><c- s>&quot;</c->, <c- s>&quot;</c-><a href='#dom-scrollrestoration-manual' id='the-history-interface:dom-scrollrestoration-manual'><c- s>manual</c-></a><c- s>&quot;</c-> };

[<c- g>Exposed</c->=<c- n>Window</c->]
<c- b>interface</c-> <dfn id='history-3'><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>void</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>void</c-> <a href='#dom-history-back' id='the-history-interface:dom-history-back'><c- g>back</c-></a>();
  <c- b>void</c-> <a href='#dom-history-forward' id='the-history-interface:dom-history-forward'><c- g>forward</c-></a>();
  <c- b>void</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>title</c->, <c- b>optional</c-> <c- b>USVString</c->? <c- g>url</c-> = <c- b>null</c->);
  <c- b>void</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>title</c->, <c- b>optional</c-> <c- b>USVString</c->? <c- g>url</c-> = <c- b>null</c->);
};</code></pre>

  <dl class=domintro><dt><var>window</var> . <code id=dom-history-dev><a href=#dom-history>history</a></code> . <code id=dom-history-length-dev><a href=#dom-history-length>length</a></code><dd>

    <p>Returns the number of entries in the <a href=#joint-session-history id=the-history-interface:joint-session-history>joint session history</a>.</p>

   <dt><var>window</var> . <code id=the-history-interface:dom-history><a href=#dom-history>history</a></code> . <code id=dom-history-scroll-restoration-dev><a href=#dom-history-scroll-restoration>scrollRestoration</a></code> [ = <var>value</var> ]<dd>

    <p>Returns the <a href=#scroll-restoration-mode id=the-history-interface:scroll-restoration-mode>scroll restoration mode</a> of the current entry in the <a href=#session-history id=the-history-interface:session-history>session
    history</a>.</p>

    <p>Can be set, to change the <a href=#scroll-restoration-mode id=the-history-interface:scroll-restoration-mode-2>scroll restoration mode</a> of the current entry in the <a href=#session-history id=the-history-interface:session-history-2>session history</a>.</p>

   <dt><var>window</var> . <code id=the-history-interface:dom-history-2><a href=#dom-history>history</a></code> . <code id=dom-history-state-dev><a href=#dom-history-state>state</a></code><dd>

    <p>Returns the current <a href=#serialized-state id=the-history-interface:serialized-state>serialized state</a>, deserialized into an object.</p>

   <dt><var>window</var> . <code id=the-history-interface:dom-history-3><a href=#dom-history>history</a></code> . <code id=dom-history-go-dev><a href=#dom-history-go>go</a></code>( [ <var>delta</var> ] )<dd>

    <p>Goes back or forward the specified number of steps in the <a href=#joint-session-history id=the-history-interface:joint-session-history-2>joint session history</a>.</p>

    <p>A zero delta will reload the current page.</p>

    <p>If the delta is out of range, does nothing.</p>

   <dt><var>window</var> . <code id=the-history-interface:dom-history-4><a href=#dom-history>history</a></code> . <code id=dom-history-back-dev><a href=#dom-history-back>back</a></code>()<dd>

    <p>Goes back one step in the <a href=#joint-session-history id=the-history-interface:joint-session-history-3>joint session history</a>.</p>

    <p>If there is no previous page, does nothing.</p>

   <dt><var>window</var> . <code id=the-history-interface:dom-history-5><a href=#dom-history>history</a></code> . <code id=dom-history-forward-dev><a href=#dom-history-forward>forward</a></code>()<dd>

    <p>Goes forward one step in the <a href=#joint-session-history id=the-history-interface:joint-session-history-4>joint session history</a>.</p>

    <p>If there is no next page, does nothing.</p>

   <dt><var>window</var> . <code id=the-history-interface:dom-history-6><a href=#dom-history>history</a></code> . <code id=dom-history-pushstate-dev><a href=#dom-history-pushstate>pushState</a></code>(<var>data</var>, <var>title</var> [, <var>url</var> ] )<dd>

    <p>Pushes the given data onto the session history, with the given title, and, if provided and
    not null, the given URL.</p>

   <dt><var>window</var> . <code id=the-history-interface:dom-history-7><a href=#dom-history>history</a></code> . <code id=dom-history-replacestate-dev><a href=#dom-history-replacestate>replaceState</a></code>(<var>data</var>, <var>title</var> [, <var>url</var> ] )<dd>

    <p>Updates the current entry in the session history to have the given data, title, and, if
    provided and not null, URL.</p>

   </dl>


  <p>The <dfn id=joint-session-history>joint session history</dfn> of a <a href=#top-level-browsing-context id=the-history-interface:top-level-browsing-context>top-level browsing context</a> is the union
  of all the <a href=#session-history id=the-history-interface:session-history-3>session histories</a> of all <a href=#concept-document-bc id=the-history-interface:concept-document-bc>browsing contexts</a> of all the <a href=#fully-active id=the-history-interface:fully-active>fully active</a>
  <code id=the-history-interface:document><a href=#document>Document</a></code> objects that share that <a href=#top-level-browsing-context id=the-history-interface:top-level-browsing-context-2>top-level browsing context</a>, with all
  the entries that are <a href=#current-entry id=the-history-interface:current-entry>current entries</a> in their respective <a href=#session-history id=the-history-interface:session-history-4>session histories</a> removed except for the <a href=#current-entry-of-the-joint-session-history id=the-history-interface:current-entry-of-the-joint-session-history>current entry of
  the joint session history</a>.</p>

  <p>The <dfn id=current-entry-of-the-joint-session-history>current entry of the joint session history</dfn> is the entry that most recently
  became a <a href=#current-entry id=the-history-interface:current-entry-2>current entry</a> in its <a href=#session-history id=the-history-interface:session-history-5>session history</a>.</p>

  <p>Entries in the <a href=#joint-session-history id=the-history-interface:joint-session-history-5>joint session history</a> are ordered chronologically by the time they
  were added to their respective <a href=#session-history id=the-history-interface:session-history-6>session histories</a>. Each entry
  has an index; the earliest entry has index 0, and the subsequent entries are numbered with
  consecutively increasing integers (1, 2, 3, etc).</p>

  <p class=note>Since each <code id=the-history-interface:document-2><a href=#document>Document</a></code> in a <a href=#browsing-context id=the-history-interface:browsing-context>browsing context</a> might have a
  different <a href=#event-loop id=the-history-interface:event-loop>event loop</a>, the actual state of the <a href=#joint-session-history id=the-history-interface:joint-session-history-6>joint session history</a> can
  be somewhat nebulous. For example, two sibling <code id=the-history-interface:the-iframe-element><a href=#the-iframe-element>iframe</a></code> elements could both <a href=#traverse-the-history id=the-history-interface:traverse-the-history>traverse</a> from one unique origin to another at the same time,
  so their precise order might not be well-defined; similarly, since they might only find out about
  each other later, they might disagree about the length of the <a href=#joint-session-history id=the-history-interface:joint-session-history-7>joint session
  history</a>.</p>


  

  <p>The <dfn id=dom-history-length><code>length</code></dfn> attribute of the
  <code id=the-history-interface:history-3-2><a href=#history-3>History</a></code> interface, on getting, must return the number of entries in the
  <a href=#top-level-browsing-context id=the-history-interface:top-level-browsing-context-3>top-level browsing context</a>'s <a href=#joint-session-history id=the-history-interface:joint-session-history-8>joint session history</a>. If this
  <code id=the-history-interface:history-3-3><a href=#history-3>History</a></code> object is associated with a <code id=the-history-interface:document-3><a href=#document>Document</a></code> that is not
  <a href=#fully-active id=the-history-interface:fully-active-2>fully active</a>, getting must instead throw a <a id=the-history-interface:securityerror href=https://heycam.github.io/webidl/#securityerror data-x-internal=securityerror>"<code>SecurityError</code>"</a>
  <code id=the-history-interface:domexception><a data-x-internal=domexception href=https://heycam.github.io/webidl/#dfn-DOMException>DOMException</a></code>.</p>

  <p>The actual entries are not accessible from script.</p>

  <p>The <dfn id=dom-history-scroll-restoration><code>scrollRestoration</code></dfn> attribute
  of the History interface, on getting, must return the <a href=#scroll-restoration-mode id=the-history-interface:scroll-restoration-mode-3>scroll restoration mode</a> of the
  current entry in the <a href=#session-history id=the-history-interface:session-history-7>session history</a>. On setting, the <a href=#scroll-restoration-mode id=the-history-interface:scroll-restoration-mode-4>scroll restoration mode
  </a> of the current entry in the <a href=#session-history id=the-history-interface:session-history-8>session history</a> must be set to the new
  value.  If this <code id=the-history-interface:history-3-4><a href=#history-3>History</a></code> object is associated with a <code id=the-history-interface:document-4><a href=#document>Document</a></code> that is
  not <a href=#fully-active id=the-history-interface:fully-active-3>fully active</a>, both getting and setting must instead throw a
  <a id=the-history-interface:securityerror-2 href=https://heycam.github.io/webidl/#securityerror data-x-internal=securityerror>"<code>SecurityError</code>"</a> <code id=the-history-interface:domexception-2><a data-x-internal=domexception href=https://heycam.github.io/webidl/#dfn-DOMException>DOMException</a></code>.</p>

  <p>The <dfn id=dom-history-state><code>state</code></dfn> attribute of the
  <code id=the-history-interface:history-3-5><a href=#history-3>History</a></code> interface, on getting, must return the last value it was set to by the user
  agent. If this <code id=the-history-interface:history-3-6><a href=#history-3>History</a></code> object is associated with a <code id=the-history-interface:document-5><a href=#document>Document</a></code> that is
  not <a href=#fully-active id=the-history-interface:fully-active-4>fully active</a>, getting must instead throw a
  <a id=the-history-interface:securityerror-3 href=https://heycam.github.io/webidl/#securityerror data-x-internal=securityerror>"<code>SecurityError</code>"</a> <code id=the-history-interface:domexception-3><a data-x-internal=domexception href=https://heycam.github.io/webidl/#dfn-DOMException>DOMException</a></code>. Initially, its value must be
  null.</p>

  <p>When the <dfn id=dom-history-go><code>go(<var>delta</var>)</code></dfn> method is
  invoked, if <var>delta</var> is zero, the user agent must act as if the
  <code id=the-history-interface:dom-location-reload><a href=#dom-location-reload>location.reload()</a></code> method was called instead. Otherwise,
  the user agent must <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> whose value is
  <var>delta</var>. If this <code id=the-history-interface:history-3-7><a href=#history-3>History</a></code> object is associated with a <code id=the-history-interface:document-6><a href=#document>Document</a></code>
  that is not <a href=#fully-active id=the-history-interface:fully-active-5>fully active</a>, invoking must instead throw a
  <a id=the-history-interface:securityerror-4 href=https://heycam.github.io/webidl/#securityerror data-x-internal=securityerror>"<code>SecurityError</code>"</a> <code id=the-history-interface:domexception-4><a data-x-internal=domexception href=https://heycam.github.io/webidl/#dfn-DOMException>DOMException</a></code>.</p>

  <p>When the <dfn id=dom-history-back><code>back()</code></dfn> method is invoked, the user
  agent must <a href=#traverse-the-history-by-a-delta id=the-history-interface:traverse-the-history-by-a-delta-2>traverse the history by a delta</a> −1. If this <code id=the-history-interface:history-3-8><a href=#history-3>History</a></code>
  object is associated with a <code id=the-history-interface:document-7><a href=#document>Document</a></code> that is not <a href=#fully-active id=the-history-interface:fully-active-6>fully active</a>,
  invoking must instead throw a <a id=the-history-interface:securityerror-5 href=https://heycam.github.io/webidl/#securityerror data-x-internal=securityerror>"<code>SecurityError</code>"</a>
  <code id=the-history-interface:domexception-5><a data-x-internal=domexception href=https://heycam.github.io/webidl/#dfn-DOMException>DOMException</a></code>.</p>

  <p>When the <dfn id=dom-history-forward><code>forward()</code></dfn> method is invoked, the
  user agent must <a href=#traverse-the-history-by-a-delta id=the-history-interface:traverse-the-history-by-a-delta-3>traverse the history by a delta</a> +1. If this <code id=the-history-interface:history-3-9><a href=#history-3>History</a></code>
  object is associated with a <code id=the-history-interface:document-8><a href=#document>Document</a></code> that is not <a href=#fully-active id=the-history-interface:fully-active-7>fully active</a>,
  invoking must instead throw a <a id=the-history-interface:securityerror-6 href=https://heycam.github.io/webidl/#securityerror data-x-internal=securityerror>"<code>SecurityError</code>"</a>
  <code id=the-history-interface:domexception-6><a data-x-internal=domexception href=https://heycam.github.io/webidl/#dfn-DOMException>DOMException</a></code>.</p>


  <hr>

  <p>Each <a href=#top-level-browsing-context id=the-history-interface:top-level-browsing-context-4>top-level browsing context</a> has a <dfn id=session-history-traversal-queue>session history traversal queue</dfn>,
  initially empty, to which <a href=#concept-task id=the-history-interface:concept-task>tasks</a> can be added.</p>

  <p>Each <a href=#top-level-browsing-context id=the-history-interface:top-level-browsing-context-5>top-level browsing context</a>, when created, must begin running
  the following algorithm, known as the <dfn id=session-history-event-loop>session history event loop</dfn> for that
  <a href=#top-level-browsing-context id=the-history-interface:top-level-browsing-context-6>top-level browsing context</a>, <a href=#in-parallel id=the-history-interface:in-parallel>in parallel</a>:</p>

  <ol><li><p>Wait until this <a href=#top-level-browsing-context id=the-history-interface:top-level-browsing-context-7>top-level browsing context</a>'s <a href=#session-history-traversal-queue id=the-history-interface:session-history-traversal-queue>session history traversal
   queue</a> is not empty.<li><p>Pull the first <a href=#concept-task id=the-history-interface:concept-task-2>task</a> from this <a href=#top-level-browsing-context id=the-history-interface:top-level-browsing-context-8>top-level browsing
   context</a>'s <a href=#session-history-traversal-queue id=the-history-interface:session-history-traversal-queue-2>session history traversal queue</a>, and execute it.<li><p>Return to the first step of this algorithm.</p>

  </ol>

  <p>The <a href=#session-history-event-loop id=the-history-interface:session-history-event-loop>session history event loop</a> helps coordinate cross-browsing-context transitions
  of the <a href=#joint-session-history id=the-history-interface:joint-session-history-9>joint session history</a>: since each <a href=#browsing-context id=the-history-interface:browsing-context-2>browsing context</a> might, at any
  particular time, have a different <a href=#event-loop id=the-history-interface:event-loop-2>event loop</a> (this can happen if the user agent has
  more than one <a href=#event-loop id=the-history-interface:event-loop-3>event loop</a> per <a href=#unit-of-related-browsing-contexts id=the-history-interface:unit-of-related-browsing-contexts>unit of related browsing contexts</a>),
  transitions would otherwise have to involve cross-event-loop synchronization.</p>

  <hr>

  <p>To <dfn id=traverse-the-history-by-a-delta>traverse the history by a delta</dfn> <var>delta</var>, the user agent must
  append a <a href=#concept-task id=the-history-interface:concept-task-3>task</a> to this <a href=#top-level-browsing-context id=the-history-interface:top-level-browsing-context-9>top-level browsing context</a>'s
  <a href=#session-history-traversal-queue id=the-history-interface:session-history-traversal-queue-3>session history traversal queue</a>, the <a href=#concept-task id=the-history-interface:concept-task-4>task</a>
  consisting of running the following steps:</p>

  <ol><li><p>If the index of the <a href=#current-entry-of-the-joint-session-history id=the-history-interface:current-entry-of-the-joint-session-history-2>current entry of the joint session history</a> plus <var>delta</var> is less than zero or greater than or equal to the number of items in the
   <a href=#joint-session-history id=the-history-interface:joint-session-history-10>joint session history</a>, then return.</p>

   <li><p>Let <var>specified entry</var> be the entry in the <a href=#joint-session-history id=the-history-interface:joint-session-history-11>joint session
   history</a> whose index is the sum of <var>delta</var> and the index of the
   <a href=#current-entry-of-the-joint-session-history id=the-history-interface:current-entry-of-the-joint-session-history-3>current entry of the joint session history</a>.<li><p>Let <var>specified browsing context</var> be the <a href=#browsing-context id=the-history-interface:browsing-context-3>browsing context</a> of
   the <var>specified entry</var>.<li><p>If the <var>specified browsing context</var>'s <a href=#active-document id=the-history-interface:active-document>active document</a>'s
   <a href=#unload-a-document id=the-history-interface:unload-a-document>unload a document</a> algorithm is currently running, return.<li>

    <p><a href=#queue-a-task id=the-history-interface:queue-a-task>Queue a task</a> that consists of running the following substeps. The relevant
    <a href=#event-loop id=the-history-interface:event-loop-4>event loop</a> is that of the <var>specified browsing context</var>'s
    <a href=#active-document id=the-history-interface:active-document-2>active document</a>. The <a href=#task-source id=the-history-interface:task-source>task source</a> for the queued task is the
    <a href=#history-traversal-task-source id=the-history-interface:history-traversal-task-source>history traversal task source</a>.</p>

    <ol><li><p>If there is an ongoing attempt to navigate <var>specified browsing context</var>
     that has not yet <a href=#concept-navigate-mature id=the-history-interface:concept-navigate-mature>matured</a> (i.e. it has not passed the
     point of making its <code id=the-history-interface:document-9><a href=#document>Document</a></code> the <a href=#active-document id=the-history-interface:active-document-3>active document</a>), then cancel that
     attempt to navigate the <a href=#browsing-context id=the-history-interface:browsing-context-4>browsing context</a>.<li>

      <p>If the <var>specified browsing context</var>'s <a href=#active-document id=the-history-interface:active-document-4>active document</a> is not
      the same <code id=the-history-interface:document-10><a href=#document>Document</a></code> as the <code id=the-history-interface:document-11><a href=#document>Document</a></code> of the <var>specified
      entry</var>, then run these substeps:</p>

      <ol><li><p><a href=#prompt-to-unload-a-document id=the-history-interface:prompt-to-unload-a-document>Prompt to unload</a> the <a href=#active-document id=the-history-interface:active-document-5>active document</a> of the <var>specified
       browsing context</var>. If the user <a href=#refused-to-allow-the-document-to-be-unloaded id=the-history-interface:refused-to-allow-the-document-to-be-unloaded>refused to allow the document to be
       unloaded</a>, then return.<li><p><a href=#unload-a-document id=the-history-interface:unload-a-document-2>Unload</a> the <a href=#active-document id=the-history-interface:active-document-6>active document</a> of the
       <var>specified browsing context</var>.</ol>

     <li><p><a href=#traverse-the-history id=the-history-interface:traverse-the-history-2>Traverse the history</a> of the <var>specified browsing context</var> to
     the <var>specified entry</var> with the <i id=the-history-interface:history-navigation-flag><a href=#history-navigation-flag>history-navigation
     flag</a></i> set.</p>

    </ol>

   </ol>

  <p>When the user navigates through a <a href=#browsing-context id=the-history-interface:browsing-context-5>browsing context</a>, e.g. using a browser's back
  and forward buttons, the user agent must <a href=#traverse-the-history-by-a-delta id=the-history-interface:traverse-the-history-by-a-delta-4>traverse the history by a delta</a> equivalent
  to the action specified by the user.</p>

  <hr id=history-1>

  <p>The <dfn id=url-and-history-update-steps>URL and history update steps</dfn>, given a <code id=the-history-interface:document-12><a href=#document>Document</a></code> object
  <var>document</var>, a <a id=the-history-interface: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=the-history-interface:serialized-state-2>serialized
  state</a> <var>serializedData</var>, and an optional string <var>title</var>, optionally with a
  <var>state push flag</var>, are:</p>

  <ol><li><p>Let <var>browsingContext</var> be <var>document</var>'s <a href=#concept-document-bc id=the-history-interface:concept-document-bc-2>browsing context</a>.<li>
    <p>If the <var>state push flag</var> is set, then:</p>

    <ol><li>
      <p>Remove all the entries in <var>browsingContext</var>'s <a href=#session-history id=the-history-interface:session-history-9>session history</a> after
      the <a href=#current-entry id=the-history-interface:current-entry-3>current entry</a>. If the <a href=#current-entry id=the-history-interface:current-entry-4>current entry</a> is the last entry in the
      session history, then no entries are removed.</p>

      <p class=note>This <a href=#history-notes>doesn't necessarily have to affect</a> the user
      agent's user interface.</p>
     <li><p>Remove any <a href=#concept-task id=the-history-interface:concept-task-5>tasks</a> queued by the <a href=#history-traversal-task-source id=the-history-interface:history-traversal-task-source-2>history
     traversal task source</a> that are associated with any <code id=the-history-interface:document-13><a href=#document>Document</a></code> objects in the
     <a href=#top-level-browsing-context id=the-history-interface:top-level-browsing-context-10>top-level browsing context</a>'s <a href=#document-family id=the-history-interface:document-family>document family</a>.<li><p>If appropriate, update the <a href=#current-entry id=the-history-interface:current-entry-5>current entry</a> to reflect any state that the user
     agent wishes to persist. The entry is then said to be <a href=#an-entry-with-persisted-user-state id=the-history-interface:an-entry-with-persisted-user-state>an entry with persisted user
     state</a>.<li>
      <p>Add a <a href=#session-history-entry id=the-history-interface:session-history-entry>session history entry</a> entry to the session history, after the
      <a href=#current-entry id=the-history-interface:current-entry-6>current entry</a>, with</p>

      <ul><li><p><var>newURL</var> as the <a id=the-history-interface:url-2 href=https://url.spec.whatwg.org/#concept-url data-x-internal=url>URL</a>;<li><p>the <a href=#scroll-restoration-mode id=the-history-interface:scroll-restoration-mode-5>scroll restoration mode</a> of the current entry in the <a href=#session-history id=the-history-interface:session-history-10>session
       history</a> as the scroll restoration mode;<li><p><var>serializedData</var> as the <a href=#serialized-state id=the-history-interface:serialized-state-3>serialized state</a>, if it is
       given;<li><p><var>title</var> as the title, if it is given.</ul>
     <li><p>Update the <a href=#current-entry id=the-history-interface:current-entry-7>current entry</a> to be this newly added entry.</ol>
   <li>
    <p>Otherwise, update the <a href=#current-entry id=the-history-interface:current-entry-8>current entry</a> in <var>browsingContext</var>'s
    <a href=#session-history id=the-history-interface:session-history-11>session history</a> so that:</p>

    <ul><li><p><var>newURL</var> is the entry's new <a id=the-history-interface:url-3 href=https://url.spec.whatwg.org/#concept-url data-x-internal=url>URL</a>;<li><p><var>serializedData</var> is the entry's new <a href=#serialized-state id=the-history-interface:serialized-state-4>serialized state</a>, if it is
     given; otherwise, the <a href=#current-entry id=the-history-interface:current-entry-9>current entry</a>'s current <a href=#serialized-state id=the-history-interface:serialized-state-5>serialized state</a> is
     kept;<li><p><var>title</var> is the entry's new title, if it is given; otherwise, the entry does not
     have a title;<li><p>it represents a GET request, if it currently represents a non-GET request (e.g. it was
     the result of a POST submission).</ul>
   <li>
    <p>Set <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> to
    <var>newURL</var>.</p>

    <p class=note>Since this is neither a <a href=#navigate id=the-history-interface:navigate>navigation</a> of the
    <a href=#browsing-context id=the-history-interface:browsing-context-6>browsing context</a> nor a <a href=#traverse-the-history id=the-history-interface:traverse-the-history-3>history traversal</a>,
    it does not cause a <code id=the-history-interface:event-hashchange><a href=#event-hashchange>hashchange</a></code> event to be fired.</p>
   </ol>

  <p>The <dfn id=dom-history-pushstate><code>pushState(<var>data</var>, <var>title</var>, <var>url</var>)</code></dfn> method adds a state object entry to
  the history.<div class=status><input onclick=toggleStatus(this) value=⋰ type=button><p class=support><strong>Support:</strong> history<span class="and_chr yes"><span>Chrome for Android</span> <span>67+</span></span><span class="chrome yes"><span>Chrome</span> <span>5+</span></span><span class="ios_saf yes"><span>iOS Safari</span> <span>5.0+</span></span><span class="and_uc yes"><span>UC Browser for Android</span> <span>11.8+</span></span><span class="firefox yes"><span>Firefox</span> <span>4+</span></span><span class="ie yes"><span>IE</span> <span>10+</span></span><span class="op_mini no"><span>Opera Mini</span> <span>None</span></span><span class="safari yes"><span>Safari</span> <span>6+</span></span><span class="edge yes"><span>Edge</span> <span>12+</span></span><span class="samsung yes"><span>Samsung Internet</span> <span>4+</span></span><span class="opera yes"><span>Opera</span> <span>11.5+</span></span><span class="android yes"><span>Android Browser</span> <span>4.2+</span></span><p class=caniuse>Source: <a href="https://caniuse.com/#feat=history">caniuse.com</a></div>

  <p>The <dfn id=dom-history-replacestate><code>replaceState(<var>data</var>, <var>title</var>, <var>url</var>)</code></dfn> method updates the state object,
  title, and optionally the <a id=the-history-interface:url-4 href=https://url.spec.whatwg.org/#concept-url data-x-internal=url>URL</a> of the <a href=#current-entry id=the-history-interface:current-entry-10>current entry</a> in the history.</p>

  <p>When either of these methods is invoked, the user agent must run the following steps:</p>

  <ol><li><p>Let <var>document</var> be the unique <code id=the-history-interface:document-14><a href=#document>Document</a></code> object this
   <code id=the-history-interface:history-3-10><a href=#history-3>History</a></code> object is associated with.<li><p>If <var>document</var> is not <a href=#fully-active id=the-history-interface:fully-active-8>fully active</a>, throw a
   <a id=the-history-interface:securityerror-7 href=https://heycam.github.io/webidl/#securityerror data-x-internal=securityerror>"<code>SecurityError</code>"</a> <code id=the-history-interface:domexception-7><a data-x-internal=domexception href=https://heycam.github.io/webidl/#dfn-DOMException>DOMException</a></code>.<li><p>Optionally, return. (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.)<li><p>Let <var>targetRealm</var> be this <code id=the-history-interface:history-3-11><a href=#history-3>History</a></code> object's <a href=#concept-relevant-realm id=the-history-interface:concept-relevant-realm>relevant Realm</a>.<li><p>Let <var>serializedData</var> be
   <a href=#structuredserializeforstorage id=the-history-interface:structuredserializeforstorage>StructuredSerializeForStorage</a>(<var>data</var>). Rethrow any exceptions.<li><p>Let <var>newURL</var> be the <a id=the-history-interface:url-5 href=https://url.spec.whatwg.org/#concept-url data-x-internal=url>URL</a> of the <a href=#current-entry id=the-history-interface:current-entry-11>current entry</a> in
   <var>browsingContext</var>'s <a href=#session-history id=the-history-interface:session-history-12>session history</a>.<li>
    <p>If <var>url</var> is not null, then:</p>

    <ol><li><p><a href=#parse-a-url id=the-history-interface:parse-a-url>Parse</a> <var>url</var>, relative to the <a href=#relevant-settings-object id=the-history-interface:relevant-settings-object>relevant
     settings object</a> of this <code id=the-history-interface:history-3-12><a href=#history-3>History</a></code> object.<li><p>If that fails, then throw a <a id=the-history-interface:securityerror-8 href=https://heycam.github.io/webidl/#securityerror data-x-internal=securityerror>"<code>SecurityError</code>"</a>
     <code id=the-history-interface:domexception-8><a data-x-internal=domexception href=https://heycam.github.io/webidl/#dfn-DOMException>DOMException</a></code>.<li><p>Set <var>newURL</var> to the <a href=#resulting-url-record id=the-history-interface:resulting-url-record>resulting URL record</a>.<li><p>Compare <var>newURL</var> to <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>. If any component of these two <a href=https://url.spec.whatwg.org/#concept-url id=the-history-interface:url-record data-x-internal=url-record>URL records</a> differ other than the <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> components, then throw a
     <a id=the-history-interface:securityerror-9 href=https://heycam.github.io/webidl/#securityerror data-x-internal=securityerror>"<code>SecurityError</code>"</a> <code id=the-history-interface:domexception-9><a data-x-internal=domexception href=https://heycam.github.io/webidl/#dfn-DOMException>DOMException</a></code>.<li><p>If the <a href=https://url.spec.whatwg.org/#concept-url-origin id=the-history-interface:concept-url-origin data-x-internal=concept-url-origin>origin</a> of <var>newURL</var> is not
     <a href=#same-origin id=the-history-interface:same-origin>same origin</a> with the <a href=#concept-origin id=the-history-interface:concept-origin>origin</a> of <var>document</var>, and either the
     <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> or <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>
     components of the two <a href=https://url.spec.whatwg.org/#concept-url id=the-history-interface:url-record-2 data-x-internal=url-record>URL records</a> compared in the previous
     step differ, throw a <a id=the-history-interface:securityerror-10 href=https://heycam.github.io/webidl/#securityerror data-x-internal=securityerror>"<code>SecurityError</code>"</a> <code id=the-history-interface:domexception-10><a data-x-internal=domexception href=https://heycam.github.io/webidl/#dfn-DOMException>DOMException</a></code>. (This
     prevents sandboxed content from spoofing other pages on the same origin.)</ol>

   <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>,
   <var>newURL</var>, <var>serializedData</var>, and <var>title</var>, with the <var>state push
   flag</var> set if the method invoked was the <code id=the-history-interface:dom-history-pushstate-2><a href=#dom-history-pushstate>pushState()</a></code> method.<li><p>Let <var>state</var> be <a href=#structureddeserialize id=the-history-interface:structureddeserialize>StructuredDeserialize</a>(<var>serializedData</var>,
   <var>targetRealm</var>). If this throws an exception, catch it, ignore the exception, and set
   <var>state</var> to null.<li><p>Set <code id=the-history-interface:dom-history-state-2><a href=#dom-history-state>history.state</a></code> to <var>state</var>.<li><p>Set the <a href=#current-entry id=the-history-interface:current-entry-12>current entry</a>'s <code id=the-history-interface:document-15><a href=#document>Document</a></code> object's <a href=#latest-entry id=the-history-interface:latest-entry>latest
   entry</a> to the <a href=#current-entry id=the-history-interface:current-entry-13>current entry</a>.</ol>

  <p class=note>The <var>title</var> is purely advisory. User agents might use the title
  in the user interface.</p>

  <p>User agents may limit the number of state objects added to the session history per page. If a
  page hits the UA-defined limit, user agents must remove the entry immediately after the first
  entry for that <code id=the-history-interface:document-16><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 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>&quot;en&quot;</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>&quot;?x=6&quot;</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>&quot;?x=4&quot;</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>&quot;en&quot;</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>&quot;coord&quot;</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>&quot;?x=6&quot;</c-> <c- e>onclick</c-><c- o>=</c-><c- s>&quot;go(1); return false;&quot;</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>&quot;?x=4&quot;</c-> <c- e>onclick</c-><c- o>=</c-><c- s>&quot;go(-1); return false;&quot;</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- mi>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-> document<c- p>.</c->title<c- p>,</c-> <c- t>&apos;?x=&apos;</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>&apos;Line Game - &apos;</c-> <c- o>+</c-> currentPage<c- p>;</c->
   document<c- p>.</c->getElementById<c- p>(</c-><c- t>&apos;coord&apos;</c-><c- p>).</c->textContent <c- o>=</c-> currentPage<c- p>;</c->
   document<c- p>.</c->links<c- p>[</c-><c- mi>0</c-><c- p>].</c->href <c- o>=</c-> <c- t>&apos;?x=&apos;</c-> <c- o>+</c-> <c- p>(</c->currentPage<c- o>+</c-><c- mi>1</c-><c- p>);</c->
   document<c- p>.</c->links<c- p>[</c-><c- mi>0</c-><c- p>].</c->textContent <c- o>=</c-> <c- t>&apos;Advance to &apos;</c-> <c- o>+</c-> <c- p>(</c->currentPage<c- o>+</c-><c- mi>1</c-><c- p>);</c->
   document<c- p>.</c->links<c- p>[</c-><c- mi>1</c-><c- p>].</c->href <c- o>=</c-> <c- t>&apos;?x=&apos;</c-> <c- o>+</c-> <c- p>(</c->currentPage<c- o>-</c-><c- mi>1</c-><c- p>);</c->
   document<c- p>.</c->links<c- p>[</c-><c- mi>1</c-><c- p>].</c->textContent <c- o>=</c-> <c- t>&apos;retreat to &apos;</c-> <c- o>+</c-> <c- p>(</c->currentPage<c- o>-</c-><c- mi>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>Applications might not use the same title for a <a href=#session-history-entry id=the-history-interface:session-history-entry-2>session history entry</a> as the
   value of the document's <code id=the-history-interface:the-title-element><a href=#the-title-element>title</a></code> element at that time. For example, here is a simple
   page that shows a block in the <code id=the-history-interface:the-title-element-2><a href=#the-title-element>title</a></code> element. Clearly, when navigating backwards to
   a previous state the user does not go back in time, and therefore it would be inappropriate to
   put the time in the session history title.</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->Line<c- p>&lt;/</c-><c- f>TITLE</c-><c- p>&gt;</c->
<c- p>&lt;</c-><c- f>SCRIPT</c-><c- p>&gt;</c->
 setInterval<c- p>(</c-><c- a>function</c-> <c- p>()</c-> <c- p>{</c-> document<c- p>.</c->title <c- o>=</c-> <c- t>&apos;Line - &apos;</c-> <c- o>+</c-> <c- k>new</c-> Date<c- p>();</c-> <c- p>},</c-> <c- mi>1000</c-><c- p>);</c->
 <c- a>var</c-> i <c- o>=</c-> <c- mi>1</c-><c- p>;</c->
 <c- a>function</c-> inc<c- p>()</c-> <c- p>{</c->
   set<c- p>(</c->i<c- o>+</c-><c- mi>1</c-><c- p>);</c->
   history<c- p>.</c->pushState<c- p>(</c->i<c- p>,</c-> <c- t>&apos;Line - &apos;</c-> <c- o>+</c-> i<c- p>);</c->
 <c- p>}</c->
 <c- a>function</c-> set<c- p>(</c->newI<c- p>)</c-> <c- p>{</c->
   i <c- o>=</c-> newI<c- p>;</c->
   document<c- p>.</c->forms<c- p>.</c->F<c- p>.</c->I<c- p>.</c->value <c- o>=</c-> newI<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- e>ONPOPSTATE</c-><c- o>=</c-><c- s>&quot;set(event.state)&quot;</c-><c- p>&gt;</c->
<c- p>&lt;</c-><c- f>FORM</c-> <c- e>NAME</c-><c- o>=</c-><c- s>F</c-><c- p>&gt;</c->
State: <c- p>&lt;</c-><c- f>OUTPUT</c-> <c- e>NAME</c-><c- o>=</c-><c- s>I</c-><c- p>&gt;</c->1<c- p>&lt;/</c-><c- f>OUTPUT</c-><c- p>&gt;</c-> <c- p>&lt;</c-><c- f>INPUT</c-> <c- e>VALUE</c-><c- o>=</c-><c- s>&quot;Increment&quot;</c-> <c- e>TYPE</c-><c- o>=</c-><c- s>BUTTON</c-> <c- e>ONCLICK</c-><c- o>=</c-><c- s>&quot;inc()&quot;</c-><c- p>&gt;</c->
<c- p>&lt;/</c-><c- f>FORM</c-><c- p>&gt;</c-></code></pre>

  </div>

  <div class=example>
   <p>Most applications want to use the same <a href=#scroll-restoration-mode id=the-history-interface:scroll-restoration-mode-6>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-2><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>&apos;scrollRestoration&apos;</c-> <c- k>in</c-> history<c- p>)</c->
            history<c- p>.</c->scrollRestoration <c- o>=</c-> <c- t>&apos;manual&apos;</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=history-notes><span class=secno>7.7.3</span> Implementation notes for session history<a href=#history-notes class=self-link></a></h4>
  

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

  <p>The <code id=history-notes:history-3><a href=#history-3>History</a></code> interface is not meant to place restrictions on how implementations
  represent the session history to the user.</p>

  <p>For example, session history could be implemented in a tree-like manner, with each page having
  multiple "forward" pages. This specification doesn't define how the linear list of pages in the
  <code id=history-notes:dom-history><a href=#dom-history>history</a></code> object are derived from the actual session history as
  seen from the user's perspective.</p>

  <p>Similarly, a page containing two <code id=history-notes:the-iframe-element><a href=#the-iframe-element>iframe</a></code>s has a <code id=history-notes:dom-history-2><a href=#dom-history>history</a></code> object distinct from the <code id=history-notes:the-iframe-element-2><a href=#the-iframe-element>iframe</a></code>s' <code id=history-notes:dom-history-3><a href=#dom-history>history</a></code> objects, despite the fact that typical Web browsers present the
  user with just one "Back" button, with a session history that interleaves the navigation of the
  two inner frames and the outer page.</p>


  <p><strong>Security</strong>: It is suggested that to avoid letting a page "hijack" the history
  navigation facilities of a UA by abusing <code id=history-notes:dom-history-pushstate><a href=#dom-history-pushstate>pushState()</a></code>,
  the UA provide the user with a way to jump back to the previous page (rather than just going back
  to the previous state). For example, the back button could have a drop down showing just the pages
  in the session history, and not showing any of the states. Similarly, an aural browser could have
  two "back" commands, one that goes back to the previous state, and one that jumps straight back to
  the previous page.</p>

  <p>For both <code id=history-notes:dom-history-pushstate-2><a href=#dom-history-pushstate>pushState()</a></code> and <code id=history-notes:dom-history-replacestate><a href=#dom-history-replacestate>replaceState()</a></code>, user agents are encouraged to prevent
  abuse of these APIs via too-frequent calls or over-large state objects. As detailed above, the
  algorithm explicitly allows user agents to ignore any such calls when appropriate.</p>


  


  <h4 id=the-location-interface><span class=secno>7.7.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>

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

  <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://heycam.github.io/webidl/#dfn-platform-object data-x-internal=platform-object>platform
   object</a>.<li><p>Perform ! <var>location</var>.[[DefineOwnProperty]]("<code>valueOf</code>", {
   [[Value]]: <a id=the-location-interface:objproto_valueof href=https://tc39.github.io/ecma262/#sec-object.prototype.valueof data-x-internal=objproto_valueof>%ObjProto_valueOf%</a>,
   [[Writable]]: false,
   [[Enumerable]]: false,
   [[Configurable]]: false }).<li><p>Perform ! <var>location</var>.[[DefineOwnProperty]](<a href=#@@toprimitive id=the-location-interface:@@toprimitive>@@toPrimitive</a>, {
   [[Value]]: undefined,
   [[Writable]]: false,
   [[Enumerable]]: false,
   [[Configurable]]: false }).<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]]().<li><p>Return <var>location</var>.</ol>

  <p class=note>The addition of <code>valueOf</code> and <a href=#@@toprimitive id=the-location-interface:@@toprimitive-2>@@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>[Unforgeable]</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=#@@toprimitive id=the-location-interface:@@toprimitive-3>@@toPrimitive</a>, and <code>[Unforgeable]</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><var>document</var> . <code id=dom-document-location-dev><a href=#dom-document-location>location</a></code> [ = <var>value</var> ]<dt><var>window</var> . <code id=dom-location-dev><a href=#dom-location>location</a></code> [ = <var>value</var> ]<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>

   </dl>

  

  <p>The <code id=the-location-interface:document><a href=#document>Document</a></code> object's <dfn id=dom-document-location><code>location</code></dfn> attribute's getter must return this
  <code id=the-location-interface:document-2><a href=#document>Document</a></code> object'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 this <code id=the-location-interface:document-3><a href=#document>Document</a></code> object is <a href=#fully-active id=the-location-interface:fully-active>fully active</a>, and null otherwise.</p>

  <p>The <code id=the-location-interface:window-3><a href=#window>Window</a></code> object's <dfn id=dom-location><code>location</code></dfn>
  attribute's getter must return this <code id=the-location-interface:window-4><a href=#window>Window</a></code> object's <code id=the-location-interface:location-10><a href=#location>Location</a></code> object.</p>

  

  <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 the <a href=#active-document id=the-location-interface:active-document>active document</a> of their
  <code id=the-location-interface:document-4><a href=#document>Document</a></code>'s <a href=#concept-document-bc id=the-location-interface:concept-document-bc>browsing context</a>, and allow the
  <a href=#current-entry id=the-location-interface:current-entry>current entry</a> of the <a href=#browsing-context id=the-location-interface:browsing-context>browsing context</a>'s session history to be changed,
  by adding or replacing entries in the <code id=the-location-interface:dom-history><a href=#dom-history>history</a></code> object.</p>

  <pre><code class='idl'>[<c- g>Exposed</c->=<c- n>Window</c->]
<c- b>interface</c-> <dfn id='location'><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>
  [<c- g>Unforgeable</c->] <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>;
  [<c- g>Unforgeable</c->] <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>;
  [<c- g>Unforgeable</c->] <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>;
  [<c- g>Unforgeable</c->] <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>;
  [<c- g>Unforgeable</c->] <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>;
  [<c- g>Unforgeable</c->] <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>;
  [<c- g>Unforgeable</c->] <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>;
  [<c- g>Unforgeable</c->] <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>;
  [<c- g>Unforgeable</c->] <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>;

  [<c- g>Unforgeable</c->] <c- b>void</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->);
  [<c- g>Unforgeable</c->] <c- b>void</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->);
  [<c- g>Unforgeable</c->] <c- b>void</c-> <a href='#dom-location-reload' id='the-location-interface:dom-location-reload'><c- g>reload</c-></a>();

  [<c- g>Unforgeable</c->, <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><var>location</var> . <code>toString()</code><dt><var>location</var> . <code id=dom-location-href-dev><a href=#dom-location-href>href</a></code><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>
   <dt><var>location</var> . <code id=dom-location-origin-dev><a href=#dom-location-origin>origin</a></code><dd>
    <p>Returns the <code id=the-location-interface:location-13><a href=#location>Location</a></code> object's URL's origin.</p>
   <dt><var>location</var> . <code id=dom-location-protocol-dev><a href=#dom-location-protocol>protocol</a></code><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>
   <dt><var>location</var> . <code id=dom-location-host-dev><a href=#dom-location-host>host</a></code><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>
   <dt><var>location</var> . <code id=dom-location-hostname-dev><a href=#dom-location-hostname>hostname</a></code><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>
   <dt><var>location</var> . <code id=dom-location-port-dev><a href=#dom-location-port>port</a></code><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>
   <dt><var>location</var> . <code id=dom-location-pathname-dev><a href=#dom-location-pathname>pathname</a></code><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>
   <dt><var>location</var> . <code id=dom-location-search-dev><a href=#dom-location-search>search</a></code><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>
   <dt><var>location</var> . <code id=dom-location-hash-dev><a href=#dom-location-hash>hash</a></code><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>
   <dt><var>location</var> . <code id=dom-location-assign-dev><a href=#dom-location-assign>assign</a></code>(<var>url</var>)<dd>
    <p>Navigates to the given URL.</p>
   <dt><var>location</var> . <code id=dom-location-replace-dev><a href=#dom-location-replace>replace</a></code>(<var>url</var>)<dd>
    <p>Removes the current page from the session history and navigates to the given URL.</p>
   <dt><var>location</var> . <code id=dom-location-reload-dev><a href=#dom-location-reload>reload</a></code>()<dd>
    <p>Reloads the current page.</p>
   <dt><var>location</var> . <code id=dom-location-ancestororigins-dev><a href=#dom-location-ancestororigins>ancestorOrigins</a></code><dd>
    <p>Returns a <code id=the-location-interface:domstringlist-2><a href=#domstringlist>DOMStringList</a></code> object listing the origins of the ancestor <a href=#browsing-context id=the-location-interface:browsing-context-2>browsing contexts</a>, from the <a href=#parent-browsing-context id=the-location-interface:parent-browsing-context>parent browsing
    context</a> to the <a href=#top-level-browsing-context id=the-location-interface:top-level-browsing-context>top-level browsing context</a>.</p>
   </dl>

  

  <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 this <code id=the-location-interface:location-22><a href=#location>Location</a></code> object's associated <code id=the-location-interface:document-5><a href=#document>Document</a></code> object's <a href=#concept-document-bc id=the-location-interface:concept-document-bc-2>browsing context</a>'s <a href=#active-document id=the-location-interface:active-document-2>active document</a>.</p>

  <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>.</p>

  <p>A <code id=the-location-interface:location-25><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-26><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.<li><p>Let <var>current</var> be the <a href=#concept-document-bc id=the-location-interface:concept-document-bc-3>browsing context</a>
   of the <code id=the-location-interface:document-6><a href=#document>Document</a></code> with which this <code id=the-location-interface:location-27><a href=#location>Location</a></code> object is associated.<li><p><i>Loop</i>: If <var>current</var> has no <a href=#parent-browsing-context id=the-location-interface:parent-browsing-context-2>parent browsing context</a>, jump to
   the step labeled <i>end</i>.<li><p>Let <var>current</var> be <var>current</var>'s <a href=#parent-browsing-context id=the-location-interface:parent-browsing-context-3>parent browsing
   context</a>.<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=#active-document id=the-location-interface:active-document-3>active document</a>'s
   <a href=#concept-origin id=the-location-interface:concept-origin>origin</a> to <var>output</var>.<li><p>Return to the step labeled <i>loop</i>.<li><p><i>End</i>: Return <var>output</var>.</ol>

  <p>A <code id=the-location-interface:location-28><a href=#location>Location</a></code> object has an associated <dfn id=location-object-setter-navigate><code>Location</code>-object-setter
  navigate</dfn> algorithm, which given a <var>url</var>, runs these steps:</p>

  <ol><li>
    <p>If any of the following conditions are met, let <var>replacement flag</var> be unset;
    otherwise, let it be set:</p>

    <ul class=brief><li>This <code id=the-location-interface:location-29><a href=#location>Location</a></code> object's <a href=#relevant-document id=the-location-interface:relevant-document-2>relevant <code>Document</code></a> has
     <a href=#completely-loaded id=the-location-interface:completely-loaded>completely loaded</a>, or<li>In the <a href=#concept-task id=the-location-interface:concept-task>task</a> in which the algorithm is running, an
     <a id=the-location-interface:activation-behaviour href=https://dom.spec.whatwg.org/#eventtarget-activation-behavior data-x-internal=activation-behaviour>activation behavior</a> is currently being processed whose <code id=the-location-interface:event-click><a data-x-internal=event-click href=https://w3c.github.io/uievents/#event-type-click>click</a></code> event's <code id=the-location-interface: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, or<li>In the <a href=#concept-task id=the-location-interface:concept-task-2>task</a> in which the algorithm is running, the event
     listener for a <code id=the-location-interface:event-click-2><a data-x-internal=event-click href=https://w3c.github.io/uievents/#event-type-click>click</a></code> event, whose <code id=the-location-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 is true, is being handled.</ul>
   <li><p><a href=#location-object-navigate id=the-location-interface:location-object-navigate><code>Location</code>-object navigate</a>, given <var>url</var> and
   <var>replacement flag</var>.</ol>

  <p>To <dfn id=location-object-navigate><code>Location</code>-object navigate</dfn>, given a <var>url</var> and
  <var>replacement flag</var>, run these steps:</p>

  <ol><li><p>The <a href=#source-browsing-context id=the-location-interface:source-browsing-context>source browsing context</a> is the <a href=#responsible-browsing-context id=the-location-interface:responsible-browsing-context>responsible browsing context</a>
   specified by the <a href=#incumbent-settings-object id=the-location-interface:incumbent-settings-object>incumbent settings object</a>.<li>
    <p><a href=#navigate id=the-location-interface:navigate>Navigate</a> the <a href=#browsing-context id=the-location-interface:browsing-context-3>browsing context</a> to
    <var>url</var>, with the <var><a href=#exceptions-enabled id=the-location-interface:exceptions-enabled>exceptions enabled flag</a></var> set. Rethrow any
    exceptions.</p>

    <p>If the <var>replacement flag</var> is set or the <a href=#browsing-context id=the-location-interface:browsing-context-4>browsing context</a>'s
    <a href=#session-history id=the-location-interface:session-history>session history</a> contains only one <code id=the-location-interface:document-7><a href=#document>Document</a></code>, and that was the
    <code id=the-location-interface:about:blank><a href=#about:blank>about:blank</a></code> <code id=the-location-interface:document-8><a href=#document>Document</a></code> created when the <a href=#browsing-context id=the-location-interface:browsing-context-5>browsing context</a>
    was created, then the navigation must be done with <a href=#replacement-enabled id=the-location-interface:replacement-enabled>replacement enabled</a>.</p>
    
   </ol>

  <p>The <dfn id=dom-location-href><code>href</code></dfn> attribute's getter must run these
  steps:</p>

  <ol><li><p>If this <code id=the-location-interface:location-30><a href=#location>Location</a></code> object's <a href=#relevant-document id=the-location-interface:relevant-document-3>relevant <code>Document</code></a>'s
   <a href=#concept-origin id=the-location-interface:concept-origin-2>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://heycam.github.io/webidl/#securityerror data-x-internal=securityerror>"<code>SecurityError</code>"</a> <code id=the-location-interface:domexception><a data-x-internal=domexception href=https://heycam.github.io/webidl/#dfn-DOMException>DOMException</a></code>.<li><p>Return this <code id=the-location-interface:location-31><a href=#location>Location</a></code> object'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>.</ol>

  <p>The <code id=the-location-interface:dom-location-href-2><a href=#dom-location-href>href</a></code> attribute's setter must run these steps:</p>

  <ol><li><p><a href=#parse-a-url id=the-location-interface:parse-a-url>Parse</a> the given value relative to the <a href=#entry-settings-object id=the-location-interface:entry-settings-object-2>entry
   settings object</a>. If that failed, throw a <code id=the-location-interface:typeerror><a data-x-internal=typeerror href=https://tc39.github.io/ecma262/#sec-native-error-types-used-in-this-standard-typeerror>TypeError</a></code> exception.<li><p><a href=#location-object-setter-navigate id=the-location-interface:location-object-setter-navigate><code>Location</code>-object-setter navigate</a> to the <a href=#resulting-url-record id=the-location-interface:resulting-url-record>resulting URL
   record</a>.</ol>

  <p class=note>The <code id=the-location-interface:dom-location-href-3><a href=#dom-location-href>href</a></code> attribute setter intentionally
  has no security check.</p>

  <p>The <dfn id=dom-location-origin><code>origin</code></dfn> attribute's getter must run
  these steps:</p>

  <ol><li><p>If this <code id=the-location-interface:location-32><a href=#location>Location</a></code> object's <a href=#relevant-document id=the-location-interface:relevant-document-4>relevant <code>Document</code></a>'s
   <a href=#concept-origin id=the-location-interface:concept-origin-3>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://heycam.github.io/webidl/#securityerror data-x-internal=securityerror>"<code>SecurityError</code>"</a> <code id=the-location-interface:domexception-2><a data-x-internal=domexception href=https://heycam.github.io/webidl/#dfn-DOMException>DOMException</a></code>.<li><p>Return the <a href=#ascii-serialisation-of-an-origin id=the-location-interface:ascii-serialisation-of-an-origin-2>serialization</a> of this
   <code id=the-location-interface:location-33><a href=#location>Location</a></code> object'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>.</ol>

  <p>The <dfn id=dom-location-protocol><code>protocol</code></dfn> attribute's getter must run
  these steps:</p>

  <ol><li><p>If this <code id=the-location-interface:location-34><a href=#location>Location</a></code> object's <a href=#relevant-document id=the-location-interface:relevant-document-5>relevant <code>Document</code></a>'s
   <a href=#concept-origin id=the-location-interface:concept-origin-4>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://heycam.github.io/webidl/#securityerror data-x-internal=securityerror>"<code>SecurityError</code>"</a> <code id=the-location-interface:domexception-3><a data-x-internal=domexception href=https://heycam.github.io/webidl/#dfn-DOMException>DOMException</a></code>.<li><p>Return this <code id=the-location-interface:location-35><a href=#location>Location</a></code> object'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>".</ol>

  <p>The <code id=the-location-interface:dom-location-protocol-2><a href=#dom-location-protocol>protocol</a></code> attribute's setter must run these
  steps:</p>

  <ol><li><p>If this <code id=the-location-interface:location-36><a href=#location>Location</a></code> object's <a href=#relevant-document id=the-location-interface:relevant-document-6>relevant <code>Document</code></a>'s
   <a href=#concept-origin id=the-location-interface:concept-origin-5>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://heycam.github.io/webidl/#securityerror data-x-internal=securityerror>"<code>SecurityError</code>"</a> <code id=the-location-interface:domexception-4><a data-x-internal=domexception href=https://heycam.github.io/webidl/#dfn-DOMException>DOMException</a></code>.<li><p>Let <var>copyURL</var> be a copy of this <code id=the-location-interface:location-37><a href=#location>Location</a></code> object's <a href=#concept-location-url id=the-location-interface:concept-location-url-4>url</a>.<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 <var>url</var> 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 <var>state override</var>.</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><p>If <var>possibleFailure</var> is failure, then throw a
   <a id=the-location-interface:syntaxerror href=https://heycam.github.io/webidl/#syntaxerror data-x-internal=syntaxerror>"<code>SyntaxError</code>"</a> <code id=the-location-interface:domexception-5><a data-x-internal=domexception href=https://heycam.github.io/webidl/#dfn-DOMException>DOMException</a></code>.<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.<li><p><a href=#location-object-setter-navigate id=the-location-interface:location-object-setter-navigate-2><code>Location</code>-object-setter navigate</a> to <var>copyURL</var>.</ol>

  <p>The <dfn id=dom-location-host><code>host</code></dfn> attribute's getter must run these
  steps:</p>

  <ol><li><p>If this <code id=the-location-interface:location-38><a href=#location>Location</a></code> object's <a href=#relevant-document id=the-location-interface:relevant-document-7>relevant <code>Document</code></a>'s
   <a href=#concept-origin id=the-location-interface:concept-origin-6>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://heycam.github.io/webidl/#securityerror data-x-internal=securityerror>"<code>SecurityError</code>"</a> <code id=the-location-interface:domexception-6><a data-x-internal=domexception href=https://heycam.github.io/webidl/#dfn-DOMException>DOMException</a></code>.<li><p>Let <var>url</var> be this <code id=the-location-interface:location-39><a href=#location>Location</a></code> object's <a href=#concept-location-url id=the-location-interface:concept-location-url-5>url</a>.<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.<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>.<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>.</ol>

  <p>The <code id=the-location-interface:dom-location-host-2><a href=#dom-location-host>host</a></code> attribute's setter must run these steps:</p>

  <ol><li><p>If this <code id=the-location-interface:location-40><a href=#location>Location</a></code> object's <a href=#relevant-document id=the-location-interface:relevant-document-8>relevant <code>Document</code></a>'s
   <a href=#concept-origin id=the-location-interface:concept-origin-7>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://heycam.github.io/webidl/#securityerror data-x-internal=securityerror>"<code>SecurityError</code>"</a> <code id=the-location-interface:domexception-7><a data-x-internal=domexception href=https://heycam.github.io/webidl/#dfn-DOMException>DOMException</a></code>.<li><p>Let <var>copyURL</var> be a copy of this <code id=the-location-interface:location-41><a href=#location>Location</a></code> object's <a href=#concept-location-url id=the-location-interface:concept-location-url-6>url</a>.<li><p>If <var>copyURL</var>'s <a id=the-location-interface:cannot-be-a-base-url-flag href=https://url.spec.whatwg.org/#url-cannot-be-a-base-url-flag data-x-internal=cannot-be-a-base-url-flag>cannot-be-a-base-URL flag</a> is set, terminate these
   steps.<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 <var>url</var> 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 <var>state
   override</var>.<li><p><a href=#location-object-setter-navigate id=the-location-interface:location-object-setter-navigate-3><code>Location</code>-object-setter navigate</a> to <var>copyURL</var>.</ol>

  <p>The <dfn id=dom-location-hostname><code>hostname</code></dfn> attribute's getter must
  run these steps:</p>

  <ol><li><p>If this <code id=the-location-interface:location-42><a href=#location>Location</a></code> object's <a href=#relevant-document id=the-location-interface:relevant-document-9>relevant <code>Document</code></a>'s
   <a href=#concept-origin id=the-location-interface:concept-origin-8>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://heycam.github.io/webidl/#securityerror data-x-internal=securityerror>"<code>SecurityError</code>"</a> <code id=the-location-interface:domexception-8><a data-x-internal=domexception href=https://heycam.github.io/webidl/#dfn-DOMException>DOMException</a></code>.<li><p>If this <code id=the-location-interface:location-43><a href=#location>Location</a></code> object'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.<li><p>Return this <code id=the-location-interface:location-44><a href=#location>Location</a></code> object'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>.</ol>

  <p>The <code id=the-location-interface:dom-location-hostname-2><a href=#dom-location-hostname>hostname</a></code> attribute's setter must run these
  steps:</p>

  <ol><li><p>If this <code id=the-location-interface:location-45><a href=#location>Location</a></code> object's <a href=#relevant-document id=the-location-interface:relevant-document-10>relevant <code>Document</code></a>'s
   <a href=#concept-origin id=the-location-interface:concept-origin-9>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://heycam.github.io/webidl/#securityerror data-x-internal=securityerror>"<code>SecurityError</code>"</a> <code id=the-location-interface:domexception-9><a data-x-internal=domexception href=https://heycam.github.io/webidl/#dfn-DOMException>DOMException</a></code>.<li><p>Let <var>copyURL</var> be a copy of this <code id=the-location-interface:location-46><a href=#location>Location</a></code> object's <a href=#concept-location-url id=the-location-interface:concept-location-url-9>url</a>.<li><p>If <var>copyURL</var>'s <a id=the-location-interface:cannot-be-a-base-url-flag-2 href=https://url.spec.whatwg.org/#url-cannot-be-a-base-url-flag data-x-internal=cannot-be-a-base-url-flag>cannot-be-a-base-URL flag</a> is set, terminate these
   steps.<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 <var>url</var> 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 <var>state
   override</var>.<li><p><a href=#location-object-setter-navigate id=the-location-interface:location-object-setter-navigate-4><code>Location</code>-object-setter navigate</a> to <var>copyURL</var>.</ol>

  <p>The <dfn id=dom-location-port><code>port</code></dfn> attribute's getter must run these
  steps:</p>

  <ol><li><p>If this <code id=the-location-interface:location-47><a href=#location>Location</a></code> object's <a href=#relevant-document id=the-location-interface:relevant-document-11>relevant <code>Document</code></a>'s
   <a href=#concept-origin id=the-location-interface:concept-origin-10>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://heycam.github.io/webidl/#securityerror data-x-internal=securityerror>"<code>SecurityError</code>"</a> <code id=the-location-interface:domexception-10><a data-x-internal=domexception href=https://heycam.github.io/webidl/#dfn-DOMException>DOMException</a></code>.<li><p>If this <code id=the-location-interface:location-48><a href=#location>Location</a></code> object'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.<li><p>Return this <code id=the-location-interface:location-49><a href=#location>Location</a></code> object'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>.</ol>

  <p>The <code id=the-location-interface:dom-location-port-2><a href=#dom-location-port>port</a></code> attribute's setter must run these steps:</p>

  <ol><li><p>If this <code id=the-location-interface:location-50><a href=#location>Location</a></code> object's <a href=#relevant-document id=the-location-interface:relevant-document-12>relevant <code>Document</code></a>'s
   <a href=#concept-origin id=the-location-interface:concept-origin-11>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://heycam.github.io/webidl/#securityerror data-x-internal=securityerror>"<code>SecurityError</code>"</a> <code id=the-location-interface:domexception-11><a data-x-internal=domexception href=https://heycam.github.io/webidl/#dfn-DOMException>DOMException</a></code>.<li><p>Let <var>copyURL</var> be a copy of this <code id=the-location-interface:location-51><a href=#location>Location</a></code> object's <a href=#concept-location-url id=the-location-interface:concept-location-url-12>url</a>.<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.<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.<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 <var>url</var> 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 <var>state
   override</var>.<li><p><a href=#location-object-setter-navigate id=the-location-interface:location-object-setter-navigate-5><code>Location</code>-object-setter navigate</a> to <var>copyURL</var>.</ol>

  <p>The <dfn id=dom-location-pathname><code>pathname</code></dfn> attribute's getter must
  run these steps:</p>

  <ol><li><p>If this <code id=the-location-interface:location-52><a href=#location>Location</a></code> object's <a href=#relevant-document id=the-location-interface:relevant-document-13>relevant <code>Document</code></a>'s
   <a href=#concept-origin id=the-location-interface:concept-origin-12>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://heycam.github.io/webidl/#securityerror data-x-internal=securityerror>"<code>SecurityError</code>"</a> <code id=the-location-interface:domexception-12><a data-x-internal=domexception href=https://heycam.github.io/webidl/#dfn-DOMException>DOMException</a></code>.<li><p>Let <var>url</var> be this <code id=the-location-interface:location-53><a href=#location>Location</a></code> object's <a href=#concept-location-url id=the-location-interface:concept-location-url-13>url</a>.<li><p>If <var>url</var>'s <a id=the-location-interface:cannot-be-a-base-url-flag-3 href=https://url.spec.whatwg.org/#url-cannot-be-a-base-url-flag data-x-internal=cannot-be-a-base-url-flag>cannot-be-a-base-URL flag</a> is set, return the first string
   in <var>url</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>.<li><p>If <var>url</var>'s <a href=https://url.spec.whatwg.org/#concept-url-path id=the-location-interface:concept-url-path-2 data-x-internal=concept-url-path>path</a> is empty, then return the
   empty string.<li><p>Return "<code>/</code>", followed by the strings in <var>url</var>'s <a href=https://url.spec.whatwg.org/#concept-url-path id=the-location-interface:concept-url-path-3 data-x-internal=concept-url-path>path</a> (including empty strings), separated from each other by
   "<code>/</code>".</ol>

  <p>The <code id=the-location-interface:dom-location-pathname-2><a href=#dom-location-pathname>pathname</a></code> attribute's setter must run these
  steps:</p>

  <ol><li><p>If this <code id=the-location-interface:location-54><a href=#location>Location</a></code> object's <a href=#relevant-document id=the-location-interface:relevant-document-14>relevant <code>Document</code></a>'s
   <a href=#concept-origin id=the-location-interface:concept-origin-13>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://heycam.github.io/webidl/#securityerror data-x-internal=securityerror>"<code>SecurityError</code>"</a> <code id=the-location-interface:domexception-13><a data-x-internal=domexception href=https://heycam.github.io/webidl/#dfn-DOMException>DOMException</a></code>.<li><p>Let <var>copyURL</var> be a copy of this <code id=the-location-interface:location-55><a href=#location>Location</a></code> object's <a href=#concept-location-url id=the-location-interface:concept-location-url-14>url</a>.<li><p>If <var>copyURL</var>'s <a id=the-location-interface:cannot-be-a-base-url-flag-4 href=https://url.spec.whatwg.org/#url-cannot-be-a-base-url-flag data-x-internal=cannot-be-a-base-url-flag>cannot-be-a-base-URL flag</a> is set, terminate these
   steps.<li><p>Set <var>copyURL</var>'s <a href=https://url.spec.whatwg.org/#concept-url-path id=the-location-interface:concept-url-path-4 data-x-internal=concept-url-path>path</a> to the empty
   list.<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 <var>url</var> 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 <var>state
   override</var>.<li><p><a href=#location-object-setter-navigate id=the-location-interface:location-object-setter-navigate-6><code>Location</code>-object-setter navigate</a> to <var>copyURL</var>.</ol>

  <p>The <dfn id=dom-location-search><code>search</code></dfn> attribute's getter must run
  these steps:</p>

  <ol><li><p>If this <code id=the-location-interface:location-56><a href=#location>Location</a></code> object's <a href=#relevant-document id=the-location-interface:relevant-document-15>relevant <code>Document</code></a>'s
   <a href=#concept-origin id=the-location-interface:concept-origin-14>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://heycam.github.io/webidl/#securityerror data-x-internal=securityerror>"<code>SecurityError</code>"</a> <code id=the-location-interface:domexception-14><a data-x-internal=domexception href=https://heycam.github.io/webidl/#dfn-DOMException>DOMException</a></code>.<li><p>If this <code id=the-location-interface:location-57><a href=#location>Location</a></code> object'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.<li><p>Return "<code>?</code>", followed by this <code id=the-location-interface:location-58><a href=#location>Location</a></code> object'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>.</ol>

  <p>The <code id=the-location-interface:dom-location-search-2><a href=#dom-location-search>search</a></code> attribute's setter must run these
  steps:</p>

  <ol><li><p>If this <code id=the-location-interface:location-59><a href=#location>Location</a></code> object's <a href=#relevant-document id=the-location-interface:relevant-document-16>relevant <code>Document</code></a>'s
   <a href=#concept-origin id=the-location-interface:concept-origin-15>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://heycam.github.io/webidl/#securityerror data-x-internal=securityerror>"<code>SecurityError</code>"</a> <code id=the-location-interface:domexception-15><a data-x-internal=domexception href=https://heycam.github.io/webidl/#dfn-DOMException>DOMException</a></code>.<li><p>Let <var>copyURL</var> be a copy of this <code id=the-location-interface:location-60><a href=#location>Location</a></code> object's <a href=#concept-location-url id=the-location-interface:concept-location-url-17>url</a>.<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.

   <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.<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.<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
     <var>copyURL</var> as <var>url</var> 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 <var>state override</var>,
     and the <a href=#relevant-document id=the-location-interface:relevant-document-17>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> as <var>encoding override</var>.</ol>
   <li><p><a href=#location-object-setter-navigate id=the-location-interface:location-object-setter-navigate-7><code>Location</code>-object-setter navigate</a> to <var>copyURL</var>.</ol>

  <p>The <dfn id=dom-location-hash><code>hash</code></dfn> attribute's getter must run these
  steps:</p>

  <ol><li><p>If this <code id=the-location-interface:location-61><a href=#location>Location</a></code> object's <a href=#relevant-document id=the-location-interface:relevant-document-18>relevant <code>Document</code></a>'s
   <a href=#concept-origin id=the-location-interface:concept-origin-16>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://heycam.github.io/webidl/#securityerror data-x-internal=securityerror>"<code>SecurityError</code>"</a> <code id=the-location-interface:domexception-16><a data-x-internal=domexception href=https://heycam.github.io/webidl/#dfn-DOMException>DOMException</a></code>.<li><p>If this <code id=the-location-interface:location-62><a href=#location>Location</a></code> object'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.<li><p>Return "<code>#</code>", followed by this <code id=the-location-interface:location-63><a href=#location>Location</a></code> object'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>.</ol>

  <p>The <code id=the-location-interface:dom-location-hash-2><a href=#dom-location-hash>hash</a></code> attribute's setter must run these steps:</p>

  <ol><li><p>If this <code id=the-location-interface:location-64><a href=#location>Location</a></code> object's <a href=#relevant-document id=the-location-interface:relevant-document-19>relevant <code>Document</code></a>'s
   <a href=#concept-origin id=the-location-interface:concept-origin-17>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://heycam.github.io/webidl/#securityerror data-x-internal=securityerror>"<code>SecurityError</code>"</a> <code id=the-location-interface:domexception-17><a data-x-internal=domexception href=https://heycam.github.io/webidl/#dfn-DOMException>DOMException</a></code>.<li><p>Let <var>copyURL</var> be a copy of this <code id=the-location-interface:location-65><a href=#location>Location</a></code> object's <a href=#concept-location-url id=the-location-interface:concept-location-url-20>url</a>.<li><p>Let <var>input</var> be the given value with a single leading "<code>#</code>"
   removed, if any.<li><p>Set <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> to the empty
   string.<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 <var>url</var> 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 <var>state
   override</var>.<li><p><a href=#location-object-setter-navigate id=the-location-interface:location-object-setter-navigate-8><code>Location</code>-object-setter navigate</a> to <var>copyURL</var>.</ol>

  <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> attribute's setter does not special case the
  empty string to remain compatible with deployed scripts.</p>

  <hr>

  <p>When the <dfn id=dom-location-assign><code>assign(<var>url</var>)</code></dfn>
  method is invoked, the user agent must run the following steps:

  <ol><li><p>If this <code id=the-location-interface:location-66><a href=#location>Location</a></code> object's <a href=#relevant-document id=the-location-interface:relevant-document-20>relevant <code>Document</code></a>'s
   <a href=#concept-origin id=the-location-interface:concept-origin-18>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://heycam.github.io/webidl/#securityerror data-x-internal=securityerror>"<code>SecurityError</code>"</a> <code id=the-location-interface:domexception-18><a data-x-internal=domexception href=https://heycam.github.io/webidl/#dfn-DOMException>DOMException</a></code>.<li><p><a href=#parse-a-url id=the-location-interface:parse-a-url-2>Parse</a> <var>url</var> relative to the <a href=#entry-settings-object id=the-location-interface:entry-settings-object-19>entry
   settings object</a>. If that failed, throw a <a id=the-location-interface:syntaxerror-2 href=https://heycam.github.io/webidl/#syntaxerror data-x-internal=syntaxerror>"<code>SyntaxError</code>"</a>
   <code id=the-location-interface:domexception-19><a data-x-internal=domexception href=https://heycam.github.io/webidl/#dfn-DOMException>DOMException</a></code>.<li><p><a href=#location-object-navigate id=the-location-interface:location-object-navigate-2><code>Location</code>-object navigate</a> to the <a href=#resulting-url-record id=the-location-interface:resulting-url-record-2>resulting URL
   record</a>.</ol>

  <p>When the <dfn id=dom-location-replace><code>replace(<var>url</var>)</code></dfn>
  method is invoked, the user agent must run the following steps:

  <ol><li><p><a href=#parse-a-url id=the-location-interface:parse-a-url-3>Parse</a> <var>url</var> relative to the <a href=#entry-settings-object id=the-location-interface:entry-settings-object-20>entry
   settings object</a>. If that failed, throw a <a id=the-location-interface:syntaxerror-3 href=https://heycam.github.io/webidl/#syntaxerror data-x-internal=syntaxerror>"<code>SyntaxError</code>"</a>
   <code id=the-location-interface:domexception-20><a data-x-internal=domexception href=https://heycam.github.io/webidl/#dfn-DOMException>DOMException</a></code>.<li><p><a href=#location-object-navigate id=the-location-interface:location-object-navigate-3><code>Location</code>-object navigate</a> to the <a href=#resulting-url-record id=the-location-interface:resulting-url-record-3>resulting URL
   record</a> with the <var>replacement flag</var> set.</ol>

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

  <p>When the <dfn id=dom-location-reload><code>reload()</code></dfn> method is invoked, the
  user agent must run the appropriate steps from the following list:</p>

  <dl class=switch><dt>If this <code id=the-location-interface:location-67><a href=#location>Location</a></code> object's <a href=#relevant-document id=the-location-interface:relevant-document-21>relevant <code>Document</code></a>'s
   <a href=#concept-origin id=the-location-interface:concept-origin-19>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><dd><p>Throw a <a id=the-location-interface:securityerror-18 href=https://heycam.github.io/webidl/#securityerror data-x-internal=securityerror>"<code>SecurityError</code>"</a> <code id=the-location-interface:domexception-21><a data-x-internal=domexception href=https://heycam.github.io/webidl/#dfn-DOMException>DOMException</a></code>.<dt>If the currently executing <a href=#concept-task id=the-location-interface:concept-task-3>task</a> is the dispatch of a <code id=the-location-interface:event-resize><a data-x-internal=event-resize href=https://drafts.csswg.org/cssom-view/#eventdef-window-resize>resize</a></code> event in response to the user resizing the <a href=#browsing-context id=the-location-interface:browsing-context-6>browsing
   context</a><dd><p>Repaint the <a href=#browsing-context id=the-location-interface:browsing-context-7>browsing context</a> and return.<dt>If the <a href=#browsing-context id=the-location-interface:browsing-context-8>browsing context</a>'s <a href=#active-document id=the-location-interface:active-document-4>active document</a> is <a href=#an-iframe-srcdoc-document id=the-location-interface:an-iframe-srcdoc-document>an
   <code>iframe</code> <code>srcdoc</code> document</a><dd><p><a href=#process-the-iframe-attributes id=the-location-interface:process-the-iframe-attributes>Reprocess the <code>iframe</code>
   attributes</a> of the <a href=#browsing-context id=the-location-interface:browsing-context-9>browsing context</a>'s <a href=#browsing-context-container id=the-location-interface:browsing-context-container>browsing context
   container</a>.<dt>Otherwise<dd><p><a href=#navigate id=the-location-interface:navigate-2>Navigate</a> the <a href=#browsing-context id=the-location-interface:browsing-context-10>browsing context</a> to
   this <code id=the-location-interface:location-68><a href=#location>Location</a></code> object'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-url id="the-location-interface:the-document's-address-4" data-x-internal="the-document's-address">URL</a> to perform an <a href=#entry-update id=the-location-interface:entry-update>entry update</a> of the
   <a href=#browsing-context id=the-location-interface:browsing-context-11>browsing context</a>'s <a href=#current-entry id=the-location-interface:current-entry-2>current entry</a>, with the <var><a href=#exceptions-enabled id=the-location-interface:exceptions-enabled-2>exceptions
   enabled flag</a></var> set. The <a href=#source-browsing-context id=the-location-interface:source-browsing-context-2>source browsing context</a> must be the
   <a href=#browsing-context id=the-location-interface:browsing-context-12>browsing context</a> being navigated. This is a <a href=#reload-triggered-navigation id=the-location-interface:reload-triggered-navigation>reload-triggered
   navigation</a>. Rethrow any exceptions.</dl>

  <p>When a user requests that the <a href=#active-document id=the-location-interface:active-document-5>active document</a> of a <a href=#browsing-context id=the-location-interface:browsing-context-13>browsing context</a>
  be reloaded through a user interface element, the user agent should <a href=#navigate id=the-location-interface:navigate-3>navigate</a> the <a href=#browsing-context id=the-location-interface:browsing-context-14>browsing context</a> to the same resource as that
  <code id=the-location-interface:document-9><a href=#document>Document</a></code>, to perform an <a href=#entry-update id=the-location-interface:entry-update-2>entry update</a> of the <a href=#browsing-context id=the-location-interface:browsing-context-15>browsing
  context</a>'s <a href=#current-entry id=the-location-interface:current-entry-3>current entry</a>. This is a <a href=#reload-triggered-navigation id=the-location-interface:reload-triggered-navigation-2>reload-triggered navigation</a>.
  In the case of non-idempotent methods (e.g. HTTP POST), the user agent should prompt the user to
  confirm the operation first, since otherwise transactions (e.g. purchases or database
  modifications) could be repeated. User agents may allow the user to explicitly override any caches
  when reloading.</p>

  <hr>

  <p>The <dfn id=dom-location-ancestororigins><code>ancestorOrigins</code></dfn> attribute's
  getter must run these steps:

  <ol><li><p>If this <code id=the-location-interface:location-69><a href=#location>Location</a></code> object's <a href=#relevant-document id=the-location-interface:relevant-document-23>relevant <code>Document</code></a>'s
   <a href=#concept-origin id=the-location-interface:concept-origin-20>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://heycam.github.io/webidl/#securityerror data-x-internal=securityerror>"<code>SecurityError</code>"</a> <code id=the-location-interface:domexception-22><a data-x-internal=domexception href=https://heycam.github.io/webidl/#dfn-DOMException>DOMException</a></code>.<li><p>Otherwise, return this <code id=the-location-interface:location-70><a href=#location>Location</a></code> object's <a href=#concept-location-ancestor-origins-list id=the-location-interface:concept-location-ancestor-origins-list-2>ancestor origins list</a>.</ol>

  <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-71><a href=#location>Location</a></code> exotic object
  requires additional logic beyond IDL for security purposes. The internal slot and internal methods
  <code id=the-location-interface:location-72><a href=#location>Location</a></code> objects must implement are defined below.</p>

  <p>Every <code id=the-location-interface:location-73><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>

  <h5 id=location-getprototypeof><span class=secno>7.7.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.github.io/ecma262/#sec-ordinarygetprototypeof data-x-internal=ordinarygetprototypeof>OrdinaryGetPrototypeOf</a>(<b>this</b>).<li><p>Return null.</ol>

  <h5 id=location-setprototypeof><span class=secno>7.7.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.github.io/ecma262/#sec-set-immutable-prototype data-x-internal=setimmutableprototype>SetImmutablePrototype</a>(<b>this</b>, <var>V</var>).</ol>

  <h5 id=location-isextensible><span class=secno>7.7.4.3</span> [[IsExtensible]] ( )<a href=#location-isextensible class=self-link></a></h5>

  <ol><li><p>Return true.</ol>

  <h5 id=location-preventextensions><span class=secno>7.7.4.4</span> [[PreventExtensions]] ( )<a href=#location-preventextensions class=self-link></a></h5>

  <ol><li><p>Return false.</ol>

  <h5 id=location-getownproperty><span class=secno>7.7.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.github.io/ecma262/#sec-ordinarygetownproperty data-x-internal=ordinarygetownproperty>OrdinaryGetOwnProperty</a>(<b>this</b>,
     <var>P</var>).<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.<li><p>Return <var>desc</var>.</ol>
   <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>).<li><p>If <var>property</var> is not undefined, return <var>property</var>.<li><p>Throw a <a id=location-getownproperty:securityerror href=https://heycam.github.io/webidl/#securityerror data-x-internal=securityerror>"<code>SecurityError</code>"</a> <code id=location-getownproperty:domexception><a data-x-internal=domexception href=https://heycam.github.io/webidl/#dfn-DOMException>DOMException</a></code>.</ol>

  <h5 id=location-defineownproperty><span class=secno>7.7.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.<li><p>Return ? <a id=location-defineownproperty:ordinarydefineownproperty href=https://tc39.github.io/ecma262/#sec-ordinarydefineownproperty data-x-internal=ordinarydefineownproperty>OrdinaryDefineOwnProperty</a>(<b>this</b>, <var>P</var>,
     <var>Desc</var>).</ol>
   <li><p>Throw a <a id=location-defineownproperty:securityerror href=https://heycam.github.io/webidl/#securityerror data-x-internal=securityerror>"<code>SecurityError</code>"</a> <code id=location-defineownproperty:domexception><a data-x-internal=domexception href=https://heycam.github.io/webidl/#dfn-DOMException>DOMException</a></code>.</ol>

  <h5 id=location-get><span class=secno>7.7.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.github.io/ecma262/#sec-ordinaryget data-x-internal=ordinaryget>OrdinaryGet</a>(<b>this</b>, <var>P</var>, <var>Receiver</var>).<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>).</ol>

  <h5 id=location-set><span class=secno>7.7.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.github.io/ecma262/#sec-ordinaryset data-x-internal=ordinaryset>OrdinarySet</a>(<b>this</b>, <var>P</var>, <var>Receiver</var>).<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>).</ol>

  <h5 id=location-delete><span class=secno>7.7.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.github.io/ecma262/#sec-ordinarydelete data-x-internal=ordinarydelete>OrdinaryDelete</a>(<b>this</b>, <var>P</var>).<li><p>Throw a <a id=location-delete:securityerror href=https://heycam.github.io/webidl/#securityerror data-x-internal=securityerror>"<code>SecurityError</code>"</a> <code id=location-delete:domexception><a data-x-internal=domexception href=https://heycam.github.io/webidl/#dfn-DOMException>DOMException</a></code>.</ol>

  <h5 id=location-ownpropertykeys><span class=secno>7.7.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.github.io/ecma262/#sec-ordinaryownpropertykeys data-x-internal=ordinaryownpropertykeys>OrdinaryOwnPropertyKeys</a>(<b>this</b>).<li><p>Return ! <a href=#crossoriginownpropertykeys-(-o-) id=location-ownpropertykeys:crossoriginownpropertykeys-(-o-)>CrossOriginOwnPropertyKeys</a>(<b>this</b>).</ol>

  


  <h3 id=browsing-the-web><span class=secno>7.8</span> Browsing the Web<a href=#browsing-the-web class=self-link></a></h3>

  

  <h4 id=navigating-across-documents><span class=secno>7.8.1</span> Navigating across documents<a href=#navigating-across-documents class=self-link></a></h4>

  <p>Certain actions cause the <a href=#browsing-context id=navigating-across-documents:browsing-context>browsing context</a> to <i id=navigating-across-documents:navigate><a href=#navigate>navigate</a></i> to
  a new resource. A user agent may provide various ways for the user to explicitly cause a browsing
  context to navigate, in addition to those defined in this specification.</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 a browsing context to
  navigate.</p>

  <p class=note>A <i>resource</i> has a URL, but that might not be the only information necessary
  to identify it. For example, a form submission that uses HTTP POST would also have the HTTP method
  and payload. Similarly, <a href=#an-iframe-srcdoc-document id=navigating-across-documents:an-iframe-srcdoc-document>an <code>iframe</code> <code>srcdoc</code> document</a> needs to know the data it is to use.</p>

  <p>Navigation always involves <dfn id=source-browsing-context data-export="">source browsing context</dfn>, which is the
  browsing context which was responsible for starting the navigation.</p>

  <p class=XXX>As explained in <a href=https://github.com/whatwg/html/issues/1130>issue #1130</a> the use of a browsing context as
  source might not be the correct architecture.</p>

  
  
  <p>To <dfn id=navigate data-export="">navigate</dfn> a browsing context <var>browsingContext</var> to a
  resource <var>resource</var>, optionally with an <dfn data-export="" id=exceptions-enabled><var>exceptions enabled flag</var></dfn>, the user agent must run these steps:</p>

  <ol><li><p>If <var>resource</var> is a <a id=navigating-across-documents:url href=https://url.spec.whatwg.org/#concept-url data-x-internal=url>URL</a>, then set <var>resource</var> to a new <a href=https://fetch.spec.whatwg.org/#concept-request id=navigating-across-documents:concept-request data-x-internal=concept-request>request</a> whose <a href=https://fetch.spec.whatwg.org/#concept-request-url id=navigating-across-documents:concept-request-url data-x-internal=concept-request-url>url</a> is
   <var>resource</var>.<li><p>If <var>resource</var> is a <a href=https://fetch.spec.whatwg.org/#concept-request id=navigating-across-documents:concept-request-2 data-x-internal=concept-request>request</a> and this is
   a <dfn id=reload-triggered-navigation>reload-triggered navigation</dfn>, then set <var>resource</var>'s <a href=https://fetch.spec.whatwg.org/#concept-request-reload-navigation-flag id=navigating-across-documents:concept-request-reload-navigation-flag data-x-internal=concept-request-reload-navigation-flag>reload-navigation flag</a>.

   <li id=sandboxLinks>
    <p>If the <a href=#source-browsing-context id=navigating-across-documents:source-browsing-context>source browsing context</a> is not <a href=#allowed-to-navigate id=navigating-across-documents:allowed-to-navigate>allowed to navigate</a>
    <var>browsingContext</var>, then:</p>

    <ol><li><p>If the <var><a href=#exceptions-enabled id=navigating-across-documents:exceptions-enabled>exceptions enabled flag</a></var> is set, then throw a
     <a id=navigating-across-documents:securityerror href=https://heycam.github.io/webidl/#securityerror data-x-internal=securityerror>"<code>SecurityError</code>"</a> <code id=navigating-across-documents:domexception><a data-x-internal=domexception href=https://heycam.github.io/webidl/#dfn-DOMException>DOMException</a></code>.<li>
      <p>Otherwise, the user agent may instead offer to open <var>resource</var> in a new
      <a href=#top-level-browsing-context id=navigating-across-documents:top-level-browsing-context>top-level browsing context</a> or in the <a href=#top-level-browsing-context id=navigating-across-documents:top-level-browsing-context-2>top-level browsing context</a> of
      the <a href=#source-browsing-context id=navigating-across-documents:source-browsing-context-2>source browsing context</a>, at the user's option, in which case the user agent
      must <a href=#navigate id=navigating-across-documents:navigate-2>navigate</a> that designated <a href=#top-level-browsing-context id=navigating-across-documents:top-level-browsing-context-3>top-level
      browsing context</a> to <var>resource</var> as if the user had requested it
      independently.</p>

      <p class=note>Doing so, however, can be dangerous, as it means that the user is overriding
      the author's explicit request to sandbox the content.</p>
     </ol>
   <li><p>If there is a preexisting attempt to navigate <var>browsingContext</var>, and the
   <a href=#source-browsing-context id=navigating-across-documents:source-browsing-context-3>source browsing context</a> is the same as <var>browsingContext</var>, and that attempt
   is currently running the <a href=#unload-a-document id=navigating-across-documents:unload-a-document>unload a document</a> algorithm, then return without
   affecting the preexisting attempt to navigate <var>browsingContext</var>.<li><p>If the <a href=#prompt-to-unload-a-document id=navigating-across-documents:prompt-to-unload-a-document>prompt to unload</a> algorithm is being run for the <a href=#active-document id=navigating-across-documents:active-document>active
   document</a> of <var>browsingContext</var>, then return without affecting the
   <a href=#prompt-to-unload-a-document id=navigating-across-documents:prompt-to-unload-a-document-2>prompt to unload</a> algorithm.<li id=navigate-fragid-step><p>If this is not a <a href=#reload-triggered-navigation id=navigating-across-documents:reload-triggered-navigation>reload-triggered navigation</a>,
   <var>resource</var> is a <a href=https://fetch.spec.whatwg.org/#concept-request id=navigating-across-documents:concept-request-3 data-x-internal=concept-request>request</a>, <var>resource</var>'s
   <a href=https://fetch.spec.whatwg.org/#concept-request-url id=navigating-across-documents:concept-request-url-2 data-x-internal=concept-request-url>url</a> <a href=https://url.spec.whatwg.org/#concept-url-equals id=navigating-across-documents:concept-url-equals data-x-internal=concept-url-equals>equals</a>
   <var>browsingContext</var>'s <a href=#active-document id=navigating-across-documents:active-document-2>active document</a>'s <a href=https://dom.spec.whatwg.org/#concept-document-url id="navigating-across-documents:the-document's-address" data-x-internal="the-document's-address">URL</a> with <var>exclude fragments flag</var> set, and
   <var>resource</var>'s <a href=https://fetch.spec.whatwg.org/#concept-request-url id=navigating-across-documents:concept-request-url-3 data-x-internal=concept-request-url>url</a>'s <a href=https://url.spec.whatwg.org/#concept-url-fragment id=navigating-across-documents:concept-url-fragment data-x-internal=concept-url-fragment>fragment</a> is non-null, then <a href=#scroll-to-fragid id=navigating-across-documents:scroll-to-fragid>navigate to that fragment</a>, with <a href=#replacement-enabled id=navigating-across-documents:replacement-enabled>replacement enabled</a>
   if this was invoked with <a href=#replacement-enabled id=navigating-across-documents:replacement-enabled-2>replacement enabled</a>, and return.<li><p>Cancel any preexisting but not yet <a href=#concept-navigate-mature id=navigating-across-documents:concept-navigate-mature>mature</a>
   attempt to navigate <var>browsingContext</var>, including canceling any instances of the <a href=https://fetch.spec.whatwg.org/#concept-fetch id=navigating-across-documents:concept-fetch data-x-internal=concept-fetch>fetch</a> algorithm started by those attempts. If one of those attempts
   has already created and <a href=#initialise-the-document-object id=navigating-across-documents:initialise-the-document-object>initialized a new
   <code>Document</code> object</a>, <a href=#abort-a-document id=navigating-across-documents:abort-a-document>abort</a> that
   <code id=navigating-across-documents:document><a href=#document>Document</a></code> also. (Navigation attempts that have <a href=#concept-navigate-mature id=navigating-across-documents:concept-navigate-mature-2>matured</a> already have session history entries, and are
   therefore handled during the <a href=#update-the-session-history-with-the-new-page id=navigating-across-documents:update-the-session-history-with-the-new-page>update the session history with the new page</a> algorithm,
   later.)<li>
    <p><a href=#prompt-to-unload-a-document id=navigating-across-documents:prompt-to-unload-a-document-3>Prompt to unload</a> the <a href=#active-document id=navigating-across-documents:active-document-3>active document</a> of <var>browsingContext</var>.
    If the user <a href=#refused-to-allow-the-document-to-be-unloaded id=navigating-across-documents:refused-to-allow-the-document-to-be-unloaded>refused to allow the document to be unloaded</a>, then return.</p>

    <p>If this instance of the <a href=#navigate id=navigating-across-documents:navigate-3>navigation</a> algorithm gets canceled
    while this step is running, the <a href=#prompt-to-unload-a-document id=navigating-across-documents:prompt-to-unload-a-document-4>prompt to unload</a> algorithm must nonetheless be run
    to completion.</p>
   <li><p><a href=#abort-a-document id=navigating-across-documents:abort-a-document-2>Abort</a> the <a href=#active-document id=navigating-across-documents:active-document-4>active document</a> of
   <var>browsingContext</var>.<li>

    <p>If <var>browsingContext</var> is a <a href=#nested-browsing-context id=navigating-across-documents:nested-browsing-context>nested browsing context</a>, then put it in the
    <a href=#delaying-load-events-mode id=navigating-across-documents:delaying-load-events-mode>delaying <code>load</code> events mode</a>.</p>

    <p>The user agent must take this <a href=#nested-browsing-context id=navigating-across-documents:nested-browsing-context-2>nested browsing context</a> out of the <a href=#delaying-load-events-mode id=navigating-across-documents:delaying-load-events-mode-2>delaying
    <code>load</code> events mode</a> when this <a href=#navigate id=navigating-across-documents:navigate-4>navigation</a> algorithm later <a href=#concept-navigate-mature id=navigating-across-documents:concept-navigate-mature-3>matures</a>, or when it terminates (whether due to having
    run all the steps, or being canceled, or being aborted), whichever happens first.</p>

    

   <li><p>Let <var>navigationType</var> be "<code>form-submission</code>" if the <a href=#navigate id=navigating-across-documents:navigate-5>navigation algorithm</a> was invoked as a result of the <a href=#concept-form-submit id=navigating-across-documents:concept-form-submit-2>form submission algorithm</a>, and "<code>other</code>"
   otherwise.<li><p>Return to whatever algorithm invoked the navigation steps and continue running these steps
   <a href=#in-parallel id=navigating-across-documents:in-parallel>in parallel</a>.<li>

    <p>This is the step that attempts to obtain <var>resource</var>, if necessary. Jump to the first
    appropriate substep:</p>

    <dl><dt>If <var>resource</var> is a <a href=https://fetch.spec.whatwg.org/#concept-response id=navigating-across-documents:concept-response data-x-internal=concept-response>response</a><dd><p>Run <a href=#process-a-navigate-response id=navigating-across-documents:process-a-navigate-response>process a navigate response</a> with null, <var>resource</var>,
     <var>navigationType</var>, the <a href=#source-browsing-context id=navigating-across-documents:source-browsing-context-4>source browsing context</a>, and
     <var>browsingContext</var>, and then return.<dt>If <var>resource</var> is a <a href=https://fetch.spec.whatwg.org/#concept-request id=navigating-across-documents:concept-request-4 data-x-internal=concept-request>request</a> whose <a href=https://fetch.spec.whatwg.org/#concept-request-url id=navigating-across-documents:concept-request-url-4 data-x-internal=concept-request-url>url</a>'s <a href=https://url.spec.whatwg.org/#concept-url-scheme id=navigating-across-documents:concept-url-scheme data-x-internal=concept-url-scheme>scheme</a>
     is "<code id=navigating-across-documents:javascript-protocol><a href=#javascript-protocol>javascript</a></code>"<dd>

      

      <p><a href=#queue-a-task id=navigating-across-documents:queue-a-task>Queue a task</a> to run <dfn id=javascript-protocol>these
      "<code>javascript:</code> URL" steps</dfn>, associated with the <a href=#active-document id=navigating-across-documents:active-document-5>active document</a>
      of <var>browsingContext</var>:</p>

      <ol id=concept-js-deref><li>
        <p>Let <var>result</var> be undefined, and jump to the step labeled <i>process result</i>
        below if either of the following are true:</p>

        <ul><li>
          <p>The <a href=#source-browsing-context id=navigating-across-documents:source-browsing-context-5>source browsing context</a>'s <a href=#active-document id=navigating-across-documents:active-document-6>active document</a>'s
          <a href=#concept-origin id=navigating-across-documents:concept-origin>origin</a> is not the <a href=#same-origin id=navigating-across-documents:same-origin>same origin</a> as <var>browsingContext</var>'s
          <a href=#active-document id=navigating-across-documents:active-document-7>active document</a>'s <a href=#concept-origin id=navigating-across-documents:concept-origin-2>origin</a>.</p>

          <p class=XXX>As explained in <a href=https://github.com/whatwg/html/issues/2591>issue #2591</a> this step does not work
          and presents a security issue.</p>
         <li><p>The <a id=navigating-across-documents:should-navigation-request-of-type-from-source-in-target-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-from-source-in-target-be-blocked-by-content-security-policy>Should navigation request of type from source in target be blocked by
         Content Security Policy?</a> algorithm returns "<code>Blocked</code>" when
         executed upon <var>resource</var>, "<code>other</code>", the <a href=#source-browsing-context id=navigating-across-documents:source-browsing-context-6>source
         browsing context</a>, and <var>browsingContext</var>. <a href=#refsCSP>[CSP]</a></ul>
       <li><p>Let <var>urlString</var> be the result of running the <a href=https://url.spec.whatwg.org/#concept-url-serializer id=navigating-across-documents:concept-url-serializer data-x-internal=concept-url-serializer>URL serializer</a> on <var>resource</var>'s <a href=https://fetch.spec.whatwg.org/#concept-request-url id=navigating-across-documents:concept-request-url-5 data-x-internal=concept-request-url>url</a>.<li><p>Remove the leading "<code>javascript:</code>" string from
       <var>urlString</var>.<li><p>Let <var>script source</var> be the result of <a href=https://url.spec.whatwg.org/#string-percent-decode id=navigating-across-documents:string-percent-decode data-x-internal=string-percent-decode>string percent decoding</a> <var>urlString</var>.<li><p>Replace <var>script source</var> with the result of applying the <a id=navigating-across-documents:utf-8-decode href=https://encoding.spec.whatwg.org/#utf-8-decode data-x-internal=utf-8-decode>UTF-8
       decode</a> algorithm to <var>script source</var>.<li><p>Let <var>address</var> be the <a href=https://dom.spec.whatwg.org/#concept-document-url id="navigating-across-documents:the-document's-address-2" data-x-internal="the-document's-address">URL</a> of the
       <a href=#active-document id=navigating-across-documents:active-document-8>active document</a> of <var>browsingContext</var>.<li><p>Let <var>settings</var> be the <a href=#relevant-settings-object id=navigating-across-documents:relevant-settings-object>relevant settings object</a> for the
       <a href=#active-document id=navigating-across-documents:active-document-9>active document</a> of <var>browsingContext</var>.<li><p>Let <var>base URL</var> be <var>settings object</var>'s <a href=#api-base-url id=navigating-across-documents:api-base-url>API base
       URL</a>.<li><p>Let <var>script</var> be the result of <a href=#creating-a-classic-script id=navigating-across-documents:creating-a-classic-script>creating a classic script</a> given
       <var>script source</var>, <var>settings</var>, <var>base URL</var>, and the <a href=#default-classic-script-fetch-options id=navigating-across-documents:default-classic-script-fetch-options>default
       classic script fetch options</a>.<li><p>Let <var>evaluationStatus</var> be the result of <a href=#run-a-classic-script id=navigating-across-documents:run-a-classic-script>running the classic script</a> <var>script</var>.<li><p>Let <var>result</var> be undefined if <var>evaluationStatus</var> is an
       <a id=navigating-across-documents:abrupt-completion href=https://tc39.github.io/ecma262/#sec-completion-record-specification-type data-x-internal=abrupt-completion>abrupt completion</a> or <var>evaluationStatus</var>.[[Value]] is
       empty, or <var>evaluationStatus</var>.[[Value]] otherwise.<li><p>Let <var>response</var> be null.<li>

        <p><i>Process result</i>: If <a href=https://tc39.github.io/ecma262/#sec-ecmascript-data-types-and-values id=navigating-across-documents:js-type data-x-internal=js-type>Type</a>(<var>result</var>) is not
        String, then set <var>response</var> to a <a href=https://fetch.spec.whatwg.org/#concept-response id=navigating-across-documents:concept-response-2 data-x-internal=concept-response>response</a> whose <a href=https://fetch.spec.whatwg.org/#concept-response-status id=navigating-across-documents:concept-response-status data-x-internal=concept-response-status>status</a> is <code>204</code>.</p>

        <p>Otherwise, set <var>response</var> a <a href=https://fetch.spec.whatwg.org/#concept-response id=navigating-across-documents:concept-response-3 data-x-internal=concept-response>response</a>
        whose <a href=https://fetch.spec.whatwg.org/#concept-response-header-list id=navigating-across-documents:concept-response-header-list data-x-internal=concept-response-header-list>header list</a> consists of `<code>Content-Type</code>`/`<code id=navigating-across-documents:text/html><a href=#text/html>text/html</a></code>` and `<code id=navigating-across-documents: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>`/<var>settings</var>'s <a id=navigating-across-documents:referrer-policy href=https://w3c.github.io/webappsec-referrer-policy/#referrer-policy data-x-internal=referrer-policy>referrer
        policy</a>, whose <a href=https://fetch.spec.whatwg.org/#concept-response-body id=navigating-across-documents:concept-response-body data-x-internal=concept-response-body>body</a> is <var>result</var>,
        and whose <a href=https://fetch.spec.whatwg.org/#concept-response-https-state id=navigating-across-documents:concept-response-https-state data-x-internal=concept-response-https-state>HTTPS state</a> is
        <var>settings</var>'s <a href=#https-state id=navigating-across-documents:https-state>HTTPS state</a>.</p>

        <p class=warning>The exact conversion between the JavaScript string <var>result</var> and
        the bytes that comprise a <a href=https://fetch.spec.whatwg.org/#concept-response-body id=navigating-across-documents:concept-response-body-2 data-x-internal=concept-response-body>response body</a> is
        not yet specified, pending further investigation into user agent behavior. See <a href=https://github.com/whatwg/html/issues/1129>issue #1129</a>.</p>
       <li><p>Run <a href=#process-a-navigate-response id=navigating-across-documents:process-a-navigate-response-2>process a navigate response</a> with <var>resource</var>,
       <var>response</var>, <var>navigationType</var>, the <a href=#source-browsing-context id=navigating-across-documents:source-browsing-context-7>source browsing context</a>, and
       <var>browsingContext</var>, and then return.</ol>

      <p>The <a href=#task-source id=navigating-across-documents:task-source>task source</a> for this <a href=#concept-task id=navigating-across-documents:concept-task>task</a> is the
      <a href=#dom-manipulation-task-source id=navigating-across-documents:dom-manipulation-task-source>DOM manipulation task source</a>.</p>

      <div class=example>

       <p>So for example a <a href=#javascript-protocol id=navigating-across-documents:javascript-protocol-2><code>javascript:</code> URL</a> in
       an <code id=navigating-across-documents:attr-hyperlink-href><a href=#attr-hyperlink-href>href</a></code> attribute of an <code id=navigating-across-documents:the-a-element><a href=#the-a-element>a</a></code> element
       would only be evaluated when the link was <a href=#following-hyperlinks-2 id=navigating-across-documents:following-hyperlinks-2-2>followed</a>, while such a URL in the <code id=navigating-across-documents:attr-iframe-src><a href=#attr-iframe-src>src</a></code> attribute of an <code id=navigating-across-documents:the-iframe-element><a href=#the-iframe-element>iframe</a></code> element would be
       evaluated in the context of the <code id=navigating-across-documents:the-iframe-element-2><a href=#the-iframe-element>iframe</a></code>'s own <a href=#nested-browsing-context id=navigating-across-documents:nested-browsing-context-3>nested browsing
       context</a> when the <code id=navigating-across-documents:the-iframe-element-3><a href=#the-iframe-element>iframe</a></code> is being set up; once evaluated, its return value
       (if it was a string) would replace that <a href=#browsing-context id=navigating-across-documents:browsing-context-2>browsing context</a>'s
       <code id=navigating-across-documents:document-2><a href=#document>Document</a></code>, thus also changing the <code id=navigating-across-documents:window><a href=#window>Window</a></code> object of that
       <a href=#browsing-context id=navigating-across-documents:browsing-context-3>browsing context</a>.</p>

      </div>

     <dt>If <var>resource</var> is to be fetched using `<code>GET</code>`, and there are
     <a href=#relevant-application-cache id=navigating-across-documents:relevant-application-cache>relevant application caches</a> that are
     identified by a URL with the <a href=#same-origin id=navigating-across-documents:same-origin-2>same origin</a> as the URL in question, and that have
     this URL as one of their entries, excluding entries marked as <a href=#concept-appcache-foreign id=navigating-across-documents:concept-appcache-foreign>foreign</a>, and whose <a href=#concept-appcache-mode id=navigating-across-documents:concept-appcache-mode>mode</a> is <a href=#concept-appcache-mode-fast id=navigating-across-documents:concept-appcache-mode-fast>fast</a>, and the user agent is not in a mode where it
     will avoid using <a href=#application-cache id=navigating-across-documents:application-cache>application caches</a><dd>

      <p>Fetch <var>resource</var> from the <a href=#concept-appcache-selection id=navigating-across-documents:concept-appcache-selection>most
      appropriate application cache</a> of those that match.</p>

      <p class=example>For example, imagine an HTML page with an associated application cache
      displaying an image and a form, where the image is also used by several other application
      caches. If the user right-clicks on the image and chooses "View Image", then the user agent
      could decide to show the image from any of those caches, but it is likely that the most useful
      cache for the user would be the one that was used for the aforementioned HTML page. On the
      other hand, if the user submits the form, and the form does a POST submission, then the user
      agent will not use an application cache at all; the submission will be made to the
      network.</p>

      <p class=XXX>This still needs to be integrated with the Fetch
      standard. <a href=#refsFETCH>[FETCH]</a></p>

     <dt>If <var>resource</var> is a <a href=https://fetch.spec.whatwg.org/#concept-request id=navigating-across-documents:concept-request-5 data-x-internal=concept-request>request</a> whose <a href=https://fetch.spec.whatwg.org/#concept-request-url id=navigating-across-documents:concept-request-url-6 data-x-internal=concept-request-url>url</a>'s <a href=https://url.spec.whatwg.org/#concept-url-scheme id=navigating-across-documents:concept-url-scheme-2 data-x-internal=concept-url-scheme>scheme</a>
     is a <a id=navigating-across-documents:fetch-scheme href=https://fetch.spec.whatwg.org/#fetch-scheme data-x-internal=fetch-scheme>fetch scheme</a><dd><p>Run <a href=#process-a-navigate-fetch id=navigating-across-documents:process-a-navigate-fetch>process a navigate fetch</a> given <var>resource</var>, the <a href=#source-browsing-context id=navigating-across-documents:source-browsing-context-8>source
     browsing context</a>, and <var>browsingContext</var>, and <var>navigationType</var>.<dt>Otherwise, <var>resource</var> is a <a href=https://fetch.spec.whatwg.org/#concept-request id=navigating-across-documents:concept-request-6 data-x-internal=concept-request>request</a> whose
     <a href=https://fetch.spec.whatwg.org/#concept-request-url id=navigating-across-documents:concept-request-url-7 data-x-internal=concept-request-url>url</a>'s <a href=https://url.spec.whatwg.org/#concept-url-scheme id=navigating-across-documents:concept-url-scheme-3 data-x-internal=concept-url-scheme>scheme</a>
     is neither "<code id=navigating-across-documents:javascript-protocol-3><a href=#javascript-protocol>javascript</a></code>" nor a <a id=navigating-across-documents:fetch-scheme-2 href=https://fetch.spec.whatwg.org/#fetch-scheme data-x-internal=fetch-scheme>fetch
     scheme</a><dd><p>Run <a href=#process-a-navigate-url-scheme id=navigating-across-documents:process-a-navigate-url-scheme>process a navigate URL scheme</a> given <var>resource</var>'s <a href=https://fetch.spec.whatwg.org/#concept-request-url id=navigating-across-documents:concept-request-url-8 data-x-internal=concept-request-url>url</a> and <var>browsingContext</var>.</dl>
   </ol>

  <p>To <dfn id=process-a-navigate-fetch data-export="">process a navigate fetch</dfn>, given a <a href=https://fetch.spec.whatwg.org/#concept-request id=navigating-across-documents:concept-request-7 data-x-internal=concept-request>request</a> <var>request</var>, <a href=#browsing-context id=navigating-across-documents:browsing-context-4>browsing context</a>
  <var>sourceBrowsingContext</var>, <a href=#browsing-context id=navigating-across-documents:browsing-context-5>browsing context</a> <var>browsingContext</var>, and
  string <var>navigationType</var>, run these steps:</p>

  <ol><li><p>Let <var>response</var> be null.<li><p>Set <var>request</var>'s <a href=https://fetch.spec.whatwg.org/#concept-request-client id=navigating-across-documents:concept-request-client data-x-internal=concept-request-client>client</a> to
   <var>sourceBrowsingContext</var>'s <a href=#active-document id=navigating-across-documents:active-document-10>active document</a>'s <a href=#relevant-settings-object id=navigating-across-documents:relevant-settings-object-2>relevant settings
   object</a>, <a href=https://fetch.spec.whatwg.org/#concept-request-destination id=navigating-across-documents:concept-request-destination data-x-internal=concept-request-destination>destination</a> to "<code>document</code>", <a href=https://fetch.spec.whatwg.org/#concept-request-mode id=navigating-across-documents:concept-request-mode data-x-internal=concept-request-mode>mode</a> to "<code>navigate</code>", <a href=https://fetch.spec.whatwg.org/#concept-request-credentials-mode id=navigating-across-documents:concept-request-credentials-mode data-x-internal=concept-request-credentials-mode>credentials
   mode</a> to "<code>include</code>", <a id=navigating-across-documents: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>, <a href=https://fetch.spec.whatwg.org/#concept-request-redirect-mode id=navigating-across-documents:concept-request-redirect-mode data-x-internal=concept-request-redirect-mode>redirect mode</a> to "<code>manual</code>",
   and <a href=https://fetch.spec.whatwg.org/#concept-request-replaces-client-id id=navigating-across-documents:concept-request-replaces-client-id data-x-internal=concept-request-replaces-client-id>replaces client id</a> to
   <var>browsingContext</var>'s <a href=#active-document id=navigating-across-documents:active-document-11>active document</a>'s <a href=#relevant-settings-object id=navigating-across-documents:relevant-settings-object-3>relevant settings
   object</a>'s <a href=#concept-environment-id id=navigating-across-documents:concept-environment-id>id</a>.<li><p>If <var>browsingContext</var> is a <a href=#child-browsing-context id=navigating-across-documents:child-browsing-context>child browsing context</a> and the
   <a href=#browsing-context-container id=navigating-across-documents:browsing-context-container>browsing context container</a> of <var>browsingContext</var> has a <a href=#browsing-context-scope-origin id=navigating-across-documents: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=navigating-across-documents:concept-request-origin data-x-internal=concept-request-origin>origin</a> to that <a href=#browsing-context-scope-origin id=navigating-across-documents:browsing-context-scope-origin-2>browsing context scope
   origin</a>.<li>
    <p>Create a new <a href=#environment id=navigating-across-documents:environment>environment</a> <var>reservedEnvironment</var>, and set its <a href=#concept-environment-id id=navigating-across-documents:concept-environment-id-2>id</a> to a new unique opaque string, its <a href=#concept-environment-creation-url id=navigating-across-documents:concept-environment-creation-url>creation URL</a> to <var>request</var>'s
    <a id=navigating-across-documents:url-2 href=https://url.spec.whatwg.org/#concept-url data-x-internal=url>url</a>, and its <a href=#concept-environment-target-browsing-context id=navigating-across-documents:concept-environment-target-browsing-context>target
    browsing context</a> to <var>browsingContext</var>.</p>

    <p class=note>The created environment's <a href=#concept-environment-active-service-worker id=navigating-across-documents: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=navigating-across-documents:on-fetch-request-algorithm data-x-internal=on-fetch-request-algorithm>handle fetch</a> algorithm during the fetch if its
    <a href=#concept-environment-creation-url id=navigating-across-documents:concept-environment-creation-url-2>creation URL</a> matches a service worker
    registration. <a href=#refsSW>[SW]</a></p>
   <li><p>Set <var>request</var>'s <a href=https://fetch.spec.whatwg.org/#concept-request-reserved-client id=navigating-across-documents:concept-request-reserved-client data-x-internal=concept-request-reserved-client>reserved
   client</a> to <var>reservedEnvironment</var>.<li>
    <p>If the <a id=navigating-across-documents:should-navigation-request-of-type-from-source-in-target-be-blocked-by-content-security-policy-2 href=https://w3c.github.io/webappsec-csp/#should-block-navigation-request data-x-internal=should-navigation-request-of-type-from-source-in-target-be-blocked-by-content-security-policy>Should navigation request of type from source in target be blocked by Content
    Security Policy?</a> algorithm returns "<code>Blocked</code>" when executed upon
    <var>request</var>, <var>navigationType</var>, <var>sourceBrowsingContext</var>, and
    <var>browsingContext</var>, then set <var>response</var> to a network error.
    <a href=#refsCSP>[CSP]</a></p>

    <p>Otherwise:</p>

    <ol><li><p><a href=https://fetch.spec.whatwg.org/#concept-fetch id=navigating-across-documents:concept-fetch-2 data-x-internal=concept-fetch>Fetch</a> <var>request</var>.<li><p>Wait for the <a href=#concept-task id=navigating-across-documents:concept-task-2>task</a> on the <a href=#networking-task-source id=navigating-across-documents:networking-task-source>networking task
     source</a> to <a id=navigating-across-documents:process-response href=https://fetch.spec.whatwg.org/#process-response data-x-internal=process-response>process response</a> and set <var>response</var> to the
     result.</ol>
   <li id=navigate-redirect-step>
    <p>If <var>response</var> has a <a href=https://fetch.spec.whatwg.org/#concept-response-location-url id=navigating-across-documents:concept-response-location-url data-x-internal=concept-response-location-url>location URL</a>
    and it is either failure or a <a id=navigating-across-documents: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=navigating-across-documents:concept-url-scheme-4 data-x-internal=concept-url-scheme>scheme</a> is an <a id=navigating-across-documents:http(s)-scheme href=https://fetch.spec.whatwg.org/#http-scheme data-x-internal=http(s)-scheme>HTTP(S) scheme</a>, then set
    <var>response</var> to the result of performing <a id=navigating-across-documents:http-redirect-fetch href=https://fetch.spec.whatwg.org/#concept-http-redirect-fetch data-x-internal=http-redirect-fetch>HTTP-redirect fetch</a> using
    <var>request</var> and <var>response</var> and then run this step again.</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=navigating-across-documents:mailto-protocol><a data-x-internal=mailto-protocol href=https://tools.ietf.org/html/rfc6068#section-2>mailto:</a></code> URLs and
    such.</p>
   <li><p>Otherwise, if <var>response</var> has a <a href=https://fetch.spec.whatwg.org/#concept-response-location-url id=navigating-across-documents:concept-response-location-url-2 data-x-internal=concept-response-location-url>location URL</a> that is a <a id=navigating-across-documents:url-4 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=navigating-across-documents:concept-url-scheme-5 data-x-internal=concept-url-scheme>scheme</a> is "<code>blob</code>", "<code>file</code>", "<code>filesystem</code>", or "<code>javascript</code>", then set <var>response</var> to a network error.<li><p>Otherwise, if <var>response</var> has a <a href=https://fetch.spec.whatwg.org/#concept-response-location-url id=navigating-across-documents:concept-response-location-url-3 data-x-internal=concept-response-location-url>location URL</a> that is a <a id=navigating-across-documents:url-5 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=navigating-across-documents:concept-url-scheme-6 data-x-internal=concept-url-scheme>scheme</a> is a <a id=navigating-across-documents:fetch-scheme-3 href=https://fetch.spec.whatwg.org/#fetch-scheme data-x-internal=fetch-scheme>fetch scheme</a>, then run
   <a href=#process-a-navigate-fetch id=navigating-across-documents:process-a-navigate-fetch-2>process a navigate fetch</a> with a new <a href=https://fetch.spec.whatwg.org/#concept-request id=navigating-across-documents:concept-request-8 data-x-internal=concept-request>request</a>
   whose <a href=https://fetch.spec.whatwg.org/#concept-request-url id=navigating-across-documents:concept-request-url-9 data-x-internal=concept-request-url>url</a> is <var>response</var>'s <a href=https://fetch.spec.whatwg.org/#concept-response-location-url id=navigating-across-documents:concept-response-location-url-4 data-x-internal=concept-response-location-url>location URL</a>, <var>sourceBrowsingContext</var>,
   <var>browsingContext</var>, and <var>navigationType</var>.

   <li><p>Otherwise, if <var>response</var> has a <a href=https://fetch.spec.whatwg.org/#concept-response-location-url id=navigating-across-documents:concept-response-location-url-5 data-x-internal=concept-response-location-url>location URL</a> that is a <a id=navigating-across-documents:url-6 href=https://url.spec.whatwg.org/#concept-url data-x-internal=url>URL</a>, run the
   <a href=#process-a-navigate-url-scheme id=navigating-across-documents:process-a-navigate-url-scheme-2>process a navigate URL scheme</a> given <var>response</var>'s <a href=https://fetch.spec.whatwg.org/#concept-response-location-url id=navigating-across-documents:concept-response-location-url-6 data-x-internal=concept-response-location-url>location URL</a> and
   <var>browsingContext</var>.<li>

    <p><strong>Fallback in prefer-online mode</strong>: If <var>response</var> was not fetched from
    an <a href=#application-cache id=navigating-across-documents:application-cache-2>application cache</a>, and was to be fetched using `<code>GET</code>`, and
    there are <a href=#relevant-application-cache id=navigating-across-documents:relevant-application-cache-2>relevant application caches</a> that are
    identified by a URL with the <a href=#same-origin id=navigating-across-documents:same-origin-3>same origin</a> as the URL in question, and that have this
    URL as one of their entries, excluding entries marked as <a href=#concept-appcache-foreign id=navigating-across-documents:concept-appcache-foreign-2>foreign</a>, and whose <a href=#concept-appcache-mode id=navigating-across-documents:concept-appcache-mode-2>mode</a> is <a href=#concept-appcache-mode-prefer-online id=navigating-across-documents:concept-appcache-mode-prefer-online>prefer-online</a>, and the user didn't cancel
    the navigation attempt during the earlier step, and <var>response</var> is either a network
    error or its <a href=https://fetch.spec.whatwg.org/#concept-response-status id=navigating-across-documents:concept-response-status-2 data-x-internal=concept-response-status>status</a> is not an <a id=navigating-across-documents:ok-status href=https://fetch.spec.whatwg.org/#ok-status data-x-internal=ok-status>ok
    status</a>, then:</p>

    <p>Let <var>candidate</var> be the response identified by the URL in question from the
    <a href=#concept-appcache-selection id=navigating-across-documents:concept-appcache-selection-2>most appropriate application cache</a> of those that
    match.</p> 

    <p>If <var>candidate</var> is not marked as <a href=#concept-appcache-foreign id=navigating-across-documents:concept-appcache-foreign-3>foreign</a>, then the user agent must discard the failed
    load and instead continue along these steps using <var>candidate</var> as <var>response</var>.
    The user agent may indicate to the user that the original page load failed, and that the page
    used was a previously cached response.</p>

   <li>

    <p><strong>Fallback for fallback entries</strong>: If <var>response</var> was not fetched from
    an <a href=#application-cache id=navigating-across-documents:application-cache-3>application cache</a>, and was to be fetched using `<code>GET</code>`, and
    its URL <a href=#concept-appcache-matches-fallback id=navigating-across-documents:concept-appcache-matches-fallback>matches the fallback namespace</a>
    of one or more <a href=#relevant-application-cache id=navigating-across-documents:relevant-application-cache-3>relevant application caches</a>, and
    the <a href=#concept-appcache-selection id=navigating-across-documents:concept-appcache-selection-3>most appropriate application cache</a> of those
    that match does not have an entry in its <a href=#concept-appcache-onlinesafelist id=navigating-across-documents:concept-appcache-onlinesafelist>online
    safelist</a> that has the <a href=#same-origin id=navigating-across-documents:same-origin-4>same origin</a> as <var>response</var>'s URL and that is a
    <a href=#prefix-match id=navigating-across-documents:prefix-match>prefix match</a> for <var>response</var>'s URL, and the user didn't cancel the
    navigation attempt during the earlier step, and <var>response</var> is either a network error or
    its <a href=https://fetch.spec.whatwg.org/#concept-response-status id=navigating-across-documents:concept-response-status-3 data-x-internal=concept-response-status>status</a> is not an <a id=navigating-across-documents:ok-status-2 href=https://fetch.spec.whatwg.org/#ok-status data-x-internal=ok-status>ok status</a>,
    then:</p>
    

    <p>Let <var>candidate</var> be the <a href=#concept-appcache-fallback id=navigating-across-documents:concept-appcache-fallback>fallback
    response</a> specified for the <a href=#concept-appcache-fallback-ns id=navigating-across-documents:concept-appcache-fallback-ns>fallback
    namespace</a> in question. If multiple application caches match, the user agent must use the
    fallback of the <a href=#concept-appcache-selection id=navigating-across-documents:concept-appcache-selection-4>most appropriate application
    cache</a> of those that match.</p>

    <p>If <var>candidate</var> is not marked as <a href=#concept-appcache-foreign id=navigating-across-documents:concept-appcache-foreign-4>foreign</a>, then the user agent must discard the failed
    load and instead continue along these steps using <var>candidate</var> as <var>response</var>.
    The document's <a href=https://dom.spec.whatwg.org/#concept-document-url id="navigating-across-documents:the-document's-address-3" data-x-internal="the-document's-address">URL</a>, if appropriate, will still be the
    originally requested URL, not the fallback URL, but the user agent may indicate to the user that
    the original page load failed, that the page used was a fallback response, and what the URL of
    the fallback response actually is.</p>
   <li><p>Run <a href=#process-a-navigate-response id=navigating-across-documents:process-a-navigate-response-3>process a navigate response</a> given <var>request</var>,
   <var>response</var>, <var>navigationType</var>, the <a href=#source-browsing-context id=navigating-across-documents:source-browsing-context-9>source browsing context</a>,
   <var>browsingContext</var>, and <var>reservedEnvironment</var>.</ol>

  <p>To <dfn id=process-a-navigate-response data-export="">process a navigate response</dfn>, given null or a <a href=https://fetch.spec.whatwg.org/#concept-request id=navigating-across-documents:concept-request-9 data-x-internal=concept-request>request</a> <var>request</var>, a <a href=https://fetch.spec.whatwg.org/#concept-response id=navigating-across-documents:concept-response-4 data-x-internal=concept-response>response</a> <var>response</var>, a string <var>navigationType</var>,
  two <a href=#browsing-context id=navigating-across-documents:browsing-context-6>browsing contexts</a> <var>source</var> and
  <var>browsingContext</var>, and an optional <a href=#environment id=navigating-across-documents:environment-2>environment</a>
  <var>reservedEnvironment</var>, run these steps:</p>

  <ol><li>
    <p>If any of the following are true, then <a href=#read-ua-inline id=navigating-across-documents:read-ua-inline>display the inline
    content with an appropriate error shown to the user</a>, with the newly created
    <code id=navigating-across-documents:document-3><a href=#document>Document</a></code> object's <a href=#concept-origin id=navigating-across-documents:concept-origin-3>origin</a> set to a new <a href=#concept-origin-opaque id=navigating-across-documents:concept-origin-opaque>opaque origin</a>, run the <a href=#environment-discarding-steps id=navigating-across-documents:environment-discarding-steps>environment discarding steps</a> for <var>reservedEnvironment</var>, and
    return.</p>

    <ul><li><p><var>response</var> is a network error.<li><p class=XXX>TODO: Define <code>X-Frame-Options</code>
     processing here [<a href=https://github.com/whatwg/html/issues/1230>whatwg/html#1230</a>].<li><p>The <a id=navigating-across-documents:should-navigation-response-to-navigation-request-of-type-from-source-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-from-source-in-target-be-blocked-by-content-security-policy>Should navigation response to navigation request of type from source in target
     be blocked by Content Security Policy?</a> algorithm returns "<code>Blocked</code>" when executed upon <var>request</var>, <var>response</var>,
     <var>navigationType</var>, <var>source</var>, and <var>browsingContext</var>. <a href=#refsCSP>[CSP]</a></ul>

    <p class=note>This is where the network errors defined and propagated by the WHATWG Fetch
    standard, such as DNS or TLS errors, end up being displayed to users. <a href=#refsFETCH>[FETCH]</a></p>
   <li><p>If <var>response</var>'s <a href=https://fetch.spec.whatwg.org/#concept-response-status id=navigating-across-documents:concept-response-status-4 data-x-internal=concept-response-status>status</a> is
   <code>204</code> or <code>205</code>, then return.<li><p>If <var>response</var> has an `<code id=navigating-across-documents:http-content-disposition><a data-x-internal=http-content-disposition href=https://tools.ietf.org/html/rfc6266>Content-Disposition</a></code>` header specifying the <code>attachment</code> disposition type, then handle it <a href=#as-a-download id=navigating-across-documents:as-a-download>as a download</a> and
   return.<li><p>Let <var>type</var> be the <a href=https://mimesniff.spec.whatwg.org/#computed-mime-type id=navigating-across-documents:content-type-sniffing-2 data-x-internal=content-type-sniffing-2>computed type of
   <var>response</var></a>.<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=#browsing-context id=navigating-across-documents:browsing-context-7>browsing context</a>, then
    skip this step. Otherwise, if the <var>type</var> is one of the following types, jump to the
    appropriate entry in the following list, and process <var>response</var> as described there:</p>

    <dl class=switch><dt>an <a id=navigating-across-documents:html-mime-type href=https://mimesniff.spec.whatwg.org/#html-mime-type data-x-internal=html-mime-type>HTML MIME type</a><dd>Follow the steps given in the <a href=#read-html id=navigating-across-documents:read-html>HTML document</a>
     section, and then, once they have completed, return.<dt>an <a id=navigating-across-documents: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=navigating-across-documents:explicitly-supported-xml-mime-type>explicitly supported XML MIME
     type</a><dd>Follow the steps given in the <a href=#read-xml id=navigating-across-documents:read-xml>XML document</a> section. If
     that section determines that the content is <em>not</em> to be displayed as a generic XML
     document, then proceed to the next step in this overall set of steps. Otherwise, once the steps
     given in the <a href=#read-xml id=navigating-across-documents:read-xml-2>XML document</a> section have completed,
     return.<dt>a <a id=navigating-across-documents:javascript-mime-type href=https://mimesniff.spec.whatwg.org/#javascript-mime-type data-x-internal=javascript-mime-type>JavaScript MIME type</a><dt>a <a id=navigating-across-documents: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=navigating-across-documents:explicitly-supported-json-mime-type>explicitly supported JSON MIME
     type</a><dt>"<code id=navigating-across-documents:text/cache-manifest><a href=#text/cache-manifest>text/cache-manifest</a></code>"<dt>"<code id=navigating-across-documents:text/css><a href=#text/css>text/css</a></code>"<dt>"<code id=navigating-across-documents:text/plain><a data-x-internal=text/plain href=https://tools.ietf.org/html/rfc2046#section-4.1.3>text/plain</a></code>"<dt>"<code id=navigating-across-documents:text/vtt><a href=#text/vtt>text/vtt</a></code>"<dd>Follow the steps given in the <a href=#read-text id=navigating-across-documents:read-text>plain text file</a>
     section, and then, once they have completed, return..<dt>"<code id=navigating-across-documents:multipart/x-mixed-replace><a href=#multipart/x-mixed-replace>multipart/x-mixed-replace</a></code>"<dd>Follow the steps given in the <a href=#read-multipart-x-mixed-replace id=navigating-across-documents:read-multipart-x-mixed-replace>multipart/x-mixed-replace</a> section, and then,
     once they have completed, return.<dt>A supported image, video, or audio type<dd>Follow the steps given in the <a href=#read-media id=navigating-across-documents:read-media>media</a> section, and then,
     once they have completed, return.<dt>A type that will use an external application to render the content in
     <var>browsingContext</var><dd>Follow the steps given in the <a href=#read-plugin id=navigating-across-documents:read-plugin>plugin</a> section, and then, once they have
     completed, return.</dl>

    <p>An <dfn id=explicitly-supported-xml-mime-type>explicitly supported XML MIME type</dfn> is an <a id=navigating-across-documents: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 (either a
    <a href=#plugin id=navigating-across-documents:plugin>plugin</a> rendering directly in <var>browsingContext</var>, or a separate
    application), or one for which the user agent has dedicated processing rules (e.g. a Web browser
    with a built-in Atom feed viewer would be said to explicitly support the
    <code id=navigating-across-documents:application/atom+xml><a href=#application/atom+xml>application/atom+xml</a></code> MIME type), or one for which the user agent has a dedicated
    handler.</p>

    <p>An <dfn id=explicitly-supported-json-mime-type>explicitly supported JSON MIME type</dfn> is a <a id=navigating-across-documents: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 (either a
    <a href=#plugin id=navigating-across-documents:plugin-2>plugin</a> rendering directly in <var>browsingContext</var>, or a separate
    application), or one for which the user agent has dedicated processing rules, or one for which
    the user agent has a dedicated handler.</p>

    <p><dfn id="set-the-document's-address">Setting the document's address</dfn>: Any
    <code id=navigating-across-documents:document-4><a href=#document>Document</a></code> created by these steps must have its <a href=https://dom.spec.whatwg.org/#concept-document-url id="navigating-across-documents:the-document's-address-4" data-x-internal="the-document's-address">URL</a> set to the <a id=navigating-across-documents:url-7 href=https://url.spec.whatwg.org/#concept-url data-x-internal=url>URL</a> that was originally to be
    fetched, ignoring any other data that was used to obtain the resource.</p>

    <p><dfn id=initialise-the-document-object data-export="">Initializing a new <code>Document</code> object</dfn>: when a
    <code id=navigating-across-documents:document-5><a href=#document>Document</a></code> is created as part of the above steps, the user agent will be required to
    additionally run the following algorithm after creating the new object:</p>

    <ol><li><p>If <var>browsingContext</var>'s only entry in its <a href=#session-history id=navigating-across-documents:session-history>session history</a> is the
     <code id=navigating-across-documents:about:blank><a href=#about:blank>about:blank</a></code> <code id=navigating-across-documents:document-6><a href=#document>Document</a></code> that was added when <var>browsingContext</var>
     was <a href=#creating-a-new-browsing-context id=navigating-across-documents:creating-a-new-browsing-context>created</a>, and navigation is occurring
     with <a href=#replacement-enabled id=navigating-across-documents:replacement-enabled-3>replacement enabled</a>, and that <code id=navigating-across-documents:document-7><a href=#document>Document</a></code> has the <a href=#same-origin id=navigating-across-documents:same-origin-5>same
     origin</a> as the new <code id=navigating-across-documents:document-8><a href=#document>Document</a></code>, then do nothing.<li>
      <p>Otherwise:</p>

      <ol><li>
        <p>Let <var>realm execution context</var> be the result of <a href=#creating-a-new-javascript-realm id=navigating-across-documents:creating-a-new-javascript-realm>creating a new JavaScript
        realm</a> with the following customizations:</p>

        <ul><li><p>For the global object, create a new <code id=navigating-across-documents:window-2><a href=#window>Window</a></code> object.<li><p>For the global <b>this</b> binding, use <var>browsingContext</var>'s
         <code id=navigating-across-documents:windowproxy><a href=#windowproxy>WindowProxy</a></code> object.</ul>
       <li><p><a href=#set-up-a-window-environment-settings-object id=navigating-across-documents:set-up-a-window-environment-settings-object>Set up a window environment settings object</a> with <var>realm execution
       context</var> and <var>reservedEnvironment</var>, if present.</ol>
     <li><p>Set the <code id=navigating-across-documents:document-9><a href=#document>Document</a></code>'s <a href=#concept-document-https-state id=navigating-across-documents:concept-document-https-state>HTTPS
     state</a> to the <a href=https://fetch.spec.whatwg.org/#concept-response-https-state id=navigating-across-documents:concept-response-https-state-2 data-x-internal=concept-response-https-state>HTTPS state</a> of
     <var>response</var>.<li><p>Set the <code id=navigating-across-documents:document-10><a href=#document>Document</a></code>'s <a href=#concept-document-referrer-policy id=navigating-across-documents:concept-document-referrer-policy>referrer
     policy</a> to the result of <a href=https://w3c.github.io/webappsec-referrer-policy/#parse-referrer-policy-from-header id=navigating-across-documents:parse-referrer-policy-header data-x-internal=parse-referrer-policy-header>parsing the
     `<code>Referrer-Policy</code>` header</a> of <var>response</var>. <a href=#refsREFERRERPOLICY>[REFERRERPOLICY]</a><li><p>Execute the <a id="navigating-across-documents:initialize-a-document's-csp-list" href=https://w3c.github.io/webappsec-csp/#initialize-document-csp data-x-internal="initialize-a-document's-csp-list">Initialize a <code>Document</code>'s CSP list</a>
     algorithm on the <code id=navigating-across-documents:document-11><a href=#document>Document</a></code> object and the <a href=https://fetch.spec.whatwg.org/#concept-response id=navigating-across-documents:concept-response-5 data-x-internal=concept-response>response</a> used to generate the document. <a href=#refsCSP>[CSP]</a></p>

     <li>
      <p>If <var>request</var> is non-null, then set <a href="#the-document's-referrer" id="navigating-across-documents:the-document's-referrer">the document's referrer</a> to the
      <a href=https://url.spec.whatwg.org/#concept-url-serializer id=navigating-across-documents:concept-url-serializer-2 data-x-internal=concept-url-serializer>serialization</a> of <var>request</var>'s <a href=https://fetch.spec.whatwg.org/#concept-request-referrer id=navigating-across-documents:concept-request-referrer data-x-internal=concept-request-referrer>referrer</a>, if <var>request</var>'s <a href=https://fetch.spec.whatwg.org/#concept-request-referrer id=navigating-across-documents:concept-request-referrer-2 data-x-internal=concept-request-referrer>referrer</a> is a <a id=navigating-across-documents:url-record href=https://url.spec.whatwg.org/#concept-url data-x-internal=url-record>URL record</a>, and the empty
      string otherwise.</p>

      <p class=note>Per the WHATWG Fetch standard a <a href=https://fetch.spec.whatwg.org/#concept-request id=navigating-across-documents:concept-request-10 data-x-internal=concept-request>request</a>'s <a href=https://fetch.spec.whatwg.org/#concept-request-referrer id=navigating-across-documents:concept-request-referrer-3 data-x-internal=concept-request-referrer>referrer</a> will be either a <a id=navigating-across-documents: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><p><a href=#implement-the-sandboxing id=navigating-across-documents:implement-the-sandboxing>Implement the sandboxing</a> for the <code id=navigating-across-documents:document-12><a href=#document>Document</a></code>.<li>
       <p>Execute the <a id=navigating-across-documents:initialize-document’s-feature-policy-from-response href=https://wicg.github.io/feature-policy/#initialize-from-response data-x-internal=initialize-document’s-feature-policy-from-response>Initialize document’s Feature Policy from response</a>
       algorithm on the <code id=navigating-across-documents:document-13><a href=#document>Document</a></code> object and the <a href=https://fetch.spec.whatwg.org/#concept-response id=navigating-across-documents:concept-response-6 data-x-internal=concept-response>response</a> used to generate the document.  <a href=#refsFEATUREPOLICY>[FEATUREPOLICY]</a></p>

       <p class=note>The <a id=navigating-across-documents:initialize-document’s-feature-policy-from-response-2 href=https://wicg.github.io/feature-policy/#initialize-from-response data-x-internal=initialize-document’s-feature-policy-from-response>Initialize document’s Feature Policy from response</a> algorithm
       makes use of the <code id=navigating-across-documents:document-14><a href=#document>Document</a></code>'s <a href=#concept-origin id=navigating-across-documents:concept-origin-4>origin</a>. If <code id=navigating-across-documents:dom-document-domain><a href=#dom-document-domain>document.domain</a></code> has been used for the <a href=#browsing-context-container id=navigating-across-documents:browsing-context-container-2>browsing
       context container</a>'s <a id=navigating-across-documents:node-document href=https://dom.spec.whatwg.org/#concept-node-document data-x-internal=node-document>node document</a>, then its <a href=#concept-origin id=navigating-across-documents:concept-origin-5>origin</a> cannot be
       <a href=#same-origin-domain id=navigating-across-documents:same-origin-domain>same origin-domain</a> with <var>document</var>'s <a href=#concept-origin id=navigating-across-documents:concept-origin-6>origin</a>, because these
       steps run when <var>document</var> is initialized, so it cannot itself yet have used <code id=navigating-across-documents:dom-document-domain-2><a href=#dom-document-domain>document.domain</a></code>. Note that this means that Feature Policy
       checks are less permissive compared to doing a <a href=#same-origin id=navigating-across-documents:same-origin-6>same origin</a> check instead.</p>

       <div class=example>
         <p>In this example, the child document is not allowed to use <code id=navigating-across-documents: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=navigating-across-documents:same-origin-domain-2>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=navigating-across-documents: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>&apos;example.com&apos;</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>&apos;example.com&apos;</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=navigating-across-documents: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=navigating-across-documents: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, none of
	 the documents have set <code id=navigating-across-documents:dom-document-domain-4><a href=#dom-document-domain>document.domain</a></code> yet so
	 <a href=#same-origin-domain id=navigating-across-documents:same-origin-domain-4>same origin-domain</a> falls back to a normal <a href=#same-origin id=navigating-across-documents:same-origin-7>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>&apos;example.com&apos;</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>
     <li>
      <p>If <var>response</var> has a `<code id=navigating-across-documents:refresh><a href=#refresh>Refresh</a></code>` header, then:</p>

      <ol><li><p class=XXX><a href=https://github.com/whatwg/html/issues/2900>Multiple `<code>Refresh</code>` headers</a>.<li><p>Let <var>value</var> be the <a href=https://infra.spec.whatwg.org/#isomorphic-decode id=navigating-across-documents:isomorphic-decode data-x-internal=isomorphic-decode>isomorphic decoding</a>
       of the value of the header.<li><p>Run the <a href=#shared-declarative-refresh-steps id=navigating-across-documents:shared-declarative-refresh-steps>shared declarative refresh steps</a> with the <code id=navigating-across-documents:document-15><a href=#document>Document</a></code>
       and <var>value</var>.</ol>
     </ol>
   <li id=navigate-non-Document><p><i>Non-document content</i>: 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 <a href=#read-ua-inline id=navigating-across-documents:read-ua-inline-2>display the inline content</a>, and then return.<li><p>Otherwise, the document's <var>type</var> is such that the resource will not affect
   <var>browsingContext</var>, e.g., because the resource is to be handed to an external application
   or because it is an unknown type that will be processed <a href=#as-a-download id=navigating-across-documents:as-a-download-2>as a download</a>. <a href=#hand-off-to-external-software id=navigating-across-documents:hand-off-to-external-software>Process the resource appropriately</a>.</p>

  </ol>

  <p>To <dfn id=process-a-navigate-url-scheme>process a navigate URL scheme</dfn>, given a <a id=navigating-across-documents:url-8 href=https://url.spec.whatwg.org/#concept-url data-x-internal=url>URL</a> <var>url</var> and
  <a href=#browsing-context id=navigating-across-documents:browsing-context-8>browsing context</a> <var>browsingContext</var>, run these steps:</p>

  <ol><li><p>If <var>url</var> is to be handled using a mechanism that does not affect
   <var>browsingContext</var>, e.g., because <var>url</var>'s <a href=https://url.spec.whatwg.org/#concept-url-scheme id=navigating-across-documents:concept-url-scheme-7 data-x-internal=concept-url-scheme>scheme</a> is handled externally, then <a href=#hand-off-to-external-software id=navigating-across-documents:hand-off-to-external-software-2>proceed with that mechanism instead</a>.<li>
    <p>Otherwise, <var>url</var> is to be handled 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=navigating-across-documents:dom-navigator-registerprotocolhandler>a
    registered handler</a> for the given scheme. <a href=#read-ua-inline id=navigating-across-documents:read-ua-inline-3>Display the
    inline content</a>.</p>

    <p class=note>In the case of a registered handler being used, <a href=#navigate id=navigating-across-documents:navigate-6>navigate</a> will be
    invoked with a new URL.</p>
   </ol>

  <p>When a resource is handled by <dfn id=hand-off-to-external-software>passing its URL or
  data to an external software package</dfn> separate from the user agent (e.g. handing a <code id=navigating-across-documents:mailto-protocol-2><a data-x-internal=mailto-protocol href=https://tools.ietf.org/html/rfc6068#section-2>mailto:</a></code> URL to a mail client, or a Word document to a word
  processor), user agents should attempt to mitigate the risk that this is an attempt to exploit the
  target software, e.g. by prompting the user to confirm that the <a href=#source-browsing-context id=navigating-across-documents:source-browsing-context-10>source browsing
  context</a>'s <a href=#active-document id=navigating-across-documents:active-document-12>active document</a>'s <a href=#concept-origin id=navigating-across-documents:concept-origin-7>origin</a> is to be allowed to invoke the
  specified software. In particular, if the <a href=#navigate id=navigating-across-documents:navigate-7>navigate</a> algorithm, when it was invoked,
  was not <a href=#triggered-by-user-activation id=navigating-across-documents:triggered-by-user-activation>triggered by user activation</a>, 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>

  <hr>

  <p>Some of the sections below, to which the above algorithm defers in certain cases, require the
  user agent to <dfn id=update-the-session-history-with-the-new-page>update the session history with the new page</dfn>. When a user agent is
  required to do this, it must <a href=#queue-a-task id=navigating-across-documents:queue-a-task-2>queue a task</a> (associated with the <code id=navigating-across-documents:document-16><a href=#document>Document</a></code>
  object of the <a href=#current-entry id=navigating-across-documents:current-entry>current entry</a>, not the new one) to run the following steps:</p>

  <ol><li>

    <p><a href=#unload-a-document id=navigating-across-documents:unload-a-document-2>Unload</a> the <code id=navigating-across-documents:document-17><a href=#document>Document</a></code> object of the
    <a href=#current-entry id=navigating-across-documents:current-entry-2>current entry</a>.</p>

    <p>If this instance of the <a href=#navigate id=navigating-across-documents:navigate-8>navigation</a> algorithm is canceled while
    this step is running the <a href=#unload-a-document id=navigating-across-documents:unload-a-document-3>unload a document</a> algorithm, then the <a href=#unload-a-document id=navigating-across-documents:unload-a-document-4>unload a
    document</a> algorithm must be allowed to run to completion, but this instance of the <a href=#navigate id=navigating-across-documents:navigate-9>navigation</a> algorithm must not run beyond this step. (In particular, for
    instance, the cancelation of this algorithm does not abort any event dispatch or script
    execution occurring as part of unloading the document or its descendants.)</p>

   <li>

    <dl><dt>If the navigation was initiated for <dfn id=entry-update>entry update</dfn> of an entry<dd>

      <ol><li><p>Replace the <code id=navigating-across-documents:document-18><a href=#document>Document</a></code> of the entry being updated, and any other entries
       that referenced the same document as that entry, with the new <code id=navigating-across-documents:document-19><a href=#document>Document</a></code>.<li><p><a href=#traverse-the-history id=navigating-across-documents:traverse-the-history>Traverse the history</a> to the new entry.</ol>

     <dt>If the navigation was initiated with a <a id=navigating-across-documents:url-9 href=https://url.spec.whatwg.org/#concept-url data-x-internal=url>URL</a> that <a href=https://url.spec.whatwg.org/#concept-url-equals id=navigating-across-documents:concept-url-equals-2 data-x-internal=concept-url-equals>equals</a> the <a href=#browsing-context id=navigating-across-documents:browsing-context-9>browsing context</a>'s <a href=#active-document id=navigating-across-documents:active-document-13>active
     document</a>'s <a href=https://dom.spec.whatwg.org/#concept-document-url id="navigating-across-documents:the-document's-address-5" data-x-internal="the-document's-address">URL</a><dd>
      <ol><li><p>Replace the <a href=#current-entry id=navigating-across-documents:current-entry-3>current entry</a> with a new entry representing the new resource
       and its <code id=navigating-across-documents:document-20><a href=#document>Document</a></code> object, related state, and the default <a href=#scroll-restoration-mode id=navigating-across-documents:scroll-restoration-mode>scroll restoration
       mode</a> of "<code id=navigating-across-documents:dom-scrollrestoration-auto><a href=#dom-scrollrestoration-auto>auto</a></code>".<li><p><a href=#traverse-the-history id=navigating-across-documents:traverse-the-history-2>Traverse the history</a> to the new entry.</ol>
     <dt>Otherwise<dd>

      <ol><li>

        <p>Remove all the entries in the <a href=#browsing-context id=navigating-across-documents:browsing-context-10>browsing context</a>'s <a href=#session-history id=navigating-across-documents:session-history-2>session
        history</a> after the <a href=#current-entry id=navigating-across-documents:current-entry-4>current entry</a>. If the <a href=#current-entry id=navigating-across-documents:current-entry-5>current entry</a> is
        the last entry in the session history, then no entries are removed.</p>

        <p class=note>This <a href=#history-notes>doesn't necessarily have to affect</a> the
        user agent's user interface.</p>

       <li><p>Append a new entry at the end of the <code id=navigating-across-documents:history-3><a href=#history-3>History</a></code> object representing the new
       resource and its <code id=navigating-across-documents:document-21><a href=#document>Document</a></code> object, related state, and the default <a href=#scroll-restoration-mode id=navigating-across-documents:scroll-restoration-mode-2>scroll
       restoration mode</a> of "<code id=navigating-across-documents:dom-scrollrestoration-auto-2><a href=#dom-scrollrestoration-auto>auto</a></code>".<li><p><a href=#traverse-the-history id=navigating-across-documents:traverse-the-history-3>Traverse the history</a> to the new entry. If the navigation was initiated
       with <a href=#replacement-enabled id=navigating-across-documents:replacement-enabled-4>replacement enabled</a>, then the traversal must itself be initiated with
       <a href=#replacement-enabled id=navigating-across-documents:replacement-enabled-5>replacement enabled</a>.</p>

       </ol>

     </dl>

   <li><p>The <a href=#navigate id=navigating-across-documents:navigate-10>navigation algorithm</a> has now <dfn id=concept-navigate-mature>matured</dfn>.<li><p><i>Fragment loop</i>: <a href=#spin-the-event-loop id=navigating-across-documents:spin-the-event-loop>Spin the event loop</a> for a user-agent-defined amount of
   time, as desired by the user agent implementer. (This is intended to allow the user agent to
   optimize the user experience in the face of performance concerns.)<li><p>If the <code id=navigating-across-documents:document-22><a href=#document>Document</a></code> object has no parser, or its parser has <a href=#stop-parsing id=navigating-across-documents: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=navigating-across-documents:concept-url-fragment-2 data-x-internal=concept-url-fragment>fragment</a>, then
   return.<li><p><a href=#scroll-to-the-fragment-identifier id=navigating-across-documents:scroll-to-the-fragment-identifier>Scroll to the fragment</a> given in the document's <a href=https://dom.spec.whatwg.org/#concept-document-url id="navigating-across-documents:the-document's-address-6" data-x-internal="the-document's-address">URL</a>. If this fails to find <a href=#the-indicated-part-of-the-document id=navigating-across-documents:the-indicated-part-of-the-document>an indicated part of the document</a>, then return to the <i>fragment
   loop</i> step.</ol>

  <p>The <a href=#task-source id=navigating-across-documents:task-source-2>task source</a> for this <a href=#concept-task id=navigating-across-documents:concept-task-3>task</a> is the
  <a href=#networking-task-source id=navigating-across-documents:networking-task-source-2>networking task source</a>.</p>


  <h4 id=read-html><span class=secno>7.8.2</span> <dfn>Page load processing model for HTML files</dfn><a href=#read-html class=self-link></a></h4>

  <p>When an HTML document is to be loaded in a <a href=#browsing-context id=read-html:browsing-context>browsing context</a>, the user agent must
  <a href=#queue-a-task id=read-html:queue-a-task>queue a task</a> to create a <code id=read-html:document><a href=#document>Document</a></code> object, mark it as being an <a href=https://dom.spec.whatwg.org/#html-document id=read-html:html-documents data-x-internal=html-documents>HTML document</a>, set its <a href=https://dom.spec.whatwg.org/#concept-document-content-type id=read-html:concept-document-content-type data-x-internal=concept-document-content-type>content type</a> to "<code>text/html</code>",
  <a href=#initialise-the-document-object id=read-html:initialise-the-document-object>initialize the <code>Document</code> object</a>, and finally create an <a href=#html-parser id=read-html:html-parser>HTML
  parser</a> and associate it with the <code id=read-html:document-2><a href=#document>Document</a></code>. 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-2>HTML parser</a> to perform the
  appropriate processing of the input stream.</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-task id=read-html:queue-a-task-2>queue a task</a> for the parser
  to 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>

  <p>After creating the <code id=read-html:document-3><a href=#document>Document</a></code> object, but before any script execution, certainly
  before the parser <a href=#stop-parsing id=read-html:stop-parsing>stops</a>, the user agent must <a href=#update-the-session-history-with-the-new-page id=read-html:update-the-session-history-with-the-new-page>update the
  session history with the new page</a>.</p>

  <p class=note><a href=#concept-appcache-init id=read-html:concept-appcache-init>Application cache selection</a> happens <a href=#parser-appcache>in the HTML parser</a>.</p>

  <p>The <a href=#task-source id=read-html:task-source>task source</a> for the two tasks mentioned in this section must be the
  <a href=#networking-task-source id=read-html:networking-task-source-2>networking task source</a>.</p>



  <h4 id=read-xml><span class=secno>7.8.3</span> <dfn>Page load processing model for XML files</dfn><a href=#read-xml class=self-link></a></h4>

  <p>When faced with displaying an XML file inline, user agents must follow the requirements defined
  in the XML and Namespaces in XML recommendations, RFC 7303, DOM, and other relevant specifications
  to create a <code id=read-xml:document><a href=#document>Document</a></code> object and 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>After the <code id=read-xml:document-2><a href=#document>Document</a></code> is created, the user agent must <a href=#initialise-the-document-object id=read-xml:initialise-the-document-object>initialize the
  <code>Document</code> object</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>If the <a id=read-xml:document-element href=https://dom.spec.whatwg.org/#document-element data-x-internal=document-element>document element</a>, as parsed according to the XML specifications cited
  above, is found to be an <code id=read-xml:the-html-element><a href=#the-html-element>html</a></code> element with an attribute <code id=read-xml:attr-html-manifest><a href=#attr-html-manifest>manifest</a></code> whose value is not the empty string, then, as soon as
  the element is <a href=#insert-an-element-into-a-document id=read-xml:insert-an-element-into-a-document>inserted into the document</a>,
  the user agent must <a href=#parse-a-url id=read-xml:parse-a-url>parse</a> the value of that attribute relative
  to that element's <a id=read-xml:node-document href=https://dom.spec.whatwg.org/#concept-node-document data-x-internal=node-document>node document</a>, and if that is successful, must apply the <a href=https://url.spec.whatwg.org/#concept-url-serializer id=read-xml:concept-url-serializer data-x-internal=concept-url-serializer>URL serializer</a> algorithm to the <a href=#resulting-url-record id=read-xml:resulting-url-record>resulting URL
  record</a> with the <i>exclude fragment flag</i> set to obtain <var>manifest URL</var>, and
  then run the <a href=#concept-appcache-init id=read-xml:concept-appcache-init>application cache selection algorithm</a>
  with <var>manifest URL</var> as the manifest URL, passing in the newly-created
  <code id=read-xml:document-3><a href=#document>Document</a></code>. Otherwise, if the attribute is absent, its value is the empty string, or
  parsing its value fails, then as soon as the <a id=read-xml:document-element-2 href=https://dom.spec.whatwg.org/#document-element data-x-internal=document-element>document element</a> is <a href=#insert-an-element-into-a-document id=read-xml:insert-an-element-into-a-document-2>inserted into the document</a>, the user agent must run the <a href=#concept-appcache-init id=read-xml:concept-appcache-init-2>application cache selection algorithm</a> with no manifest, and
  passing in the <code id=read-xml:document-4><a href=#document>Document</a></code>.</p>

  <p class=note>Because the processing of the <code id=read-xml:attr-html-manifest-2><a href=#attr-html-manifest>manifest</a></code>
  attribute happens only once the <a id=read-xml:document-element-3 href=https://dom.spec.whatwg.org/#document-element data-x-internal=document-element>document element</a> is parsed, any URLs referenced by
  processing instructions before the <a id=read-xml:document-element-4 href=https://dom.spec.whatwg.org/#document-element data-x-internal=document-element>document element</a> (such as <code>&lt;?xml-stylesheet?></code> PIs) will be fetched from the network and cannot be
  cached.</p>

  <p>User agents may examine the namespace of the root <code id=read-xml:element><a data-x-internal=element href=https://dom.spec.whatwg.org/#interface-element>Element</a></code> node of this
  <code id=read-xml:document-5><a href=#document>Document</a></code> object to perform namespace-based dispatch to alternative processing tools,
  e.g. determining that the content is actually a syndication feed and passing it to a feed handler.
  If such processing is to take place, abort the steps in this section, and jump to <a href=#navigate-non-Document>the next step</a> (labeled <i>non-document content</i>) in the
  <a href=#navigate id=read-xml:navigate>navigate</a> steps above.</p>

  <p>Otherwise, then, with the newly created <code id=read-xml:document-6><a href=#document>Document</a></code>, the user agent must <a href=#update-the-session-history-with-the-new-page id=read-xml:update-the-session-history-with-the-new-page>update
  the session history with the new page</a>. User agents may do this before the complete document
  has been parsed (thus achieving <i>incremental rendering</i>), and must do this before any scripts
  are to be executed.</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-7><a href=#document>Document</a></code>.</p>


  <h4 id=read-text><span class=secno>7.8.4</span> <dfn>Page load processing model for text files</dfn><a href=#read-text class=self-link></a></h4>

  <p>When a plain text document is to be loaded in a <a href=#browsing-context id=read-text:browsing-context>browsing context</a>, the user agent
  must <a href=#queue-a-task id=read-text:queue-a-task>queue a task</a> to create a <code id=read-text:document><a href=#document>Document</a></code> object, mark it as being an <a href=https://dom.spec.whatwg.org/#html-document id=read-text:html-documents data-x-internal=html-documents>HTML document</a>, set its <a href=https://dom.spec.whatwg.org/#concept-document-content-type id=read-text:concept-document-content-type data-x-internal=concept-document-content-type>content type</a> to 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 (<var>type</var> in the
  <a href=#navigate id=read-text:navigate>navigate</a> algorithm), <a href=#initialise-the-document-object id=read-text:initialise-the-document-object>initialize the <code>Document</code> object</a>,
  create an <a href=#html-parser id=read-text:html-parser>HTML parser</a>, associate it with the <code id=read-text:document-2><a href=#document>Document</a></code>, 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>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-2 data-x-internal=content-type-sniffing-2>computed MIME type</a> of the resource (<var>type</var>
  in the <a href=#navigate id=read-text:navigate-2>navigate</a> algorithm).</p>

  <p>The <a id="read-text: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 the character encoding used to
  decode the document.</p>

  <p>Upon creation of the <code id=read-text:document-3><a href=#document>Document</a></code> object, the user agent must run the <a href=#concept-appcache-init id=read-text:concept-appcache-init>application cache selection algorithm</a> with no manifest, and
  passing in the newly-created <code id=read-text:document-4><a href=#document>Document</a></code>.</p>

  

  <p>When no more bytes are available, the user agent must <a href=#queue-a-task id=read-text:queue-a-task-2>queue a task</a> for the parser
  to 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>

  <p>After creating the <code id=read-text:document-5><a href=#document>Document</a></code> object, but potentially before the page has finished
  parsing, the user agent must <a href=#update-the-session-history-with-the-new-page id=read-text:update-the-session-history-with-the-new-page>update the session history with the new page</a>.</p>

  <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 the <code id=read-text:document-6><a href=#document>Document</a></code>,
  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>

  <p>The <a href=#task-source id=read-text:task-source>task source</a> for the two tasks mentioned in this section must be the
  <a href=#networking-task-source id=read-text:networking-task-source-2>networking task source</a>.</p>


  <h4 id=read-multipart-x-mixed-replace><span class=secno>7.8.5</span> <dfn>Page load processing model for <code>multipart/x-mixed-replace</code> resources</dfn><a href=#read-multipart-x-mixed-replace class=self-link></a></h4>

  <p>When a resource with the type <code id=read-multipart-x-mixed-replace:multipart/x-mixed-replace><a href=#multipart/x-mixed-replace>multipart/x-mixed-replace</a></code> is to be loaded in a
  <a href=#browsing-context id=read-multipart-x-mixed-replace:browsing-context>browsing context</a>, the user agent must parse the resource using the rules for
  multipart types. <a href=#refsRFC2046>[RFC2046]</a></p>

  <p>For each body part obtained from the resource, the user agent must run <a href=#process-a-navigate-response id=read-multipart-x-mixed-replace:process-a-navigate-response>process a navigate
  response</a> using the new body part and the same <a href=#browsing-context id=read-multipart-x-mixed-replace:browsing-context-2>browsing context</a>, with
  <a href=#replacement-enabled id=read-multipart-x-mixed-replace:replacement-enabled>replacement enabled</a> if a previous body part from the same resource resulted in a
  <code id=read-multipart-x-mixed-replace:document><a href=#document>Document</a></code> object being created and <a href=#initialise-the-document-object id=read-multipart-x-mixed-replace:initialise-the-document-object>initialized</a>, and otherwise using the same setup as the <a href=#navigate id=read-multipart-x-mixed-replace:navigate>navigate</a>
  attempt that caused this section to be invoked in the first place.</p>

  <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.8.6</span> <dfn>Page load processing model for media</dfn><a href=#read-media class=self-link></a></h4>

  <p>When an image, video, or audio resource is to be loaded in a <a href=#browsing-context id=read-media:browsing-context>browsing context</a>, the
  user agent should create a <code id=read-media:document><a href=#document>Document</a></code> object, mark it as being an <a href=https://dom.spec.whatwg.org/#html-document id=read-media:html-documents data-x-internal=html-documents>HTML document</a>, set its <a href=https://dom.spec.whatwg.org/#concept-document-content-type id=read-media:concept-document-content-type data-x-internal=concept-document-content-type>content
  type</a> to the <a href=https://mimesniff.spec.whatwg.org/#computed-mime-type id=read-media:content-type-sniffing-2 data-x-internal=content-type-sniffing-2>computed MIME type</a> of the
  resource (<var>type</var> in the <a href=#navigate id=read-media:navigate>navigate</a> algorithm), <a href=#initialise-the-document-object id=read-media:initialise-the-document-object>initialize the
  <code>Document</code> object</a>, append an <code id=read-media:the-html-element><a href=#the-html-element>html</a></code> element to the
  <code id=read-media:document-2><a href=#document>Document</a></code>, append a <code id=read-media:the-head-element><a href=#the-head-element>head</a></code> element and a <code id=read-media:the-body-element><a href=#the-body-element>body</a></code> element to the
  <code id=read-media:the-html-element-2><a href=#the-html-element>html</a></code> element, append an element <var>host element</var> for the media, as described
  below, to the <code id=read-media:the-body-element-2><a href=#the-body-element>body</a></code> element, and 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>

  <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> Element for the media
         <th> Appropriate attribute
   <tbody><tr><td> Image
         <td> <code id=read-media:the-img-element><a href=#the-img-element>img</a></code>
         <td> <code id=read-media:attr-img-src><a href=#attr-img-src>src</a></code>
    <tr><td> Video
         <td> <code id=read-media:the-video-element><a href=#the-video-element>video</a></code>
         <td> <code id=read-media:attr-media-src><a href=#attr-media-src>src</a></code>
    <tr><td> Audio
         <td> <code id=read-media:the-audio-element><a href=#the-audio-element>audio</a></code>
         <td> <code id=read-media:attr-media-src-2><a href=#attr-media-src>src</a></code>
  </table>

  

  <p>Then, the user agent must act as if it had <a href=#stop-parsing id=read-media:stop-parsing>stopped
  parsing</a>.</p>

  <p>Upon creation of the <code id=read-media:document-3><a href=#document>Document</a></code> object, the user agent must run the <a href=#concept-appcache-init id=read-media:concept-appcache-init>application cache selection algorithm</a> with no manifest, and
  passing in the newly-created <code id=read-media:document-4><a href=#document>Document</a></code>.</p>

  <p>After creating the <code id=read-media:document-5><a href=#document>Document</a></code> object, but potentially before the page has finished
  fully loading, the user agent must <a href=#update-the-session-history-with-the-new-page id=read-media:update-the-session-history-with-the-new-page>update the session history with the new page</a>.</p>

  <p>User agents may add content to the <code id=read-media:the-head-element-2><a href=#the-head-element>head</a></code> element of the <code id=read-media:document-6><a href=#document>Document</a></code>, or
  attributes to the element <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>


  <h4 id=read-plugin><span class=secno>7.8.7</span> <dfn>Page load processing model for content that uses plugins</dfn><a href=#read-plugin class=self-link></a></h4>

  <p>When a resource that requires an external resource to be rendered is to be loaded in a
  <a href=#browsing-context id=read-plugin:browsing-context>browsing context</a>, the user agent should create a <code id=read-plugin:document><a href=#document>Document</a></code> object, mark
  it as being an <a href=https://dom.spec.whatwg.org/#html-document id=read-plugin:html-documents data-x-internal=html-documents>HTML document</a> and mark it as being a
  <dfn id=plugin-document>plugin document</dfn>, set its <a href=https://dom.spec.whatwg.org/#concept-document-content-type id=read-plugin:concept-document-content-type data-x-internal=concept-document-content-type>content
  type</a> to the <a href=https://mimesniff.spec.whatwg.org/#computed-mime-type id=read-plugin:content-type-sniffing-2 data-x-internal=content-type-sniffing-2>computed MIME type</a> of the
  resource (<var>type</var> in the <a href=#navigate id=read-plugin:navigate>navigate</a> algorithm), <a href=#initialise-the-document-object id=read-plugin:initialise-the-document-object>initialize the
  <code>Document</code> object</a>, append an <code id=read-plugin:the-html-element><a href=#the-html-element>html</a></code> element to the
  <code id=read-plugin:document-2><a href=#document>Document</a></code>, append a <code id=read-plugin:the-head-element><a href=#the-head-element>head</a></code> element and a <code id=read-plugin:the-body-element><a href=#the-body-element>body</a></code> element to the
  <code id=read-plugin:the-html-element-2><a href=#the-html-element>html</a></code> element, append an <code id=read-plugin:the-embed-element><a href=#the-embed-element>embed</a></code> to the <code id=read-plugin:the-body-element-2><a href=#the-body-element>body</a></code> element, and
  set the <code id=read-plugin:attr-embed-src><a href=#attr-embed-src>src</a></code> attribute of the <code id=read-plugin:the-embed-element-2><a href=#the-embed-element>embed</a></code> element to
  the address of the resource.</p>

  <p class=note>The term <a href=#plugin-document id=read-plugin:plugin-document>plugin document</a> is used by
  <cite>Content Security Policy</cite> as part of the mechanism that ensures <code id=read-plugin:the-iframe-element><a href=#the-iframe-element>iframe</a></code>s
  can't be used to evade <code>plugin-types</code> directives. <a href=#refsCSP>[CSP]</a></p>

  

  <p>Then, the user agent must act as if it had <a href=#stop-parsing id=read-plugin:stop-parsing>stopped
  parsing</a>.</p>

  <p>Upon creation of the <code id=read-plugin:document-3><a href=#document>Document</a></code> object, the user agent must run the <a href=#concept-appcache-init id=read-plugin:concept-appcache-init>application cache selection algorithm</a> with no manifest, and
  passing in the newly-created <code id=read-plugin:document-4><a href=#document>Document</a></code>.</p>

  <p>After creating the <code id=read-plugin:document-5><a href=#document>Document</a></code> object, but potentially before the page has finished
  fully loading, the user agent must <a href=#update-the-session-history-with-the-new-page id=read-plugin:update-the-session-history-with-the-new-page>update the session history with the new page</a>.</p>

  <p>User agents may add content to the <code id=read-plugin:the-head-element-2><a href=#the-head-element>head</a></code> element of the <code id=read-plugin:document-6><a href=#document>Document</a></code>, or
  attributes to the <code id=read-plugin:the-embed-element-3><a href=#the-embed-element>embed</a></code> element, e.g. to link to a style sheet or to give the
  document a <code id=read-plugin:the-title-element><a href=#the-title-element>title</a></code>.</p>

  <p id=sandboxPluginNavigate class=note>If the <code id=read-plugin:document-7><a href=#document>Document</a></code>'s <a href=#active-sandboxing-flag-set id=read-plugin:active-sandboxing-flag-set>active sandboxing
  flag set</a> has its <a href=#sandboxed-plugins-browsing-context-flag id=read-plugin:sandboxed-plugins-browsing-context-flag>sandboxed plugins browsing context flag</a> set, the synthesized
  <code id=read-plugin:the-embed-element-4><a href=#the-embed-element>embed</a></code> element will <a href=#sandboxPluginEmbed>fail to render the content</a> if
  the relevant <a href=#plugin id=read-plugin:plugin>plugin</a> cannot be <a href=#concept-plugin-secure id=read-plugin:concept-plugin-secure>secured</a>.</p>


  <h4 id=read-ua-inline><span class=secno>7.8.8</span> <dfn>Page load processing model for inline
  content that doesn't have a DOM</dfn><a href=#read-ua-inline class=self-link></a></h4>

  <p>When the user agent is to display a user agent page inline in a <a href=#browsing-context id=read-ua-inline:browsing-context>browsing context</a>,
  the user agent should create a <code id=read-ua-inline:document><a href=#document>Document</a></code> object, mark it as being an <a href=https://dom.spec.whatwg.org/#html-document id=read-ua-inline:html-documents data-x-internal=html-documents>HTML document</a>, set its <a href=https://dom.spec.whatwg.org/#concept-document-content-type id=read-ua-inline:concept-document-content-type data-x-internal=concept-document-content-type>content type</a> to "<code>text/html</code>",
  <a href=#initialise-the-document-object id=read-ua-inline:initialise-the-document-object>initialize the <code>Document</code> object</a>, and then either associate that
  <code id=read-ua-inline:document-2><a href=#document>Document</a></code> with a custom rendering that is not rendered using the normal
  <code id=read-ua-inline:document-3><a href=#document>Document</a></code> rendering rules, or mutate that <code id=read-ua-inline:document-4><a href=#document>Document</a></code> until it represents
  the content the user agent wants to render.</p>

  

  <p>Once the page has been set up, the user agent must act as if it had <a href=#stop-parsing id=read-ua-inline:stop-parsing>stopped parsing</a>.</p>

  <p>Upon creation of the <code id=read-ua-inline:document-5><a href=#document>Document</a></code> object, the user agent must run the <a href=#concept-appcache-init id=read-ua-inline:concept-appcache-init>application cache selection algorithm</a> with no manifest,
  passing in the newly-created <code id=read-ua-inline:document-6><a href=#document>Document</a></code>.</p>

  <p>After creating the <code id=read-ua-inline:document-7><a href=#document>Document</a></code> object, but potentially before the page has been
  completely set up, the user agent must <a href=#update-the-session-history-with-the-new-page id=read-ua-inline:update-the-session-history-with-the-new-page>update the session history with the new
  page</a>.</p>



  <h4 id=scroll-to-fragid><span class=secno>7.8.9</span> <dfn>Navigating to a fragment</dfn><a href=#scroll-to-fragid class=self-link></a></h4>

  <p>When a user agent is supposed to navigate to a <a href=https://url.spec.whatwg.org/#concept-url-fragment id=scroll-to-fragid:concept-url-fragment data-x-internal=concept-url-fragment>fragment</a>, optionally with <a href=#replacement-enabled id=scroll-to-fragid:replacement-enabled>replacement enabled</a>,
  then the user agent must run the following steps:</p>

  <ol><li>
    <p>If not with <a href=#replacement-enabled id=scroll-to-fragid:replacement-enabled-2>replacement enabled</a>, then remove all the entries in the
    <a href=#browsing-context id=scroll-to-fragid:browsing-context>browsing context</a>'s <a href=#session-history id=scroll-to-fragid:session-history>session history</a> after the <a href=#current-entry id=scroll-to-fragid:current-entry>current
    entry</a>. If the <a href=#current-entry id=scroll-to-fragid:current-entry-2>current entry</a> is the last entry in the session history, then
    no entries are removed.</p>

    <p class=note>This <a href=#history-notes>doesn't necessarily have to affect</a> the user
    agent's user interface.</p>
   <li><p>Remove any <a href=#concept-task id=scroll-to-fragid:concept-task>tasks</a> queued by the <a href=#history-traversal-task-source id=scroll-to-fragid:history-traversal-task-source>history traversal
   task source</a> that are associated with any <code id=scroll-to-fragid:document><a href=#document>Document</a></code> objects in the
   <a href=#top-level-browsing-context id=scroll-to-fragid:top-level-browsing-context>top-level browsing context</a>'s <a href=#document-family id=scroll-to-fragid:document-family>document family</a>.<li><p>Append a new entry at the end of the <code id=scroll-to-fragid:history-3><a href=#history-3>History</a></code> object representing the new
   resource and its <code id=scroll-to-fragid:document-2><a href=#document>Document</a></code> object, related state, and <a href=#current-entry id=scroll-to-fragid:current-entry-3>current entry</a>'s
   <a href=#scroll-restoration-mode id=scroll-to-fragid:scroll-restoration-mode>scroll restoration mode</a>. Its <a id=scroll-to-fragid:url href=https://url.spec.whatwg.org/#concept-url data-x-internal=url>URL</a> must be set to the address to which
   the user agent was <a href=#navigate id=scroll-to-fragid:navigate>navigating</a>. The title must be left
   unset.<li><p><a href=#traverse-the-history id=scroll-to-fragid:traverse-the-history>Traverse the history</a> to the new entry, with <a href=#replacement-enabled id=scroll-to-fragid:replacement-enabled-3>replacement enabled</a>
   if this was invoked with <a href=#replacement-enabled id=scroll-to-fragid:replacement-enabled-4>replacement enabled</a>, and with the <i id=scroll-to-fragid:non-blocking-events-flag><a href=#non-blocking-events-flag>non-blocking events flag</a></i> set. This will <a href=#scroll-to-the-fragment-identifier id=scroll-to-fragid:scroll-to-the-fragment-identifier>scroll to the fragment</a>
   given in what is now the document'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>.</ol>

  <p class=note>If the scrolling fails because 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 original <a href=#navigate id=scroll-to-fragid:navigate-2>navigation</a> algorithm will
  take care of the scrolling instead, as the last few steps of its <a href=#update-the-session-history-with-the-new-page id=scroll-to-fragid:update-the-session-history-with-the-new-page>update the session history
  with the new page</a> algorithm.</p>

  <hr>

  <p>When the user agent is required to <dfn id=scroll-to-the-fragment-identifier>scroll to the fragment</dfn> and <a href=#the-indicated-part-of-the-document id=scroll-to-fragid:the-indicated-part-of-the-document>the indicated part
  of the document</a>, if any, is <a href=#being-rendered id=scroll-to-fragid:being-rendered>being rendered</a>, the user agent must either change
  the scrolling position of the document using the following algorithm, or perform some other action
  such that <a href=#the-indicated-part-of-the-document id=scroll-to-fragid:the-indicated-part-of-the-document-2>the indicated part of the document</a> is brought to the user's attention. If
  there is no indicated part, or if the indicated part is not <a href=#being-rendered id=scroll-to-fragid:being-rendered-2>being rendered</a>, then the
  user agent must do nothing. The aforementioned algorithm is as follows:</p>

  <ol><li><p>If there is no <a href=#the-indicated-part-of-the-document id=scroll-to-fragid:the-indicated-part-of-the-document-3>indicated part of the
   document</a>, set the <code id=scroll-to-fragid:document-3><a href=#document>Document</a></code>'s <a href=#target-element id=scroll-to-fragid:target-element>target element</a> to null.<li>
    <p>If the <a href=#the-indicated-part-of-the-document id=scroll-to-fragid:the-indicated-part-of-the-document-4>indicated part of the
    document</a> is the top of the document, then:</p>

    <ol><li><p>Set the <code id=scroll-to-fragid:document-4><a href=#document>Document</a></code>'s <a href=#target-element id=scroll-to-fragid:target-element-2>target element</a> to null.<li><p><a id=scroll-to-fragid: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 the <code id=scroll-to-fragid:document-5><a href=#document>Document</a></code>. <a href=#refsCSSOMVIEW>[CSSOMVIEW]</a></ol>
   <li>
    <p>Otherwise:</p>

    <ol><li><p>Let <var>target</var> be element that is <a href=#the-indicated-part-of-the-document id=scroll-to-fragid:the-indicated-part-of-the-document-5>the indicated part of the
     document</a>.<li><p>Set the <code id=scroll-to-fragid:document-6><a href=#document>Document</a></code>'s <a href=#target-element id=scroll-to-fragid:target-element-3>target element</a> to
     <var>target</var>.<li><p><a href=https://drafts.csswg.org/cssom-view/#scroll-an-element-into-view id=scroll-to-fragid:scroll-an-element-into-view data-x-internal=scroll-an-element-into-view>Scroll <var>target</var> into view</a>,
     with <var>behavior</var> set to "auto", <var>block</var> set to "start", and <var>inline</var>
     set to "nearest". <a href=#refsCSSOMVIEW>[CSSOMVIEW]</a><li><p>Run the <a href=#focusing-steps id=scroll-to-fragid:focusing-steps>focusing steps</a> for <var>target</var>, with the
     <code id=scroll-to-fragid:document-7><a href=#document>Document</a></code>'s <a id=scroll-to-fragid:viewport href=https://drafts.csswg.org/css2/visuren.html#viewport data-x-internal=viewport>viewport</a> as the <i>fallback target</i>.<li><p>Move the <a href=#sequential-focus-navigation-starting-point id=scroll-to-fragid:sequential-focus-navigation-starting-point>sequential focus navigation starting point</a> to
     <var>target</var>.</ol>
   </ol>

  <p><dfn id=the-indicated-part-of-the-document>The indicated part of the document</dfn> is the one that the <a href=https://url.spec.whatwg.org/#concept-url-fragment id=scroll-to-fragid:concept-url-fragment-2 data-x-internal=concept-url-fragment>fragment</a>, if any, identifies. The semantics of the <a href=https://url.spec.whatwg.org/#concept-url-fragment id=scroll-to-fragid:concept-url-fragment-3 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=scroll-to-fragid:mime-type href=https://mimesniff.spec.whatwg.org/#mime-type data-x-internal=mime-type>MIME type</a> used by the <code id=scroll-to-fragid:document-8><a href=#document>Document</a></code> (for
  example, the processing of <a href=https://url.spec.whatwg.org/#concept-url-fragment id=scroll-to-fragid:concept-url-fragment-4 data-x-internal=concept-url-fragment>fragments</a> for <a href=https://mimesniff.spec.whatwg.org/#xml-mime-type id=scroll-to-fragid:xml-mime-type data-x-internal=xml-mime-type>XML MIME types</a> is the responsibility of RFC7303). <a href=#refsRFC7303>[RFC7303]</a></p>

  <p>There is also a <dfn id=target-element>target element</dfn> for each <code id=scroll-to-fragid:document-9><a href=#document>Document</a></code>, which is used in
  defining the <code id=scroll-to-fragid:selector-target><a href=#selector-target>:target</a></code> pseudo-class and is updated by the
  above algorithm. It is initially null.</p>

  <p>For HTML documents (and <a href=https://mimesniff.spec.whatwg.org/#html-mime-type id=scroll-to-fragid:html-mime-type data-x-internal=html-mime-type>HTML MIME types</a>), the following
  processing model must be followed to determine what <a href=#the-indicated-part-of-the-document id=scroll-to-fragid:the-indicated-part-of-the-document-6>the indicated part of the
  document</a> is.</p>

  <ol><li><p>Let <var>fragment</var> be the document's <a href=https://dom.spec.whatwg.org/#concept-document-url id="scroll-to-fragid:the-document's-address-2" data-x-internal="the-document's-address">URL</a>'s
   <a href=https://url.spec.whatwg.org/#concept-url-fragment id=scroll-to-fragid:concept-url-fragment-5 data-x-internal=concept-url-fragment>fragment</a>.<li><p>If <var>fragment</var> is the empty string, then <a href=#the-indicated-part-of-the-document id=scroll-to-fragid:the-indicated-part-of-the-document-7>the indicated part of the
   document</a> is the top of the document; return.<li><p>If <a href=#find-a-potential-indicated-element id=scroll-to-fragid:find-a-potential-indicated-element>find a potential indicated element</a> with <var>fragment</var> returns
   non-null, then the return value is <a href=#the-indicated-part-of-the-document id=scroll-to-fragid:the-indicated-part-of-the-document-8>the indicated part of the document</a>;
   return.<li><p>Let <var>fragmentBytes</var> be the result of <a href=https://url.spec.whatwg.org/#string-percent-decode id=scroll-to-fragid:string-percent-decode data-x-internal=string-percent-decode>string
   percent decoding</a> <var>fragment</var>.<li><p>Let <var>decodedFragment</var> be the result of running <a id=scroll-to-fragid: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>.<li><p>If <a href=#find-a-potential-indicated-element id=scroll-to-fragid:find-a-potential-indicated-element-2>find a potential indicated element</a> with <var>decodedFragment</var> returns
   non-null, then the return value is <a href=#the-indicated-part-of-the-document id=scroll-to-fragid:the-indicated-part-of-the-document-9>the indicated part of the document</a>;
   return.<li><p>If <var>decodedFragment</var> is an <a id=scroll-to-fragid: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 <a href=#the-indicated-part-of-the-document id=scroll-to-fragid:the-indicated-part-of-the-document-10>the indicated part of the document</a> is the
   top of the document; return.<li><p>There is no <a href=#the-indicated-part-of-the-document id=scroll-to-fragid:the-indicated-part-of-the-document-11>indicated part of the
   document</a>.</ol>

  <p>To <dfn id=find-a-potential-indicated-element>find a potential indicated element</dfn> given 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=scroll-to-fragid:in-a-document-tree data-x-internal=in-a-document-tree>in the document tree</a> that
   has an <a href=https://dom.spec.whatwg.org/#concept-id id=scroll-to-fragid:concept-id-2 data-x-internal=concept-id>ID</a> equal to <var>fragment</var>, then return the first
   such element in <a id=scroll-to-fragid:tree-order href=https://dom.spec.whatwg.org/#concept-tree-order data-x-internal=tree-order>tree order</a>.<li><p>If there is an <code id=scroll-to-fragid:the-a-element><a href=#the-a-element>a</a></code> element <a href=https://dom.spec.whatwg.org/#in-a-document-tree id=scroll-to-fragid:in-a-document-tree-2 data-x-internal=in-a-document-tree>in the document
   tree</a> that has a <code id=scroll-to-fragid: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=scroll-to-fragid:tree-order-2 href=https://dom.spec.whatwg.org/#concept-tree-order data-x-internal=tree-order>tree order</a>.<li><p>Return null.</ol>

  <p>The <a href=#task-source id=scroll-to-fragid:task-source>task source</a> for the task mentioned in this section must be the <a href=#dom-manipulation-task-source id=scroll-to-fragid:dom-manipulation-task-source>DOM
  manipulation task source</a>.</p>

  



  <h4 id=history-traversal><span class=secno>7.8.10</span> History traversal<a href=#history-traversal class=self-link></a></h4> 

  

  <p>To <dfn id=traverse-the-history>traverse the history</dfn> to a <a href=#session-history-entry id=history-traversal:session-history-entry>session history entry</a> <var>entry</var>,
  optionally with <dfn id=replacement-enabled data-export="">replacement enabled</dfn>, optionally with the
  <dfn id=non-blocking-events-flag>non-blocking events flag</dfn> set, and optionally with the <dfn id=history-navigation-flag>history-navigation
  flag</dfn> set:</p>

  <p class=note>This algorithm is not just invoked when <a href=#traverse-the-history-by-a-delta id=history-traversal:traverse-the-history-by-a-delta>explicitly going back or forwards in the session history</a> — it is also invoked
  in other situations, for example when <a href=#navigate id=history-traversal:navigate>navigating a browsing context</a>,
  as part of <a href=#update-the-session-history-with-the-new-page id=history-traversal:update-the-session-history-with-the-new-page>updating the session history
  with the new page</a>.</p>

  <ol><li>
    <p>If <var>entry</var> no longer holds a <code id=history-traversal:document><a href=#document>Document</a></code> object, then:</p>

    <ol><li><p>Let <var>request</var> be a new <a href=https://fetch.spec.whatwg.org/#concept-request id=history-traversal:concept-request data-x-internal=concept-request>request</a> whose
     <a href=https://fetch.spec.whatwg.org/#concept-request-url id=history-traversal:concept-request-url data-x-internal=concept-request-url>url</a> is <var>entry</var>'s <a id=history-traversal:url href=https://url.spec.whatwg.org/#concept-url data-x-internal=url>URL</a>.<li><p>If the <i id=history-traversal:history-navigation-flag><a href=#history-navigation-flag>history-navigation flag</a></i> is set, then set
     <var>request</var>'s <a href=https://fetch.spec.whatwg.org/#concept-request-history-navigation-flag id=history-traversal:concept-request-history-navigation-flag data-x-internal=concept-request-history-navigation-flag>history-navigation
     flag</a>.<li>
      <p><a href=#navigate id=history-traversal:navigate-2>Navigate</a> the <a href=#browsing-context id=history-traversal:browsing-context>browsing
      context</a> to <var>request</var> to perform an <a href=#entry-update id=history-traversal:entry-update>entry update</a> of
      <var>entry</var>. The navigation must be done using the same <a href=#source-browsing-context id=history-traversal:source-browsing-context>source browsing
      context</a> as was used the first time <var>entry</var> was created. (This can never happen
      with <a href=#replacement-enabled id=history-traversal:replacement-enabled>replacement enabled</a>.)</p>

      <p class=note>The "<a href=#navigate id=history-traversal:navigate-3>navigate</a>" algorithm reinvokes this "traverse" algorithm to
      complete the traversal, at which point <var>entry</var> holds a <code id=history-traversal:document-2><a href=#document>Document</a></code>
      object.</p>

      <p class=note>If the resource was obtained using a non-idempotent action, for example a POST
      form submission, or if the resource is no longer available, for example because the computer
      is now offline and the page wasn't cached, navigating to it again might not be possible. In
      this case, the navigation will result in a different page than previously; for example, it
      might be an error message explaining the problem or offering to resubmit the form.</p>
     <li><p>Return.</ol>
   <li><p>If the <a href=#current-entry id=history-traversal:current-entry>current entry</a>'s title was not set by the <code id=history-traversal:dom-history-pushstate><a href=#dom-history-pushstate>pushState()</a></code> or <code id=history-traversal:dom-history-replacestate><a href=#dom-history-replacestate>replaceState()</a></code> methods, then set its title to the value
   returned by the <code id=history-traversal:document.title><a href=#document.title>document.title</a></code> IDL attribute.<li><p>If appropriate, update the <a href=#current-entry id=history-traversal:current-entry-2>current entry</a> in the <a href=#browsing-context id=history-traversal:browsing-context-2>browsing
   context</a>'s <code id=history-traversal:document-3><a href=#document>Document</a></code> object's <code id=history-traversal:history-3><a href=#history-3>History</a></code> object to reflect any state
   that the user agent wishes to persist. The entry is then said to be <a href=#an-entry-with-persisted-user-state id=history-traversal:an-entry-with-persisted-user-state>an entry with persisted
   user state</a>.<li><p>If <var>entry</var> has a different <code id=history-traversal:document-4><a href=#document>Document</a></code> object than the <a href=#current-entry id=history-traversal:current-entry-3>current
   entry</a>, then run the following substeps:</p>

    <ol><li><p>Remove any <a href=#concept-task id=history-traversal:concept-task>tasks</a> queued by the <a href=#history-traversal-task-source id=history-traversal:history-traversal-task-source>history traversal
     task source</a> that are associated with any <code id=history-traversal:document-5><a href=#document>Document</a></code> objects in the
     <a href=#top-level-browsing-context id=history-traversal:top-level-browsing-context>top-level browsing context</a>'s <a href=#document-family id=history-traversal:document-family>document family</a>.<li>

      <p>If the <a href=#concept-origin id=history-traversal:concept-origin>origin</a> of <var>entry</var>'s <code id=history-traversal:document-6><a href=#document>Document</a></code> object is not the
      <a href=#same-origin id=history-traversal:same-origin>same</a> as the <a href=#concept-origin id=history-traversal:concept-origin-2>origin</a> of the <a href=#current-entry id=history-traversal:current-entry-4>current
      entry</a>'s <code id=history-traversal:document-7><a href=#document>Document</a></code> object, then run the following subsubsteps:</p>

      <ol><li><p>The current <a href=#browsing-context-name id=history-traversal:browsing-context-name>browsing context name</a> must be stored with all the entries in
       the history that are associated with <code id=history-traversal:document-8><a href=#document>Document</a></code> objects with the <a href=#same-origin id=history-traversal:same-origin-2>same
       origin</a> as the <a href=#active-document id=history-traversal:active-document>active document</a> <em>and</em> that are contiguous with the
       <a href=#current-entry id=history-traversal:current-entry-5>current entry</a>.<li id=resetBCName><p>If the browsing context is a <a href=#top-level-browsing-context id=history-traversal:top-level-browsing-context-2>top-level browsing context</a>,
       but not an <a href=#auxiliary-browsing-context id=history-traversal:auxiliary-browsing-context>auxiliary browsing context</a>, then set the browsing context's <a href=#browsing-context-name id=history-traversal:browsing-context-name-2>name</a> to the empty string.</ol>

     <li id=appcache-history-2><p><a href=#set-the-active-document id=history-traversal:set-the-active-document>Set the active document</a> of the <a href=#browsing-context id=history-traversal:browsing-context-3>browsing
     context</a> to <var>entry</var>'s <code id=history-traversal:document-9><a href=#document>Document</a></code> object.<li>

      <p>If <var>entry</var> has a <a href=#browsing-context-name id=history-traversal:browsing-context-name-3>browsing context name</a>, then run the following
      subsubsteps:</p>

      <ol><li><p>Set the browsing context's <a href=#browsing-context-name id=history-traversal:browsing-context-name-4>browsing context name</a> to <var>entry</var>'s
       <a href=#browsing-context-name id=history-traversal:browsing-context-name-5>browsing context name</a>.<li><p>Clear any <a href=#browsing-context-name id=history-traversal:browsing-context-name-6>browsing context names</a> of all
       entries in the history that are associated with <code id=history-traversal:document-10><a href=#document>Document</a></code> objects with the
       <a href=#same-origin id=history-traversal:same-origin-3>same origin</a> as the new <a href=#active-document id=history-traversal:active-document-2>active document</a> and that are contiguous with
       <var>entry</var>.</ol>

     <li id=history-autocomplete><p>If <var>entry</var>'s <code id=history-traversal:document-11><a href=#document>Document</a></code> object has any
     form controls whose <a href=#autofill-field-name id=history-traversal:autofill-field-name>autofill field name</a> is "<code id=history-traversal:attr-fe-autocomplete-off><a href=#attr-fe-autocomplete-off>off</a></code>", invoke the <a href=#concept-form-reset-control id=history-traversal:concept-form-reset-control>reset algorithm</a> of each of those elements.<li>

      <p>If the <a href=#current-document-readiness id=history-traversal:current-document-readiness>current document readiness</a> of <var>entry</var>'s <code id=history-traversal:document-12><a href=#document>Document</a></code>
      object is "<code>complete</code>", then <a href=#queue-a-task id=history-traversal:queue-a-task>queue a task</a> to run the
      following subsubsteps:</p>

      <ol><li><p>If the <code id=history-traversal:document-13><a href=#document>Document</a></code>'s <a href=#page-showing id=history-traversal:page-showing>page showing</a> flag is true, then abort
       these steps.<li><p>Set the <code id=history-traversal:document-14><a href=#document>Document</a></code>'s <a href=#page-showing id=history-traversal:page-showing-2>page showing</a> flag to true.<li>

        <p>Run any <dfn id=session-history-document-visibility-change-steps>session history document visibility change steps</dfn> for <code id=history-traversal:document-15><a href=#document>Document</a></code> that
        are defined by <a href=#other-applicable-specifications id=history-traversal:other-applicable-specifications>other applicable specifications</a>.</p>

        <p class=note>This is specifically intended for use by the Page Visibility specification. <a href=#refsPAGEVIS>[PAGEVIS]</a></p>

       <li><p><a href=https://dom.spec.whatwg.org/#concept-event-fire id=history-traversal:concept-event-fire data-x-internal=concept-event-fire>Fire an event</a> named <code id=history-traversal:event-pageshow><a href=#event-pageshow>pageshow</a></code> at the <code id=history-traversal:document-16><a href=#document>Document</a></code> object's <a href=#concept-relevant-global id=history-traversal:concept-relevant-global>relevant
       global object</a>, using <code id=history-traversal:pagetransitionevent><a href=#pagetransitionevent>PageTransitionEvent</a></code>, with the <code id=history-traversal:dom-pagetransitionevent-persisted><a href=#dom-pagetransitionevent-persisted>persisted</a></code> attribute initialized to true,
       and <var>legacy target override flag</var> set.</ol>

      

     </ol>

   <li><p>Set the document's <a href=https://dom.spec.whatwg.org/#concept-document-url id="history-traversal:the-document's-address" data-x-internal="the-document's-address">URL</a> to <var>entry</var>'s
   <a id=history-traversal:url-2 href=https://url.spec.whatwg.org/#concept-url data-x-internal=url>URL</a>.<li><p>If <var>entry</var> has a <a id=history-traversal: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-fragment id=history-traversal:concept-url-fragment data-x-internal=concept-url-fragment>fragment</a> differs from that of the
   <a href=#current-entry id=history-traversal:current-entry-6>current entry</a>'s when compared in a <a href=#case-sensitive id=history-traversal:case-sensitive>case-sensitive</a> manner, and the two
   share the same <code id=history-traversal:document-17><a href=#document>Document</a></code> object, then let <var>hash changed</var> be true, and let
   <var>old URL</var> be the <a href=#current-entry id=history-traversal:current-entry-7>current entry</a>'s <a id=history-traversal:url-4 href=https://url.spec.whatwg.org/#concept-url data-x-internal=url>URL</a> and <var>new URL</var> be
   <var>entry</var>'s <a id=history-traversal:url-5 href=https://url.spec.whatwg.org/#concept-url data-x-internal=url>URL</a>. Otherwise, let <var>hash changed</var> be false.<li><p>If the traversal was initiated with <a href=#replacement-enabled id=history-traversal:replacement-enabled-2>replacement enabled</a>, remove the entry
   immediately before the <var>specified entry</var> in the session history.<li><p>If <var>entry</var> is not <a href=#an-entry-with-persisted-user-state id=history-traversal:an-entry-with-persisted-user-state-2>an entry with persisted user state</a>, but its
   <a id=history-traversal: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-fragment id=history-traversal:concept-url-fragment-2 data-x-internal=concept-url-fragment>fragment</a> is non-null, then
   <a href=#scroll-to-the-fragment-identifier id=history-traversal:scroll-to-the-fragment-identifier>scroll to the fragment</a>.<li><p>Set the <a href=#current-entry id=history-traversal:current-entry-8>current entry</a> to <var>entry</var>.<li><p>Let <var>targetRealm</var> be the <a id=history-traversal:current-realm-record href=https://tc39.github.io/ecma262/#current-realm data-x-internal=current-realm-record>current Realm Record</a>.<li><p>If <var>entry</var> has <a href=#serialized-state id=history-traversal:serialized-state>serialized state</a>, then let <var>state</var> be
   <a href=#structureddeserialize id=history-traversal:structureddeserialize>StructuredDeserialize</a>(<var>entry</var>'s <a href=#serialized-state id=history-traversal:serialized-state-2>serialized state</a>,
   <var>targetRealm</var>). If this throws an exception, catch it, ignore the exception, and let
   <var>state</var> be null.<li><p>Otherwise, let <var>state</var> be null.<li><p>Set <code id=history-traversal:dom-history-state><a href=#dom-history-state>history.state</a></code> to <var>state</var>.<li><p>Let <var>state changed</var> be true if <var>entry</var>'s <code id=history-traversal:document-18><a href=#document>Document</a></code> object
   has a <a href=#latest-entry id=history-traversal:latest-entry>latest entry</a>, and that entry is not <var>entry</var>; otherwise let it be
   false.</p>

   <li><p>Set <var>entry</var>'s <code id=history-traversal:document-19><a href=#document>Document</a></code> object's <a href=#latest-entry id=history-traversal:latest-entry-2>latest entry</a> to
   <var>entry</var>.<li>

    <p>If the <i id=history-traversal:non-blocking-events-flag><a href=#non-blocking-events-flag>non-blocking events flag</a></i> is not set, then run
    the following substeps <a href=#immediately id=history-traversal:immediately>immediately</a>. Otherwise, the <i id=history-traversal:non-blocking-events-flag-2><a href=#non-blocking-events-flag>non-blocking events flag</a></i> flag is set; <a href=#queue-a-task id=history-traversal:queue-a-task-2>queue a task</a> to run the following
    substeps instead.</p>

    <ol><li><p>If <var>state changed</var> is true, then <a href=https://dom.spec.whatwg.org/#concept-event-fire id=history-traversal:concept-event-fire-2 data-x-internal=concept-event-fire>fire an
     event</a> named <code id=history-traversal:event-popstate><a href=#event-popstate>popstate</a></code> at the <code id=history-traversal:document-20><a href=#document>Document</a></code>
     object's <a href=#concept-relevant-global id=history-traversal:concept-relevant-global-2>relevant global object</a>, using <code id=history-traversal:popstateevent><a href=#popstateevent>PopStateEvent</a></code>, with the <code id=history-traversal:dom-popstateevent-state><a href=#dom-popstateevent-state>state</a></code> attribute initialized to
     <var>state</var>.<li><p>If <var>entry</var> is <a href=#an-entry-with-persisted-user-state id=history-traversal:an-entry-with-persisted-user-state-3>an entry with persisted user state</a>, then the user
     agent may <a href=#restore-persisted-user-state id=history-traversal:restore-persisted-user-state>restore persisted user state</a> and update aspects of the document and its
     rendering.<li><p>If <var>hash changed</var> is true, then <a href=https://dom.spec.whatwg.org/#concept-event-fire id=history-traversal:concept-event-fire-3 data-x-internal=concept-event-fire>fire an
     event</a> named <code id=history-traversal:event-hashchange><a href=#event-hashchange>hashchange</a></code> at the <a href=#browsing-context id=history-traversal:browsing-context-4>browsing
     context</a>'s <code id=history-traversal:window><a href=#window>Window</a></code> object, using <code id=history-traversal:hashchangeevent><a href=#hashchangeevent>HashChangeEvent</a></code>, with the
     <code id=history-traversal:dom-hashchangeevent-oldurl><a href=#dom-hashchangeevent-oldurl>oldURL</a></code> attribute initialized to <var>old
     URL</var> and the <code id=history-traversal:dom-hashchangeevent-newurl><a href=#dom-hashchangeevent-newurl>newURL</a></code> attribute
     initialized to <var>new URL</var>.</ol>

   </ol>

  <p>The <a href=#task-source id=history-traversal:task-source>task source</a> for the tasks mentioned above is the <a href=#dom-manipulation-task-source id=history-traversal:dom-manipulation-task-source>DOM manipulation task
  source</a>.</p>

  

  <h5 id=persisted-user-state-restoration><span class=secno>7.8.10.1</span> Persisted user state restoration<a href=#persisted-user-state-restoration class=self-link></a></h5>
  

  <p>When the user agent is to <dfn id=restore-persisted-user-state>restore persisted user state</dfn> from a history entry, it must
  run the following steps immediately:</p>

  <ol><li><p>If the entry has a <a href=#scroll-restoration-mode id=persisted-user-state-restoration:scroll-restoration-mode>scroll restoration mode</a>, let <var>scrollRestoration</var>
   be that. Otherwise let <var>scrollRestoration</var> be "<code id=persisted-user-state-restoration:dom-scrollrestoration-auto><a href=#dom-scrollrestoration-auto>auto</a></code>"<li><p>If <var>scrollRestoration</var> is "<code id=persisted-user-state-restoration:dom-scrollrestoration-manual><a href=#dom-scrollrestoration-manual>manual</a></code>" the user agent should not restore the scroll
   position for the <code id=persisted-user-state-restoration:document><a href=#document>Document</a></code> or any of its scrollable regions, with the exception of
   any nested browsing contexts whose scroll restoration is controlled by their own history entry's
   <a href=#scroll-restoration-mode id=persisted-user-state-restoration:scroll-restoration-mode-2>scroll restoration mode</a>, otherwise, it may do so.<li><p>Optionally, update other aspects of the document and its rendering, for instance values of
   form fields, that the user agent had previously recorded.</ol>
  

  
  <p class=note>This can even include updating the <code id=persisted-user-state-restoration:the-dir-attribute><a href=#the-dir-attribute>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 either 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> state or 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)-2">Search</a> state, if the persisted state includes the
  directionality of user input in such controls.</p>

  <p class=note>Not restoring the scroll position by user agent does not imply that the scroll
  position 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>

  <h5 id=the-popstateevent-interface><span class=secno>7.8.10.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>

  <pre><code class='idl'>[<c- g>Exposed</c->=<c- n>Window</c->,
 <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>interface</c-> <dfn id='popstateevent'><c- g>PopStateEvent</c-></dfn> : <a href='https://dom.spec.whatwg.org/#interface-event' data-x-internal='event' id='the-popstateevent-interface:event'><c- n>Event</c-></a> {
  <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>dictionary</c-> <dfn id='popstateeventinit'><c- g>PopStateEventInit</c-></dfn> : <a href='https://dom.spec.whatwg.org/#dictdef-eventinit' data-x-internal='eventinit' id='the-popstateevent-interface:eventinit'><c- n>EventInit</c-></a> {
  <c- b>any</c-> <c- g>state</c-> = <c- b>null</c->;
};</code></pre>

  <dl class=domintro><dt><var>event</var> . <code id=dom-popstateevent-state-dev><a href=#dom-popstateevent-state>state</a></code><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>

   </dl>

  

  <p>The <dfn id=dom-popstateevent-state><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>

  


  <h5 id=the-hashchangeevent-interface><span class=secno>7.8.10.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=status><input onclick=toggleStatus(this) value=⋰ type=button><p class=support><strong>Support:</strong> hashchange<span class="and_chr yes"><span>Chrome for Android</span> <span>67+</span></span><span class="chrome yes"><span>Chrome</span> <span>5+</span></span><span class="ios_saf yes"><span>iOS Safari</span> <span>4.0+</span></span><span class="and_uc yes"><span>UC Browser for Android</span> <span>11.8+</span></span><span class="firefox yes"><span>Firefox</span> <span>3.6+</span></span><span class="ie yes"><span>IE</span> <span>8+</span></span><span class="op_mini no"><span>Opera Mini</span> <span>None</span></span><span class="safari yes"><span>Safari</span> <span>5+</span></span><span class="edge yes"><span>Edge</span> <span>12+</span></span><span class="samsung yes"><span>Samsung Internet</span> <span>4+</span></span><span class="opera yes"><span>Opera</span> <span>10.6+</span></span><span class="android yes"><span>Android Browser</span> <span>2.2+</span></span><p class=caniuse>Source: <a href="https://caniuse.com/#feat=hashchange">caniuse.com</a></div>

  <pre><code class='idl'>[<c- g>Exposed</c->=<c- n>Window</c->,
 <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>interface</c-> <dfn id='hashchangeevent'><c- g>HashChangeEvent</c-></dfn> : <a href='https://dom.spec.whatwg.org/#interface-event' data-x-internal='event' id='the-hashchangeevent-interface:event'><c- n>Event</c-></a> {
  <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'><c- g>HashChangeEventInit</c-></dfn> : <a href='https://dom.spec.whatwg.org/#dictdef-eventinit' data-x-internal='eventinit' id='the-hashchangeevent-interface:eventinit'><c- n>EventInit</c-></a> {
  <c- b>USVString</c-> <c- g>oldURL</c-> = &quot;&quot;;
  <c- b>USVString</c-> <c- g>newURL</c-> = &quot;&quot;;
};</code></pre>

  <dl class=domintro><dt><var>event</var> . <code id=dom-hashchangeevent-oldurl-dev><a href=#dom-hashchangeevent-oldurl>oldURL</a></code><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>

   <dt><var>event</var> . <code id=dom-hashchangeevent-newurl-dev><a href=#dom-hashchangeevent-newurl>newURL</a></code><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>

   </dl>

  

  <p>The <dfn id=dom-hashchangeevent-oldurl><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>

  <p>The <dfn id=dom-hashchangeevent-newurl><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>

  


  <h5 id=the-pagetransitionevent-interface><span class=secno>7.8.10.4</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>

  <pre><code class='idl'>[<c- g>Exposed</c->=<c- n>Window</c->,
 <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>interface</c-> <dfn id='pagetransitionevent'><c- g>PageTransitionEvent</c-></dfn> : <a href='https://dom.spec.whatwg.org/#interface-event' data-x-internal='event' id='the-pagetransitionevent-interface:event'><c- n>Event</c-></a> {
  <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'><c- g>PageTransitionEventInit</c-></dfn> : <a href='https://dom.spec.whatwg.org/#dictdef-eventinit' data-x-internal='eventinit' id='the-pagetransitionevent-interface:eventinit'><c- n>EventInit</c-></a> {
  <c- b>boolean</c-> <c- g>persisted</c-> = <c- b>false</c->;
};</code></pre>

  <dl class=domintro><dt><var>event</var> . <code id=dom-pagetransitionevent-persisted-dev><a href=#dom-pagetransitionevent-persisted>persisted</a></code><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 (if nothing conspires to
    make the page unsalvageable) the page might be reused if the user navigates back to this
    page.</p>

    <p>Things that can cause the page to be unsalvageable include:</p>

    <ul class=brief><li>Listening for <code id=the-pagetransitionevent-interface:event-beforeunload><a href=#event-beforeunload>beforeunload</a></code> events
     <li>Listening for <code id=the-pagetransitionevent-interface:event-unload><a href=#event-unload>unload</a></code> events
     <li>Having <code id=the-pagetransitionevent-interface:the-iframe-element><a href=#the-iframe-element>iframe</a></code>s that are not salvageable
     <li>Active <code id=the-pagetransitionevent-interface:websocket><a href=#websocket>WebSocket</a></code> objects
     <li><a href=#abort-a-document id=the-pagetransitionevent-interface:abort-a-document>Aborting a <code>Document</code></a>
    </ul>

   </dl>

  

  <p>The <dfn id=dom-pagetransitionevent-persisted><code>persisted</code></dfn> attribute must
  return the value it was initialized to. It represents the context information for the event.</p>

  



  <h4 id=unloading-documents><span class=secno>7.8.11</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, a <dfn id=fired-unload>fired unload</dfn> flag, which must initially be false, and a <dfn id=page-showing>page showing</dfn>
  flag, which must initially be false. The <a href=#page-showing id=unloading-documents:page-showing>page showing</a> flag 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 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>To <dfn id=prompt-to-unload-a-document>prompt to unload</dfn>, given a <code id=unloading-documents:document-2><a href=#document>Document</a></code>
  object <var>document</var> and optionally a <var>recursiveFlag</var>, run these steps:</p>

  <ol><li><p>Increase the <a href=#event-loop id=unloading-documents:event-loop-2>event loop</a>'s <a href=#termination-nesting-level id=unloading-documents:termination-nesting-level>termination nesting level</a> by
   1.<li><p>Increase the <var>document</var>'s <a href=#ignore-opens-during-unload-counter id=unloading-documents:ignore-opens-during-unload-counter>ignore-opens-during-unload counter</a> by
   1.<li><p>Let <var>event</var> be the result of <a id=unloading-documents: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=unloading-documents:beforeunloadevent><a href=#beforeunloadevent>BeforeUnloadEvent</a></code>.<li><p>Initialize <var>event</var>'s <code id=unloading-documents: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=unloading-documents:event-beforeunload><a href=#event-beforeunload>beforeunload</a></code> and its <code id=unloading-documents:dom-event-cancelable><a data-x-internal=dom-event-cancelable href=https://dom.spec.whatwg.org/#dom-event-cancelable>cancelable</a></code> attribute true.<li><p><i>Dispatch</i>: <a href=https://dom.spec.whatwg.org/#concept-event-dispatch id=unloading-documents:concept-event-dispatch data-x-internal=concept-event-dispatch>Dispatch</a> <var>event</var> at
   <var>document</var>'s <a href=#concept-relevant-global id=unloading-documents:concept-relevant-global>relevant global object</a>.<li><p>Decrease the <a href=#event-loop id=unloading-documents:event-loop-3>event loop</a>'s <a href=#termination-nesting-level id=unloading-documents:termination-nesting-level-2>termination nesting level</a> by
   1.<li><p>If any event listeners were triggered by the earlier <i>dispatch</i> step, then set
   <var>document</var>'s <i id=unloading-documents:concept-document-salvageable><a href=#concept-document-salvageable>salvageable</a></i> state to
   false.<li>
    <p>If <var>document</var>'s <a href=#active-sandboxing-flag-set id=unloading-documents:active-sandboxing-flag-set>active sandboxing flag set</a> does not have its
    <a href=#sandboxed-modals-flag id=unloading-documents:sandboxed-modals-flag>sandboxed modals flag</a> set, and the <code id=unloading-documents:dom-beforeunloadevent-returnvalue><a href=#dom-beforeunloadevent-returnvalue>returnValue</a></code> attribute of the <var>event</var>
    object is not the empty string, or if the event was canceled, then the user agent may ask the
    user to confirm that they wish to unload the document.</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=unloading-documents:dom-beforeunloadevent-returnvalue-2><a href=#dom-beforeunloadevent-returnvalue>returnValue</a></code> attribute is ignored.</p>

    <p>The user agent is encouraged to avoid asking the user for confirmation if it judges that
    doing so would be annoying, deceptive, or pointless. A simple heuristic might be that if the
    user has not interacted with the document, the user agent would not ask for confirmation before
    unloading it.</p>

    <p>If the user agent asks the user for confirmation, it must <a href=#pause id=unloading-documents:pause>pause</a> while waiting
    for the user's response.</p>

    <p>If the user did not confirm the page navigation, then the user agent <dfn id=refused-to-allow-the-document-to-be-unloaded>refused to allow
    the document to be unloaded</dfn>.</p>
   <li>
    <p>If the <var>recursiveFlag</var> is not set, then:</p>

    <ol><li><p>Let <var>descendants</var> be the <a href=#list-of-the-descendant-browsing-contexts id=unloading-documents:list-of-the-descendant-browsing-contexts>list of the descendant browsing contexts</a>
     of <var>document</var>.<li>
      <p>For each <var>browsingContext</var> in <var>descendants</var>:</p>

      <ol><li><p><a href=#prompt-to-unload-a-document id=unloading-documents:prompt-to-unload-a-document>Prompt to unload</a> <var>browsingContext</var>'s <a href=#active-document id=unloading-documents:active-document>active
       document</a> with the <var>recursiveFlag</var> set. If the user <a href=#refused-to-allow-the-document-to-be-unloaded id=unloading-documents:refused-to-allow-the-document-to-be-unloaded>refused to allow
       the document to be unloaded</a>, then the user implicitly also <a href=#refused-to-allow-the-document-to-be-unloaded id=unloading-documents:refused-to-allow-the-document-to-be-unloaded-2>refused to allow <var>document</var> to be
       unloaded</a>; <a id=unloading-documents:break href=https://infra.spec.whatwg.org/#iteration-break data-x-internal=break>break</a>.<li><p>If the <i id=unloading-documents:concept-document-salvageable-2><a href=#concept-document-salvageable>salvageable</a></i> state of
       <var>browsingContext</var>'s <a href=#active-document id=unloading-documents:active-document-2>active document</a> is false, then set the <i id=unloading-documents:concept-document-salvageable-3><a href=#concept-document-salvageable>salvageable</a></i> state of <var>document</var> to
       false.</ol>
     </ol>
   <li><p>Decrease the <var>document</var>'s <a href=#ignore-opens-during-unload-counter id=unloading-documents:ignore-opens-during-unload-counter-2>ignore-opens-during-unload counter</a> by
   1.</ol>

  <p>To <dfn id=unload-a-document data-lt="unload a document" data-export="">unload</dfn> a
  <code id=unloading-documents:document-3><a href=#document>Document</a></code> <var>document</var>, optionally given a <var>recursiveFlag</var>:</p>

  <ol><li><p>Increase the <a href=#event-loop id=unloading-documents:event-loop-4>event loop</a>'s <a href=#termination-nesting-level id=unloading-documents:termination-nesting-level-3>termination nesting level</a> by
   one.<li><p>Increase <var>document</var>'s <a href=#ignore-opens-during-unload-counter id=unloading-documents:ignore-opens-during-unload-counter-3>ignore-opens-during-unload counter</a> by
   one.<li><p>If <var>document</var>'s <a href=#page-showing id=unloading-documents:page-showing-2>page showing</a> flag is false, then jump to the
   step labeled <i>unload event</i> below (i.e. skip firing the <code id=unloading-documents:event-pagehide-3><a href=#event-pagehide>pagehide</a></code> event and don't rerun the <a href=#unloading-document-visibility-change-steps id=unloading-documents:unloading-document-visibility-change-steps>unloading document
   visibility change steps</a>).<li><p>Set <var>document</var>'s <a href=#page-showing id=unloading-documents:page-showing-3>page showing</a> flag to false.<li><p><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-pagehide-4><a href=#event-pagehide>pagehide</a></code> at <var>document</var>'s <a href=#concept-relevant-global id=unloading-documents:concept-relevant-global-2>relevant global
   object</a>, using <code id=unloading-documents:pagetransitionevent><a href=#pagetransitionevent>PageTransitionEvent</a></code>, with the <code id=unloading-documents:dom-pagetransitionevent-persisted><a href=#dom-pagetransitionevent-persisted>persisted</a></code> attribute initialized to true if
   <var>document</var>'s <i id=unloading-documents:concept-document-salvageable-4><a href=#concept-document-salvageable>salvageable</a></i> state is
   true, and false otherwise, and <var>legacy target override flag</var> set.<li>
    <p>Run any <dfn id=unloading-document-visibility-change-steps>unloading document visibility change steps</dfn> for <var>document</var> that
    are defined by <a href=#other-applicable-specifications id=unloading-documents:other-applicable-specifications>other applicable specifications</a>.</p>

    <p class=note>This is specifically intended for use by the Page Visibility specification. <a href=#refsPAGEVIS>[PAGEVIS]</a></p>
   <li><p><i>Unload event</i>: If <var>document</var>'s <a href=#fired-unload id=unloading-documents:fired-unload>fired unload</a> flag is
   false, then <a href=https://dom.spec.whatwg.org/#concept-event-fire id=unloading-documents:concept-event-fire-2 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>document</var>'s <a href=#concept-relevant-global id=unloading-documents:concept-relevant-global-3>relevant global object</a>,
   with <var>legacy target override flag</var> set.<li><p>Decrease the <a href=#event-loop id=unloading-documents:event-loop-5>event loop</a>'s <a href=#termination-nesting-level id=unloading-documents:termination-nesting-level-4>termination nesting level</a> by
   one.<li><p>If any event listeners were triggered by the earlier <i>unload event</i> step, then set
   <var>document</var>'s <i id=unloading-documents:concept-document-salvageable-5><a href=#concept-document-salvageable>salvageable</a></i> state
   to false and set <var>document</var>'s <a href=#fired-unload id=unloading-documents:fired-unload-2>fired unload</a> flag to true.<li><p>Run any <a href=#unloading-document-cleanup-steps id=unloading-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=unloading-documents:other-applicable-specifications-2>other applicable specifications</a>.<li>
    <p>If the <var>recursiveFlag</var> is not set, then:</p>

    <ol><li><p>Let <var>descendants</var> be the <a href=#list-of-the-descendant-browsing-contexts id=unloading-documents:list-of-the-descendant-browsing-contexts-2>list of the descendant browsing
     contexts</a> of <var>document</var>.<li>
      <p>For each <var>browsingContext</var> in <var>descendants</var>:</p>

      <ol><li><p><a href=#unload-a-document id=unloading-documents:unload-a-document>Unload</a> the <a href=#active-document id=unloading-documents:active-document-3>active document</a> of
       <var>browsingContext</var> with the <var>recursiveFlag</var> set.<li><p>If the <i id=unloading-documents:concept-document-salvageable-6><a href=#concept-document-salvageable>salvageable</a></i> state of the
       <a href=#active-document id=unloading-documents:active-document-4>active document</a> of <var>browsingContext</var> is false, then set the
       <i id=unloading-documents:concept-document-salvageable-7><a href=#concept-document-salvageable>salvageable</a></i> state of <var>document</var> to
       false also.</ol>
     <li><p>If <var>document</var>'s <i id=unloading-documents:concept-document-salvageable-8><a href=#concept-document-salvageable>salvageable</a></i> state
     is false, then <a href=#discard-a-document id=unloading-documents:discard-a-document>discard</a><var>document</var>.</ol>
   <li><p>Decrease <var>document</var>'s <a href=#ignore-opens-during-unload-counter id=unloading-documents:ignore-opens-during-unload-counter-4>ignore-opens-during-unload counter</a> by
   one.</ol>

  <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-4><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-4>relevant global
   object</a>.<li>
    <p>For each <code id=unloading-documents:websocket><a href=#websocket>WebSocket</a></code> object <var>webSocket</var> whose <a href=#concept-relevant-global id=unloading-documents:concept-relevant-global-5>relevant global
    object</a> is <var>window</var>, <a href=#make-disappear id=unloading-documents:make-disappear>make disappear</a> <var>webSocket</var>.</p>

    <p>If this affected any <code id=unloading-documents:websocket-2><a href=#websocket>WebSocket</a></code> objects, then set <var>document</var>'s <i id=unloading-documents:concept-document-salvageable-9><a href=#concept-document-salvageable>salvageable</a></i> state to false.</p>
   <li>
    <p>If <var>document</var>'s <i id=unloading-documents:concept-document-salvageable-10><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-6>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>.<li><p>Empty <var>window</var>'s <a href=#list-of-active-timers id=unloading-documents:list-of-active-timers>list of active timers</a>.</ol>
   </ol>

  



  <h5 id=the-beforeunloadevent-interface><span class=secno>7.8.11.1</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>

  <pre><code class='idl'>[<c- g>Exposed</c->=<c- n>Window</c->]
<c- b>interface</c-> <dfn id='beforeunloadevent'><c- g>BeforeUnloadEvent</c-></dfn> : <a href='https://dom.spec.whatwg.org/#interface-event' data-x-internal='event' id='the-beforeunloadevent-interface: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=#prompt-to-unload-a-document id=the-beforeunloadevent-interface:prompt-to-unload-a-document>prompting to unload</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>

  

  <p>The <dfn id=dom-beforeunloadevent-returnvalue><code>returnValue</code></dfn> attribute
  controls the process of <a href=#prompt-to-unload-a-document id=the-beforeunloadevent-interface:prompt-to-unload-a-document-2>prompting to unload</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>

  <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=aborting-a-document-load><span class=secno>7.8.12</span> Aborting a document load<a href=#aborting-a-document-load class=self-link></a></h4>

  <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 href=#abort-a-document id=aborting-a-document-load:abort-a-document>Abort</a> the <a href=#active-document id=aborting-a-document-load:active-document>active
   documents</a> of every <a href=#child-browsing-context id=aborting-a-document-load:child-browsing-context>child browsing context</a>. If this results in any of those
   <code id=aborting-a-document-load:document-2><a href=#document>Document</a></code> objects having their <i id=aborting-a-document-load:concept-document-salvageable><a href=#concept-document-salvageable>salvageable</a></i> state set to 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> state to false
   also.<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>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-2>tasks</a> or any network data getting
   discarded, then set <var>document</var>'s <i id=aborting-a-document-load:concept-document-salvageable-3><a href=#concept-document-salvageable>salvageable</a></i> state to false.<li><p>If <var>document</var> has an <a href=#active-parser id=aborting-a-document-load:active-parser>active parser</a>, then <a href=#abort-a-parser id=aborting-a-document-load:abort-a-parser>abort that parser</a> and set <var>document</var>'s <i id=aborting-a-document-load:concept-document-salvageable-4><a href=#concept-document-salvageable>salvageable</a></i> state to false.</ol>

  <p>User agents may allow users to explicitly invoke the <a href=#abort-a-document id=aborting-a-document-load:abort-a-document-2>abort a
  document</a> algorithm for a <code id=aborting-a-document-load:document-3><a href=#document>Document</a></code>. If the user does so, then, if that
  <code id=aborting-a-document-load:document-4><a href=#document>Document</a></code> is an <a href=#active-document id=aborting-a-document-load:active-document-2>active document</a>, the user agent should <a href=#queue-a-task id=aborting-a-document-load:queue-a-task-3>queue a
  task</a> to <a href=https://dom.spec.whatwg.org/#concept-event-fire id=aborting-a-document-load:concept-event-fire data-x-internal=concept-event-fire>fire an event</a> named <code id=aborting-a-document-load:event-abort><a href=#event-abort>abort</a></code> at that <code id=aborting-a-document-load:document-5><a href=#document>Document</a></code> object's <a href=#concept-relevant-global id=aborting-a-document-load:concept-relevant-global>relevant global
  object</a> before invoking the <a href=#abort-a-document id=aborting-a-document-load:abort-a-document-3>abort</a> algorithm.</p>

  

  <p>To <dfn id=stop-document-loading>stop document loading</dfn> given a <code id=aborting-a-document-load:document-6><a href=#document>Document</a></code> object <var>document</var>,
  run these steps:</p>

  <ol><li><p>If <var>document</var> is not an <a href=#active-document id=aborting-a-document-load:active-document-3>active document</a>, then return.<li><p>Let <var>browsingContext</var> be <var>document</var>'s <a href=#concept-document-bc id=aborting-a-document-load:concept-document-bc>browsing context</a>.<li><p>If there is an existing attempt to <a href=#navigate id=aborting-a-document-load:navigate>navigate</a> <var>browsingContext</var> and
   that attempt is not currently running the <a href=#unload-a-document id=aborting-a-document-load:unload-a-document>unload a document</a> algorithm, then cancel
   that <a href=#navigate id=aborting-a-document-load:navigate-2>navigation</a>.<li><p><a href=#abort-a-document id=aborting-a-document-load:abort-a-document-4>Abort</a> <var>document</var>.</ol>

  


  <h3 id=offline><span class=secno>7.9</span> Offline Web applications<a href=#offline class=self-link></a></h3><div class=status><input onclick=toggleStatus(this) value=⋰ type=button><p class=support><strong>Support:</strong> offline-apps<span class="and_chr yes"><span>Chrome for Android</span> <span>67+</span></span><span class="chrome yes"><span>Chrome</span> <span>4+</span></span><span class="ios_saf yes"><span>iOS Safari</span> <span>3.2+</span></span><span class="and_uc yes"><span>UC Browser for Android</span> <span>11.8+</span></span><span class="firefox yes"><span>Firefox</span> <span>3.5+</span></span><span class="ie yes"><span>IE</span> <span>10+</span></span><span class="op_mini no"><span>Opera Mini</span> <span>None</span></span><span class="safari yes"><span>Safari</span> <span>4+</span></span><span class="edge yes"><span>Edge</span> <span>12+</span></span><span class="samsung yes"><span>Samsung Internet</span> <span>4+</span></span><span class="opera yes"><span>Opera</span> <span>10.6+</span></span><span class="android yes"><span>Android Browser</span> <span>2.1+</span></span><p class=caniuse>Source: <a href="https://caniuse.com/#feat=offline-apps">caniuse.com</a></div> 

  <p class=critical>This feature is in the process of being removed from the Web platform. (This
  is a long process that takes many years.) Using any of the offline Web application features at
  this time is highly discouraged. Use service workers instead. <a href=#refsSW>[SW]</a></p>

  

  <h4 id=introduction-10><span class=secno>7.9.1</span> Introduction<a href=#introduction-10 class=self-link></a></h4>

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

  <p>In order to enable users to continue interacting with Web applications and documents even when
  their network connection is unavailable — for instance, because they are traveling outside
  of their ISP's coverage area — authors can provide a manifest which lists the files that are
  needed for the Web application to work offline and which causes the user's browser to keep a copy
  of the files for use offline.</p>

  <p>To illustrate this, consider a simple clock applet consisting of an HTML page "<code>clock1.html</code>", a CSS style sheet "<code>clock.css</code>", and a
  JavaScript script "<code>clock.js</code>".</p>

  <p>Before adding the manifest, these three files might look like this:</p>

  <pre><code class='html'><c- c>&lt;!-- clock1.html --&gt;</c->
<c- cp>&lt;!DOCTYPE HTML&gt;</c->
<c- p>&lt;</c-><c- f>html</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>&quot;utf-8&quot;</c-><c- p>&gt;</c->
  <c- p>&lt;</c-><c- f>title</c-><c- p>&gt;</c->Clock<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>&quot;clock.js&quot;</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>&quot;stylesheet&quot;</c-> <c- e>href</c-><c- o>=</c-><c- s>&quot;clock.css&quot;</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 time is: <c- p>&lt;</c-><c- f>output</c-> <c- e>id</c-><c- o>=</c-><c- s>&quot;clock&quot;</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>body</c-><c- p>&gt;</c->
<c- p>&lt;/</c-><c- f>html</c-><c- p>&gt;</c->
</code></pre>
  <pre><code class='css'><c- c>/* clock.css */</c->
<c- f>output </c-><c- p>{</c-> <c- k>font</c-><c- p>:</c-> <c- m>2</c-><c- l>em</c-> sans-serif<c- p>;</c-> <c- p>}</c->
</code></pre>
  <pre><code class='js'><c- d>/* clock.js */</c->
setInterval<c- p>(</c-><c- a>function</c-> <c- p>()</c-> <c- p>{</c->
    document<c- p>.</c->getElementById<c- p>(</c-><c- t>&apos;clock&apos;</c-><c- p>).</c->value <c- o>=</c-> <c- k>new</c-> Date<c- p>();</c->
<c- p>},</c-> <c- mi>1000</c-><c- p>);</c->
</code></pre>

  <p>If the user tries to open the "<code>clock1.html</code>" page while offline, though,
  the user agent (unless it happens to have it still in the local cache) will fail with an
  error.</p>

  <p>The author can instead provide a manifest of the three files, say "<code>clock.appcache</code>":</p>

  <pre>CACHE MANIFEST
clock2.html
clock.css
clock.js
</pre>

  <p>With a small change to the HTML file, the manifest (served as <code id=introduction-10:text/cache-manifest><a href=#text/cache-manifest>text/cache-manifest</a></code>)
  is linked to the application:</p>

  <pre><code class='html'><c- c>&lt;!-- clock2.html --&gt;</c->
<c- cp>&lt;!DOCTYPE HTML&gt;</c->
<c- p>&lt;</c-><c- f>html</c-> <c- e>manifest</c-><c- o>=</c-><c- s>&quot;clock.appcache&quot;</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>&quot;utf-8&quot;</c-><c- p>&gt;</c->
  <c- p>&lt;</c-><c- f>title</c-><c- p>&gt;</c->Clock<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>&quot;clock.js&quot;</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>&quot;stylesheet&quot;</c-> <c- e>href</c-><c- o>=</c-><c- s>&quot;clock.css&quot;</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 time is: <c- p>&lt;</c-><c- f>output</c-> <c- e>id</c-><c- o>=</c-><c- s>&quot;clock&quot;</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>body</c-><c- p>&gt;</c->
<c- p>&lt;/</c-><c- f>html</c-><c- p>&gt;</c->
</code></pre>

  <p>Now, if the user goes to the page, the browser will cache the files and make them available
  even when the user is offline.</p>

  <p class=note>Authors are encouraged to include the main page in the manifest also, but in
  practice the page that referenced the manifest is automatically cached even if it isn't explicitly
  mentioned.</p>

  <p class=note>With the exception of "no-store" directive, HTTP cache headers and restrictions on
  caching pages served over TLS (encrypted, using <code id=introduction-10:https-protocol><a data-x-internal=https-protocol href=https://tools.ietf.org/html/rfc7230#section-2.7.2>https:</a></code>) are
  overridden by manifests. Thus, pages will not expire from an application cache before the user
  agent has updated it, and even applications served over TLS can be made to work offline.</p>

  <p><a href=/demos/offline/clock/clock2.html>View this example online</a>.</p>



  <h5 id=supporting-offline-caching-for-legacy-applications><span class=secno>7.9.1.1</span> Supporting offline caching for legacy applications<a href=#supporting-offline-caching-for-legacy-applications class=self-link></a></h5>

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

  <p>The application cache feature works best if the application logic is separate from the
  application and user data, with the logic (markup, scripts, style sheets, images, etc) listed in
  the manifest and stored in the application cache, with a finite number of static HTML pages for
  the application, and with the application and user data stored in Web Storage or a client-side
  Indexed Database, updated dynamically using Web Sockets, <code id=supporting-offline-caching-for-legacy-applications:xmlhttprequest><a data-x-internal=xmlhttprequest href=https://xhr.spec.whatwg.org/#xmlhttprequest>XMLHttpRequest</a></code>, server-sent
  events, or some other similar mechanism.</p>

  <p>This model results in a fast experience for the user: the application immediately loads, and
  fresh data is obtained as fast as the network will allow it (possibly while stale data shows).</p>

  <p>Legacy applications, however, tend to be designed so that the user data and the logic are mixed
  together in the HTML, with each operation resulting in a new HTML page from the server.</p>

  <div class=example>

   <p>For example, consider a news application. The typical architecture of such an application,
   when not using the application cache feature, is that the user fetches the main page, and the
   server returns a dynamically-generated page with the current headlines and the user interface
   logic mixed together.</p>

   <p>A news application designed for the application cache feature, however, would instead have the
   main page just consist of the logic, and would then have the main page fetch the data separately
   from the server, e.g. using <code id=supporting-offline-caching-for-legacy-applications:xmlhttprequest-2><a data-x-internal=xmlhttprequest href=https://xhr.spec.whatwg.org/#xmlhttprequest>XMLHttpRequest</a></code>.</p>

  </div>

  <p>The mixed-content model does not work well with the application cache feature: since the
  content is cached, it would result in the user always seeing the stale data from the previous time
  the cache was updated.</p>

  <p>While there is no way to make the legacy model work as fast as the separated model, it
  <em>can</em> at least be retrofitted for offline use using the <a href=#concept-appcache-mode-prefer-online id=supporting-offline-caching-for-legacy-applications:concept-appcache-mode-prefer-online>prefer-online</a> <a href=#concept-appcache-mode id=supporting-offline-caching-for-legacy-applications:concept-appcache-mode>application cache mode</a>. To do so, list all the static
  resources used by the HTML page you want to have work offline in an <a href=#concept-appcache-manifest id=supporting-offline-caching-for-legacy-applications:concept-appcache-manifest>application cache manifest</a>, use the <code id=supporting-offline-caching-for-legacy-applications:attr-html-manifest><a href=#attr-html-manifest>manifest</a></code> attribute to select that manifest from the HTML file,
  and then add the following line at the bottom of the manifest:</p>

  <pre>SETTINGS:
prefer-online
NETWORK:
*</pre>

  <p>This causes the <a href=#application-cache id=supporting-offline-caching-for-legacy-applications:application-cache>application cache</a> to only be used for <a href=#concept-appcache-master id=supporting-offline-caching-for-legacy-applications:concept-appcache-master>master entries</a> when the user is offline, and causes the
  application cache to be used as an atomic HTTP cache (essentially pinning resources listed in the
  manifest), while allowing all resources not listed in the manifest to be accessed normally when
  the user is online.</p>



  <h5 id=appcacheevents><span class=secno>7.9.1.2</span> Events summary<a href=#appcacheevents class=self-link></a></h5>

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

  <p>When the user visits a page that declares a manifest, the browser will try to update the cache.
  It does this by fetching a copy of the manifest and, if the manifest has changed since the user
  agent last saw it, redownloading all the resources it mentions and caching them anew.</p>

  <p>As this is going on, a number of events get fired on the <code id=appcacheevents:applicationcache><a href=#applicationcache>ApplicationCache</a></code> object
  to keep the script updated as to the state of the cache update, so that the user can be notified
  appropriately. The events are as follows:</p>

  <table><thead><tr><th> Event name
     <th> Interface
     <th> Fired when...
     <th> Next events
   <tbody><tr><td> <dfn id=event-appcache-checking><code>checking</code></dfn>
     <td> <code id=appcacheevents:event><a data-x-internal=event href=https://dom.spec.whatwg.org/#interface-event>Event</a></code>
     <td> The user agent is checking for an update, or attempting to download the manifest for the
          first time. <strong>This is always the first event in the sequence.</strong>
     <td> <code id=appcacheevents:event-appcache-noupdate><a href=#event-appcache-noupdate>noupdate</a></code>, <code id=appcacheevents:event-appcache-downloading><a href=#event-appcache-downloading>downloading</a></code>, <code id=appcacheevents:event-appcache-obsolete><a href=#event-appcache-obsolete>obsolete</a></code>, <code id=appcacheevents:event-appcache-error><a href=#event-appcache-error>error</a></code>

    <tr><td> <dfn id=event-appcache-noupdate><code>noupdate</code></dfn>
     <td> <code id=appcacheevents:event-2><a data-x-internal=event href=https://dom.spec.whatwg.org/#interface-event>Event</a></code>
     <td> The manifest hadn't changed.
     <td> Last event in sequence.

    <tr><td> <dfn id=event-appcache-downloading><code>downloading</code></dfn>
     <td> <code id=appcacheevents:event-3><a data-x-internal=event href=https://dom.spec.whatwg.org/#interface-event>Event</a></code>
     <td> The user agent has found an update and is fetching it, or is downloading the resources
          listed by the manifest for the first time.
     <td> <code id=appcacheevents:event-appcache-progress><a href=#event-appcache-progress>progress</a></code>, <code id=appcacheevents:event-appcache-error-2><a href=#event-appcache-error>error</a></code>, <code id=appcacheevents:event-appcache-cached><a href=#event-appcache-cached>cached</a></code>, <code id=appcacheevents:event-appcache-updateready><a href=#event-appcache-updateready>updateready</a></code>

    <tr><td> <dfn id=event-appcache-progress><code>progress</code></dfn>
     <td> <code id=appcacheevents:progressevent><a data-x-internal=progressevent href=https://xhr.spec.whatwg.org/#interface-progressevent>ProgressEvent</a></code>
     <td> The user agent is downloading resources listed by the manifest.
          The event object's <code id=appcacheevents:dom-progressevent-total><a data-x-internal=dom-progressevent-total href=https://xhr.spec.whatwg.org/#dom-progressevent-total>total</a></code> attribute returns the total number of files to be downloaded.
          The event object's <code id=appcacheevents:dom-progressevent-loaded><a data-x-internal=dom-progressevent-loaded href=https://xhr.spec.whatwg.org/#dom-progressevent-loaded>loaded</a></code> attribute returns the number of files processed so far.
     <td> <code id=appcacheevents:event-appcache-progress-2><a href=#event-appcache-progress>progress</a></code>, <code id=appcacheevents:event-appcache-error-3><a href=#event-appcache-error>error</a></code>, <code id=appcacheevents:event-appcache-cached-2><a href=#event-appcache-cached>cached</a></code>, <code id=appcacheevents:event-appcache-updateready-2><a href=#event-appcache-updateready>updateready</a></code>

    <tr><td> <dfn id=event-appcache-cached><code>cached</code></dfn>
     <td> <code id=appcacheevents:event-4><a data-x-internal=event href=https://dom.spec.whatwg.org/#interface-event>Event</a></code>
     <td> The resources listed in the manifest have been downloaded, and the application is now cached.
     <td> Last event in sequence.

    <tr><td> <dfn id=event-appcache-updateready><code>updateready</code></dfn>
     <td> <code id=appcacheevents:event-5><a data-x-internal=event href=https://dom.spec.whatwg.org/#interface-event>Event</a></code>
     <td> The resources listed in the manifest have been newly redownloaded, and the script can use
          <code id=appcacheevents:dom-appcache-swapcache><a href=#dom-appcache-swapcache>swapCache()</a></code> to switch to the new cache.
     <td> Last event in sequence.

    <tr><td> <dfn id=event-appcache-obsolete><code>obsolete</code></dfn>
     <td> <code id=appcacheevents:event-6><a data-x-internal=event href=https://dom.spec.whatwg.org/#interface-event>Event</a></code>
     <td> The manifest was found to have become a 404 or 410 page, so the application cache is being deleted.
     <td> Last event in sequence.

    <tr><td rowspan=4> <dfn id=event-appcache-error><code>error</code></dfn>
     <td rowspan=4> <code id=appcacheevents:event-7><a data-x-internal=event href=https://dom.spec.whatwg.org/#interface-event>Event</a></code>
     <td> The manifest was a 404 or 410 page, so the attempt to cache the application has been aborted.
     <td rowspan=3> Last event in sequence.

    <tr><td> The manifest hadn't changed, but the page referencing the manifest failed to download properly.

    <tr><td> A fatal error occurred while fetching the resources listed in the manifest.

    <tr><td> The manifest changed while the update was being run.
     <td> The user agent will try fetching the files again momentarily.

  </table>

  <p>These events are cancelable; their default action is for the user agent to show download
  progress information. If the page shows its own update UI, canceling the events will prevent the
  user agent from showing redundant progress information.</p>



  

  <h4 id=appcache><span class=secno>7.9.2</span> Application caches<a href=#appcache class=self-link></a></h4> 

  <p>An <dfn id=application-cache data-export="">application cache</dfn> is a set of cached resources consisting of:</p>

  <ul><li>

    <p>One or more resources (including their out-of-band metadata, such as HTTP headers, if any),
    identified by URLs, each falling into one (or more) of the following categories:</p>

    <dl><dt><dfn id=concept-appcache-master>Master entries</dfn>

     <dd><p class=note>These are documents that were added to the cache because a <a href=#browsing-context id=appcache:browsing-context>browsing
     context</a> was <a href=#navigate id=appcache:navigate>navigated</a> to that document and the document
     indicated that this was its cache, using the <code id=appcache:attr-html-manifest><a href=#attr-html-manifest>manifest</a></code>
     attribute.</p>


     <dt><dfn id=concept-appcache-manifest>The manifest</dfn>

     <dd><p class=note>This is the resource corresponding to the URL that was given in a master
     entry's <code id=appcache:the-html-element><a href=#the-html-element>html</a></code> element's <code id=appcache:attr-html-manifest-2><a href=#attr-html-manifest>manifest</a></code> attribute.
     The manifest is fetched and processed during the <a href=#application-cache-download-process id=appcache:application-cache-download-process>application cache download
     process</a>. All the <a href=#concept-appcache-master id=appcache:concept-appcache-master>master entries</a> have the
     <a href=#same-origin id=appcache:same-origin>same origin</a> as the manifest.</p>


     <dt><dfn id=concept-appcache-explicit>Explicit entries</dfn>

     <dd><p class=note>These are the resources that were listed in the cache's <a href=#concept-appcache-manifest id=appcache:concept-appcache-manifest>manifest</a> in an <a href=#concept-appcache-manifest-explicit id=appcache:concept-appcache-manifest-explicit>explicit section</a>.</p>


     <dt><dfn id=concept-appcache-fallback>Fallback entries</dfn>

     <dd><p class=note>These are the resources that were listed in the cache's <a href=#concept-appcache-manifest id=appcache:concept-appcache-manifest-2>manifest</a> in a <a href=#concept-appcache-manifest-fallback id=appcache:concept-appcache-manifest-fallback>fallback section</a>.</p>


    </dl>

    <p><a href=#concept-appcache-explicit id=appcache:concept-appcache-explicit>Explicit entries</a> and <a href=#concept-appcache-fallback id=appcache:concept-appcache-fallback>Fallback entries</a> can be marked as <dfn id=concept-appcache-foreign>foreign</dfn>, which means that they have a <code id=appcache:attr-html-manifest-3><a href=#attr-html-manifest>manifest</a></code> attribute but that it doesn't point at this cache's
    <a href=#concept-appcache-manifest id=appcache:concept-appcache-manifest-3>manifest</a>.</p>

    <p class=note>A URL in the list can be flagged with multiple different types, and thus an
    entry can end up being categorized as multiple entries. For example, an entry can be a manifest
    entry and an explicit entry at the same time, if the manifest is listed within the manifest.</p>

   <li>

    <p>Zero or more <dfn id=concept-appcache-fallback-ns>fallback namespaces</dfn>, each of
    which is mapped to a <a href=#concept-appcache-fallback id=appcache:concept-appcache-fallback-2>fallback entry</a>.</p>

    <p class=note>These are URLs used as <a href=#concept-appcache-matches-fallback id=appcache:concept-appcache-matches-fallback>prefix
    match patterns</a> for resources that are to be fetched from the network if possible, or to
    be replaced by the corresponding <a href=#concept-appcache-fallback id=appcache:concept-appcache-fallback-3>fallback entry</a>
    if not. Each namespace URL has the <a href=#same-origin id=appcache:same-origin-2>same origin</a> as <a href=#concept-appcache-manifest id=appcache:concept-appcache-manifest-4>the manifest</a>.</p>

   <li>

    <p>Zero or more URLs that form the <dfn id=concept-appcache-onlinesafelist>online
    safelist namespaces</dfn>.</p>

    <p class=note>These are used as prefix match patterns, and declare URLs for which the user
    agent will ignore the application cache, instead fetching them normally (i.e. from the network
    or local HTTP cache as appropriate).</p>

   <li>

    <p>An <dfn id=concept-appcache-onlinesafelist-wildcard>online safelist wildcard
    flag</dfn>, which is either <i>open</i> or <i>blocking</i>.</p>

    <p class=note>The <i>open</i> state indicates that any URL not listed as cached is to
    be implicitly treated as being in the <a href=#concept-appcache-onlinesafelist id=appcache:concept-appcache-onlinesafelist>online
    safelist namespaces</a>; the <i>blocking</i> state indicates that URLs not listed
    explicitly in the manifest are to be treated as unavailable.</p>

   <li>

    <p>A <dfn id=concept-appcache-mode>cache mode flag</dfn>, which is either in the <dfn id=concept-appcache-mode-fast><i>fast</i></dfn> state or the <dfn id=concept-appcache-mode-prefer-online><i>prefer-online</i></dfn> state.</p>

   </ul>

  <p>Each <a href=#application-cache id=appcache:application-cache>application cache</a> has a <dfn id=concept-appcache-completeness>completeness flag</dfn>, which is either <i>complete</i> or
  <i>incomplete</i>.</p>

  <hr>

  <p>An <dfn id=application-cache-group>application cache group</dfn> is a group of <a href=#application-cache id=appcache:application-cache-2>application
  caches</a>, identified by the <a id=appcache:absolute-url href=https://url.spec.whatwg.org/#syntax-url-absolute data-x-internal=absolute-url>absolute URL</a> of a resource <a href=#concept-appcache-manifest id=appcache:concept-appcache-manifest-5>manifest</a> which is used to populate the caches in the
  group.</p>

  <p>An <a href=#application-cache id=appcache:application-cache-3>application cache</a> is <dfn id=concept-appcache-newer>newer</dfn> than
  another if it was created after the other (in other words, <a href=#application-cache id=appcache:application-cache-4>application caches</a> in an <a href=#application-cache-group id=appcache:application-cache-group>application cache group</a> have a chronological
  order).</p>

  <p>Only the newest <a href=#application-cache id=appcache:application-cache-5>application cache</a> in an <a href=#application-cache-group id=appcache:application-cache-group-2>application cache group</a> can
  have its <a href=#concept-appcache-completeness id=appcache:concept-appcache-completeness>completeness flag</a> set to
  <i>incomplete</i>; the others are always all <i>complete</i>.</p>

  <p>Each <a href=#application-cache-group id=appcache:application-cache-group-3>application cache group</a> has an <dfn id=concept-appcache-status>update
  status</dfn>, which is one of the following: <i>idle</i>, <i>checking</i>, <i>downloading</i>.</p>

  <p>A <dfn id=relevant-application-cache>relevant application cache</dfn> is an <a href=#application-cache id=appcache:application-cache-6>application cache</a> that is the <a href=#concept-appcache-newer id=appcache:concept-appcache-newer>newest</a> in its <a href=#application-cache-group id=appcache:application-cache-group-4>group</a> to be <i>complete</i>.</p>

  <p>Each <a href=#application-cache-group id=appcache:application-cache-group-5>application cache group</a> has a <dfn id=concept-appcache-pending-masters>list of pending master entries</dfn>. Each entry in this
  list consists of a resource and a corresponding <code id=appcache:document><a href=#document>Document</a></code> object. It is used during
  the <a href=#application-cache-download-process id=appcache:application-cache-download-process-2>application cache download process</a> to ensure that new master entries are cached
  even if the <a href=#application-cache-download-process id=appcache:application-cache-download-process-3>application cache download process</a> was already running for their
  <a href=#application-cache-group id=appcache:application-cache-group-6>application cache group</a> when they were loaded.</p>

  <p>An <a href=#application-cache-group id=appcache:application-cache-group-7>application cache group</a> can be marked as <dfn id=concept-appcache-obsolete>obsolete</dfn>, meaning that it must be ignored when looking at
  what <a href=#application-cache-group id=appcache:application-cache-group-8>application cache groups</a> exist.</p>

  <hr>

  <p>A <dfn id=cache-host>cache host</dfn> is a <code id=appcache:document-2><a href=#document>Document</a></code> object.</p>

  <p>Each <a href=#cache-host id=appcache:cache-host>cache host</a> has an associated <code id=appcache:applicationcache><a href=#applicationcache>ApplicationCache</a></code> object.</p>

  <p>Each <a href=#cache-host id=appcache:cache-host-2>cache host</a> initially is not associated with an <a href=#application-cache id=appcache:application-cache-7>application
  cache</a>, but can become associated with one early during the page load process, when steps <a href=#parser-appcache>in the parser</a> and in the <a href=#navigate id=appcache:navigate-2>navigation</a>
  sections cause <a href=#concept-appcache-init id=appcache:concept-appcache-init>cache selection</a> to occur.</p>

  <hr>

  <p>Multiple <a href=#application-cache id=appcache:application-cache-8>application caches</a> in different <a href=#application-cache-group id=appcache:application-cache-group-9>application cache groups</a> can contain the same resource,
  e.g. if the manifests all reference that resource. If the user agent is to <dfn id=concept-appcache-selection>select an application cache</dfn> from a list of <a href=#relevant-application-cache id=appcache:relevant-application-cache>relevant application caches</a> that contain a resource, the
  user agent must use the application cache that the user most likely wants to see the resource
  from, taking into account the following:</p>

  <ul><li>which application cache was most recently updated,

   <li>which application cache was being used to display the resource from which the user decided to
   look at the new resource, and

   <li>which application cache the user prefers.

  </ul>

  <hr>

  <p>A URL <dfn id=concept-appcache-matches-fallback>matches a fallback namespace</dfn> if
  there exists a <a href=#relevant-application-cache id=appcache:relevant-application-cache-2>relevant application cache</a> whose <a href=#concept-appcache-manifest id=appcache:concept-appcache-manifest-6>manifest</a>'s URL has the <a href=#same-origin id=appcache:same-origin-3>same origin</a> as the
  URL in question, and that has a <a href=#concept-appcache-fallback-ns id=appcache:concept-appcache-fallback-ns>fallback
  namespace</a> that is a <a href=#prefix-match id=appcache:prefix-match>prefix match</a> for the URL being examined. If multiple
  fallback namespaces match the same URL, the longest one is the one that matches. A URL looking for
  a fallback namespace can match more than one application cache at a time, but only matches one
  namespace in each cache.</p>

  <div class=example>

   <p>If a manifest <code>https://example.com/app1/manifest</code> declares that <code>https://example.com/resources/images</code> is a fallback namespace, and the user
   navigates to <code>https://example.com:80/resources/images/cat.png</code>, then the user
   agent will decide that the application cache identified by <code>https://example.com/app1/manifest</code> contains a namespace with a match for that
   URL.</p>

   

  </div>

  



  <h4 id=manifests><span class=secno>7.9.3</span> The cache manifest syntax<a href=#manifests class=self-link></a></h4>


  <h5 id=some-sample-manifests><span class=secno>7.9.3.1</span> Some sample manifests<a href=#some-sample-manifests class=self-link></a></h5>

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

  <div class=example>

   <p>This example manifest requires two images and a style sheet to be cached and safelists a CGI
   script.</p>

   <pre>CACHE MANIFEST
# the above line is required

# this is a comment
# there can be as many of these anywhere in the file
# they are all ignored
  # comments can have spaces before them
  # but must be alone on the line

# blank lines are ignored too

# these are files that need to be cached they can either be listed
# first, or a "CACHE:" header could be put before them, as is done
# lower down.
images/sound-icon.png
images/background.png
# note that each file has to be put on its own line

# here is a file for the online safelist -- it isn't cached, and
# references to this file will bypass the cache, always hitting the
# network (or trying to, if the user is offline).
NETWORK:
comm.cgi

# here is another set of files to cache, this time just the CSS file.
CACHE:
style/default.css</pre>

   <p>It could equally well be written as follows:</p>

   <pre>CACHE MANIFEST
NETWORK:
comm.cgi
CACHE:
style/default.css
images/sound-icon.png
images/background.png</pre>

  </div>

  <div class=example>

   <p>Offline application cache manifests can use absolute paths or even absolute URLs:</p>

   <pre>CACHE MANIFEST

/main/home
/main/app.js
/settings/home
/settings/app.js
https://img.example.com/logo.png
https://img.example.com/check.png
https://img.example.com/cross.png</pre>

  </div>

  <div class=example>

   <p>The following manifest defines a catch-all error page that is displayed for any page on the
   site while the user is offline. It also specifies that the <a href=#concept-appcache-onlinesafelist-wildcard id=some-sample-manifests:concept-appcache-onlinesafelist-wildcard>online safelist wildcard flag</a> is <i>open</i>, meaning that accesses to resources on other sites will not be blocked.
   (Resources on the same site are already not blocked because of the catch-all fallback
   namespace.)</p>

   <p>So long as all pages on the site reference this manifest, they will get cached locally as they
   are fetched, so that subsequent hits to the same page will load the page immediately from the
   cache. Until the manifest is changed, those pages will not be fetched from the server again. When
   the manifest changes, then all the files will be redownloaded.</p>

   <p>Subresources, such as style sheets, images, etc, would only be cached using the regular HTTP
   caching semantics, however.</p>

   <pre>CACHE MANIFEST
FALLBACK:
/ /offline.html
NETWORK:
*</pre>

  </div>



  <h5 id=writing-cache-manifests><span class=secno>7.9.3.2</span> Writing cache manifests<a href=#writing-cache-manifests class=self-link></a></h5>

  <p>Manifests must be served using the <code id=writing-cache-manifests:text/cache-manifest><a href=#text/cache-manifest>text/cache-manifest</a></code> <a id=writing-cache-manifests:mime-type href=https://mimesniff.spec.whatwg.org/#mime-type data-x-internal=mime-type>MIME type</a>. All
  resources served using the <code id=writing-cache-manifests:text/cache-manifest-2><a href=#text/cache-manifest>text/cache-manifest</a></code> <a id=writing-cache-manifests:mime-type-2 href=https://mimesniff.spec.whatwg.org/#mime-type data-x-internal=mime-type>MIME type</a> must follow the
  syntax of application cache manifests, as described in this section.</p>

  <p>An application cache manifest is a text file, whose text is encoded using UTF-8. Data in
  application cache manifests is line-based. Newlines must be represented by U+000A LINE FEED (LF)
  characters, U+000D CARRIAGE RETURN (CR) characters, or U+000D CARRIAGE RETURN (CR) U+000A LINE
  FEED (LF) pairs. <a href=#refsENCODING>[ENCODING]</a></p>

  <p class=note>This is a <a href=#willful-violation id=writing-cache-manifests:willful-violation>willful violation</a> of RFC 2046, which requires all <code>text/*</code> types to only allow CRLF line breaks. This requirement, however, is
  outdated; the use of CR, LF, and CRLF line breaks is commonly supported and indeed sometimes CRLF
  is <em>not</em> supported by text editors. <a href=#refsRFC2046>[RFC2046]</a></p>

  <p>The first line of an application cache manifest must consist of the string "CACHE", a single
  U+0020 SPACE character, the string "MANIFEST", and either a U+0020 SPACE character, a U+0009
  CHARACTER TABULATION (tab) character, a U+000A LINE FEED (LF) character, or a U+000D CARRIAGE
  RETURN (CR) character. The first line may optionally be preceded by a U+FEFF BYTE ORDER MARK (BOM)
  character. If any other text is found on the first line, it is ignored.</p>

  <p>Subsequent lines, if any, must all be one of the following:</p>

  <dl><dt>A blank line
   <dd>
    <p>Blank lines must consist of zero or more U+0020 SPACE and
    U+0009 CHARACTER TABULATION (tab) characters only.</p>

   <dt>A comment
   <dd>
    <p>Comment lines must consist of zero or more U+0020 SPACE and U+0009 CHARACTER TABULATION (tab)
    characters, followed by a single U+0023 NUMBER SIGN character (#), followed by zero or more
    characters other than U+000A LINE FEED (LF) and U+000D CARRIAGE RETURN (CR) characters.</p>

    <p class=note>Comments need to be on a line on their own. If they were to be included on a
    line with a URL, the "#" would be mistaken for part of a <a href=https://url.spec.whatwg.org/#concept-url-fragment id=writing-cache-manifests:concept-url-fragment data-x-internal=concept-url-fragment>fragment</a>.</p>

   <dt>A section header
   <dd>

    <p>Section headers change the current section. There are four possible section headers:

    <dl><dt><code>CACHE:</code>
     <dd>Switches to the <dfn id=concept-appcache-manifest-explicit>explicit section</dfn>.

     <dt><code>FALLBACK:</code>
     <dd>Switches to the <dfn id=concept-appcache-manifest-fallback>fallback section</dfn>.

     <dt><code>NETWORK:</code>
     <dd>Switches to the <dfn id=concept-appcache-manifest-network>online safelist section</dfn>.

     <dt><code>SETTINGS:</code>
     <dd>Switches to the <dfn id=concept-appcache-manifest-settings>settings section</dfn>.

    </dl>

    <p>Section header lines must consist of zero or more U+0020 SPACE and U+0009 CHARACTER
    TABULATION (tab) characters, followed by one of the names above (including the U+003A COLON
    character (:)) followed by zero or more U+0020 SPACE and U+0009 CHARACTER TABULATION (tab)
    characters.</p>

    <p>Ironically, by default, the current section is the <a href=#concept-appcache-manifest-explicit id=writing-cache-manifests:concept-appcache-manifest-explicit>explicit section</a>.</p>

   <dt>Data for the current section
   <dd>

    <p>The format that data lines must take depends on the current section.</p>

    <p>When the current section is the <a href=#concept-appcache-manifest-explicit id=writing-cache-manifests:concept-appcache-manifest-explicit-2>explicit
    section</a>, data lines must consist of zero or more U+0020 SPACE and U+0009 CHARACTER
    TABULATION (tab) characters, a <a id=writing-cache-manifests:valid-url-string href=https://url.spec.whatwg.org/#valid-url-string data-x-internal=valid-url-string>valid URL string</a> identifying a resource other than
    the manifest itself, and then zero or more U+0020 SPACE and U+0009 CHARACTER TABULATION (tab)
    characters.</p>

    <p>When the current section is the <a href=#concept-appcache-manifest-fallback id=writing-cache-manifests:concept-appcache-manifest-fallback>fallback
    section</a>, data lines must consist of zero or more U+0020 SPACE and U+0009 CHARACTER
    TABULATION (tab) characters, a <a id=writing-cache-manifests:valid-url-string-2 href=https://url.spec.whatwg.org/#valid-url-string data-x-internal=valid-url-string>valid URL string</a> identifying a resource other than
    the manifest itself, one or more U+0020 SPACE and U+0009 CHARACTER TABULATION (tab) characters,
    another <a id=writing-cache-manifests:valid-url-string-3 href=https://url.spec.whatwg.org/#valid-url-string data-x-internal=valid-url-string>valid URL string</a> identifying a resource other than the manifest itself, and
    then zero or more U+0020 SPACE and U+0009 CHARACTER TABULATION (tab) characters.</p>

    <p>When the current section is the <a href=#concept-appcache-manifest-network id=writing-cache-manifests:concept-appcache-manifest-network>online
    safelist section</a>, data lines must consist of zero or more U+0020 SPACE and U+0009
    CHARACTER TABULATION (tab) characters, either a single U+002A ASTERISK character (*)  or a <a id=writing-cache-manifests:valid-url-string-4 href=https://url.spec.whatwg.org/#valid-url-string data-x-internal=valid-url-string>valid URL string</a> identifying a
    resource other than the manifest itself, and then zero or more U+0020 SPACE and U+0009 CHARACTER
    TABULATION (tab) characters.</p>

    <p>When the current section is the <a href=#concept-appcache-manifest-settings id=writing-cache-manifests:concept-appcache-manifest-settings>settings
    section</a>, data lines must consist of zero or more U+0020 SPACE and U+0009 CHARACTER
    TABULATION (tab) characters, a <a href=#concept-appcache-manifest-setting id=writing-cache-manifests:concept-appcache-manifest-setting>setting</a>,
    and then zero or more U+0020 SPACE and U+0009 CHARACTER TABULATION (tab) characters.</p>

    <p>Currently only one <dfn id=concept-appcache-manifest-setting>setting</dfn> is
    defined:</p>

    <dl><dt>The cache mode setting<dd>This consists of the string "<code>prefer-online</code>". It sets the <a href=#concept-appcache-mode id=writing-cache-manifests:concept-appcache-mode>cache mode</a> to <a href=#concept-appcache-mode-prefer-online id=writing-cache-manifests:concept-appcache-mode-prefer-online>prefer-online</a>. (The <a href=#concept-appcache-mode id=writing-cache-manifests:concept-appcache-mode-2>cache mode</a> defaults to <a href=#concept-appcache-mode-fast id=writing-cache-manifests:concept-appcache-mode-fast>fast</a>.)</dl>

    <p>Within a <a href=#concept-appcache-manifest-settings id=writing-cache-manifests:concept-appcache-manifest-settings-2>settings section</a>, each <a href=#concept-appcache-manifest-setting id=writing-cache-manifests:concept-appcache-manifest-setting-2>setting</a> must occur no more than once.</p>



  </dl>

  <p>Manifests may contain sections more than once. Sections may be empty.</p>

  <p>URLs that are to be fallback pages associated with <a href=#concept-appcache-fallback-ns id=writing-cache-manifests:concept-appcache-fallback-ns>fallback namespaces</a>, and those namespaces themselves,
  must be given in <a href=#concept-appcache-manifest-fallback id=writing-cache-manifests:concept-appcache-manifest-fallback-2>fallback sections</a>, with
  the namespace being the first URL of the data line, and the corresponding fallback page being the
  second URL. All the other pages to be cached must be listed in <a href=#concept-appcache-manifest-explicit id=writing-cache-manifests:concept-appcache-manifest-explicit-3>explicit sections</a>.</p>

  <p><a href=#concept-appcache-fallback-ns id=writing-cache-manifests:concept-appcache-fallback-ns-2>Fallback namespaces</a> and <a href=#concept-appcache-fallback id=writing-cache-manifests:concept-appcache-fallback>fallback entries</a> must have the <a href=#same-origin id=writing-cache-manifests:same-origin>same origin</a>
  as the manifest itself. <a href=#concept-appcache-fallback-ns id=writing-cache-manifests:concept-appcache-fallback-ns-3>Fallback namespaces</a>
  must also be in the same path as the manifest's URL.</p>

  <p>A <a href=#concept-appcache-fallback-ns id=writing-cache-manifests:concept-appcache-fallback-ns-4>fallback namespace</a> must not be listed more
  than once.</p>

  <p>Namespaces that the user agent is to put into the <a href=#concept-appcache-onlinesafelist id=writing-cache-manifests:concept-appcache-onlinesafelist>online safelist</a> must all be specified in <a href=#concept-appcache-manifest-network id=writing-cache-manifests:concept-appcache-manifest-network-2>online safelist sections</a>. (This is needed for
  any URL that the page is intending to use to communicate back to the server.) To specify that all
  URLs are automatically safelisted in this way, a U+002A ASTERISK character (*) may be specified
  as one of the URLs. </p>

  <p>Authors should not include namespaces in the <a href=#concept-appcache-onlinesafelist id=writing-cache-manifests:concept-appcache-onlinesafelist-2>online safelist</a> for which another namespace in
  the <a href=#concept-appcache-onlinesafelist id=writing-cache-manifests:concept-appcache-onlinesafelist-3>online safelist</a> is a <a href=#prefix-match id=writing-cache-manifests:prefix-match>prefix
  match</a>.</p>

  <p><a href=https://url.spec.whatwg.org/#syntax-url-relative id=writing-cache-manifests:relative-url data-x-internal=relative-url>Relative URLs</a> must be given relative to the manifest's own
  URL. All URLs in the manifest must have the same <a href=https://url.spec.whatwg.org/#concept-url-scheme id=writing-cache-manifests:concept-url-scheme data-x-internal=concept-url-scheme>scheme</a> as
  the manifest itself (either explicitly or implicitly, through the use of <a href=https://url.spec.whatwg.org/#syntax-url-relative id=writing-cache-manifests:relative-url-2 data-x-internal=relative-url>relative URLs</a>). <a href=#refsURL>[URL]</a></p>

  <p>URLs in manifests must not have <a href=https://url.spec.whatwg.org/#concept-url-fragment id=writing-cache-manifests:concept-url-fragment-2 data-x-internal=concept-url-fragment>fragments</a> (i.e. the
  U+0023 NUMBER SIGN character isn't allowed in URLs in manifests).</p>

  <p><a href=#concept-appcache-fallback-ns id=writing-cache-manifests:concept-appcache-fallback-ns-5>Fallback namespaces</a> and namespaces in the
  <a href=#concept-appcache-onlinesafelist id=writing-cache-manifests:concept-appcache-onlinesafelist-4>online safelist</a> are matched by <a href=#prefix-match id=writing-cache-manifests:prefix-match-2>prefix
  match</a>.</p>


  

  <h5 id=parsing-cache-manifests><span class=secno>7.9.3.3</span> Parsing cache manifests<a href=#parsing-cache-manifests class=self-link></a></h5>

  <p>When a user agent is to <dfn id=parse-a-manifest>parse a manifest</dfn>, it means that the user agent must run the
  following steps:</p>

  <ol><li>

    <p><a id=parsing-cache-manifests:utf-8-decode href=https://encoding.spec.whatwg.org/#utf-8-decode data-x-internal=utf-8-decode>UTF-8 decode</a> the byte stream corresponding with the manifest to be parsed.</p>

    <p class=note>The <a id=parsing-cache-manifests: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 a leading BOM, if any.</p>

    

   <li><p>Let <var>base URL</var> be the <a id=parsing-cache-manifests:absolute-url href=https://url.spec.whatwg.org/#syntax-url-absolute data-x-internal=absolute-url>absolute URL</a> representing the
   manifest.<li><p>Apply the <a id=parsing-cache-manifests:url-parser href=https://url.spec.whatwg.org/#concept-url-parser data-x-internal=url-parser>URL parser</a> to <var>base URL</var>, and let <var>manifest path</var>
   be the <a href=https://url.spec.whatwg.org/#concept-url-path id=parsing-cache-manifests:concept-url-path data-x-internal=concept-url-path>path</a> component thus obtained.<li><p>Remove all the characters in <var>manifest path</var> after the last U+002F SOLIDUS
   character (/), if any. (The first character and the last character in <var>manifest path</var>
   after this step will both be slashes, the URL path separator character.)<li><p>Apply the <a id=parsing-cache-manifests:url-parser-2 href=https://url.spec.whatwg.org/#concept-url-parser data-x-internal=url-parser>URL parser</a> steps to the <var>base URL</var>, so that the
   components from its <a id=parsing-cache-manifests:url-record href=https://url.spec.whatwg.org/#concept-url data-x-internal=url-record>URL record</a> can be used by the subsequent steps of this
   algorithm.<li><p>Let <var>explicit URLs</var> be an initially empty list of <a href=https://url.spec.whatwg.org/#syntax-url-absolute id=parsing-cache-manifests:absolute-url-2 data-x-internal=absolute-url>absolute URLs</a> for <a href=#concept-appcache-explicit id=parsing-cache-manifests:concept-appcache-explicit>explicit
   entries</a>.<li><p>Let <var>fallback URLs</var> be an initially empty mapping of <a href=#concept-appcache-fallback-ns id=parsing-cache-manifests:concept-appcache-fallback-ns>fallback namespaces</a> to <a href=https://url.spec.whatwg.org/#syntax-url-absolute id=parsing-cache-manifests:absolute-url-3 data-x-internal=absolute-url>absolute URLs</a> for <a href=#concept-appcache-fallback id=parsing-cache-manifests:concept-appcache-fallback>fallback
   entries</a>.<li><p>Let <var>online safelist namespaces</var> be an initially empty list of <a href=https://url.spec.whatwg.org/#syntax-url-absolute id=parsing-cache-manifests:absolute-url-4 data-x-internal=absolute-url>absolute URLs</a> for an <a href=#concept-appcache-onlinesafelist id=parsing-cache-manifests:concept-appcache-onlinesafelist>online safelist</a>.<li><p>Let <var>online safelist wildcard flag</var> be <i>blocking</i>. <li><p>Let <var>cache mode flag</var> be <i>fast</i>. <li><p>Let <var>input</var> be the decoded text of the manifest's byte stream.<li><p>Let <var>position</var> be a pointer into <var>input</var>, initially
   pointing at the first character.<li><p>If the characters starting from <var>position</var> are "CACHE", followed by a
   U+0020 SPACE character, followed by "MANIFEST", then advance <var>position</var> to the
   next character after those. Otherwise, this isn't a cache manifest; return with a
   failure while checking for the magic signature.<li><p>If the character at <var>position</var> is neither a U+0020 SPACE character, a
   U+0009 CHARACTER TABULATION (tab) character, U+000A LINE FEED (LF) character, nor a U+000D
   CARRIAGE RETURN (CR) character, then this isn't a cache manifest; return with a
   failure while checking for the magic signature.<li><p>This is a cache manifest. The algorithm cannot fail beyond
   this point (though bogus lines can get ignored).<li><p><a id=parsing-cache-manifests: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 <em>not</em> U+000A LINE FEED (LF)
   or U+000D CARRIAGE RETURN (CR) characters from <var>input</var> given <var>position</var>, and
   ignore those characters. (Extra text on the first line, after the signature, is
   ignored.)<li><p>Let <var>mode</var> be "explicit".<li><p><i>Start of line</i>: If <var>position</var> is past the end of <var>input</var>, then
   jump to the last step. Otherwise, <a id=parsing-cache-manifests: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 U+000A
   LINE FEED (LF), U+000D CARRIAGE RETURN (CR), U+0020 SPACE, or U+0009 CHARACTER TABULATION (tab)
   characters from <var>input</var> given <var>position</var>.<li><p>Now, <a id=parsing-cache-manifests: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 <em>not</em> U+000A LINE FEED
   (LF) or U+000D CARRIAGE RETURN (CR) characters from <var>input</var> given <var>position</var>,
   and let the result be <var>line</var>.<li><p>Drop any trailing U+0020 SPACE and U+0009 CHARACTER TABULATION (tab) characters at the end
   of <var>line</var>.<li><p>If <var>line</var> is the empty string, then jump back to the step labeled <i>start
   of line</i>.<li><p>If the first character in <var>line</var> is a U+0023 NUMBER SIGN character (#),
   then jump back to the step labeled <i>start of line</i>.<li><p>If <var>line</var> equals "CACHE:" (the word "CACHE" followed by a U+003A COLON
   character (:)), then set <var>mode</var> to "explicit" and jump back to the step labeled
   <i>start of line</i>.<li><p>If <var>line</var> equals "FALLBACK:" (the word "FALLBACK" followed by a U+003A
   COLON character (:)), then set <var>mode</var> to "fallback" and jump back to the step
   labeled <i>start of line</i>.<li><p>If <var>line</var> equals "NETWORK:" (the word "NETWORK" followed by a U+003A
   COLON character (:)), then set <var>mode</var> to "online safelist" and jump back to
   the step labeled <i>start of line</i>.<li><p>If <var>line</var> equals "SETTINGS:" (the word "SETTINGS" followed by a U+003A
   COLON character (:)), then set <var>mode</var> to "settings" and jump back to the step
   labeled <i>start of line</i>.<li><p>If <var>line</var> ends with a U+003A COLON character (:), then set <var>mode</var> to "unknown" and jump back to the step labeled <i>start of line</i>.<li><p>This is either a data line or it is syntactically incorrect.<li><p>Let <var>position</var> be a pointer into <var>line</var>, initially
   pointing at the start of the string.<li><p>Let <var>tokens</var> be a list of strings, initially empty.<li>

    <p>While <var>position</var> doesn't point past the end of <var>line</var>:</p>

    <ol><li><p>Let <var>current token</var> be an empty string.<li><p>While <var>position</var> doesn't point past the end of <var>line</var> and the character at <var>position</var> is neither a U+0020 SPACE
     nor a U+0009 CHARACTER TABULATION (tab) character, add the character at <var>position</var> to <var>current token</var> and advance <var>position</var> to the next character in <var>input</var>.<li><p>Add <var>current token</var> to the <var>tokens</var> list.<li><p>While <var>position</var> doesn't point past the end of <var>line</var> and the character at <var>position</var> is either a U+0020 SPACE
     or a U+0009 CHARACTER TABULATION (tab) character, advance <var>position</var> to the
     next character in <var>input</var>.</ol>

   <li>

    <p>Process <var>tokens</var> as follows:</p>

    <dl class=switch><dt>If <var>mode</var> is "explicit"<dd>

      <p>Let <var>urlRecord</var> be the result of <a href=https://url.spec.whatwg.org/#concept-url-parser id=parsing-cache-manifests:url-parser-3 data-x-internal=url-parser>parsing</a> the
      first item in <var>tokens</var> with <var>base URL</var>; ignore the rest.</p>

      <p>If <var>urlRecord</var> is failure, then jump back to the step labeled <i>start of
      line</i>.</p>

      <p>If <var>urlRecord</var> has a different <a href=https://url.spec.whatwg.org/#concept-url-scheme id=parsing-cache-manifests:concept-url-scheme data-x-internal=concept-url-scheme>scheme</a>
      component than <var>base URL</var> (the manifest's URL), then jump back to the step labeled
      <i>start of line</i>.</p>

      <p>Let <var>new URL</var> be the result of applying the <a href=https://url.spec.whatwg.org/#concept-url-serializer id=parsing-cache-manifests:concept-url-serializer data-x-internal=concept-url-serializer>URL serializer</a> algorithm to <var>urlRecord</var>, with
      the <i>exclude fragment flag</i> set.</p>

      <p>Add <var>new URL</var> to the <var>explicit URLs</var>.</p>

     <dt>If <var>mode</var> is "fallback"<dd>

      <p>Let <var>part one</var> be the first token in <var>tokens</var>, and let
      <var>part two</var> be the second token in <var>tokens</var>.</p>

      <p>Let <var>urlRecordOne</var> be the result of <a href=https://url.spec.whatwg.org/#concept-url-parser id=parsing-cache-manifests:url-parser-4 data-x-internal=url-parser>parsing</a>
      <var>part one</var> with <var>base URL</var>.</p>

      <p>Let <var>urlRecordTwo</var> be the result of <a href=https://url.spec.whatwg.org/#concept-url-parser id=parsing-cache-manifests:url-parser-5 data-x-internal=url-parser>parsing</a>
      <var>part two</var> with <var>base URL</var>.</p>

      <p>If either <var>urlRecordOne</var> or <var>urlRecordTwo</var> are failure, then jump back to
      the step labeled <i>start of line</i>.</p>

      <p>If the <a href=https://url.spec.whatwg.org/#concept-url-origin id=parsing-cache-manifests:concept-url-origin data-x-internal=concept-url-origin>origin</a> of either <var>urlRecordOne</var> or
      <var>urlRecordTwo</var> is not <a href=#same-origin id=parsing-cache-manifests:same-origin>same origin</a> with the manifest's URL <a href=https://url.spec.whatwg.org/#concept-url-origin id=parsing-cache-manifests:concept-url-origin-2 data-x-internal=concept-url-origin>origin</a>, then jump back to the step labeled <i>start of
      line</i>.</p>

      <p>Let <var>part one path</var> be the <a href=https://url.spec.whatwg.org/#concept-url-path id=parsing-cache-manifests:concept-url-path-2 data-x-internal=concept-url-path>path</a> component
      of <var>urlRecordOne</var>.</p>

      <p>If <var>manifest path</var> is not a <a href=#prefix-match id=parsing-cache-manifests:prefix-match>prefix match</a> for <var>part one
      path</var>, then jump back to the step labeled <i>start of line</i>.</p> 


      <p>Let <var>part one</var> be the result of applying the <a href=https://url.spec.whatwg.org/#concept-url-serializer id=parsing-cache-manifests:concept-url-serializer-2 data-x-internal=concept-url-serializer>URL serializer</a> algorithm to <var>urlRecordOne</var>,
      with the <i>exclude fragment flag</i> set.</p>

      <p>Let <var>part two</var> be the result of applying the <a href=https://url.spec.whatwg.org/#concept-url-serializer id=parsing-cache-manifests:concept-url-serializer-3 data-x-internal=concept-url-serializer>URL serializer</a> algorithm to <var>urlRecordTwo</var>,
      with the <i>exclude fragment flag</i> set.</p>

      <p>If <var>part one</var> is already in the <var>fallback URLs</var> mapping
      as a <a href=#concept-appcache-fallback-ns id=parsing-cache-manifests:concept-appcache-fallback-ns-2>fallback namespace</a>, then jump back to
      the step labeled <i>start of line</i>.</p>

      <p>Otherwise, add <var>part one</var> to the <var>fallback URLs</var>
      mapping as a <a href=#concept-appcache-fallback-ns id=parsing-cache-manifests:concept-appcache-fallback-ns-3>fallback namespace</a>, mapped to
      <var>part two</var> as the <a href=#concept-appcache-fallback id=parsing-cache-manifests:concept-appcache-fallback-2>fallback
      entry</a>.</p>

     <dt>If <var>mode</var> is "online safelist"<dd>

      <p>If the first item in <var>tokens</var> is a U+002A ASTERISK character (*), then
      set <var>online safelist wildcard flag</var> to <i>open</i> and jump back
      to the step labeled <i>start of line</i>.</p>

      <p>Otherwise, let <var>urlRecord</var> be the result of <a href=https://url.spec.whatwg.org/#concept-url-parser id=parsing-cache-manifests:url-parser-6 data-x-internal=url-parser>parsing</a> the first item in <var>tokens</var> with <var>base URL</var>.</p>

      <p>If <var>urlRecord</var> is failure, then jump back to the step labeled <i>start of
      line</i>.</p>

      <p>If <var>urlRecord</var> has a different <a href=https://url.spec.whatwg.org/#concept-url-scheme id=parsing-cache-manifests:concept-url-scheme-2 data-x-internal=concept-url-scheme>scheme</a>
      component than <var>base URL</var> (the manifest's URL), then jump back to the step labeled
      <i>start of line</i>.</p>

      <p>Let <var>new URL</var> be the result of applying the <a href=https://url.spec.whatwg.org/#concept-url-serializer id=parsing-cache-manifests:concept-url-serializer-4 data-x-internal=concept-url-serializer>URL serializer</a> algorithm to <var>urlRecord</var>, with
      the <i>exclude fragment flag</i> set.</p>

      <p>Add <var>new URL</var> to the <var>online safelist namespaces</var>.</p>

     <dt>If <var>mode</var> is "settings"<dd>

      <p>If <var>tokens</var> contains a single token, and that token is a
      <a href=#case-sensitive id=parsing-cache-manifests:case-sensitive>case-sensitive</a> match for the string "<code>prefer-online</code>", then
      set <var>cache mode flag</var> to <i>prefer-online</i> and jump back to the
      step labeled <i>start of line</i>.</p>

      <p>Otherwise, the line is an unsupported setting: do nothing; the line is ignored.</p>

     <dt>If <var>mode</var> is "unknown"<dd>

      <p>Do nothing. The line is ignored.</p>

     </dl>

   <li><p>Jump back to the step labeled <i>start of line</i>. (That step jumps to the next, and last,
   step when the end of the file is reached.)<li><p>Return the <var>explicit URLs</var> list, the <var>fallback URLs</var>
   mapping, the <var>online safelist namespaces</var>, the <var>online safelist
   wildcard flag</var>, and the <var>cache mode flag</var>.</ol>

  <div class=note>

   <p>The resource that declares the manifest (with the <code id=parsing-cache-manifests:attr-html-manifest><a href=#attr-html-manifest>manifest</a></code> attribute) will always get taken from the cache,
   whether it is listed in the cache or not, even if it is listed in an <a href=#concept-appcache-onlinesafelist id=parsing-cache-manifests:concept-appcache-onlinesafelist-2>online safelist namespace</a>.</p>

   <p>If a resource is listed in the <a href=#concept-appcache-manifest-explicit id=parsing-cache-manifests:concept-appcache-manifest-explicit>explicit
   section</a> or as a <a href=#concept-appcache-fallback id=parsing-cache-manifests:concept-appcache-fallback-3>fallback entry</a> in the <a href=#concept-appcache-manifest-fallback id=parsing-cache-manifests:concept-appcache-manifest-fallback>fallback section</a>, the resource will always be
   taken from the cache, regardless of any other matching entries in the <a href=#concept-appcache-fallback-ns id=parsing-cache-manifests:concept-appcache-fallback-ns-4>fallback namespaces</a> or <a href=#concept-appcache-onlinesafelist id=parsing-cache-manifests:concept-appcache-onlinesafelist-3>online safelist namespaces</a>.</p>

   <p>When a <a href=#concept-appcache-fallback-ns id=parsing-cache-manifests:concept-appcache-fallback-ns-5>fallback namespace</a> and an <a href=#concept-appcache-onlinesafelist id=parsing-cache-manifests:concept-appcache-onlinesafelist-4>online safelist namespace</a> overlap, the <a href=#concept-appcache-onlinesafelist id=parsing-cache-manifests:concept-appcache-onlinesafelist-5>online safelist namespace</a> has priority.</p>

   <p>The <a href=#concept-appcache-onlinesafelist-wildcard id=parsing-cache-manifests:concept-appcache-onlinesafelist-wildcard>online safelist wildcard
   flag</a> is applied last, only for URLs that match neither the <a href=#concept-appcache-onlinesafelist id=parsing-cache-manifests:concept-appcache-onlinesafelist-6>online safelist namespace</a> nor the <a href=#concept-appcache-fallback-ns id=parsing-cache-manifests:concept-appcache-fallback-ns-6>fallback namespace</a> and that are not listed in the
   <a href=#concept-appcache-manifest-explicit id=parsing-cache-manifests:concept-appcache-manifest-explicit-2>explicit section</a>.</p>

  </div>


  <h4 id=downloading-or-updating-an-application-cache><span class=secno>7.9.4</span> Downloading or updating an application cache<a href=#downloading-or-updating-an-application-cache class=self-link></a></h4>

  <p>When the user agent is required (by other parts of this specification) to start the
  <dfn id=application-cache-download-process>application cache download process</dfn> for an <a id=downloading-or-updating-an-application-cache:absolute-url href=https://url.spec.whatwg.org/#syntax-url-absolute data-x-internal=absolute-url>absolute URL</a> purported to
  identify a <a href=#concept-appcache-manifest id=downloading-or-updating-an-application-cache:concept-appcache-manifest>manifest</a>, or for an <a href=#application-cache-group id=downloading-or-updating-an-application-cache:application-cache-group>application
  cache group</a>, potentially given a particular <a href=#cache-host id=downloading-or-updating-an-application-cache:cache-host>cache host</a>, and potentially given
  a <a href=#concept-appcache-master id=downloading-or-updating-an-application-cache:concept-appcache-master>master</a> resource, the user agent must run the steps
  below. These steps are always run <a href=#in-parallel id=downloading-or-updating-an-application-cache:in-parallel>in parallel</a> with the <a href=#event-loop id=downloading-or-updating-an-application-cache:event-loop>event loop</a>
  <a href=#concept-task id=downloading-or-updating-an-application-cache:concept-task>tasks</a>.</p>

  <p>Some of these steps have requirements that only apply if the user agent <dfn id=shows-caching-progress>shows caching
  progress</dfn>. Support for this is optional. Caching progress UI could consist of a progress bar
  or message panel in the user agent's interface, or an overlay, or something else. Certain events
  fired during the <a href=#application-cache-download-process id=downloading-or-updating-an-application-cache:application-cache-download-process>application cache download process</a> allow the script to override the
  display of such an interface. (Such events are delayed until after the <code id=downloading-or-updating-an-application-cache:event-load><a href=#event-load>load</a></code> event has fired.)

  The goal of this is to allow Web applications to provide more
  seamless update mechanisms, hiding from the user the mechanics of the application cache mechanism.
  User agents may display user interfaces independent of this, but are encouraged to not show
  prominent update progress notifications for applications that cancel the relevant events.</p>

  <p>The <a href=#application-cache-download-process id=downloading-or-updating-an-application-cache:application-cache-download-process-2>application cache download process</a> steps are as follows:

  <ol><li><p>Optionally, wait until the permission to start the <a href=#application-cache-download-process id=downloading-or-updating-an-application-cache:application-cache-download-process-3>application cache download
   process</a> has been obtained from the user and until the user agent is confident that the
   network is available. This could include doing nothing until the user explicitly opts-in to
   caching the site, or could involve prompting the user for permission. The algorithm might never
   get past this point. (This step is particularly intended to be used by user agents running on
   severely space-constrained devices or in highly privacy-sensitive environments).<li>

    <p>Atomically, so as to avoid race conditions, perform the following substeps:</p>

    <ol><li>

      <p>Pick the appropriate substeps:</p>

      <dl class=switch><dt>If these steps were invoked with an <a id=downloading-or-updating-an-application-cache:absolute-url-2 href=https://url.spec.whatwg.org/#syntax-url-absolute data-x-internal=absolute-url>absolute URL</a> purported to identify a
       <a href=#concept-appcache-manifest id=downloading-or-updating-an-application-cache:concept-appcache-manifest-2>manifest</a><dd>

        <p>Let <var>manifest URL</var> be that <a id=downloading-or-updating-an-application-cache:absolute-url-3 href=https://url.spec.whatwg.org/#syntax-url-absolute data-x-internal=absolute-url>absolute URL</a>.</p>

        <p>If there is no <a href=#application-cache-group id=downloading-or-updating-an-application-cache:application-cache-group-2>application cache group</a> identified by <var>manifest
        URL</var>, then create a new <a href=#application-cache-group id=downloading-or-updating-an-application-cache:application-cache-group-3>application cache group</a> identified by <var>manifest URL</var>. Initially, it has no <a href=#application-cache id=downloading-or-updating-an-application-cache:application-cache>application caches</a>. One will be created later in this algorithm.</p>

       <dt>If these steps were invoked with an <a href=#application-cache-group id=downloading-or-updating-an-application-cache:application-cache-group-4>application cache group</a><dd>

        <p>Let <var>manifest URL</var> be the <a id=downloading-or-updating-an-application-cache:absolute-url-4 href=https://url.spec.whatwg.org/#syntax-url-absolute data-x-internal=absolute-url>absolute URL</a> of the <a href=#concept-appcache-manifest id=downloading-or-updating-an-application-cache:concept-appcache-manifest-3>manifest</a> used to identify the <a href=#application-cache-group id=downloading-or-updating-an-application-cache:application-cache-group-5>application
        cache group</a> to be updated.</p>

        <p>If that <a href=#application-cache-group id=downloading-or-updating-an-application-cache:application-cache-group-6>application cache group</a> is <a href=#concept-appcache-obsolete id=downloading-or-updating-an-application-cache:concept-appcache-obsolete>obsolete</a>, then abort this instance of the
        <a href=#application-cache-download-process id=downloading-or-updating-an-application-cache:application-cache-download-process-4>application cache download process</a>. This can happen if another instance of this
        algorithm found the manifest to be 404 or 410 while this algorithm was waiting in the first
        step above.</p>

       </dl>

     <li><p>Let <var>cache group</var> be the <a href=#application-cache-group id=downloading-or-updating-an-application-cache:application-cache-group-7>application cache group</a>
     identified by <var>manifest URL</var>.<li><p>If these steps were invoked with a <a href=#concept-appcache-master id=downloading-or-updating-an-application-cache:concept-appcache-master-2>master</a>
     resource, then add the resource, along with the resource's <code id=downloading-or-updating-an-application-cache:document><a href=#document>Document</a></code>, to <var>cache group</var>'s <a href=#concept-appcache-pending-masters id=downloading-or-updating-an-application-cache:concept-appcache-pending-masters>list of pending
     master entries</a>.<li>
      <p>If these steps were invoked with a <a href=#cache-host id=downloading-or-updating-an-application-cache:cache-host-2>cache host</a>, and the <a href=#concept-appcache-status id=downloading-or-updating-an-application-cache:concept-appcache-status>status</a> of <var>cache group</var> is
      <i>checking</i> or <i>downloading</i>, then <a href=#queue-a-post-load-task id=downloading-or-updating-an-application-cache:queue-a-post-load-task>queue a post-load task</a> to run these
      steps:</p>

      <ol><li><p>Let <var>showProgress</var> be the result of <a href=https://dom.spec.whatwg.org/#concept-event-fire id=downloading-or-updating-an-application-cache:concept-event-fire data-x-internal=concept-event-fire>firing
       an event</a> named <code id=downloading-or-updating-an-application-cache:event-appcache-checking><a href=#event-appcache-checking>checking</a></code> at the
       <code id=downloading-or-updating-an-application-cache:applicationcache><a href=#applicationcache>ApplicationCache</a></code> singleton of that <a href=#cache-host id=downloading-or-updating-an-application-cache:cache-host-3>cache host</a>, with the <code id=downloading-or-updating-an-application-cache: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.<li><p>If <var>showProgress</var> is true and the user agent <a href=#shows-caching-progress id=downloading-or-updating-an-application-cache:shows-caching-progress>shows caching
       progress</a>, then display some sort of user interface indicating to the user that the
       user agent is checking to see if it can download the application.</ol>
     <li>
      <p>If these steps were invoked with a <a href=#cache-host id=downloading-or-updating-an-application-cache:cache-host-4>cache host</a>, and the <a href=#concept-appcache-status id=downloading-or-updating-an-application-cache:concept-appcache-status-2>status</a> of <var>cache group</var> is
      <i>downloading</i>, then also <a href=#queue-a-post-load-task id=downloading-or-updating-an-application-cache:queue-a-post-load-task-2>queue a post-load task</a> to run these steps:</p>

      <ol><li><p>Let <var>showProgress</var> be the result of <a href=https://dom.spec.whatwg.org/#concept-event-fire id=downloading-or-updating-an-application-cache:concept-event-fire-2 data-x-internal=concept-event-fire>firing
       an event</a> named <code id=downloading-or-updating-an-application-cache:event-appcache-downloading><a href=#event-appcache-downloading>downloading</a></code> at the
       <code id=downloading-or-updating-an-application-cache:applicationcache-2><a href=#applicationcache>ApplicationCache</a></code> singleton of that <a href=#cache-host id=downloading-or-updating-an-application-cache:cache-host-5>cache host</a>, with the <code id=downloading-or-updating-an-application-cache: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.<li><p>If <var>showProgress</var> is true and the user agent <a href=#shows-caching-progress id=downloading-or-updating-an-application-cache:shows-caching-progress-2>shows caching
       progress</a>, then display some sort of user interface indicating to the user the
       application is being downloaded.</ol>
     <li><p>If the <a href=#concept-appcache-status id=downloading-or-updating-an-application-cache:concept-appcache-status-3>status</a> of the <var>cache
     group</var> is either <i>checking</i> or <i>downloading</i>, then abort this instance of the
     <a href=#application-cache-download-process id=downloading-or-updating-an-application-cache:application-cache-download-process-5>application cache download process</a>, as an update is already in progress.<li><p>Set the <a href=#concept-appcache-status id=downloading-or-updating-an-application-cache:concept-appcache-status-4>status</a> of <var>cache
     group</var> to <i>checking</i>.</p>

     <li>
      <p>For each <a href=#cache-host id=downloading-or-updating-an-application-cache:cache-host-6>cache host</a> associated with an <a href=#application-cache id=downloading-or-updating-an-application-cache:application-cache-2>application cache</a> in
      <var>cache group</var>, <a href=#queue-a-post-load-task id=downloading-or-updating-an-application-cache:queue-a-post-load-task-3>queue a post-load task</a> run these steps:</p>

      <ol><li><p>Let <var>showProgress</var> be the result of <a href=https://dom.spec.whatwg.org/#concept-event-fire id=downloading-or-updating-an-application-cache:concept-event-fire-3 data-x-internal=concept-event-fire>firing
       an event</a> named <code id=downloading-or-updating-an-application-cache:event-appcache-checking-2><a href=#event-appcache-checking>checking</a></code> at the
       <code id=downloading-or-updating-an-application-cache:applicationcache-3><a href=#applicationcache>ApplicationCache</a></code> singleton of the <a href=#cache-host id=downloading-or-updating-an-application-cache:cache-host-7>cache host</a>, with the <code id=downloading-or-updating-an-application-cache: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 true.<li><p>If <var>showProgress</var> is true and the user agent <a href=#shows-caching-progress id=downloading-or-updating-an-application-cache:shows-caching-progress-3>shows caching
       progress</a>, then display some sort of user interface indicating to the user that the
       user agent is checking for the availability of updates.</ol>
     </ol>

    <p class=note>The remainder of the steps run <a href=#in-parallel id=downloading-or-updating-an-application-cache:in-parallel-2>in parallel</a>.</p>

    <p>If <var>cache group</var> already has an <a href=#application-cache id=downloading-or-updating-an-application-cache:application-cache-3>application cache</a> in it, then
    this is an <dfn id=concept-appcache-upgrade>upgrade attempt</dfn>. Otherwise, this is a
    <dfn id=concept-appcache-cache>cache attempt</dfn>.</p>

   <li>
    <p>If this is a <a href=#concept-appcache-cache id=downloading-or-updating-an-application-cache:concept-appcache-cache>cache attempt</a>, then this algorithm
    was invoked with a <a href=#cache-host id=downloading-or-updating-an-application-cache:cache-host-8>cache host</a>; <a href=#queue-a-post-load-task id=downloading-or-updating-an-application-cache:queue-a-post-load-task-4>queue a post-load task</a> to run these
    steps:</p>

    <ol><li><p>Let <var>showProgress</var> be the result of <a href=https://dom.spec.whatwg.org/#concept-event-fire id=downloading-or-updating-an-application-cache:concept-event-fire-4 data-x-internal=concept-event-fire>firing an
     event</a> named <code id=downloading-or-updating-an-application-cache:event-appcache-checking-3><a href=#event-appcache-checking>checking</a></code> at the
     <code id=downloading-or-updating-an-application-cache:applicationcache-4><a href=#applicationcache>ApplicationCache</a></code> singleton of that <a href=#cache-host id=downloading-or-updating-an-application-cache:cache-host-9>cache host</a>, with the <code id=downloading-or-updating-an-application-cache:dom-event-cancelable-4><a data-x-internal=dom-event-cancelable href=https://dom.spec.whatwg.org/#dom-event-cancelable>cancelable</a></code> attribute initialized to true.<li><p>If <var>showProgress</var> is true and the user agent <a href=#shows-caching-progress id=downloading-or-updating-an-application-cache:shows-caching-progress-4>shows caching
     progress</a>, then display some sort of user interface indicating to the user that the user
     agent is checking for the availability of updates.</ol>
   <li><p>Let <var>request</var> be a new <a href=https://fetch.spec.whatwg.org/#concept-request id=downloading-or-updating-an-application-cache:concept-request data-x-internal=concept-request>request</a> whose
   <a href=https://fetch.spec.whatwg.org/#concept-request-url id=downloading-or-updating-an-application-cache:concept-request-url data-x-internal=concept-request-url>url</a> is <var>manifest URL</var>, <a href=https://fetch.spec.whatwg.org/#concept-request-client id=downloading-or-updating-an-application-cache:concept-request-client data-x-internal=concept-request-client>client</a> is null, <a href=https://fetch.spec.whatwg.org/#concept-request-destination id=downloading-or-updating-an-application-cache:concept-request-destination data-x-internal=concept-request-destination>destination</a> is the empty string, <a href=https://fetch.spec.whatwg.org/#concept-request-referrer id=downloading-or-updating-an-application-cache:concept-request-referrer data-x-internal=concept-request-referrer>referrer</a> is "<code>no-referrer</code>",
   <a id=downloading-or-updating-an-application-cache: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=downloading-or-updating-an-application-cache:concept-request-credentials-mode data-x-internal=concept-request-credentials-mode>credentials
   mode</a> is "<code>include</code>", and whose <a id=downloading-or-updating-an-application-cache: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.<li>

    <p><i>Fetching the manifest</i>: Let <var>manifest</var> be the result of <a href=https://fetch.spec.whatwg.org/#concept-fetch id=downloading-or-updating-an-application-cache:concept-fetch data-x-internal=concept-fetch>fetching</a> <var>request</var>. HTTP caching semantics should be
    honored for this request.</p>

    <p>Parse <var>manifest</var>'s <a href=https://fetch.spec.whatwg.org/#concept-response-body id=downloading-or-updating-an-application-cache:concept-response-body data-x-internal=concept-response-body>body</a> according to the
    <a href=#parse-a-manifest id=downloading-or-updating-an-application-cache:parse-a-manifest>rules for parsing manifests</a>, obtaining a list of
    <a href=#concept-appcache-explicit id=downloading-or-updating-an-application-cache:concept-appcache-explicit>explicit entries</a>, <a href=#concept-appcache-fallback id=downloading-or-updating-an-application-cache:concept-appcache-fallback>fallback entries</a> and the <a href=#concept-appcache-fallback-ns id=downloading-or-updating-an-application-cache:concept-appcache-fallback-ns>fallback namespaces</a> that map to them, entries for
    the <a href=#concept-appcache-onlinesafelist id=downloading-or-updating-an-application-cache:concept-appcache-onlinesafelist>online safelist</a>, and values for the
    <a href=#concept-appcache-onlinesafelist-wildcard id=downloading-or-updating-an-application-cache:concept-appcache-onlinesafelist-wildcard>online safelist wildcard flag</a>
    and the <a href=#concept-appcache-mode id=downloading-or-updating-an-application-cache:concept-appcache-mode>cache mode flag</a>.</p>

    <p class=note>The <a id=downloading-or-updating-an-application-cache:mime-type href=https://mimesniff.spec.whatwg.org/#mime-type data-x-internal=mime-type>MIME type</a> of the resource is ignored — it is assumed to
    be <code id=downloading-or-updating-an-application-cache:text/cache-manifest><a href=#text/cache-manifest>text/cache-manifest</a></code>. In the future, if new manifest formats are supported, the
    different types will probably be distinguished on the basis of the file signatures (for the
    current format, that is the "<code>CACHE MANIFEST</code>" string at the top of the
    file).</p>

   <li>

    <p>If <i>fetching the manifest</i> fails due to a 404 or 410 response status, then run these
    substeps:</p>

    <ol><li><p>Mark <var>cache group</var> as <a href=#concept-appcache-obsolete id=downloading-or-updating-an-application-cache:concept-appcache-obsolete-2>obsolete</a>. This <var>cache group</var> no
     longer exists for any purpose other than the processing of <code id=downloading-or-updating-an-application-cache:document-2><a href=#document>Document</a></code> objects
     already associated with an <a href=#application-cache id=downloading-or-updating-an-application-cache:application-cache-4>application cache</a> in the <var>cache
     group</var>.<li><p>Let <var>task list</var> be an empty list of <a href=#concept-task id=downloading-or-updating-an-application-cache:concept-task-2>tasks</a>.</p>

     <li>
      <p>For each <a href=#cache-host id=downloading-or-updating-an-application-cache:cache-host-10>cache host</a> associated with an <a href=#application-cache id=downloading-or-updating-an-application-cache:application-cache-5>application cache</a> in
      <var>cache group</var>, create a <a href=#concept-task id=downloading-or-updating-an-application-cache:concept-task-3>task</a> to run these
      steps and append it to <var>task list</var>:</p>

      <ol><li><p>Let <var>showProgress</var> be the result of <a href=https://dom.spec.whatwg.org/#concept-event-fire id=downloading-or-updating-an-application-cache:concept-event-fire-5 data-x-internal=concept-event-fire>firing
       an event</a> named <code id=downloading-or-updating-an-application-cache:event-appcache-obsolete><a href=#event-appcache-obsolete>obsolete</a></code> at the
       <code id=downloading-or-updating-an-application-cache:applicationcache-5><a href=#applicationcache>ApplicationCache</a></code> singleton of the <a href=#cache-host id=downloading-or-updating-an-application-cache:cache-host-11>cache host</a>, with the <code id=downloading-or-updating-an-application-cache:dom-event-cancelable-5><a data-x-internal=dom-event-cancelable href=https://dom.spec.whatwg.org/#dom-event-cancelable>cancelable</a></code> attribute initialized to true.<li><p>If <var>showProgress</var> is true and the user agent <a href=#shows-caching-progress id=downloading-or-updating-an-application-cache:shows-caching-progress-5>shows caching
       progress</a>, then display some sort of user interface indicating to the user that the
       application is no longer available for offline use.</ol>
     <li>
      <p>For each entry in <var>cache group</var>'s <a href=#concept-appcache-pending-masters id=downloading-or-updating-an-application-cache:concept-appcache-pending-masters-2>list of pending master entries</a>, create a
      <a href=#concept-task id=downloading-or-updating-an-application-cache:concept-task-4>task</a> to run these steps and append it to <var>task
      list</var>:</p>

      <ol><li><p>Let <var>showProgress</var> be the result of <a href=https://dom.spec.whatwg.org/#concept-event-fire id=downloading-or-updating-an-application-cache:concept-event-fire-6 data-x-internal=concept-event-fire>firing
       an event</a> named <code id=downloading-or-updating-an-application-cache:event-appcache-error><a href=#event-appcache-error>error</a></code> (not <code id=downloading-or-updating-an-application-cache:event-appcache-obsolete-2><a href=#event-appcache-obsolete>obsolete</a></code>!) at the <code id=downloading-or-updating-an-application-cache:applicationcache-6><a href=#applicationcache>ApplicationCache</a></code>
       singleton of the <code id=downloading-or-updating-an-application-cache:document-3><a href=#document>Document</a></code> for this entry, if there still is one, with the <code id=downloading-or-updating-an-application-cache:dom-event-cancelable-6><a data-x-internal=dom-event-cancelable href=https://dom.spec.whatwg.org/#dom-event-cancelable>cancelable</a></code> attribute initialized to true.<li><p>If <var>showProgress</var> is true and the user agent <a href=#shows-caching-progress id=downloading-or-updating-an-application-cache:shows-caching-progress-6>shows caching
       progress</a>, then display some sort of user interface indicating to the user that the
       user agent failed to save the application for offline use.</ol>
     <li><p>If <var>cache group</var> has an <a href=#application-cache id=downloading-or-updating-an-application-cache:application-cache-6>application cache</a> whose <a href=#concept-appcache-completeness id=downloading-or-updating-an-application-cache:concept-appcache-completeness>completeness flag</a> is <i>incomplete</i>, then
     discard that <a href=#application-cache id=downloading-or-updating-an-application-cache:application-cache-7>application cache</a>.</p>

     <li><p>If appropriate, remove any user interface indicating that an update for this cache is in
     progress.<li><p>Let the <a href=#concept-appcache-status id=downloading-or-updating-an-application-cache:concept-appcache-status-5>status</a> of <var>cache
     group</var> be <i>idle</i>.<li><p>For each <a href=#concept-task id=downloading-or-updating-an-application-cache:concept-task-5>task</a> in <var>task list</var>, <a href=#queue-a-post-load-task id=downloading-or-updating-an-application-cache:queue-a-post-load-task-5>queue that task as a post-load task</a>.<li><p>Abort the <a href=#application-cache-download-process id=downloading-or-updating-an-application-cache:application-cache-download-process-6>application cache download process</a>.</ol>

   <li>

    <p>Otherwise, if <i>fetching the manifest</i> fails in some other way (e.g. the server returns
    another 4xx or 5xx response, or there is a DNS error, or the connection times out, or the user
    cancels the download, or the parser for manifests fails when checking the magic signature), or
    if the server returned a redirect, then run the <a href=#cache-failure-steps id=downloading-or-updating-an-application-cache:cache-failure-steps>cache failure steps</a>. <a href=#refsHTTP>[HTTP]</a></p>

   <li>

    <p>If this is an <a href=#concept-appcache-upgrade id=downloading-or-updating-an-application-cache:concept-appcache-upgrade>upgrade attempt</a> and the newly
    downloaded <var>manifest</var> is byte-for-byte identical to the manifest found in the
    <a href=#concept-appcache-newer id=downloading-or-updating-an-application-cache:concept-appcache-newer>newest</a> <a href=#application-cache id=downloading-or-updating-an-application-cache:application-cache-8>application cache</a> in <var>cache
    group</var>, or the response status is <code>304</code>, then run these substeps:</p>

    <ol><li><p>Let <var>cache</var> be the <a href=#concept-appcache-newer id=downloading-or-updating-an-application-cache:concept-appcache-newer-2>newest</a>
     <a href=#application-cache id=downloading-or-updating-an-application-cache:application-cache-9>application cache</a> in <var>cache group</var>.<li><p>Let <var>task list</var> be an empty list of <a href=#concept-task id=downloading-or-updating-an-application-cache:concept-task-6>tasks</a>.</p>

     <li>

      <p>For each entry in <var>cache group</var>'s <a href=#concept-appcache-pending-masters id=downloading-or-updating-an-application-cache:concept-appcache-pending-masters-3>list of pending master entries</a>, wait for the
      resource for this entry to have either completely downloaded or failed.</p>

      <p>If the download failed (e.g. the server returns a 4xx or 5xx response, or there is a DNS
      error, the connection times out, or the user cancels the download), or if the resource is
      labeled with the "no-store" cache directive, then create a <a href=#concept-task id=downloading-or-updating-an-application-cache:concept-task-7>task</a> to run these steps and append it to <var>task
      list</var>:</p>

      <ol><li><p>Let <var>showProgress</var> be the result of <a href=https://dom.spec.whatwg.org/#concept-event-fire id=downloading-or-updating-an-application-cache:concept-event-fire-7 data-x-internal=concept-event-fire>firing
       an event</a> named <code id=downloading-or-updating-an-application-cache:event-appcache-error-2><a href=#event-appcache-error>error</a></code> at the
       <code id=downloading-or-updating-an-application-cache:applicationcache-7><a href=#applicationcache>ApplicationCache</a></code> singleton of the <code id=downloading-or-updating-an-application-cache:document-4><a href=#document>Document</a></code> for this entry, if there
       still is one, with the <code id=downloading-or-updating-an-application-cache:dom-event-cancelable-7><a data-x-internal=dom-event-cancelable href=https://dom.spec.whatwg.org/#dom-event-cancelable>cancelable</a></code> attribute
       initialized to true.<li><p>If <var>showProgress</var> is true and the user agent <a href=#shows-caching-progress id=downloading-or-updating-an-application-cache:shows-caching-progress-7>shows caching
       progress</a>, then display some sort of user interface indicating to the user that the
       user agent failed to save the application for offline use.</ol>

      <p>Otherwise, associate the <code id=downloading-or-updating-an-application-cache:document-5><a href=#document>Document</a></code> for this entry with <var>cache</var>; store the resource for this entry in <var>cache</var>, if it
      isn't already there, and categorize its entry as a <a href=#concept-appcache-master id=downloading-or-updating-an-application-cache:concept-appcache-master-3>master entry</a>. If applying the <a id=downloading-or-updating-an-application-cache:url-parser href=https://url.spec.whatwg.org/#concept-url-parser data-x-internal=url-parser>URL parser</a>
      algorithm to the resource's <a id=downloading-or-updating-an-application-cache:url href=https://url.spec.whatwg.org/#concept-url data-x-internal=url>URL</a> results in a <a id=downloading-or-updating-an-application-cache:url-record href=https://url.spec.whatwg.org/#concept-url data-x-internal=url-record>URL record</a> that has a
      non-null <a href=https://url.spec.whatwg.org/#concept-url-fragment id=downloading-or-updating-an-application-cache:concept-url-fragment data-x-internal=concept-url-fragment>fragment</a> component, the <a id=downloading-or-updating-an-application-cache:url-2 href=https://url.spec.whatwg.org/#concept-url data-x-internal=url>URL</a>
      used for the entry in <var>cache</var> must instead be the <a id=downloading-or-updating-an-application-cache:absolute-url-5 href=https://url.spec.whatwg.org/#syntax-url-absolute data-x-internal=absolute-url>absolute URL</a>
      obtained from applying the <a href=https://url.spec.whatwg.org/#concept-url-serializer id=downloading-or-updating-an-application-cache:concept-url-serializer data-x-internal=concept-url-serializer>URL serializer</a>
      algorithm to the <a id=downloading-or-updating-an-application-cache:url-record-2 href=https://url.spec.whatwg.org/#concept-url data-x-internal=url-record>URL record</a> with the <i>exclude fragment flag</i> set
      (application caches never include <a href=https://url.spec.whatwg.org/#concept-url-fragment id=downloading-or-updating-an-application-cache:concept-url-fragment-2 data-x-internal=concept-url-fragment>fragments</a>).</p>

     <li>
      <p>For each <a href=#cache-host id=downloading-or-updating-an-application-cache:cache-host-12>cache host</a> associated with an <a href=#application-cache id=downloading-or-updating-an-application-cache:application-cache-10>application cache</a> in
      <var>cache group</var>, create a <a href=#concept-task id=downloading-or-updating-an-application-cache:concept-task-8>task</a> to run these steps
      and append it to <var>task list</var>:</p>

      <ol><li><p>Let <var>showProgress</var> be the result of <a href=https://dom.spec.whatwg.org/#concept-event-fire id=downloading-or-updating-an-application-cache:concept-event-fire-8 data-x-internal=concept-event-fire>firing
       an event</a> named <code id=downloading-or-updating-an-application-cache:event-appcache-noupdate><a href=#event-appcache-noupdate>noupdate</a></code> at the
       <code id=downloading-or-updating-an-application-cache:applicationcache-8><a href=#applicationcache>ApplicationCache</a></code> singleton of the <a href=#cache-host id=downloading-or-updating-an-application-cache:cache-host-13>cache host</a>, with the <code id=downloading-or-updating-an-application-cache:dom-event-cancelable-8><a data-x-internal=dom-event-cancelable href=https://dom.spec.whatwg.org/#dom-event-cancelable>cancelable</a></code> attribute initialized to true.<li><p>If <var>showProgress</var> is true and the user agent <a href=#shows-caching-progress id=downloading-or-updating-an-application-cache:shows-caching-progress-8>shows caching
       progress</a>, then display some sort of user interface indicating to the user that the
       application is up to date.</ol>
     <li><p>Empty <var>cache group</var>'s <a href=#concept-appcache-pending-masters id=downloading-or-updating-an-application-cache:concept-appcache-pending-masters-4>list of pending master entries</a>.<li><p>If appropriate, remove any user interface indicating that an update for this cache is in
     progress.<li><p>Let the <a href=#concept-appcache-status id=downloading-or-updating-an-application-cache:concept-appcache-status-6>status</a> of <var>cache
     group</var> be <i>idle</i>.<li><p>For each <a href=#concept-task id=downloading-or-updating-an-application-cache:concept-task-9>task</a> in <var>task list</var>, <a href=#queue-a-post-load-task id=downloading-or-updating-an-application-cache:queue-a-post-load-task-6>queue that task as a post-load task</a>.<li><p>Abort the <a href=#application-cache-download-process id=downloading-or-updating-an-application-cache:application-cache-download-process-7>application cache download process</a>.</ol>

   <li><p>Let <var>new cache</var> be a newly created <a href=#application-cache id=downloading-or-updating-an-application-cache:application-cache-11>application cache</a> in
   <var>cache group</var>. Set its <a href=#concept-appcache-completeness id=downloading-or-updating-an-application-cache:concept-appcache-completeness-2>completeness
   flag</a> to <i>incomplete</i>.<li><p>For each entry in <var>cache group</var>'s <a href=#concept-appcache-pending-masters id=downloading-or-updating-an-application-cache:concept-appcache-pending-masters-5>list of pending master entries</a>, associate the
   <code id=downloading-or-updating-an-application-cache:document-6><a href=#document>Document</a></code> for this entry with <var>new cache</var>.<li><p>Set the <a href=#concept-appcache-status id=downloading-or-updating-an-application-cache:concept-appcache-status-7>status</a> of <var>cache
   group</var> to <i>downloading</i>.<li>
    <p>For each <a href=#cache-host id=downloading-or-updating-an-application-cache:cache-host-14>cache host</a> associated with an <a href=#application-cache id=downloading-or-updating-an-application-cache:application-cache-12>application cache</a> in
    <var>cache group</var>, <a href=#queue-a-post-load-task id=downloading-or-updating-an-application-cache:queue-a-post-load-task-7>queue a post-load task</a> to run these steps:</p>

    <ol><li><p>Let <var>showProgress</var> be the result of <a href=https://dom.spec.whatwg.org/#concept-event-fire id=downloading-or-updating-an-application-cache:concept-event-fire-9 data-x-internal=concept-event-fire>firing an
     event</a> named <code id=downloading-or-updating-an-application-cache:event-appcache-downloading-2><a href=#event-appcache-downloading>downloading</a></code> at the
     <code id=downloading-or-updating-an-application-cache:applicationcache-9><a href=#applicationcache>ApplicationCache</a></code> singleton of the <a href=#cache-host id=downloading-or-updating-an-application-cache:cache-host-15>cache host</a>, with the <code id=downloading-or-updating-an-application-cache:dom-event-cancelable-9><a data-x-internal=dom-event-cancelable href=https://dom.spec.whatwg.org/#dom-event-cancelable>cancelable</a></code> attribute initialized to true.<li><p>If <var>showProgress</var> is true and the user agent <a href=#shows-caching-progress id=downloading-or-updating-an-application-cache:shows-caching-progress-9>shows caching
     progress</a>, then display some sort of user interface indicating to the user that a new
     version is being downloaded.</ol>
   <li><p>Let <var>file list</var> be an empty list of URLs with flags.<li><p>Add all the URLs in the list of <a href=#concept-appcache-explicit id=downloading-or-updating-an-application-cache:concept-appcache-explicit-2>explicit
   entries</a> obtained by parsing <var>manifest</var> to <var>file list</var>,
   each flagged with "explicit entry".<li><p>Add all the URLs in the list of <a href=#concept-appcache-fallback id=downloading-or-updating-an-application-cache:concept-appcache-fallback-2>fallback
   entries</a> obtained by parsing <var>manifest</var> to <var>file list</var>,
   each flagged with "fallback entry".<li><p>If this is an <a href=#concept-appcache-upgrade id=downloading-or-updating-an-application-cache:concept-appcache-upgrade-2>upgrade attempt</a>, then add all
   the URLs of <a href=#concept-appcache-master id=downloading-or-updating-an-application-cache:concept-appcache-master-4>master entries</a> in the <a href=#concept-appcache-newer id=downloading-or-updating-an-application-cache:concept-appcache-newer-3>newest</a> <a href=#application-cache id=downloading-or-updating-an-application-cache:application-cache-13>application cache</a> in <var>cache group</var> whose <a href=#concept-appcache-completeness id=downloading-or-updating-an-application-cache:concept-appcache-completeness-3>completeness
   flag</a> is <i>complete</i> to <var>file list</var>, each flagged with "master
   entry".<li><p>If any URL is in <var>file list</var> more than once, then merge the entries into
   one entry for that URL, that entry having all the flags that the original entries had.<li>

    <p>For each URL in <var>file list</var>, run the following steps. These steps may be
    run in parallel for two or more of the URLs at a time. If, while running these steps, the
    <code id=downloading-or-updating-an-application-cache:applicationcache-10><a href=#applicationcache>ApplicationCache</a></code> object's <code id=downloading-or-updating-an-application-cache:dom-appcache-abort><a href=#dom-appcache-abort>abort()</a></code> method
    <a href=#send-a-signal id=downloading-or-updating-an-application-cache:send-a-signal>sends a signal</a> to this instance of the <a href=#application-cache-download-process id=downloading-or-updating-an-application-cache:application-cache-download-process-8>application
    cache download process</a> algorithm, then run the <a href=#cache-failure-steps id=downloading-or-updating-an-application-cache:cache-failure-steps-2>cache failure steps</a>
    instead.</p>

    <ol><li>

      <p>If the resource URL being processed was flagged as neither an "explicit entry" nor or a
      "fallback entry", then the user agent may skip this URL.</p>

      <p class=note>This is intended to allow user agents to expire resources not listed in the
      manifest from the cache. Generally, implementers are urged to use an approach that expires
      lesser-used resources first.</p>

     <li>
      <p>For each <a href=#cache-host id=downloading-or-updating-an-application-cache:cache-host-16>cache host</a> associated with an <a href=#application-cache id=downloading-or-updating-an-application-cache:application-cache-14>application cache</a> in
      <var>cache group</var>, <a href=#queue-a-progress-post-load-task id=downloading-or-updating-an-application-cache:queue-a-progress-post-load-task>queue a progress post-load task</a> to run these steps:</p>

      <ol><li><p>Let <var>showProgress</var> be the result of <a href=https://dom.spec.whatwg.org/#concept-event-fire id=downloading-or-updating-an-application-cache:concept-event-fire-10 data-x-internal=concept-event-fire>firing
       an event</a> named <code id=downloading-or-updating-an-application-cache:event-appcache-progress><a href=#event-appcache-progress>progress</a></code> at the
       <code id=downloading-or-updating-an-application-cache:applicationcache-11><a href=#applicationcache>ApplicationCache</a></code> singleton of the <a href=#cache-host id=downloading-or-updating-an-application-cache:cache-host-17>cache host</a>, using
       <code id=downloading-or-updating-an-application-cache:progressevent><a data-x-internal=progressevent href=https://xhr.spec.whatwg.org/#interface-progressevent>ProgressEvent</a></code>, with the <code id=downloading-or-updating-an-application-cache:dom-event-cancelable-10><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=downloading-or-updating-an-application-cache:dom-progressevent-lengthcomputable><a data-x-internal=dom-progressevent-lengthcomputable href=https://xhr.spec.whatwg.org/#dom-progressevent-lengthcomputable>lengthComputable</a></code> attribute initialized to
       true, the <code id=downloading-or-updating-an-application-cache:dom-progressevent-total><a data-x-internal=dom-progressevent-total href=https://xhr.spec.whatwg.org/#dom-progressevent-total>total</a></code> attribute initialized to the
       number of files in <var>file list</var>, and the <code id=downloading-or-updating-an-application-cache:dom-progressevent-loaded><a data-x-internal=dom-progressevent-loaded href=https://xhr.spec.whatwg.org/#dom-progressevent-loaded>loaded</a></code> attribute initialized to the number of files
       in <var>file list</var> that have been either downloaded or skipped so far. <a href=#refsXHR>[XHR]</a><li><p>If <var>showProgress</var> is true and the user agent <a href=#shows-caching-progress id=downloading-or-updating-an-application-cache:shows-caching-progress-10>shows caching
       progress</a>, then display some sort of user interface indicating to the user that a file
       is being downloaded in preparation for updating the application.</ol>
     <li><p>Let <var>request</var> be a new <a href=https://fetch.spec.whatwg.org/#concept-request id=downloading-or-updating-an-application-cache:concept-request-2 data-x-internal=concept-request>request</a> whose
     <a href=https://fetch.spec.whatwg.org/#concept-request-url id=downloading-or-updating-an-application-cache:concept-request-url-2 data-x-internal=concept-request-url>url</a> is URL, <a href=https://fetch.spec.whatwg.org/#concept-request-client id=downloading-or-updating-an-application-cache:concept-request-client-2 data-x-internal=concept-request-client>client</a> is null, <a href=https://fetch.spec.whatwg.org/#concept-request-destination id=downloading-or-updating-an-application-cache:concept-request-destination-2 data-x-internal=concept-request-destination>destination</a> is the empty string,
     <a href=https://fetch.spec.whatwg.org/#concept-request-origin id=downloading-or-updating-an-application-cache:concept-request-origin data-x-internal=concept-request-origin>origin</a> is
     <var>manifest URL</var>'s <a href=#concept-origin id=downloading-or-updating-an-application-cache:concept-origin>origin</a>, <a href=https://fetch.spec.whatwg.org/#concept-request-referrer id=downloading-or-updating-an-application-cache:concept-request-referrer-2 data-x-internal=concept-request-referrer>referrer</a> is "<code>no-referrer</code>",
     <a id=downloading-or-updating-an-application-cache:synchronous-flag-2 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=downloading-or-updating-an-application-cache:concept-request-credentials-mode-2 data-x-internal=concept-request-credentials-mode>credentials mode</a> is "<code>include</code>", <a id=downloading-or-updating-an-application-cache: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, and <a href=https://fetch.spec.whatwg.org/#concept-request-redirect-mode id=downloading-or-updating-an-application-cache:concept-request-redirect-mode data-x-internal=concept-request-redirect-mode>redirect mode</a> is "<code>manual</code>".<li><p><a href=https://fetch.spec.whatwg.org/#concept-fetch id=downloading-or-updating-an-application-cache:concept-fetch-2 data-x-internal=concept-fetch>Fetch</a> <var>request</var>. If this is an
     <a href=#concept-appcache-upgrade id=downloading-or-updating-an-application-cache:concept-appcache-upgrade-3>upgrade attempt</a>, then use the <a href=#concept-appcache-newer id=downloading-or-updating-an-application-cache:concept-appcache-newer-4>newest</a> <a href=#application-cache id=downloading-or-updating-an-application-cache:application-cache-15>application cache</a> in <var>cache
     group</var> as an HTTP cache, and honor HTTP caching semantics (such as expiration, ETags, and
     so forth) with respect to that cache. User agents may also have other caches in place that are
     also honored.<li>

      <p>If the previous step fails (e.g. the server returns a 4xx or 5xx response, or there is a
      DNS error, or the connection times out, or the user cancels the download), or if the server
      returned a redirect, or if the resource is labeled with the "no-store" cache directive, then
      run the first appropriate step from the following list: <a href=#refsHTTP>[HTTP]</a></p>

      <dl class=switch><dt>If the URL being processed was flagged as an "explicit entry" or a "fallback entry"<dd>

        <p>If these steps are being run in parallel for any other URLs in <var>file
        list</var>, then abort this algorithm for those other URLs. Run the <a href=#cache-failure-steps id=downloading-or-updating-an-application-cache:cache-failure-steps-3>cache failure
        steps</a>.</p>

        <p class=note>Redirects are fatal because they are either indicative of a network problem
        (e.g. a captive portal); or would allow resources to be added to the cache under URLs that
        differ from any URL that the networking model will allow access to, leaving orphan entries;
        or would allow resources to be stored under URLs different than their true URLs. All of
        these situations are bad.</p>

       <dt>If the error was a 404 or 410 HTTP response<dt>If the resource was labeled with the "no-store" cache directive<dd>

        <p>Skip this resource. It is dropped from the cache.</p>

       <dt>Otherwise<dd>

        <p>Copy the resource and its metadata from the <a href=#concept-appcache-newer id=downloading-or-updating-an-application-cache:concept-appcache-newer-5>newest</a> <a href=#application-cache id=downloading-or-updating-an-application-cache:application-cache-16>application cache</a> in <var>cache group</var> whose <a href=#concept-appcache-completeness id=downloading-or-updating-an-application-cache:concept-appcache-completeness-4>completeness
        flag</a> is <i>complete</i>, and act as if that was the fetched resource, ignoring the
        resource obtained from the network.</p>

       </dl>

      <p>User agents may warn the user of these errors as an aid to development.</p>

      <p class=note>These rules make errors for resources listed in the manifest fatal, while
      making it possible for other resources to be removed from caches when they are removed from
      the server, without errors, and making non-manifest resources survive server-side errors.</p>

      <p class=note>Except for the "no-store" directive, HTTP caching rules that would cause a
      file to be expired or otherwise not cached are ignored for the purposes of the
      <a href=#application-cache-download-process id=downloading-or-updating-an-application-cache:application-cache-download-process-9>application cache download process</a>.</p>

     <li>

      <p>Otherwise, the fetching succeeded. Store the resource in the <var>new
      cache</var>.</p>

      <p>If the user agent is not able to store the resource (e.g. because of quota restrictions),
      the user agent may prompt the user or try to resolve the problem in some other manner (e.g.
      automatically pruning content in other caches). If the problem cannot be resolved, the user
      agent must run the <a href=#cache-failure-steps id=downloading-or-updating-an-application-cache:cache-failure-steps-4>cache failure steps</a>.</p>

     <li><p>If the URL being processed was flagged as an "explicit entry" in <var>file
     list</var>, then categorize the entry as an <a href=#concept-appcache-explicit id=downloading-or-updating-an-application-cache:concept-appcache-explicit-3>explicit
     entry</a>.<li><p>If the URL being processed was flagged as a "fallback entry" in <var>file
     list</var>, then categorize the entry as a <a href=#concept-appcache-fallback id=downloading-or-updating-an-application-cache:concept-appcache-fallback-3>fallback
     entry</a>.<li><p>If the URL being processed was flagged as an "master entry" in <var>file
     list</var>, then categorize the entry as a <a href=#concept-appcache-master id=downloading-or-updating-an-application-cache:concept-appcache-master-5>master
     entry</a>.<li><p>As an optimization, if the resource is an HTML or XML file whose <a id=downloading-or-updating-an-application-cache:document-element href=https://dom.spec.whatwg.org/#document-element data-x-internal=document-element>document
     element</a> is an <code id=downloading-or-updating-an-application-cache:the-html-element><a href=#the-html-element>html</a></code> element with a <code id=downloading-or-updating-an-application-cache:attr-html-manifest><a href=#attr-html-manifest>manifest</a></code> attribute whose value doesn't match the manifest
     URL of the application cache being processed, then the user agent should mark the entry as
     being <a href=#concept-appcache-foreign id=downloading-or-updating-an-application-cache:concept-appcache-foreign>foreign</a>.</p>

    </ol>

   <li>
    <p>For each <a href=#cache-host id=downloading-or-updating-an-application-cache:cache-host-18>cache host</a> associated with an <a href=#application-cache id=downloading-or-updating-an-application-cache:application-cache-17>application cache</a> in
    <var>cache group</var>, <a href=#queue-a-progress-post-load-task id=downloading-or-updating-an-application-cache:queue-a-progress-post-load-task-2>queue a progress post-load task</a> to run these steps:</p>

    <ol><li><p>Let <var>showProgress</var> be the result of <a href=https://dom.spec.whatwg.org/#concept-event-fire id=downloading-or-updating-an-application-cache:concept-event-fire-11 data-x-internal=concept-event-fire>firing an
     event </a> named <code id=downloading-or-updating-an-application-cache:event-appcache-progress-2><a href=#event-appcache-progress>progress</a></code> at the
     <code id=downloading-or-updating-an-application-cache:applicationcache-12><a href=#applicationcache>ApplicationCache</a></code> singleton of the <a href=#cache-host id=downloading-or-updating-an-application-cache:cache-host-19>cache host</a>, using
     <code id=downloading-or-updating-an-application-cache:progressevent-2><a data-x-internal=progressevent href=https://xhr.spec.whatwg.org/#interface-progressevent>ProgressEvent</a></code>, with the <code id=downloading-or-updating-an-application-cache:dom-event-cancelable-11><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=downloading-or-updating-an-application-cache:dom-progressevent-lengthcomputable-2><a data-x-internal=dom-progressevent-lengthcomputable href=https://xhr.spec.whatwg.org/#dom-progressevent-lengthcomputable>lengthComputable</a></code> attribute initialized to
     true, and the <code id=downloading-or-updating-an-application-cache:dom-progressevent-total-2><a data-x-internal=dom-progressevent-total href=https://xhr.spec.whatwg.org/#dom-progressevent-total>total</a></code> and <code id=downloading-or-updating-an-application-cache:dom-progressevent-loaded-2><a data-x-internal=dom-progressevent-loaded href=https://xhr.spec.whatwg.org/#dom-progressevent-loaded>loaded</a></code> attributes initialized to the number of files
     in <var>file list</var>. <a href=#refsXHR>[XHR]</a><li><p>If <var>showProgress</var> is true and the user agent <a href=#shows-caching-progress id=downloading-or-updating-an-application-cache:shows-caching-progress-11>shows caching
     progress</a>, then display some sort of user interface indicating to the user that all the
     files have been downloaded. </ol>
   <li><p>Store the list of <a href=#concept-appcache-fallback-ns id=downloading-or-updating-an-application-cache:concept-appcache-fallback-ns-2>fallback namespaces</a>,
   and the URLs of the <a href=#concept-appcache-fallback id=downloading-or-updating-an-application-cache:concept-appcache-fallback-4>fallback entries</a> that they map
   to, in <var>new cache</var>.<li><p>Store the URLs that form the new <a href=#concept-appcache-onlinesafelist id=downloading-or-updating-an-application-cache:concept-appcache-onlinesafelist-2>online
   safelist</a> in <var>new cache</var>.<li><p>Store the value of the new <a href=#concept-appcache-onlinesafelist-wildcard id=downloading-or-updating-an-application-cache:concept-appcache-onlinesafelist-wildcard-2>online
   safelist wildcard flag</a> in <var>new cache</var>.<li><p>Store the value of the new <a href=#concept-appcache-mode id=downloading-or-updating-an-application-cache:concept-appcache-mode-2>cache mode flag</a> in
   <var>new cache</var>.<li>

    <p>For each entry in <var>cache group</var>'s <a href=#concept-appcache-pending-masters id=downloading-or-updating-an-application-cache:concept-appcache-pending-masters-6>list of pending master entries</a>, wait for the
    resource for this entry to have either completely downloaded or failed.</p>

    <p>If the download failed (e.g. the server returns a 4xx or 5xx response, or there is a DNS
    error, the connection times out, or the user cancels the download), or if the resource is
    labeled with the "no-store" cache directive, then run these substeps:</p>

    <ol><li><p>Unassociate the <code id=downloading-or-updating-an-application-cache:document-7><a href=#document>Document</a></code> for this entry from <var>new
     cache</var>.<li>
      <p><a href=#queue-a-post-load-task id=downloading-or-updating-an-application-cache:queue-a-post-load-task-8>Queue a post-load task</a> to run these steps:</p>

      <ol><li><p>Let <var>showProgress</var> be the result of <a href=https://dom.spec.whatwg.org/#concept-event-fire id=downloading-or-updating-an-application-cache:concept-event-fire-12 data-x-internal=concept-event-fire>firing
       an event</a> named <code id=downloading-or-updating-an-application-cache:event-appcache-error-3><a href=#event-appcache-error>error</a></code> at the
       <code id=downloading-or-updating-an-application-cache:applicationcache-13><a href=#applicationcache>ApplicationCache</a></code> singleton of the <code id=downloading-or-updating-an-application-cache:document-8><a href=#document>Document</a></code> for this entry, if there
       still is one, with the <code id=downloading-or-updating-an-application-cache:dom-event-cancelable-12><a data-x-internal=dom-event-cancelable href=https://dom.spec.whatwg.org/#dom-event-cancelable>cancelable</a></code> attribute
       initialized to true.<li><p>If <var>showProgress</var> is true and the user agent <a href=#shows-caching-progress id=downloading-or-updating-an-application-cache:shows-caching-progress-12>shows caching
       progress</a>, then display some sort of user interface indicating to the user that the
       user agent failed to save the application for offline use.</ol>
     <li>

      <p>If this is a <a href=#concept-appcache-cache id=downloading-or-updating-an-application-cache:concept-appcache-cache-2>cache attempt</a> and this entry is
      the last entry in <var>cache group</var>'s <a href=#concept-appcache-pending-masters id=downloading-or-updating-an-application-cache:concept-appcache-pending-masters-7>list of pending master entries</a>, then run these
      further substeps:</p>

      <ol><li><p>Discard <var>cache group</var> and its only <a href=#application-cache id=downloading-or-updating-an-application-cache:application-cache-18>application cache</a>,
       <var>new cache</var>.</p>

       <li><p>If appropriate, remove any user interface indicating that an update for this cache is
       in progress.<li><p>Abort the <a href=#application-cache-download-process id=downloading-or-updating-an-application-cache:application-cache-download-process-10>application cache download process</a>.</ol>

     <li><p>Otherwise, remove this entry from <var>cache group</var>'s <a href=#concept-appcache-pending-masters id=downloading-or-updating-an-application-cache:concept-appcache-pending-masters-8>list of pending master entries</a>.</ol>

    <p>Otherwise, store the resource for this entry in <var>new cache</var>, if it isn't
    already there, and categorize its entry as a <a href=#concept-appcache-master id=downloading-or-updating-an-application-cache:concept-appcache-master-6>master
    entry</a>.</p>

   <li><p>Let <var>request</var> be a new <a href=https://fetch.spec.whatwg.org/#concept-request id=downloading-or-updating-an-application-cache:concept-request-3 data-x-internal=concept-request>request</a> whose
   <a href=https://fetch.spec.whatwg.org/#concept-request-url id=downloading-or-updating-an-application-cache:concept-request-url-3 data-x-internal=concept-request-url>url</a> is <var>manifest URL</var>, <a href=https://fetch.spec.whatwg.org/#concept-request-client id=downloading-or-updating-an-application-cache:concept-request-client-3 data-x-internal=concept-request-client>client</a> is null, <a href=https://fetch.spec.whatwg.org/#concept-request-destination id=downloading-or-updating-an-application-cache:concept-request-destination-3 data-x-internal=concept-request-destination>destination</a> is the empty string,
   <a href=https://fetch.spec.whatwg.org/#concept-request-referrer id=downloading-or-updating-an-application-cache:concept-request-referrer-3 data-x-internal=concept-request-referrer>referrer</a> is "<code>no-referrer</code>",
   <a id=downloading-or-updating-an-application-cache:synchronous-flag-3 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=downloading-or-updating-an-application-cache:concept-request-credentials-mode-3 data-x-internal=concept-request-credentials-mode>credentials
   mode</a> is "<code>include</code>", and whose <a id=downloading-or-updating-an-application-cache:use-url-credentials-flag-3 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.<li>

    <p>Let <var>second manifest</var> be the result of <a href=https://fetch.spec.whatwg.org/#concept-fetch id=downloading-or-updating-an-application-cache:concept-fetch-3 data-x-internal=concept-fetch>fetching</a> <var>request</var>. HTTP caching semantics should again
    be honored for this request.</p>

    <p class=note>Since caching can be honored, authors are encouraged to avoid setting the cache
    headers on the manifest in such a way that the user agent would simply not contact the network
    for this second request; otherwise, the user agent would not notice if the cache had changed
    during the cache update process.</p>

   <li>

    <p>If the previous step failed for any reason, or if the fetching attempt involved a redirect,
    or if <var>second manifest</var> and <var>manifest</var> are not byte-for-byte
    identical, then schedule a rerun of the entire algorithm with the same parameters after a short
    delay, and run the <a href=#cache-failure-steps id=downloading-or-updating-an-application-cache:cache-failure-steps-5>cache failure steps</a>.</p>

   <li>

    <p>Otherwise, store <var>manifest</var> in <var>new cache</var>, if it's not
    there already, and categorize its entry as <a href=#concept-appcache-manifest id=downloading-or-updating-an-application-cache:concept-appcache-manifest-4>the
    manifest</a>.</p>

   <li><p>Set the <a href=#concept-appcache-completeness id=downloading-or-updating-an-application-cache:concept-appcache-completeness-5>completeness flag</a> of <var>new cache</var> to <i>complete</i>.<li><p>Let <var>task list</var> be an empty list of <a href=#concept-task id=downloading-or-updating-an-application-cache:concept-task-10>tasks</a>.</p>

   <li>

    <p>If this is a <a href=#concept-appcache-cache id=downloading-or-updating-an-application-cache:concept-appcache-cache-3>cache attempt</a>, then for each
    <a href=#cache-host id=downloading-or-updating-an-application-cache:cache-host-20>cache host</a> associated with an <a href=#application-cache id=downloading-or-updating-an-application-cache:application-cache-19>application cache</a> in <var>cache
    group</var>, create a <a href=#concept-task id=downloading-or-updating-an-application-cache:concept-task-11>task</a> to run these steps and append it
    to <var>task list</var>:

    <ol><li><p>Let <var>showProgress</var> be the result of <a href=https://dom.spec.whatwg.org/#concept-event-fire id=downloading-or-updating-an-application-cache:concept-event-fire-13 data-x-internal=concept-event-fire>firing an
     event</a> named <code id=downloading-or-updating-an-application-cache:event-appcache-cached><a href=#event-appcache-cached>cached</a></code> at the
     <code id=downloading-or-updating-an-application-cache:applicationcache-14><a href=#applicationcache>ApplicationCache</a></code> singleton of the <a href=#cache-host id=downloading-or-updating-an-application-cache:cache-host-21>cache host</a>, with the <code id=downloading-or-updating-an-application-cache:dom-event-cancelable-13><a data-x-internal=dom-event-cancelable href=https://dom.spec.whatwg.org/#dom-event-cancelable>cancelable</a></code> attribute initialized to true.<li><p>If <var>showProgress</var> is true and the user agent <a href=#shows-caching-progress id=downloading-or-updating-an-application-cache:shows-caching-progress-13>shows caching
     progress</a>, then display some sort of user interface indicating to the user that the
     application has been cached and that they can now use it offline.</ol>

    <p>Otherwise, it is an <a href=#concept-appcache-upgrade id=downloading-or-updating-an-application-cache:concept-appcache-upgrade-4>upgrade attempt</a>. For each
    <a href=#cache-host id=downloading-or-updating-an-application-cache:cache-host-22>cache host</a> associated with an <a href=#application-cache id=downloading-or-updating-an-application-cache:application-cache-20>application cache</a> in <var>cache
    group</var>, create a <a href=#concept-task id=downloading-or-updating-an-application-cache:concept-task-12>task</a> to run these steps and append it
    to <var>task list</var>:</p>

    <ol><li><p>Let <var>showProgress</var> be the result of <a href=https://dom.spec.whatwg.org/#concept-event-fire id=downloading-or-updating-an-application-cache:concept-event-fire-14 data-x-internal=concept-event-fire>firing an
     event</a> named <code id=downloading-or-updating-an-application-cache:event-appcache-updateready><a href=#event-appcache-updateready>updateready</a></code> at the
     <code id=downloading-or-updating-an-application-cache:applicationcache-15><a href=#applicationcache>ApplicationCache</a></code> singleton of the <a href=#cache-host id=downloading-or-updating-an-application-cache:cache-host-23>cache host</a>, with the <code id=downloading-or-updating-an-application-cache:dom-event-cancelable-14><a data-x-internal=dom-event-cancelable href=https://dom.spec.whatwg.org/#dom-event-cancelable>cancelable</a></code> attribute initialized to true.<li><p>If <var>showProgress</var> is true and the user agent <a href=#shows-caching-progress id=downloading-or-updating-an-application-cache:shows-caching-progress-14>shows caching
     progress</a>, then display some sort of user interface indicating to the user that a new
     version is available and that they can activate it by reloading the page.</ol>

   <li><p>If appropriate, remove any user interface indicating that an update for this cache is in
   progress.<li><p>Set the <a href=#concept-appcache-status id=downloading-or-updating-an-application-cache:concept-appcache-status-8>update status</a> of <var>cache
   group</var> to <i>idle</i>.<li><p>For each <a href=#concept-task id=downloading-or-updating-an-application-cache:concept-task-13>task</a> in <var>task list</var>, <a href=#queue-a-post-load-task id=downloading-or-updating-an-application-cache:queue-a-post-load-task-9>queue that task as a post-load task</a>.</ol>

  <p>The <dfn id=cache-failure-steps>cache failure steps</dfn> are as follows:</p>

  <ol><li><p>Let <var>task list</var> be an empty list of <a href=#concept-task id=downloading-or-updating-an-application-cache:concept-task-14>tasks</a>.</p>

   <li>

    <p>For each entry in <var>cache group</var>'s <a href=#concept-appcache-pending-masters id=downloading-or-updating-an-application-cache:concept-appcache-pending-masters-9>list of pending master entries</a>, run the
    following further substeps. These steps may be run in parallel for two or more entries at a
    time.</p>

    <ol><li><p>Wait for the resource for this entry to have either completely downloaded or failed.</p>

     <li><p>Unassociate the <code id=downloading-or-updating-an-application-cache:document-9><a href=#document>Document</a></code> for this entry from its <a href=#application-cache id=downloading-or-updating-an-application-cache:application-cache-21>application
     cache</a>, if it has one.<li>
      <p>Create a <a href=#concept-task id=downloading-or-updating-an-application-cache:concept-task-15>task</a> to run these steps and append it to
      <var>task list</var>:</p>

      <ol><li><p>Let <var>showProgress</var> be the result of <a href=https://dom.spec.whatwg.org/#concept-event-fire id=downloading-or-updating-an-application-cache:concept-event-fire-15 data-x-internal=concept-event-fire>firing
       an event</a> named <code id=downloading-or-updating-an-application-cache:event-appcache-error-4><a href=#event-appcache-error>error</a></code> at the
       <code id=downloading-or-updating-an-application-cache:applicationcache-16><a href=#applicationcache>ApplicationCache</a></code> singleton of the <code id=downloading-or-updating-an-application-cache:document-10><a href=#document>Document</a></code> for this entry, if there
       still is one, with the <code id=downloading-or-updating-an-application-cache:dom-event-cancelable-15><a data-x-internal=dom-event-cancelable href=https://dom.spec.whatwg.org/#dom-event-cancelable>cancelable</a></code> attribute
       initialized to true.<li><p>If <var>showProgress</var> is true and the user agent <a href=#shows-caching-progress id=downloading-or-updating-an-application-cache:shows-caching-progress-15>shows caching
       progress</a>, then display some sort of user interface indicating to the user that the
       user agent failed to save the application for offline use.</ol>
     </ol>

   <li>
    <p>For each <a href=#cache-host id=downloading-or-updating-an-application-cache:cache-host-24>cache host</a> still associated with an <a href=#application-cache id=downloading-or-updating-an-application-cache:application-cache-22>application cache</a> in
    <var>cache group</var>, create a <a href=#concept-task id=downloading-or-updating-an-application-cache:concept-task-16>task</a> to run these steps and
    append it to <var>task list</var>:</p>

    <ol><li><p>Let <var>showProgress</var> be the result of <a href=https://dom.spec.whatwg.org/#concept-event-fire id=downloading-or-updating-an-application-cache:concept-event-fire-16 data-x-internal=concept-event-fire>firing an
     event</a> named <code id=downloading-or-updating-an-application-cache:event-appcache-error-5><a href=#event-appcache-error>error</a></code> at the
     <code id=downloading-or-updating-an-application-cache:applicationcache-17><a href=#applicationcache>ApplicationCache</a></code> singleton of the <a href=#cache-host id=downloading-or-updating-an-application-cache:cache-host-25>cache host</a>, with the <code id=downloading-or-updating-an-application-cache:dom-event-cancelable-16><a data-x-internal=dom-event-cancelable href=https://dom.spec.whatwg.org/#dom-event-cancelable>cancelable</a></code> attribute initialized to true.<li><p>If <var>showProgress</var> is true and the user agent <a href=#shows-caching-progress id=downloading-or-updating-an-application-cache:shows-caching-progress-16>shows caching
     progress</a>, then display some sort of user interface indicating to the user that the user
     agent failed to save the application for offline use.</ol>
   <li><p>Empty <var>cache group</var>'s <a href=#concept-appcache-pending-masters id=downloading-or-updating-an-application-cache:concept-appcache-pending-masters-10>list of pending master entries</a>.<li><p>If <var>cache group</var> has an <a href=#application-cache id=downloading-or-updating-an-application-cache:application-cache-23>application cache</a> whose <a href=#concept-appcache-completeness id=downloading-or-updating-an-application-cache:concept-appcache-completeness-6>completeness flag</a> is <i>incomplete</i>, then discard
   that <a href=#application-cache id=downloading-or-updating-an-application-cache:application-cache-24>application cache</a>.</p>

   <li><p>If appropriate, remove any user interface indicating that an update for this cache is in
   progress.<li><p>Let the <a href=#concept-appcache-status id=downloading-or-updating-an-application-cache:concept-appcache-status-9>status</a> of <var>cache
   group</var> be <i>idle</i>.<li><p>If this was a <a href=#concept-appcache-cache id=downloading-or-updating-an-application-cache:concept-appcache-cache-4>cache attempt</a>, discard <var>cache group</var> altogether.</p>

   <li><p>For each <a href=#concept-task id=downloading-or-updating-an-application-cache:concept-task-17>task</a> in <var>task list</var>, <a href=#queue-a-post-load-task id=downloading-or-updating-an-application-cache:queue-a-post-load-task-10>queue that task as a post-load task</a>.<li><p>Abort the <a href=#application-cache-download-process id=downloading-or-updating-an-application-cache:application-cache-download-process-11>application cache download process</a>.</ol>

  <p>Attempts to fetch resources as part of the <a href=#application-cache-download-process id=downloading-or-updating-an-application-cache:application-cache-download-process-12>application cache download process</a> may
  be done with cache-defeating semantics, to avoid problems with stale or inconsistent intermediary
  caches.</p>

  <hr>

  <p>User agents may invoke the <a href=#application-cache-download-process id=downloading-or-updating-an-application-cache:application-cache-download-process-13>application cache download process</a>, in the background,
  for any <a href=#application-cache-group id=downloading-or-updating-an-application-cache:application-cache-group-8>application cache group</a>, at any time (with no <a href=#cache-host id=downloading-or-updating-an-application-cache:cache-host-26>cache host</a>). This
  allows user agents to keep caches primed and to update caches even before the user visits a
  site.</p>

  <hr>

  <p>Each <code id=downloading-or-updating-an-application-cache:document-11><a href=#document>Document</a></code> has a list of <dfn id=pending-application-cache-download-process-tasks>pending application cache download process
  tasks</dfn> that is used to delay events fired by the algorithm above until the document's <code id=downloading-or-updating-an-application-cache:event-load-2><a href=#event-load>load</a></code> event has fired. When the <code id=downloading-or-updating-an-application-cache:document-12><a href=#document>Document</a></code> is created, the
  list must be empty.</p>

  <p>When the steps above say to <dfn id=queue-a-post-load-task>queue a post-load task</dfn> <var>task</var>, where
  <var>task</var> is a <a href=#concept-task id=downloading-or-updating-an-application-cache:concept-task-18>task</a> that dispatches an event on a
  target <code id=downloading-or-updating-an-application-cache:applicationcache-18><a href=#applicationcache>ApplicationCache</a></code> object <var>target</var>, the user agent must run
  the appropriate steps from the following list:</p>

  <dl><dt>If <var>target</var>'s <a id=downloading-or-updating-an-application-cache:node-document href=https://dom.spec.whatwg.org/#concept-node-document data-x-internal=node-document>node document</a> is
   <a href=#ready-for-post-load-tasks id=downloading-or-updating-an-application-cache:ready-for-post-load-tasks>ready for post-load tasks</a><dd><p><a href=#queue-a-task id=downloading-or-updating-an-application-cache:queue-a-task>Queue</a> the task <var>task</var>.<dt>Otherwise<dd><p>Add <var>task</var> to <var>target</var>'s <a id=downloading-or-updating-an-application-cache:node-document-2 href=https://dom.spec.whatwg.org/#concept-node-document data-x-internal=node-document>node document</a>'s list
   of <a href=#pending-application-cache-download-process-tasks id=downloading-or-updating-an-application-cache:pending-application-cache-download-process-tasks>pending application cache download process tasks</a>.</dl>

  <p>When the steps above say to <dfn id=queue-a-progress-post-load-task>queue a progress post-load task</dfn> <var>task</var>, where
  <var>task</var> is a <a href=#concept-task id=downloading-or-updating-an-application-cache:concept-task-19>task</a> that dispatches an event on a
  target <code id=downloading-or-updating-an-application-cache:applicationcache-19><a href=#applicationcache>ApplicationCache</a></code> object <var>target</var>, the user agent must run
  the following steps:</p>

  <ol><li><p>If there is a <var>task</var> in <var>target</var>'s <a id=downloading-or-updating-an-application-cache:node-document-3 href=https://dom.spec.whatwg.org/#concept-node-document data-x-internal=node-document>node document</a>'s list
   of <a href=#pending-application-cache-download-process-tasks id=downloading-or-updating-an-application-cache:pending-application-cache-download-process-tasks-2>pending application cache download process tasks</a> that is labeled as a
   <i>progress task</i>, then remove that task from the list.<li><p>Label <var>task</var> as a <i>progress task</i>.<li><p><a href=#queue-a-post-load-task id=downloading-or-updating-an-application-cache:queue-a-post-load-task-11>Queue a post-load task</a> <var>task</var>.</ol>

  <p>The <a href=#task-source id=downloading-or-updating-an-application-cache:task-source>task source</a> for these <a href=#concept-task id=downloading-or-updating-an-application-cache:concept-task-20>tasks</a> is the
  <a href=#networking-task-source id=downloading-or-updating-an-application-cache:networking-task-source>networking task source</a>.</p>




  <h4 id=the-application-cache-selection-algorithm><span class=secno>7.9.5</span> The application cache selection algorithm<a href=#the-application-cache-selection-algorithm class=self-link></a></h4>

  <p>When the <dfn id=concept-appcache-init>application cache selection algorithm</dfn>
  algorithm is invoked with a <code id=the-application-cache-selection-algorithm:document><a href=#document>Document</a></code> <var>document</var> and optionally a
  manifest <a id=the-application-cache-selection-algorithm:url href=https://url.spec.whatwg.org/#concept-url data-x-internal=url>URL</a> <var>manifest URL</var>, the user agent must run the first
  applicable set of steps from the following list:</p>

  <dl class=switch><dt>If there is a <var>manifest URL</var>, and <var>document</var> was loaded
   from an <a href=#application-cache id=the-application-cache-selection-algorithm:application-cache>application cache</a>, and the URL of the <a href=#concept-appcache-manifest id=the-application-cache-selection-algorithm:concept-appcache-manifest>manifest</a> of that cache's <a href=#application-cache-group id=the-application-cache-selection-algorithm:application-cache-group>application cache
   group</a> is <em>not</em> the same as <var>manifest URL</var><dd>

    <p>Mark the entry for the resource from which <var>document</var> was taken in the
    <a href=#application-cache id=the-application-cache-selection-algorithm:application-cache-2>application cache</a> from which it was loaded as <a href=#concept-appcache-foreign id=the-application-cache-selection-algorithm:concept-appcache-foreign>foreign</a>.</p>

    <p>Restart the current navigation from the top of the <a href=#navigate id=the-application-cache-selection-algorithm:navigate>navigation
    algorithm</a>, undoing any changes that were made as part of the initial load (changes can be
    avoided by ensuring that the step to <a href=#update-the-session-history-with-the-new-page id=the-application-cache-selection-algorithm:update-the-session-history-with-the-new-page>update the session history with the new page</a>
    is only ever completed <em>after</em> this <a href=#concept-appcache-init id=the-application-cache-selection-algorithm:concept-appcache-init>application cache
    selection algorithm</a> is run, though this is not required).</p>

    <p class=note>The navigation will not result in the same resource being loaded, because
    "foreign" entries are never picked during navigation.</p>

    <p>User agents may notify the user of the inconsistency between the cache manifest and the
    document's own metadata, to aid in application development.</p>

   <dt>If <var>document</var> was loaded from an <a href=#application-cache id=the-application-cache-selection-algorithm:application-cache-3>application cache</a>, and that
   <a href=#application-cache id=the-application-cache-selection-algorithm:application-cache-4>application cache</a> still exists (it is not now <a href=#concept-appcache-obsolete id=the-application-cache-selection-algorithm:concept-appcache-obsolete>obsolete</a>)<dd>

    <p>Associate <var>document</var> with the <a href=#application-cache id=the-application-cache-selection-algorithm:application-cache-5>application cache</a> from which it
    was loaded. Invoke, in the background, the <a href=#application-cache-download-process id=the-application-cache-selection-algorithm:application-cache-download-process>application cache download process</a> for
    that <a href=#application-cache id=the-application-cache-selection-algorithm:application-cache-6>application cache</a>'s <a href=#application-cache-group id=the-application-cache-selection-algorithm:application-cache-group-2>application cache group</a>, with <var>document</var> as the <a href=#cache-host id=the-application-cache-selection-algorithm:cache-host>cache host</a>.</p>

   <dt>If <var>document</var>  was loaded using `<code>GET</code>`, and, there is a
   <var>manifest URL</var>, and <var>manifest URL</var> has the <a href=#same-origin id=the-application-cache-selection-algorithm:same-origin>same origin</a> as
   <var>document</var><dd>

    <p>Invoke, in the background, the <a href=#application-cache-download-process id=the-application-cache-selection-algorithm:application-cache-download-process-2>application cache download process</a> for <var>manifest URL</var>, with <var>document</var> as the <a href=#cache-host id=the-application-cache-selection-algorithm:cache-host-2>cache host</a>
    and with the resource from which <var>document</var> was parsed as the <a href=#concept-appcache-master id=the-application-cache-selection-algorithm:concept-appcache-master>master</a> resource.</p>

    <p>If there are <a href=#relevant-application-cache id=the-application-cache-selection-algorithm:relevant-application-cache>relevant application caches</a> that
    are identified by a URL with the <a href=#same-origin id=the-application-cache-selection-algorithm:same-origin-2>same origin</a> as the URL of <var>document</var>, and that have this URL as one of their entries, excluding entries
    marked as <a href=#concept-appcache-foreign id=the-application-cache-selection-algorithm:concept-appcache-foreign-2>foreign</a>, then the user agent should use
    the <a href=#concept-appcache-selection id=the-application-cache-selection-algorithm:concept-appcache-selection>most appropriate application cache</a> of those
    that match as an HTTP cache for any subresource loads. User agents may also have other caches in
    place that are also honored.</p>

   <dt>Otherwise<dd>

    <p>The <code id=the-application-cache-selection-algorithm:document-2><a href=#document>Document</a></code> is not associated with any <a href=#application-cache id=the-application-cache-selection-algorithm:application-cache-7>application cache</a>.</p>

    <p>If there was a <var>manifest URL</var>, the user agent may report to the user that
    it was ignored, to aid in application development.</p>

   </dl>



  <h4 id=changesToNetworkingModel><span class=secno>7.9.6</span> Changes to the networking model<a href=#changesToNetworkingModel class=self-link></a></h4>

  <p class=XXX>If "AppCache" is not removed as a feature this
  section needs to be integrated into the Fetch standard.</p>

  <p>When a <a href=#cache-host id=changesToNetworkingModel:cache-host>cache host</a> is associated with an <a href=#application-cache id=changesToNetworkingModel:application-cache>application cache</a> whose <a href=#concept-appcache-completeness id=changesToNetworkingModel:concept-appcache-completeness>completeness flag</a> is <i>complete</i>, any and all
  loads for resources related to that <a href=#cache-host id=changesToNetworkingModel:cache-host-2>cache host</a> other than those for <a href=#child-browsing-context id=changesToNetworkingModel:child-browsing-context>child browsing contexts</a> must go through the following steps
  instead of immediately invoking the mechanisms appropriate to that resource's scheme:</p>

  <ol><li><p>If the resource is not to be fetched using the GET method, or if applying the <a id=changesToNetworkingModel:url-parser href=https://url.spec.whatwg.org/#concept-url-parser data-x-internal=url-parser>URL
   parser</a> algorithm to both its <a id=changesToNetworkingModel:url href=https://url.spec.whatwg.org/#concept-url data-x-internal=url>URL</a> and the <a href=#application-cache id=changesToNetworkingModel:application-cache-2>application cache</a>'s
   <a href=#concept-appcache-manifest id=changesToNetworkingModel:concept-appcache-manifest>manifest</a>'s URL results in two <a href=https://url.spec.whatwg.org/#concept-url id=changesToNetworkingModel:url-record data-x-internal=url-record>URL records</a> with different <a href=https://url.spec.whatwg.org/#concept-url-scheme id=changesToNetworkingModel:concept-url-scheme data-x-internal=concept-url-scheme>scheme</a>
   components, then fetch the resource normally and return.<li><p>If the resource's URL is <a href=#concept-appcache-master id=changesToNetworkingModel:concept-appcache-master>a master entry</a>,
   <a href=#concept-appcache-manifest id=changesToNetworkingModel:concept-appcache-manifest-2>the manifest</a>, <a href=#concept-appcache-explicit id=changesToNetworkingModel:concept-appcache-explicit>an explicit entry</a>, or <a href=#concept-appcache-fallback id=changesToNetworkingModel:concept-appcache-fallback>a fallback entry</a> in the <a href=#application-cache id=changesToNetworkingModel:application-cache-3>application cache</a>,
   then get the resource from the cache (instead of fetching it), and return.<li><p>If there is an entry in the <a href=#application-cache id=changesToNetworkingModel:application-cache-4>application cache</a>'s <a href=#concept-appcache-onlinesafelist id=changesToNetworkingModel:concept-appcache-onlinesafelist>online safelist</a> that has the <a href=#same-origin id=changesToNetworkingModel:same-origin>same
   origin</a> as the resource's URL and that is a <a href=#prefix-match id=changesToNetworkingModel:prefix-match>prefix match</a> for the resource's
   URL, then fetch the resource normally and return.<li>

    <p>If the resource's URL has the <a href=#same-origin id=changesToNetworkingModel:same-origin-2>same origin</a> as the manifest's URL, and there is a
    <a href=#concept-appcache-fallback-ns id=changesToNetworkingModel:concept-appcache-fallback-ns>fallback namespace</a> <var>f</var> in
    the <a href=#application-cache id=changesToNetworkingModel:application-cache-5>application cache</a> that is a <a href=#prefix-match id=changesToNetworkingModel:prefix-match-2>prefix match</a> for the resource's URL,
    then:</p>

    <p>Fetch the resource normally. If this results in a redirect to a resource with another
    <a href=#concept-origin id=changesToNetworkingModel:concept-origin>origin</a> (indicative of a captive portal), or a 4xx or 5xx status code, or if there
    were network errors (but not if the user canceled the download), then instead get, from the
    cache, the resource of the <a href=#concept-appcache-fallback id=changesToNetworkingModel:concept-appcache-fallback-2>fallback entry</a>
    corresponding to the <a href=#concept-appcache-fallback-ns id=changesToNetworkingModel:concept-appcache-fallback-ns-2>fallback namespace</a>
    <var>f</var>. Return.</p>

   <li><p>If the <a href=#application-cache id=changesToNetworkingModel:application-cache-6>application cache</a>'s <a href=#concept-appcache-onlinesafelist-wildcard id=changesToNetworkingModel:concept-appcache-onlinesafelist-wildcard>online safelist wildcard flag</a> is
   <i>open</i>, then fetch the resource normally and return.<li><p>Fail the resource load as if there had been a generic network error.</ol>

  <p class=note>The above algorithm ensures that so long as the <a href=#concept-appcache-onlinesafelist-wildcard id=changesToNetworkingModel:concept-appcache-onlinesafelist-wildcard-2>online safelist wildcard flag</a> is
  <i>blocking</i>, resources that are not present in the <a href=#concept-appcache-manifest id=changesToNetworkingModel:concept-appcache-manifest-3>manifest</a> will always fail to load (at least, after the
  <a href=#application-cache id=changesToNetworkingModel:application-cache-7>application cache</a> has been primed the first time), making the testing of offline
  applications simpler.</p>

  


  

  <h4 id=expiring-application-caches><span class=secno>7.9.7</span> Expiring application caches<a href=#expiring-application-caches class=self-link></a></h4>

  <p>As a general rule, user agents should not expire application caches, except on request from the
  user, or after having been left unused for an extended period of time.</p>

  <p>Application caches and cookies have similar implications with respect to privacy (e.g. if the
  site can identify the user when providing the cache, it can store data in the cache that can be
  used for cookie resurrection). Implementors are therefore encouraged to expose application caches
  in a manner related to HTTP cookies, allowing caches to be expunged together with cookies and
  other origin-specific data.</p>

  <p class=example>For example, a user agent could have a "delete site-specific data" feature that
  clears all cookies, application caches, local storage, databases, etc, from an origin all at
  once.</p>

  


  

  <h4 id=disk-space><span class=secno>7.9.8</span> Disk space<a href=#disk-space class=self-link></a></h4>

  <p>User agents should consider applying constraints on disk usage of <a href=#application-cache id=disk-space:application-cache>application caches</a>, and care should be taken to ensure that the restrictions cannot
  be easily worked around using subdomains.</p>

  <p>User agents should allow users to see how much space each domain is using, and may offer the
  user the ability to delete specific <a href=#application-cache id=disk-space:application-cache-2>application caches</a>.</p>

  <p>For predictability, quotas should be based on the uncompressed size of data stored.</p>
  

  <p class=note>How quotas are presented to the user is not defined by this specification. User
  agents are encouraged to provide features such as allowing a user to indicate that certain sites
  are trusted to use more than the default quota, e.g. by presenting a non-modal user interface
  while a cache is being updated, or by having an explicit safelist in the user agent's
  configuration interface.</p>

  



  <h4 id=security-concerns-with-offline-applications-caches><span class=secno>7.9.9</span> Security concerns with offline applications caches<a href=#security-concerns-with-offline-applications-caches class=self-link></a></h4>

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

  <p>The main risk introduced by offline application caches is that an injection attack can be
  elevated into persistent site-wide page replacement. This attack involves using an injection
  vulnerability to upload two files to the victim site. The first file is an application cache
  manifest consisting of just a fallback entry pointing to the second file, which is an HTML page
  whose manifest is declared as that first file. Once the user has been directed to that second
  file, all subsequent accesses to any file covered by the given fallback namespace while either the
  user or the site is offline will instead show that second file. Targeted denial-of-service
  attacks or cookie bombing attacks (where the client is made to send so many cookies that the
  server refuses to process the request) can be used to ensure that the site appears offline.</p>

  <p>To mitigate this, manifests can only specify fallbacks that are in the same path as the
  manifest itself. This means that a content injection upload vulnerability in a particular
  directory on a server can only be escalated to a take-over of that directory and its
  subdirectories. If there is no way to inject a file into the root directory, the entire site
  cannot be taken over.</p>

  <p>If a site has been attacked in this way, simply removing the offending manifest might eventually
  clear the problem, since the next time the manifest is updated, a 404 error will be seen, and the
  user agent will clear the cache. "Eventually" is the key word here, however; while the attack on
  the user or server is ongoing, such that connections from an affected user to the affected site
  are blocked, the user agent will simply assume that the user is offline and will continue to use
  the hostile manifest. Unfortunately, if a cookie bombing attack has also been used, merely
  removing the manifest is insufficient; in addition, the server has to be configured to return a
  404 or 410 response instead of the 413 "Request Entity Too Large" response.</p>

  <p>TLS does not inherently protect a site from this attack, since the attack relies on content
  being served from the server itself. Not using application caches also does not prevent this
  attack, since the attack relies on an attacker-provided manifest.</p>



  <h4 id=application-cache-api><span class=secno>7.9.10</span> Application cache API<a href=#application-cache-api class=self-link></a></h4>

  <pre><code class='idl'>[<c- g>Exposed</c->=<c- n>Window</c->]
<c- b>interface</c-> <dfn id='applicationcache'><c- g>ApplicationCache</c-></dfn> : <a href='https://dom.spec.whatwg.org/#interface-eventtarget' data-x-internal='eventtarget' id='application-cache-api:eventtarget'><c- n>EventTarget</c-></a> {

  // <a href='#concept-appcache-status' id='application-cache-api:concept-appcache-status'>update status</a>
  <c- b>const</c-> <c- b>unsigned</c-> <c- b>short</c-> <a href='#dom-appcache-uncached' id='application-cache-api:dom-appcache-uncached'><c- g>UNCACHED</c-></a> = 0;
  <c- b>const</c-> <c- b>unsigned</c-> <c- b>short</c-> <a href='#dom-appcache-idle' id='application-cache-api:dom-appcache-idle'><c- g>IDLE</c-></a> = 1;
  <c- b>const</c-> <c- b>unsigned</c-> <c- b>short</c-> <a href='#dom-appcache-checking' id='application-cache-api:dom-appcache-checking'><c- g>CHECKING</c-></a> = 2;
  <c- b>const</c-> <c- b>unsigned</c-> <c- b>short</c-> <a href='#dom-appcache-downloading' id='application-cache-api:dom-appcache-downloading'><c- g>DOWNLOADING</c-></a> = 3;
  <c- b>const</c-> <c- b>unsigned</c-> <c- b>short</c-> <a href='#dom-appcache-updateready' id='application-cache-api:dom-appcache-updateready'><c- g>UPDATEREADY</c-></a> = 4;
  <c- b>const</c-> <c- b>unsigned</c-> <c- b>short</c-> <a href='#dom-appcache-obsolete' id='application-cache-api:dom-appcache-obsolete'><c- g>OBSOLETE</c-></a> = 5;
  <c- b>readonly</c-> <c- b>attribute</c-> <c- b>unsigned</c-> <c- b>short</c-> <a href='#dom-appcache-status' id='application-cache-api:dom-appcache-status'><c- g>status</c-></a>;

  // updates
  <c- b>void</c-> <a href='#dom-appcache-update' id='application-cache-api:dom-appcache-update'><c- g>update</c-></a>();
  <c- b>void</c-> <a href='#dom-appcache-abort' id='application-cache-api:dom-appcache-abort'><c- g>abort</c-></a>();
  <c- b>void</c-> <a href='#dom-appcache-swapcache' id='application-cache-api:dom-appcache-swapcache'><c- g>swapCache</c-></a>();

  // events
  <c- b>attribute</c-> <a href='#eventhandler' id='application-cache-api:eventhandler'><c- n>EventHandler</c-></a> <a href='#handler-appcache-onchecking' id='application-cache-api:handler-appcache-onchecking'><c- g>onchecking</c-></a>;
  <c- b>attribute</c-> <a href='#eventhandler' id='application-cache-api:eventhandler-2'><c- n>EventHandler</c-></a> <a href='#handler-appcache-onerror' id='application-cache-api:handler-appcache-onerror'><c- g>onerror</c-></a>;
  <c- b>attribute</c-> <a href='#eventhandler' id='application-cache-api:eventhandler-3'><c- n>EventHandler</c-></a> <a href='#handler-appcache-onnoupdate' id='application-cache-api:handler-appcache-onnoupdate'><c- g>onnoupdate</c-></a>;
  <c- b>attribute</c-> <a href='#eventhandler' id='application-cache-api:eventhandler-4'><c- n>EventHandler</c-></a> <a href='#handler-appcache-ondownloading' id='application-cache-api:handler-appcache-ondownloading'><c- g>ondownloading</c-></a>;
  <c- b>attribute</c-> <a href='#eventhandler' id='application-cache-api:eventhandler-5'><c- n>EventHandler</c-></a> <a href='#handler-appcache-onprogress' id='application-cache-api:handler-appcache-onprogress'><c- g>onprogress</c-></a>;
  <c- b>attribute</c-> <a href='#eventhandler' id='application-cache-api:eventhandler-6'><c- n>EventHandler</c-></a> <a href='#handler-appcache-onupdateready' id='application-cache-api:handler-appcache-onupdateready'><c- g>onupdateready</c-></a>;
  <c- b>attribute</c-> <a href='#eventhandler' id='application-cache-api:eventhandler-7'><c- n>EventHandler</c-></a> <a href='#handler-appcache-oncached' id='application-cache-api:handler-appcache-oncached'><c- g>oncached</c-></a>;
  <c- b>attribute</c-> <a href='#eventhandler' id='application-cache-api:eventhandler-8'><c- n>EventHandler</c-></a> <a href='#handler-appcache-onobsolete' id='application-cache-api:handler-appcache-onobsolete'><c- g>onobsolete</c-></a>;
};</code></pre>

  <dl class=domintro><dt><var>cache</var> = <var>window</var> . <code id=dom-applicationcache-dev><a href=#dom-applicationcache>applicationCache</a></code><dd>

    <p>Returns the <code id=application-cache-api:applicationcache><a href=#applicationcache>ApplicationCache</a></code> object that applies to the <a href=#active-document id=application-cache-api:active-document>active
    document</a> of that <code id=application-cache-api:window><a href=#window>Window</a></code>.</p>

   <dt><var>cache</var> . <code id=dom-appcache-status-dev><a href=#dom-appcache-status>status</a></code><dd>

    <p>Returns the current status of the application cache, as given by the constants defined
    below.</p>

   <dt><var>cache</var> . <code id=dom-appcache-update-dev><a href=#dom-appcache-update>update</a></code>()<dd>

    <p>Invokes the <a href=#application-cache-download-process id=application-cache-api:application-cache-download-process>application cache download process</a>.</p>

    <p>Throws an <a id=application-cache-api:invalidstateerror href=https://heycam.github.io/webidl/#invalidstateerror data-x-internal=invalidstateerror>"<code>InvalidStateError</code>"</a> <code id=application-cache-api:domexception><a data-x-internal=domexception href=https://heycam.github.io/webidl/#dfn-DOMException>DOMException</a></code> if there is
    no application cache to update.</p>

    <p>Calling this method is not usually necessary, as user agents will generally take care of
    updating <a href=#application-cache id=application-cache-api:application-cache>application caches</a> automatically.</p>

    <p>The method can be useful in situations such as long-lived applications. For example, a Web
    mail application might stay open in a browser tab for weeks at a time. Such an application could
    want to test for updates each day.</p>

   <dt><var>cache</var> . <code id=dom-appcache-abort-dev><a href=#dom-appcache-abort>abort</a></code>()<dd>

    <p>Cancels the <a href=#application-cache-download-process id=application-cache-api:application-cache-download-process-2>application cache download process</a>.</p>

    <p>This method is intended to be used by Web application showing their own caching progress UI,
    in case the user wants to stop the update (e.g. because bandwidth is limited).</p>

   <dt><var>cache</var> . <code id=dom-appcache-swapcache-dev><a href=#dom-appcache-swapcache>swapCache</a></code>()<dd>

    <p>Switches to the most recent application cache, if there is a newer one. If there isn't,
    throws an <a id=application-cache-api:invalidstateerror-2 href=https://heycam.github.io/webidl/#invalidstateerror data-x-internal=invalidstateerror>"<code>InvalidStateError</code>"</a> <code id=application-cache-api:domexception-2><a data-x-internal=domexception href=https://heycam.github.io/webidl/#dfn-DOMException>DOMException</a></code>.</p>

    <p>This does not cause previously-loaded resources to be reloaded; for example, images do not
    suddenly get reloaded and style sheets and scripts do not get reparsed or reevaluated. The only
    change is that subsequent requests for cached resources will obtain the newer copies.</p>

    <p>The <code id=application-cache-api:event-appcache-updateready><a href=#event-appcache-updateready>updateready</a></code> event will fire before this
    method can be called. Once it fires, the Web application can, at its leisure, call this method
    to switch the underlying cache to the one with the more recent updates. To make proper use of
    this, applications have to be able to bring the new features into play; for example, reloading
    scripts to enable new features.</p>

    <p>An easier alternative to <code id=application-cache-api:dom-appcache-swapcache-2><a href=#dom-appcache-swapcache>swapCache()</a></code> is just to
    reload the entire page at a time suitable for the user, using <code id=application-cache-api:dom-location-reload><a href=#dom-location-reload>location.reload()</a></code>.</p>

   </dl>

  

  <p>There is a one-to-one mapping from <a href=#cache-host id=application-cache-api:cache-host>cache hosts</a> to
  <code id=application-cache-api:applicationcache-2><a href=#applicationcache>ApplicationCache</a></code> objects. The <dfn id=dom-applicationcache><code>applicationCache</code></dfn> attribute on <code id=application-cache-api:window-2><a href=#window>Window</a></code>
  objects must return the <code id=application-cache-api:applicationcache-3><a href=#applicationcache>ApplicationCache</a></code> object associated with the
  <code id=application-cache-api:window-3><a href=#window>Window</a></code> object's <a href=#active-document id=application-cache-api:active-document-2>active document</a>.</p>

  <p class=note>A <code id=application-cache-api:document><a href=#document>Document</a></code> has an associated <code id=application-cache-api:applicationcache-4><a href=#applicationcache>ApplicationCache</a></code> object
  even if that <a href=#cache-host id=application-cache-api:cache-host-2>cache host</a> has no actual <a href=#application-cache id=application-cache-api:application-cache-2>application cache</a>.</p>

  <hr>

  <p>The <dfn id=dom-appcache-status><code>status</code></dfn> attribute, on getting, must
  return the current state of the <a href=#application-cache id=application-cache-api:application-cache-3>application cache</a> that the
  <code id=application-cache-api:applicationcache-5><a href=#applicationcache>ApplicationCache</a></code> object's <a href=#cache-host id=application-cache-api:cache-host-3>cache host</a> is associated with, if any. This
  must be the appropriate value from the following list:</p>

  

  <dl><dt><dfn id=dom-appcache-uncached><code>UNCACHED</code></dfn> (numeric value 0)<dd><p>The <code id=application-cache-api:applicationcache-6><a href=#applicationcache>ApplicationCache</a></code> object's <a href=#cache-host id=application-cache-api:cache-host-4>cache host</a> is not associated with
   an <a href=#application-cache id=application-cache-api:application-cache-4>application cache</a> at this time.<dt><dfn id=dom-appcache-idle><code>IDLE</code></dfn> (numeric value 1)<dd><p>The <code id=application-cache-api:applicationcache-7><a href=#applicationcache>ApplicationCache</a></code> object's <a href=#cache-host id=application-cache-api:cache-host-5>cache host</a> is associated with an
   <a href=#application-cache id=application-cache-api:application-cache-5>application cache</a> whose <a href=#application-cache-group id=application-cache-api:application-cache-group>application cache group</a>'s <a href=#concept-appcache-status id=application-cache-api:concept-appcache-status-2>update status</a> is <i>idle</i>, and that <a href=#application-cache id=application-cache-api:application-cache-6>application
   cache</a> is the <a href=#concept-appcache-newer id=application-cache-api:concept-appcache-newer>newest</a> cache in its
   <a href=#application-cache-group id=application-cache-api:application-cache-group-2>application cache group</a>, and the <a href=#application-cache-group id=application-cache-api:application-cache-group-3>application cache group</a> is not marked
   as <a href=#concept-appcache-obsolete id=application-cache-api:concept-appcache-obsolete>obsolete</a>.<dt><dfn id=dom-appcache-checking><code>CHECKING</code></dfn> (numeric value 2)<dd><p>The <code id=application-cache-api:applicationcache-8><a href=#applicationcache>ApplicationCache</a></code> object's <a href=#cache-host id=application-cache-api:cache-host-6>cache host</a> is associated with an
   <a href=#application-cache id=application-cache-api:application-cache-7>application cache</a> whose <a href=#application-cache-group id=application-cache-api:application-cache-group-4>application cache group</a>'s <a href=#concept-appcache-status id=application-cache-api:concept-appcache-status-3>update status</a> is <i>checking</i>.<dt><dfn id=dom-appcache-downloading><code>DOWNLOADING</code></dfn> (numeric value 3)<dd><p>The <code id=application-cache-api:applicationcache-9><a href=#applicationcache>ApplicationCache</a></code> object's <a href=#cache-host id=application-cache-api:cache-host-7>cache host</a> is associated with an
   <a href=#application-cache id=application-cache-api:application-cache-8>application cache</a> whose <a href=#application-cache-group id=application-cache-api:application-cache-group-5>application cache group</a>'s <a href=#concept-appcache-status id=application-cache-api:concept-appcache-status-4>update status</a> is <i>downloading</i>.<dt><dfn id=dom-appcache-updateready><code>UPDATEREADY</code></dfn> (numeric value 4)<dd><p>The <code id=application-cache-api:applicationcache-10><a href=#applicationcache>ApplicationCache</a></code> object's <a href=#cache-host id=application-cache-api:cache-host-8>cache host</a> is associated with an
   <a href=#application-cache id=application-cache-api:application-cache-9>application cache</a> whose <a href=#application-cache-group id=application-cache-api:application-cache-group-6>application cache group</a>'s <a href=#concept-appcache-status id=application-cache-api:concept-appcache-status-5>update status</a> is <i>idle</i>, and whose <a href=#application-cache-group id=application-cache-api:application-cache-group-7>application
   cache group</a> is not marked as <a href=#concept-appcache-obsolete id=application-cache-api:concept-appcache-obsolete-2>obsolete</a>, but
   that <a href=#application-cache id=application-cache-api:application-cache-10>application cache</a> is <em>not</em> the <a href=#concept-appcache-newer id=application-cache-api:concept-appcache-newer-2>newest</a> cache in its group.<dt><dfn id=dom-appcache-obsolete><code>OBSOLETE</code></dfn> (numeric value 5)<dd><p>The <code id=application-cache-api:applicationcache-11><a href=#applicationcache>ApplicationCache</a></code> object's <a href=#cache-host id=application-cache-api:cache-host-9>cache host</a> is associated with an
   <a href=#application-cache id=application-cache-api:application-cache-11>application cache</a> whose <a href=#application-cache-group id=application-cache-api:application-cache-group-8>application cache group</a> is marked as <a href=#concept-appcache-obsolete id=application-cache-api:concept-appcache-obsolete-3>obsolete</a>.</dl>

  

  <hr>

  <p>If the <dfn id=dom-appcache-update><code>update()</code></dfn> method is invoked, the user
  agent must invoke the <a href=#application-cache-download-process id=application-cache-api:application-cache-download-process-3>application cache download process</a>, in the background, for the
  <a href=#application-cache-group id=application-cache-api:application-cache-group-9>application cache group</a> of the <a href=#application-cache id=application-cache-api:application-cache-12>application cache</a> with which the
  <code id=application-cache-api:applicationcache-12><a href=#applicationcache>ApplicationCache</a></code> object's <a href=#cache-host id=application-cache-api:cache-host-10>cache host</a> is associated, but without giving
  that <a href=#cache-host id=application-cache-api:cache-host-11>cache host</a> to the algorithm. If there is no such <a href=#application-cache id=application-cache-api:application-cache-13>application cache</a>,
  or if its <a href=#application-cache-group id=application-cache-api:application-cache-group-10>application cache group</a> is marked as <a href=#concept-appcache-obsolete id=application-cache-api:concept-appcache-obsolete-4>obsolete</a>, then the method must throw an
  <a id=application-cache-api:invalidstateerror-3 href=https://heycam.github.io/webidl/#invalidstateerror data-x-internal=invalidstateerror>"<code>InvalidStateError</code>"</a> <code id=application-cache-api:domexception-3><a data-x-internal=domexception href=https://heycam.github.io/webidl/#dfn-DOMException>DOMException</a></code> instead.</p>

  <p>If the <dfn id=dom-appcache-abort><code>abort()</code></dfn> method is invoked, the user
  agent must <dfn id=send-a-signal>send a signal</dfn> to the current <a href=#application-cache-download-process id=application-cache-api:application-cache-download-process-4>application cache download process</a>
  for the <a href=#application-cache-group id=application-cache-api:application-cache-group-11>application cache group</a> of the <a href=#application-cache id=application-cache-api:application-cache-14>application cache</a> with which the
  <code id=application-cache-api:applicationcache-13><a href=#applicationcache>ApplicationCache</a></code> object's <a href=#cache-host id=application-cache-api:cache-host-12>cache host</a> is associated, if any. If there is
  no such <a href=#application-cache id=application-cache-api:application-cache-15>application cache</a>, or it does not have a current <a href=#application-cache-download-process id=application-cache-api:application-cache-download-process-5>application cache
  download process</a>, then do nothing.</p>

  <p>If the <dfn id=dom-appcache-swapcache><code>swapCache()</code></dfn> method is invoked,
  the user agent must run the following steps:

  <ol><li><p>Check that <code id=application-cache-api:applicationcache-14><a href=#applicationcache>ApplicationCache</a></code> object's <a href=#cache-host id=application-cache-api:cache-host-13>cache host</a> is associated
   with an <a href=#application-cache id=application-cache-api:application-cache-16>application cache</a>. If it is not, then throw an
   <a id=application-cache-api:invalidstateerror-4 href=https://heycam.github.io/webidl/#invalidstateerror data-x-internal=invalidstateerror>"<code>InvalidStateError</code>"</a> <code id=application-cache-api:domexception-4><a data-x-internal=domexception href=https://heycam.github.io/webidl/#dfn-DOMException>DOMException</a></code>.<li><p>Let <var>cache</var> be the <a href=#application-cache id=application-cache-api:application-cache-17>application cache</a> with which the
   <code id=application-cache-api:applicationcache-15><a href=#applicationcache>ApplicationCache</a></code> object's <a href=#cache-host id=application-cache-api:cache-host-14>cache host</a> is associated. (By definition,
   this is the same as the one that was found in the previous step.)<li><p>If <var>cache</var>'s <a href=#application-cache-group id=application-cache-api:application-cache-group-12>application cache group</a> is marked as <a href=#concept-appcache-obsolete id=application-cache-api:concept-appcache-obsolete-5>obsolete</a>, then unassociate the
   <code id=application-cache-api:applicationcache-16><a href=#applicationcache>ApplicationCache</a></code> object's <a href=#cache-host id=application-cache-api:cache-host-15>cache host</a> from <var>cache</var> and
   return. (Resources will now load from the network instead of the cache.)<li><p>Check that there is an application cache in the same <a href=#application-cache-group id=application-cache-api:application-cache-group-13>application cache group</a>
   as <var>cache</var> whose <a href=#concept-appcache-completeness id=application-cache-api:concept-appcache-completeness>completeness
   flag</a> is <i>complete</i> and that is <a href=#concept-appcache-newer id=application-cache-api:concept-appcache-newer-3>newer</a> than
   <var>cache</var>. If there is not, then throw an <a id=application-cache-api:invalidstateerror-5 href=https://heycam.github.io/webidl/#invalidstateerror data-x-internal=invalidstateerror>"<code>InvalidStateError</code>"</a>
   <code id=application-cache-api:domexception-5><a data-x-internal=domexception href=https://heycam.github.io/webidl/#dfn-DOMException>DOMException</a></code> exception.<li><p>Let <var>new cache</var> be the <a href=#concept-appcache-newer id=application-cache-api:concept-appcache-newer-4>newest</a> <a href=#application-cache id=application-cache-api:application-cache-18>application cache</a> in the same
   <a href=#application-cache-group id=application-cache-api:application-cache-group-14>application cache group</a> as <var>cache</var> whose <a href=#concept-appcache-completeness id=application-cache-api:concept-appcache-completeness-2>completeness flag</a> is <i>complete</i>.<li><p>Unassociate the <code id=application-cache-api:applicationcache-17><a href=#applicationcache>ApplicationCache</a></code> object's <a href=#cache-host id=application-cache-api:cache-host-16>cache host</a> from <var>cache</var> and instead associate it with <var>new cache</var>.</ol>

  <p>The following are the <a href=#event-handlers id=application-cache-api:event-handlers>event handlers</a> (and their corresponding <a href=#event-handler-event-type id=application-cache-api:event-handler-event-type>event handler event types</a>) that must be
  supported, as <a href=#event-handler-idl-attributes id=application-cache-api:event-handler-idl-attributes>event handler IDL attributes</a>, by all objects implementing the
  <code id=application-cache-api:applicationcache-18><a href=#applicationcache>ApplicationCache</a></code> interface:</p>

  <table><thead><tr><th><a href=#event-handlers id=application-cache-api:event-handlers-2>Event handler</a> <th><a href=#event-handler-event-type id=application-cache-api:event-handler-event-type-2>Event handler event type</a>
   <tbody><tr><td><dfn id=handler-appcache-onchecking><code>onchecking</code></dfn> <td> <code id=application-cache-api:event-appcache-checking><a href=#event-appcache-checking>checking</a></code>
    <tr><td><dfn id=handler-appcache-onerror><code>onerror</code></dfn> <td> <code id=application-cache-api:event-appcache-error><a href=#event-appcache-error>error</a></code>
    <tr><td><dfn id=handler-appcache-onnoupdate><code>onnoupdate</code></dfn> <td> <code id=application-cache-api:event-appcache-noupdate><a href=#event-appcache-noupdate>noupdate</a></code>
    <tr><td><dfn id=handler-appcache-ondownloading><code>ondownloading</code></dfn> <td> <code id=application-cache-api:event-appcache-downloading><a href=#event-appcache-downloading>downloading</a></code>
    <tr><td><dfn id=handler-appcache-onprogress><code>onprogress</code></dfn> <td> <code id=application-cache-api:event-appcache-progress><a href=#event-appcache-progress>progress</a></code>
    <tr><td><dfn id=handler-appcache-onupdateready><code>onupdateready</code></dfn> <td> <code id=application-cache-api:event-appcache-updateready-2><a href=#event-appcache-updateready>updateready</a></code>
    <tr><td><dfn id=handler-appcache-oncached><code>oncached</code></dfn> <td> <code id=application-cache-api:event-appcache-cached><a href=#event-appcache-cached>cached</a></code>
    <tr><td><dfn id=handler-appcache-onobsolete><code>onobsolete</code></dfn> <td> <code id=application-cache-api:event-appcache-obsolete><a href=#event-appcache-obsolete>obsolete</a></code>
  </table>

  


  <h4 id=navigator.online><span class=secno>7.9.11</span> <span id=browser-state>Browser state</span><a href=#navigator.online class=self-link></a></h4><div class=status><input onclick=toggleStatus(this) value=⋰ type=button><p class=support><strong>Support:</strong> online-status<span class="and_chr yes"><span>Chrome for Android</span> <span>67+</span></span><span class="chrome yes"><span>Chrome</span> <span>14+</span></span><span class="ios_saf yes"><span>iOS Safari</span> <span>4.2+</span></span><span class="and_uc yes"><span>UC Browser for Android</span> <span>11.8+</span></span><span class="firefox yes"><span>Firefox</span> <span>41+</span></span><span class="ie yes"><span>IE</span> <span>9+</span></span><span class="op_mini no"><span>Opera Mini</span> <span>None</span></span><span class="safari yes"><span>Safari</span> <span>5+</span></span><span class="edge yes"><span>Edge</span> <span>12+</span></span><span class="samsung yes"><span>Samsung Internet</span> <span>4+</span></span><span class="opera yes"><span>Opera</span> <span>15+</span></span><span class="android yes"><span>Android Browser</span> <span>2.3+</span></span><p class=caniuse>Source: <a href="https://caniuse.com/#feat=online-status">caniuse.com</a></div>

  <pre><code class='idl'><c- b>interface</c-> <c- b>mixin</c-> <dfn id='navigatoronline'><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><var>self</var> . <code id=navigator.online:dom-navigator><a href=#dom-navigator>navigator</a></code> . <code id=dom-navigator-online-dev><a href=#dom-navigator-online>onLine</a></code><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>
   </dl>

  

  <p>The <dfn id=dom-navigator-online><code>navigator.onLine</code></dfn> attribute must return
  false if the user agent will not contact the network when the user follows links or when a script
  requests a remote page (or knows that such an attempt would fail), and must return true
  otherwise.</p>

  <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> changes from true to false, the user agent must <a href=#queue-a-task id=navigator.online:queue-a-task>queue a
  task</a> 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 the <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>
  object.</p>

  <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-3><a href=#window>Window</a></code> or
  <code id=navigator.online:workerglobalscope-3><a href=#workerglobalscope>WorkerGlobalScope</a></code> changes from false to true, the user agent must <a href=#queue-a-task id=navigator.online:queue-a-task-2>queue a
  task</a> 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-4><a href=#window>Window</a></code> or <code id=navigator.online:workerglobalscope-4><a href=#workerglobalscope>WorkerGlobalScope</a></code>
  object.</p>

  <p>The <a href=#task-source id=navigator.online:task-source>task source</a> for these <a href=#concept-task id=navigator.online:concept-task>tasks</a> is the
  <a href=#networking-task-source id=navigator.online:networking-task-source>networking task source</a>.</p>

  

  <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>&quot;en&quot;</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>&apos;indicator&apos;</c-><c- p>).</c->textContent <c- o>=</c-> navigator<c- p>.</c->onLine <c- o>?</c-> <c- t>&apos;online&apos;</c-> <c- o>:</c-> <c- t>&apos;offline&apos;</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>&quot;updateIndicator()&quot;</c-> <c- e>ononline</c-><c- o>=</c-><c- s>&quot;updateIndicator()&quot;</c-> <c- e>onoffline</c-><c- o>=</c-><c- s>&quot;updateIndicator()&quot;</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>&quot;indicator&quot;</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>




  <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>Navigating to <a href=#javascript-protocol id=introduction-11:javascript-protocol><code>javascript:</code> URLs</a>.<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>Processing of technologies like SVG that have their own scripting features.</ul>


  

  <h4 id=enabling-and-disabling-scripting><span class=secno>8.1.2</span> Enabling and disabling scripting<a href=#enabling-and-disabling-scripting class=self-link></a></h4>

  <p><dfn id=concept-bc-script>Scripting is enabled</dfn> in a <em><a href=#browsing-context id=enabling-and-disabling-scripting:browsing-context>browsing
  context</a></em> when all of the following conditions are true:</p>

  <ul><li>The user agent supports scripting.<li>The user has not disabled scripting for this <a href=#browsing-context id=enabling-and-disabling-scripting:browsing-context-2>browsing context</a> 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.)
   <a href=#fingerprinting-vector id=enabling-and-disabling-scripting:fingerprinting-vector class=fingerprint title="There is a potential fingerprinting vector here."><img alt="(This is a fingerprinting vector.)" src=/images/fingerprint.png width=46 height=64></a>
   <li id=sandboxScriptBlocked>The <a href=#browsing-context id=enabling-and-disabling-scripting:browsing-context-3>browsing context</a>'s <a href=#active-document id=enabling-and-disabling-scripting:active-document>active document</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.</ul>

  <p><dfn id=concept-bc-noscript>Scripting is disabled</dfn> in a <a href=#browsing-context id=enabling-and-disabling-scripting:browsing-context-4>browsing context</a>
  when any of the above conditions are false (i.e. when scripting is not <a href=#concept-bc-script id=enabling-and-disabling-scripting:concept-bc-script>enabled</a>).</p>

  <hr>

  <p><dfn id=concept-n-script>Scripting is enabled</dfn> for a <em>node</em> if the node'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> has a <a href=#concept-document-bc id=enabling-and-disabling-scripting:concept-document-bc>browsing context</a>, and
  <a href=#concept-bc-script id=enabling-and-disabling-scripting:concept-bc-script-2>scripting is enabled</a> in that <a href=#browsing-context id=enabling-and-disabling-scripting:browsing-context-5>browsing
  context</a>.</p>

  <p><dfn id=concept-n-noscript>Scripting is disabled</dfn> for a node if there is no such
  <a href=#browsing-context id=enabling-and-disabling-scripting:browsing-context-6>browsing context</a>, or if <a href=#concept-bc-noscript id=enabling-and-disabling-scripting:concept-bc-noscript>scripting is
  disabled</a> in that <a href=#browsing-context id=enabling-and-disabling-scripting:browsing-context-7>browsing context</a>.</p>

  


  

  
  <h4 id=scripting-processing-model><span class=secno>8.1.3</span> <span id=processing-model-7></span>Processing model<a href=#scripting-processing-model class=self-link></a></h4>

  <h5 id=definitions-2><span class=secno>8.1.3.1</span> Definitions<a href=#definitions-2 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=definitions-2:struct data-x-internal=struct>structs</a>. All scripts have:</p>

  <dl><dt>A <dfn data-dfn-for=script id=settings-object data-export="">settings object</dfn><dd><p>An <a href=#environment-settings-object id=definitions-2:environment-settings-object>environment settings object</a>, containing various settings that are shared
   with other <a href=#concept-script id=definitions-2:concept-script>scripts</a> in the same context.<dt>A <dfn data-dfn-for=script id=concept-script-record data-export="">record</dfn><dd><p>Either a <a id=definitions-2:script-record href=https://tc39.github.io/ecma262/#sec-script-records data-x-internal=script-record>Script Record</a>, for <a href=#classic-script id=definitions-2:classic-script>classic
   scripts</a>; a <a id=definitions-2:source-text-module-record href=https://tc39.github.io/ecma262/#sec-source-text-module-records data-x-internal=source-text-module-record>Source Text Module Record</a>, for <a href=#module-script id=definitions-2:module-script>module scripts</a>; or null. In the former two cases, it represents a parsed script;
   null represents a failure parsing.<dt>A <dfn data-dfn-for=script id=concept-script-parse-error data-export="">parse
   error</dfn><dd><p>A JavaScript value, which has meaning only if the <a href=#concept-script-record id=definitions-2:concept-script-record>record</a> is null, indicating that the corresponding script
   source text could not be parsed.<dt>An <dfn data-dfn-for=script id=concept-script-error-to-rethrow data-export="">error
   to rethrow</dfn><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>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>
   <dt><dfn data-dfn-for=script id=concept-script-script-fetch-options data-export="">Fetch options</dfn><dd>A <a href=#script-fetch-options id=definitions-2:script-fetch-options>script fetch options</a>, containing various options related to fetching this
   script or <a href=#module-script id=definitions-2:module-script-2>module scripts</a> that it imports.<dt>A <dfn data-dfn-for=script id=concept-script-base-url data-export="">base
   URL</dfn><dd><p>A base <a id=definitions-2:url href=https://url.spec.whatwg.org/#concept-url data-x-internal=url>URL</a> used for <a href=#resolve-a-module-specifier id=definitions-2:resolve-a-module-specifier>resolving
   module specifiers</a>. This will either be the URL from which the script was obtained, for
   external scripts, or the <a href=#document-base-url id=definitions-2:document-base-url>document base URL</a> of the containing document, for inline
   scripts.</dl>


  <p>A <dfn id=classic-script data-export="">classic script</dfn> is a type of <a href=#concept-script id=definitions-2:concept-script-2>script</a> that has the following additional <a href=https://infra.spec.whatwg.org/#struct-item id=definitions-2:struct-item data-x-internal=struct-item>item</a>:</p>

  <dl><dt>A <dfn id=muted-errors>muted errors</dfn> boolean<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.</dl>

  <p>A <dfn id=module-script data-export="">module script</dfn> is another type of <a href=#concept-script id=definitions-2:concept-script-3>script</a>. It has no additional <a href=https://infra.spec.whatwg.org/#struct-item id=definitions-2:struct-item-2 data-x-internal=struct-item>items</a>.</p>

  <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=definitions-2:getactivescriptormodule href=https://tc39.github.io/ecma262/#sec-getactivescriptormodule data-x-internal=getactivescriptormodule>GetActiveScriptOrModule</a>().<li><p>If <var>record</var> is null, return null.<li><p>Return <var>record</var>.[[HostDefined]].</ol>

  <hr>

  <p>An <dfn id=environment data-export="">environment</dfn> is an object that identifies the settings of a
  current or potential execution environment. An <a href=#environment id=definitions-2:environment>environment</a> has the following
  fields:</p>

  <dl><dt>An <dfn data-dfn-for=environment id=concept-environment-id data-export="">id</dfn><dd><p>An opaque string that uniquely identifies the <a href=#environment id=definitions-2:environment-2>environment</a>.<dt>A <dfn data-dfn-for=environment id=concept-environment-creation-url data-export="">creation URL</dfn><dd>
    <p>A <a id=definitions-2:url-record href=https://url.spec.whatwg.org/#concept-url data-x-internal=url-record>URL record</a> that represents the location of the resource with which the
    <a href=#environment id=definitions-2:environment-3>environment</a> is associated.</p>

    <p class=note>In the case of an <a href=#environment-settings-object id=definitions-2:environment-settings-object-2>environment settings object</a>, this URL might be
    distinct from the <a href=#environment-settings-object id=definitions-2:environment-settings-object-3>environment settings object</a>'s <a href=#responsible-document id=definitions-2:responsible-document>responsible
    document</a>'s <a href=https://dom.spec.whatwg.org/#concept-document-url id="definitions-2:the-document's-address" data-x-internal="the-document's-address">URL</a>, due to mechanisms such as
    <code id=definitions-2:dom-history-pushstate><a href=#dom-history-pushstate>history.pushState()</a></code>.</p>
   <dt>A <dfn data-dfn-for=environment id=concept-environment-target-browsing-context data-export="">target browsing context</dfn><dd><p>Null or a target <a href=#browsing-context id=definitions-2:browsing-context>browsing context</a> for a <a href=https://fetch.spec.whatwg.org/#navigation-request id=definitions-2:navigation-request data-x-internal=navigation-request>navigation request</a>.<dt>An <dfn data-dfn-for=environment id=concept-environment-active-service-worker data-export="">active service worker</dfn><dd><p>Null or a <a href=https://w3c.github.io/ServiceWorker/#dfn-service-worker id=definitions-2:dfn-service-worker data-x-internal=dfn-service-worker>service worker</a> that <a href=https://w3c.github.io/ServiceWorker/#dfn-control id=definitions-2:dfn-control data-x-internal=dfn-control>controls</a> the <a href=#environment id=definitions-2:environment-4>environment</a>.<dt>An <dfn data-dfn-for=environment id=concept-environment-execution-ready-flag data-export="">execution ready flag</dfn><dd><p>A flag that indicates whether the environment setup is done. It is initially
   unset.</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=definitions-2:environment-5>environment</a> as input.</p>

  <p class=note>The <a href=#environment-discarding-steps id=definitions-2: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>

  <p>An <dfn id=environment-settings-object data-export="">environment settings object</dfn> is an <a href=#environment id=definitions-2:environment-6>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><dd>

    <p>A <a id=definitions-2:javascript-execution-context href=https://tc39.github.io/ecma262/#sec-execution-contexts data-x-internal=javascript-execution-context>JavaScript execution context</a> shared by all
    <a href=#the-script-element id=definitions-2:the-script-element>scripts</a> that use this settings object, i.e. all scripts in a given
    <a id=definitions-2:javascript-realm href=https://tc39.github.io/ecma262/#sec-code-realms data-x-internal=javascript-realm>JavaScript realm</a>. When we <a href=#run-a-classic-script id=definitions-2:run-a-classic-script>run a classic script</a> or <a href=#run-a-module-script id=definitions-2:run-a-module-script>run a module
    script</a>, this execution context becomes the top of the <a id=definitions-2:javascript-execution-context-stack href=https://tc39.github.io/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 href=https://tc39.github.io/ecma262/#sec-parse-script id=definitions-2:js-parsescript data-x-internal=js-parsescript>ParseScript</a> and <a id=definitions-2:source-text-module-record-2 href=https://tc39.github.io/ecma262/#sec-source-text-module-records data-x-internal=source-text-module-record>Source
    Text Module Record</a>'s <a href=https://tc39.github.io/ecma262/#sec-moduleevaluation id=definitions-2:js-evaluate data-x-internal=js-evaluate>Evaluate</a> know which Realm to
    use.)</p>

   <dt>A <dfn data-dfn-for="environment
   settings object" id=concept-settings-object-module-map data-export="">module map</dfn><dd>

    <p>A <a href=#module-map id=definitions-2:module-map>module map</a> that is used when importing JavaScript modules.</p>

   <dt>A <dfn data-dfn-for="environment settings object" id=responsible-browsing-context data-export="">responsible browsing
   context</dfn><dd>

    <p>A <a href=#browsing-context id=definitions-2:browsing-context-2>browsing context</a> that is assigned responsibility for actions taken by the
    scripts that use this <a href=#environment-settings-object id=definitions-2:environment-settings-object-4>environment settings object</a>.</p>

    <p class=example>When a script creates and <a href=#navigate id=definitions-2:navigate>navigates</a> a new
    <a href=#top-level-browsing-context id=definitions-2:top-level-browsing-context>top-level browsing context</a>, the <code id=definitions-2:dom-opener><a href=#dom-opener>opener</a></code> attribute
    of the new <a href=#browsing-context id=definitions-2:browsing-context-3>browsing context</a>'s <code id=definitions-2:window><a href=#window>Window</a></code> object will be set to the
    <a href=#responsible-browsing-context id=definitions-2:responsible-browsing-context>responsible browsing context</a>'s <code id=definitions-2:windowproxy><a href=#windowproxy>WindowProxy</a></code> object.</p>

   <dt>A <dfn data-dfn-for="environment settings object" id=responsible-event-loop data-export="">responsible event
   loop</dfn><dd>

    <p>An <a href=#event-loop id=definitions-2:event-loop>event loop</a> that is used when it would not be immediately clear what event
    loop to use.</p>

   <dt>A <dfn data-dfn-for="environment settings object" id=responsible-document data-export="">responsible document</dfn><dd>

    <p>A <code id=definitions-2:document><a href=#document>Document</a></code> that is assigned responsibility for actions taken by the scripts that
    use this <a href=#environment-settings-object id=definitions-2:environment-settings-object-5>environment settings object</a>.</p>

    <p class=example>For example, the <a href=https://dom.spec.whatwg.org/#concept-document-url id="definitions-2:the-document's-address-2" data-x-internal="the-document's-address">URL</a> of the
    <a href=#responsible-document id=definitions-2:responsible-document-2>responsible document</a> is used to set the <a href=https://dom.spec.whatwg.org/#concept-document-url id="definitions-2:the-document's-address-3" data-x-internal="the-document's-address">URL</a> of the <code id=definitions-2:document-2><a href=#document>Document</a></code> after it has been reset
    using <code id=definitions-2:dom-document-open><a href=#dom-document-open>document.open()</a></code>.</p>

    <p>If the <a href=#responsible-event-loop id=definitions-2:responsible-event-loop>responsible event loop</a> is not a <a href=#browsing-context id=definitions-2:browsing-context-4>browsing context</a> <a href=#event-loop id=definitions-2:event-loop-2>event loop</a>,
    then the <a href=#environment-settings-object id=definitions-2:environment-settings-object-6>environment settings object</a> has no <a href=#responsible-document id=definitions-2:responsible-document-3>responsible document</a>.</p>

   <dt>An <dfn data-dfn-for="environment settings object" id=api-url-character-encoding data-export="">API URL character encoding</dfn><dd>

    <p>A character encoding used to encode URLs by APIs called by scripts that use this <a href=#environment-settings-object id=definitions-2:environment-settings-object-7>environment
    settings object</a>.</p>

   <dt>An <dfn data-dfn-for="environment settings object" id=api-base-url data-export="">API base URL</dfn><dd>

    <p>A <a id=definitions-2:url-2 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=definitions-2:environment-settings-object-8>environment settings
    object</a> to <a href=#parse-a-url id=definitions-2:parse-a-url>parse URLs</a>.</p>

   <dt>An <dfn data-dfn-for="environment
   settings object" id=concept-settings-object-origin data-export="">origin</dfn><dd>

    <p>An <a href=#concept-origin id=definitions-2:concept-origin>origin</a> used in security checks.</p>

   <dt>An <dfn data-dfn-for="environment settings object" id=https-state data-export="">HTTPS state</dfn><dd><p>An <a id=definitions-2:https-state-value href=https://fetch.spec.whatwg.org/#concept-https-state-value data-x-internal=https-state-value>HTTPS state value</a> representing the security properties of the network
   channel used to deliver the resource with which the <a href=#environment-settings-object id=definitions-2:environment-settings-object-9>environment settings object</a> is
   associated.<dt>A <dfn data-dfn-for="environment settings object" id=concept-settings-object-referrer-policy data-export="">referrer policy</dfn><dd><p>The default <a id=definitions-2: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=definitions-2:concept-fetch data-x-internal=concept-fetch>fetches</a>
   performed using this <a href=#environment-settings-object id=definitions-2:environment-settings-object-10>environment settings object</a> as a <a href=https://fetch.spec.whatwg.org/#concept-request-client id=definitions-2:concept-request-client data-x-internal=concept-request-client>request client</a>. <a href=#refsREFERRERPOLICY>[REFERRERPOLICY]</a>

  </dl>

  <p>An <a href=#environment-settings-object id=definitions-2:environment-settings-object-11>environment settings object</a> also has an <dfn id=outstanding-rejected-promises-weak-set>outstanding rejected promises
  weak set</dfn> and an <dfn id=about-to-be-notified-rejected-promises-list>about-to-be-notified rejected promises list</dfn>, used to track
  <a href=#unhandled-promise-rejections>unhandled promise rejections</a>. The <a href=#outstanding-rejected-promises-weak-set id=definitions-2:outstanding-rejected-promises-weak-set>outstanding
  rejected promises weak set</a> must not create strong references to any of its members, and
  implementations are free to limit its size, e.g. by removing old entries from it when new ones
  are added.</p>

  <h5 id=fetching-scripts><span class=secno>8.1.3.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><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<dt><dfn id=concept-script-fetch-options-integrity>integrity metadata</dfn><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<dt><dfn id=concept-script-fetch-options-parser>parser metadata</dfn><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<dt><dfn id=concept-script-fetch-options-credentials>credentials mode</dfn><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>)<dt><dfn id=concept-script-fetch-options-referrer-policy>referrer policy</dfn><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</dl>

  <p class=note>Recall that via the <code id=fetching-scripts:import()><a data-x-internal=import() href=https://tc39.github.io/proposal-dynamic-import/#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-4>module scripts</a>.</p>

  <p>The <dfn id=default-classic-script-fetch-options>default classic 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>omit</code>", and <a href=#concept-script-fetch-options-referrer-policy id=fetching-scripts:concept-script-fetch-options-referrer-policy>referrer
  policy</a> is the empty string.</p>

  <p>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>, we define:</p>

  <dl><dt><dfn id=set-up-the-classic-script-request>set up the classic script request</dfn><dd><p>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>, and 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>.<dt><dfn id=set-up-the-module-script-request>set up the module script request</dfn><dd><p>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>, and 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>.</dl>

  <p>For any given <a href=#script-fetch-options id=fetching-scripts:script-fetch-options-3>script fetch options</a> <var>options</var>, the <dfn id=descendant-script-fetch-options>descendant script
  fetch options</dfn> are a new <a href=#script-fetch-options id=fetching-scripts:script-fetch-options-4>script fetch options</a> whose <a href=https://infra.spec.whatwg.org/#struct-item id=fetching-scripts:struct-item-2 data-x-internal=struct-item>items</a> all have the same values, except for the <a href=#concept-script-fetch-options-integrity id=fetching-scripts:concept-script-fetch-options-integrity-4>integrity metadata</a>, which is instead the
  empty string.</p>

  <hr>

  <p>The algorithms below can be customized by optionally supplying a custom <dfn data-dfn-for="fetching scripts" id=fetching-scripts-perform-fetch data-export="">perform the
  fetch</dfn> hook, which takes a <a href=https://fetch.spec.whatwg.org/#concept-request id=fetching-scripts:concept-request-2 data-x-internal=concept-request>request</a> and an <dfn data-dfn-for="fetching scripts" id=fetching-scripts-is-top-level data-export=""><var>is
  top-level</var></dfn> flag. The algorithm must complete with a <a href=https://fetch.spec.whatwg.org/#concept-response id=fetching-scripts:concept-response data-x-internal=concept-response>response</a> (which may be a <a id=fetching-scripts:network-error href=https://fetch.spec.whatwg.org/#concept-network-error data-x-internal=network-error>network error</a>), either
  synchronously (when using <a href=#fetch-a-classic-worker-imported-script id=fetching-scripts:fetch-a-classic-worker-imported-script>fetch a classic worker-imported script</a>) or asynchronously
  (otherwise). The <var id=fetching-scripts:fetching-scripts-is-top-level><a href=#fetching-scripts-is-top-level>is top-level</a></var> flag will be set
  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 a 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 not for the fetches resulting from
  <code>import</code> statements encountered throughout the graph.</p>

  <div class=note>
   <p>By default, not supplying the <a href=#fetching-scripts-perform-fetch id=fetching-scripts:fetching-scripts-perform-fetch>perform the
   fetch</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-3 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-4 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-2 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</a> hook that modifies the given
   <a href=https://fetch.spec.whatwg.org/#concept-request id=fetching-scripts:concept-request-5 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-3 data-x-internal=concept-response>response</a> (completing with a <a id=fetching-scripts:network-error-2 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-4 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>
  </div>

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

  <p>To <dfn id=fetch-a-classic-script data-export="">fetch a classic script</dfn> given a <var>url</var>, a <var>settings
  object</var>, some <var>options</var>, a <var>CORS setting</var>, and a <var>character
  encoding</var>, run these steps. The algorithm will asynchronously complete with either null (on
  failure) or a new <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>CORS setting</var>.<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>settings object</var>.</p>

   <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>.<li>
    <p>If the caller specified custom steps to <a href=#fetching-scripts-perform-fetch id=fetching-scripts:fetching-scripts-perform-fetch-3>perform
    the fetch</a>, perform them on <var>request</var>, with the <var id=fetching-scripts:fetching-scripts-is-top-level-2><a href=#fetching-scripts-is-top-level>is top-level</a></var> flag set. Return from this algorithm,
    and when the custom <a href=#fetching-scripts-perform-fetch id=fetching-scripts:fetching-scripts-perform-fetch-4>perform the fetch</a> steps
    complete with <a href=https://fetch.spec.whatwg.org/#concept-response id=fetching-scripts:concept-response-5 data-x-internal=concept-response>response</a> <var>response</var>, run the
    remaining steps.</p>

    <p>Otherwise, <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>. Return from this
    algorithm, and run the remaining steps as part of the fetch's <a id=fetching-scripts:process-response href=https://fetch.spec.whatwg.org/#process-response data-x-internal=process-response>process response</a> for
    the <a href=https://fetch.spec.whatwg.org/#concept-response id=fetching-scripts:concept-response-6 data-x-internal=concept-response>response</a> <var>response</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>
   <li><p>Let <var>response</var> be <var>response</var>'s <a href=#unsafe-response id=fetching-scripts:unsafe-response>unsafe response</a>.<li><p>If <var>response</var>'s <a href=https://fetch.spec.whatwg.org/#concept-response-type id=fetching-scripts:concept-response-type data-x-internal=concept-response-type>type</a> is "<code>error</code>", or <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>, asynchronously
   complete this algorithm with null, and abort these steps.<li><p>If <var>response</var>'s <a href=#content-type id=fetching-scripts:content-type>Content Type metadata</a>, if
   any, specifies a character encoding, and the user agent supports that encoding, then set
   <var>character encoding</var> to that encoding (ignoring the passed-in value).<li>
    <p>Let <var>source text</var> be the result of <a href=https://encoding.spec.whatwg.org/#decode id=fetching-scripts:decode data-x-internal=decode>decoding</a>
    <var>response</var>'s <a href=https://fetch.spec.whatwg.org/#concept-response-body id=fetching-scripts:concept-response-body data-x-internal=concept-response-body>body</a> to Unicode, using
    <var>character 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>character encoding</var> if
    the file contains a BOM.</p>
   <li><p>Let <var>muted errors</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.<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>source text</var>, <var>settings object</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>, and <var>muted
   errors</var>.<li>Asynchronously complete this algorithm with <var>script</var>.</ol>

  <p>To <dfn id=fetch-a-classic-worker-script data-export="">fetch a classic worker script</dfn> given a <var>url</var>, a <var>fetch
  client settings object</var>, a <var>destination</var>, and a <var>script settings object</var>,
  run these steps. The algorithm will asynchronously complete with either null (on failure) or a new
  <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-6 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>fetch client settings object</var>, <a href=https://fetch.spec.whatwg.org/#concept-request-destination id=fetching-scripts: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=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.<li>
    <p>If the caller specified custom steps to <a href=#fetching-scripts-perform-fetch id=fetching-scripts:fetching-scripts-perform-fetch-5>perform
    the fetch</a>, perform them on <var>request</var>, with the <var id=fetching-scripts:fetching-scripts-is-top-level-3><a href=#fetching-scripts-is-top-level>is top-level</a></var> flag set. Return from this algorithm,
    and when the custom <a href=#fetching-scripts-perform-fetch id=fetching-scripts:fetching-scripts-perform-fetch-6>perform the fetch</a> steps
    complete with <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>, run the
    remaining steps.</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>. Return from this
    algorithm, and run the remaining steps as part of the fetch's <a id=fetching-scripts:process-response-2 href=https://fetch.spec.whatwg.org/#process-response data-x-internal=process-response>process response</a> for
    the <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>.</p>
   <li><p>Let <var>response</var> be <var>response</var>'s <a href=#unsafe-response id=fetching-scripts:unsafe-response-2>unsafe response</a>.<li><p>If <var>response</var>'s <a href=https://fetch.spec.whatwg.org/#concept-response-type id=fetching-scripts:concept-response-type-2 data-x-internal=concept-response-type>type</a> is "<code>error</code>", or <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>, asynchronously
   complete this algorithm with null, and abort these steps.<li><p>Let <var>source text</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>response</var>'s <a href=https://fetch.spec.whatwg.org/#concept-response-body id=fetching-scripts:concept-response-body-2 data-x-internal=concept-response-body>body</a>.<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>source text</var>, <var>script settings object</var>, <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>, and the <a href=#default-classic-script-fetch-options id=fetching-scripts:default-classic-script-fetch-options>default classic script fetch
   options</a>.<li>Asynchronously complete this algorithm with <var>script</var>.</ol>

  <p>To <dfn id=fetch-a-classic-worker-imported-script data-export="">fetch a classic worker-imported script</dfn> given a <var>url</var> and
  a <var>settings object</var>, run these steps. The algorithm will synchronously complete with 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>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-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>settings object</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 "<code>script</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>", <a id=fetching-scripts:synchronous-flag href=https://fetch.spec.whatwg.org/#synchronous-flag data-x-internal=synchronous-flag>synchronous flag</a> is set, 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.<li>
    <p>If the caller specified custom steps to <a href=#fetching-scripts-perform-fetch id=fetching-scripts:fetching-scripts-perform-fetch-7>perform
    the fetch</a>, perform them on <var>request</var>, with the <var id=fetching-scripts:fetching-scripts-is-top-level-4><a href=#fetching-scripts-is-top-level>is top-level</a></var> flag set. Let <var>response</var> be
    the result.</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>, and let
    <var>response</var> be the result.</p>

    <p class=note>Unlike other algorithms in this section, the fetching process is synchronous
    here. Thus any <a href=#fetching-scripts-perform-fetch id=fetching-scripts:fetching-scripts-perform-fetch-8>perform the fetch</a> steps will
    also finish their work synchronously.</p>
   <li><p>Let <var>response</var> be <var>response</var>'s <a href=#unsafe-response id=fetching-scripts:unsafe-response-3>unsafe response</a>.<li><p>If <var>response</var>'s <a href=https://fetch.spec.whatwg.org/#concept-response-type id=fetching-scripts:concept-response-type-3 data-x-internal=concept-response-type>type</a> is "<code>error</code>", or <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>, throw a
   <a id=fetching-scripts:networkerror href=https://heycam.github.io/webidl/#networkerror data-x-internal=networkerror>"<code>NetworkError</code>"</a> <code id=fetching-scripts:domexception><a data-x-internal=domexception href=https://heycam.github.io/webidl/#dfn-DOMException>DOMException</a></code>.<li><p>Let <var>source text</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>response</var>'s <a href=https://fetch.spec.whatwg.org/#concept-response-body id=fetching-scripts:concept-response-body-3 data-x-internal=concept-response-body>body</a>.<li><p>Let <var>muted errors</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.<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>source text</var>, <var>settings object</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>, the <a href=#default-classic-script-fetch-options id=fetching-scripts:default-classic-script-fetch-options-2>default classic script fetch options</a>,
   and <var>muted errors</var>.<li><p>Return <var>script</var>.</ol>

  <p>To <dfn id=fetch-a-module-script-tree data-export="">fetch a module script graph</dfn> given
  a <var>url</var>, a <var>settings object</var>, a <var>destination</var>, and some
  <var>options</var>, run these steps. The algorithm will asynchronously complete with either null
  (on failure) or a <a href=#module-script id=fetching-scripts:module-script-5>module script</a> (on success).</p>

  <ol><li><p>Let <var>visited set</var> be « <var>url</var> ».<li><p>Perform the <a href=#internal-module-script-graph-fetching-procedure id=fetching-scripts:internal-module-script-graph-fetching-procedure>internal module script graph fetching procedure</a> given
   <var>url</var>, <var>settings object</var>, <var>destination</var>, <var>options</var>,
   <var>settings object</var>, <var>visited set</var>, "<code>client</code>", and with the
   <var>top-level module fetch flag</var> set. If the caller of this algorithm specified custom <a href=#fetching-scripts-perform-fetch id=fetching-scripts:fetching-scripts-perform-fetch-9>perform the fetch</a> steps, pass those along as
   well.</p>

   <li><p>When the <a href=#internal-module-script-graph-fetching-procedure id=fetching-scripts:internal-module-script-graph-fetching-procedure-2>internal module script graph fetching procedure</a> asynchronously
   completes with <var>result</var>, asynchronously complete this algorithm with
   <var>result</var>.</ol>

  <p>To <dfn id=fetch-a-module-worker-script-tree data-export="">fetch a module worker script
  graph</dfn> given a <var>url</var>, a <var>fetch client settings object</var>, a
  <var>destination</var>, a <var>credentials mode</var>, and a <var>module map settings
  object</var>, run these steps. The algorithm will asynchronously complete with either null (on
  failure) or a <a href=#module-script id=fetching-scripts:module-script-6>module script</a> (on success).</p>

  <ol><li><p>Let <var>visited set</var> be « <var>url</var> ».<li><p>Let <var>options</var> be a <a href=#script-fetch-options id=fetching-scripts:script-fetch-options-5>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-3>credentials mode</a> is <var>credentials
   mode</var>, and <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.</p>

   <li><p>Perform the <a href=#internal-module-script-graph-fetching-procedure id=fetching-scripts:internal-module-script-graph-fetching-procedure-3>internal module script graph fetching procedure</a> given
   <var>url</var>, <var>fetch client settings object</var>, <var>destination</var>,
   <var>options</var>, <var>module map settings object</var>, <var>visited set</var>, "<code>client</code>", and with the <var>top-level module fetch flag</var> set. If the caller
   of this algorithm specified custom <a href=#fetching-scripts-perform-fetch id=fetching-scripts:fetching-scripts-perform-fetch-10>perform the
   fetch</a> steps, pass those along as well.</p>

   <li><p>When the <a href=#internal-module-script-graph-fetching-procedure id=fetching-scripts:internal-module-script-graph-fetching-procedure-4>internal module script graph fetching procedure</a> asynchronously
   completes with <var>result</var>, asynchronously complete this algorithm with
   <var>result</var>.</ol>

  <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-2>fetching a module script graph</a> or <a href=#prepare-a-script id=fetching-scripts:prepare-a-script>preparing a script</a>, and should not be used directly by other specifications.</p>

  <p>To perform the <dfn id=internal-module-script-graph-fetching-procedure>internal module script graph fetching procedure</dfn> given a
  <var>url</var>, a <var>fetch client settings object</var>, a <var>destination</var>, some
  <var>options</var>, a <var>module map settings object</var>, a <var>visited set</var>, a
  <var>referrer</var>, and a <var>top-level module fetch</var> flag, perform these steps. The
  algorithm will asynchronously complete with either null (on failure) or a <a href=#module-script id=fetching-scripts:module-script-7>module
  script</a> (on success).</p>

  <ol><li><p>Assert: <var>visited set</var> <a href=https://infra.spec.whatwg.org/#list-contain id=fetching-scripts:list-contains data-x-internal=list-contains>contains</a>
   <var>url</var>.<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>fetch client settings
   object</var>, <var>destination</var>, <var>options</var>, <var>module map settings object</var>,
   <var>referrer</var>, and the <var>top-level module fetch</var> flag. If the caller of this
   algorithm specified custom <a href=#fetching-scripts-perform-fetch id=fetching-scripts:fetching-scripts-perform-fetch-11>perform the fetch</a>
   steps, pass those along while <a href=#fetch-a-single-module-script id=fetching-scripts:fetch-a-single-module-script-2>fetching a single
   module script</a>.</p>

   <li><p>Return from this algorithm, and run the following steps when <a href=#fetch-a-single-module-script id=fetching-scripts:fetch-a-single-module-script-3>fetching a single module script</a> asynchronously completes with
   <var>result</var>:<li><p>If <var>result</var> is null, asynchronously complete this algorithm with null, and abort
   these steps.<li><p>If the <var>top-level module fetch</var> flag is set, <a href=#fetch-the-descendants-of-and-instantiate-a-module-script id=fetching-scripts:fetch-the-descendants-of-and-instantiate-a-module-script>fetch the descendants of and instantiate</a>
   <var>result</var> given <var>fetch client settings object</var>, <var>destination</var>, and
   <var>visited set</var>. Otherwise, <a href=#fetch-the-descendants-of-a-module-script id=fetching-scripts:fetch-the-descendants-of-a-module-script>fetch
   the descendants of</a> <var>result</var> given the same arguments.<li><p>When the appropriate algorithm asynchronously completes with <var>final result</var>,
   asynchronously complete this algorithm with <var>final result</var>.</ol>

  <p>To <dfn id=fetch-a-single-module-script>fetch a single module script</dfn>, given a <var>url</var>, a <var>fetch client
  settings object</var>, a <var>destination</var>, some <var>options</var>, a <var>module map
  settings object</var>, a <var>referrer</var>, and a <var>top-level module fetch</var> flag, run
  these steps. The algorithm will asynchronously complete with either 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>moduleMap</var> be <var>module map settings object</var>'s <a href=#concept-settings-object-module-map id=fetching-scripts:concept-settings-object-module-map>module map</a>.<li><p>If <var>moduleMap</var>[<var>url</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.<li><p>If <var>moduleMap</var>[<var>url</var>] <a href=https://infra.spec.whatwg.org/#map-exists id=fetching-scripts:map-exists data-x-internal=map-exists>exists</a>,
   asynchronously complete this algorithm with <var>moduleMap</var>[<var>url</var>], and abort
   these steps.<li><p><a href=https://infra.spec.whatwg.org/#map-set id=fetching-scripts:map-set data-x-internal=map-set>Set</a> <var>moduleMap</var>[<var>url</var>] to "<code>fetching</code>".</p>

   <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-3 data-x-internal=concept-request-url>url</a> is <var>url</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 <var>destination</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 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>fetch client settings
   object</var>.<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>.<li>
    <p>If the caller specified custom steps to <a href=#fetching-scripts-perform-fetch id=fetching-scripts:fetching-scripts-perform-fetch-12>perform
    the fetch</a>, perform them on <var>request</var>, setting the <var id=fetching-scripts:fetching-scripts-is-top-level-5><a href=#fetching-scripts-is-top-level>is top-level</a></var> flag if the <var>top-level module
    fetch</var> flag is set. Return from this algorithm, and when the custom <a href=#fetching-scripts-perform-fetch id=fetching-scripts:fetching-scripts-perform-fetch-13>perform the fetch</a> steps complete with <a href=https://fetch.spec.whatwg.org/#concept-response id=fetching-scripts:concept-response-9 data-x-internal=concept-response>response</a> <var>response</var>, run the remaining steps.</p>

    <p>Otherwise, <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>. Return from this
    algorithm, and run the remaining steps as part of the fetch's <a id=fetching-scripts:process-response-3 href=https://fetch.spec.whatwg.org/#process-response data-x-internal=process-response>process response</a> for
    the <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>.</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>
   <li>
    <p>If any of the following conditions are met, <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>] to null, asynchronously complete this algorithm with null,
    and abort these steps:</p>

    <ul class=compact><li><p><var>response</var>'s <a href=https://fetch.spec.whatwg.org/#concept-response-type id=fetching-scripts:concept-response-type-4 data-x-internal=concept-response-type>type</a> is "<code>error</code>"<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><li>
      <p>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> from
      <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> 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>

      <p class=note>For historical reasons, <a href=#fetch-a-classic-script id=fetching-scripts:fetch-a-classic-script>fetching a
      classic script</a> does not include MIME type checking. In contrast, module scripts will
      fail to load if they are not of a correct MIME type.</p>
     </ul>
   <li><p>Let <var>source text</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>response</var>'s <a href=https://fetch.spec.whatwg.org/#concept-response-body id=fetching-scripts:concept-response-body-4 data-x-internal=concept-response-body>body</a>.<li><p>Let <var>module script</var> be the result of <a href=#creating-a-module-script id=fetching-scripts:creating-a-module-script>creating a module script</a> given
   <var>source text</var>, <var>module map settings object</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>, and <var>options</var>.<li>
    <p><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>] to <var>module
    script</var>, and asynchronously complete this algorithm with <var>module script</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-4 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-9>module script</a> is
    set to the <a href=https://fetch.spec.whatwg.org/#concept-response-url id=fetching-scripts:concept-response-url-5 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>
   </ol>

  <p>To <dfn id=fetch-the-descendants-of-a-module-script>fetch the descendants of a module script</dfn> <var>module script</var>, given a
  <var>fetch client settings object</var>, a <var>destination</var>, and a <var>visited set</var>,
  run these steps. The algorithm will asynchronously complete with either null (on failure) or
  with <var>module script</var> (on success).</p>

  <ol><li><p>If <var>module script</var>'s <a href=#concept-script-record id=fetching-scripts:concept-script-record>record</a> is null,
   then asynchronously complete this algorithm with <var>module script</var> and abort these
   steps.<li><p>Let <var>record</var> be <var>module script</var>'s <a href=#concept-script-record id=fetching-scripts:concept-script-record-2>record</a>.<li><p>If <var>record</var>.[[RequestedModules]] <a href=https://infra.spec.whatwg.org/#list-is-empty id=fetching-scripts:list-is-empty data-x-internal=list-is-empty>is empty</a>,
   asynchronously complete this algorithm with <var>module script</var>.<li><p>Let <var>urls</var> be a new empty <a id=fetching-scripts:list href=https://infra.spec.whatwg.org/#list data-x-internal=list>list</a>.<li>
    <p><a href=https://infra.spec.whatwg.org/#list-iterate id=fetching-scripts:list-iterate data-x-internal=list-iterate>For each</a> string <var>requested</var> of
    <var>record</var>.[[RequestedModules]],</p>

    <ol><li><p>Let <var>url</var> be the result of <a href=#resolve-a-module-specifier id=fetching-scripts:resolve-a-module-specifier>resolving
     a module specifier</a> given <var>module script</var>'s <a href=#concept-script-base-url id=fetching-scripts:concept-script-base-url-2>base URL</a> and <var>requested</var>.<li><p>Assert: <var>url</var> is never failure, because <a href=#resolve-a-module-specifier id=fetching-scripts:resolve-a-module-specifier-2>resolving a module specifier</a> must have been <a href=#validate-requested-module-specifiers>previously successful</a> with these same two
     arguments.<li>
      <p>If <var>visited set</var> does not <a href=https://infra.spec.whatwg.org/#list-contain id=fetching-scripts:list-contains-2 data-x-internal=list-contains>contain</a>
      <var>url</var>, then:</p>

      <ol><li><p><a href=https://infra.spec.whatwg.org/#list-append id=fetching-scripts:list-append data-x-internal=list-append>Append</a> <var>url</var> to <var>urls</var>.<li><p><a href=https://infra.spec.whatwg.org/#set-append id=fetching-scripts:set-append data-x-internal=set-append>Append</a> <var>url</var> to <var>visited
       set</var>.</ol>
     </ol>
   <li><p>Let <var>options</var> be the <a href=#descendant-script-fetch-options id=fetching-scripts:descendant-script-fetch-options>descendant script fetch options</a> for <var>module
   script</var>'s <a href=#concept-script-script-fetch-options id=fetching-scripts:concept-script-script-fetch-options>fetch options</a>.<li>
    <p><a href=https://infra.spec.whatwg.org/#list-iterate id=fetching-scripts:list-iterate-2 data-x-internal=list-iterate>For each</a> <var>url</var> in <var>urls</var>, perform the
    <a href=#internal-module-script-graph-fetching-procedure id=fetching-scripts:internal-module-script-graph-fetching-procedure-5>internal module script graph fetching procedure</a> given <var>url</var>,
    <var>fetch client settings object</var>, <var>destination</var>, <var>options</var>, <var>module
    script</var>'s <a href=#settings-object id=fetching-scripts:settings-object>settings object</a>, <var>visited set</var>, <var>module script</var>'s
    <a href=#concept-script-base-url id=fetching-scripts:concept-script-base-url-3>base URL</a>, and with the <var>top-level module
    fetch</var> flag unset. If the caller of this algorithm specified custom <a href=#fetching-scripts-perform-fetch id=fetching-scripts:fetching-scripts-perform-fetch-14>perform the fetch</a> steps, pass those along
    while performing the <a href=#internal-module-script-graph-fetching-procedure id=fetching-scripts:internal-module-script-graph-fetching-procedure-6>internal module script graph fetching procedure</a>.</p>

    <p>These invocations of the <a href=#internal-module-script-graph-fetching-procedure id=fetching-scripts:internal-module-script-graph-fetching-procedure-7>internal module script graph fetching procedure</a> should
    be performed in parallel to each other.</p>

    <p>If any of the invocations of the <a href=#internal-module-script-graph-fetching-procedure id=fetching-scripts:internal-module-script-graph-fetching-procedure-8>internal module script graph fetching procedure</a>
    asynchronously complete with null, asynchronously complete this algorithm with null, aborting
    these steps.</p>

    <p>Otherwise, wait until all of the <a href=#internal-module-script-graph-fetching-procedure id=fetching-scripts:internal-module-script-graph-fetching-procedure-9>internal module script graph fetching procedure</a>
    invocations have asynchronously completed. Asynchronously complete this algorithm with
    <var>module script</var>.</p>
   </ol>

  <p>To <dfn id=fetch-the-descendants-of-and-instantiate-a-module-script>fetch the descendants of and instantiate a module script</dfn> <var>module
  script</var>, given a <var>fetch client settings object</var>, a <var>destination</var>, and an
  optional <var>visited set</var>, run these steps. The algorithm will asynchronously complete with
  either null (on failure) or with <var>module script</var> (on success).</p>

  <ol><li><p>If <var>visited set</var> was not given, let it be an empty <a id=fetching-scripts:set href=https://infra.spec.whatwg.org/#ordered-set data-x-internal=set>set</a>.<li><p><a href=#fetch-the-descendants-of-a-module-script id=fetching-scripts:fetch-the-descendants-of-a-module-script-2>Fetch the descendants of</a>
   <var>module script</var>, given <var>fetch client settings object</var>, <var>destination</var>,
   and <var>visited set</var>.<li><p>Return from this algorithm, and run the following steps when <a href=#fetch-the-descendants-of-a-module-script id=fetching-scripts:fetch-the-descendants-of-a-module-script-3>fetching the descendants of a module script</a> asynchronously
   completes with <var>result</var>.<li>
    <p>If <var>result</var> is null, then asynchronously complete this algorithm with
    <var>result</var>.</p>

    <p class=note>In this case, there was an error fetching one or more of the descendants. We
    will not attempt to instantiate.</p>
   <li><p>Let <var>parse error</var> be the result of <a href=#finding-the-first-parse-error id=fetching-scripts:finding-the-first-parse-error>finding the first parse error</a>
   given <var>result</var>.<li><p>If <var>parse error</var> is null, then:</p>

    <ol><li><p>Let <var>record</var> be <var>result</var>'s <a href=#concept-script-record id=fetching-scripts:concept-script-record-3>record</a>.<li>
      <p>Perform <var>record</var>.<a href=https://tc39.github.io/ecma262/#sec-moduledeclarationinstantiation id=fetching-scripts:js-instantiate data-x-internal=js-instantiate>Instantiate</a>().</p>

      <p class=note>This step will recursively call <a href=https://tc39.github.io/ecma262/#sec-moduledeclarationinstantiation id=fetching-scripts:js-instantiate-2 data-x-internal=js-instantiate>Instantiate</a> on all of the module's uninstantiated
      dependencies.</p>

      <p>If this throws an exception, set <var>result</var>'s <a href=#concept-script-error-to-rethrow id=fetching-scripts:concept-script-error-to-rethrow>error to rethrow</a> to that exception.</p>
     </ol>
   <li><p>Otherwise, set <var>result</var>'s <a href=#concept-script-error-to-rethrow id=fetching-scripts:concept-script-error-to-rethrow-2>error to
   rethrow</a> to <var>parse error</var>.<li><p>Asynchronously complete this algorithm with <var>result</var>.</ol>

  <p>To <dfn id=finding-the-first-parse-error>find the first parse error</dfn> given a root
  <var>moduleScript</var> and an optional <var>discoveredSet</var>:</p>

  <ol><li><p>Let <var>moduleMap</var> be <var>moduleScript</var>'s <a href=#settings-object id=fetching-scripts:settings-object-2>settings object</a>'s
   <a href=#concept-settings-object-module-map id=fetching-scripts:concept-settings-object-module-map-2>module map</a>.<li><p>If <var>discoveredSet</var> was not given, let it be an empty <a id=fetching-scripts:set-2 href=https://infra.spec.whatwg.org/#ordered-set data-x-internal=set>set</a>.<li><p><a href=https://infra.spec.whatwg.org/#list-append id=fetching-scripts:list-append-2 data-x-internal=list-append>Append</a> <var>moduleScript</var> to
   <var>discoveredSet</var>.<li><p>If <var>moduleScript</var>'s <a href=#concept-script-record id=fetching-scripts:concept-script-record-4>record</a> is null,
   then return <var>moduleScript</var>'s <a href=#concept-script-parse-error id=fetching-scripts:concept-script-parse-error>parse
   error</a>.<li><p>Let <var>childSpecifiers</var> be the value of <var>moduleScript</var>'s <a href=#concept-script-record id=fetching-scripts:concept-script-record-5>record</a>'s [[RequestedModules]] internal slot.<li><p>Let <var>childURLs</var> be the <a id=fetching-scripts:list-2 href=https://infra.spec.whatwg.org/#list data-x-internal=list>list</a> obtained by calling
   <a href=#resolve-a-module-specifier id=fetching-scripts:resolve-a-module-specifier-3>resolve a module specifier</a> once for each item of <var>childSpecifiers</var>, given
   <var>moduleScript</var>'s <a href=#concept-script-base-url id=fetching-scripts:concept-script-base-url-4>base URL</a> and that item.
   (None of these will ever fail, as otherwise <var>moduleScript</var> would have been marked as
   itself having a parse error.)<li><p>Let <var>childModules</var> be the <a id=fetching-scripts:list-3 href=https://infra.spec.whatwg.org/#list data-x-internal=list>list</a> obtained by <a href=https://infra.spec.whatwg.org/#map-get id=fetching-scripts:map-get data-x-internal=map-get>getting each value</a> in <var>moduleMap</var> whose key is given by an
   item of <var>childURLs</var>.<li>
    <p><a href=https://infra.spec.whatwg.org/#list-iterate id=fetching-scripts:list-iterate-3 data-x-internal=list-iterate>For each</a> <var>childModule</var> of
    <var>childModules</var>:</p>

    <ol><li><p>Assert: <var>childModule</var> is a <a href=#module-script id=fetching-scripts:module-script-10>module script</a> (i.e., it is not "<code>fetching</code>" or null); by now all <a href=#module-script id=fetching-scripts:module-script-11>module
     scripts</a> in the graph rooted at <var>moduleScript</var> will have successfully been
     fetched.<li><p>If <var>discoveredSet</var> already <a href=https://infra.spec.whatwg.org/#list-contain id=fetching-scripts:list-contains-3 data-x-internal=list-contains>contains</a>
     <var>childModule</var>, <a id=fetching-scripts:continue href=https://infra.spec.whatwg.org/#iteration-continue data-x-internal=continue>continue</a>.<li><p>Let <var>childParseError</var> be the result of <a href=#finding-the-first-parse-error id=fetching-scripts:finding-the-first-parse-error-2>finding the first parse
     error</a> given <var>childModule</var> and <var>discoveredSet</var>.<li><p>If <var>childParseError</var> is not null, return <var>childParseError</var>.</ol>
   <li><p>Return null.</ol>

  <h5 id=creating-scripts><span class=secno>8.1.3.3</span> Creating scripts<a href=#creating-scripts class=self-link></a></h5>

  <p>To <dfn id=creating-a-classic-script>create a classic script</dfn>, given a
  <a id=creating-scripts:javascript-string href=https://infra.spec.whatwg.org/#javascript-string data-x-internal=javascript-string>JavaScript 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>, some <a href=#script-fetch-options id=creating-scripts:script-fetch-options>script fetch options</a>
  <var>options</var>, and an optional <var>muted errors</var> boolean:</p>

  <ol><li><p>If <var>muted errors</var> was not provided, let it be false.<li><p>If <a href=#concept-bc-noscript id=creating-scripts:concept-bc-noscript>scripting is disabled</a> for
   <var>settings</var>'s <a href=#responsible-browsing-context id=creating-scripts:responsible-browsing-context>responsible browsing context</a>, then set <var>source</var> to
   the empty string.<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.<li><p>Set <var>script</var>'s <a href=#settings-object id=creating-scripts:settings-object>settings object</a> to <var>settings</var>.<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>.<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>.<li><p>Set <var>script</var>'s <a href=#muted-errors id=creating-scripts:muted-errors>muted errors</a> to <var>muted errors</var>.<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.<li>
    <p>Let <var>result</var> be <a href=https://tc39.github.io/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>
    <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:

    <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].<li><p>Return <var>script</var>.</ol>
   <li><p>Set <var>script</var>'s <a href=#concept-script-record id=creating-scripts:concept-script-record>record</a> to
   <var>result</var>.<li><p>Return <var>script</var>.</ol>

  <p>To <dfn id=creating-a-module-script>create a module script</dfn>, given a
  <a id=creating-scripts:javascript-string-2 href=https://infra.spec.whatwg.org/#javascript-string data-x-internal=javascript-string>JavaScript 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-2 href=https://url.spec.whatwg.org/#concept-url data-x-internal=url>URL</a> <var>baseURL</var>, and some <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-bc-noscript id=creating-scripts:concept-bc-noscript-2>scripting is disabled</a> for
   <var>settings</var>'s <a href=#responsible-browsing-context id=creating-scripts:responsible-browsing-context-2>responsible browsing context</a>, then set <var>source</var> to
   the empty string.<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.<li><p>Set <var>script</var>'s <a href=#settings-object id=creating-scripts:settings-object-2>settings object</a> to <var>settings</var>.<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>.<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>.<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.<li>
    <p>Let <var>result</var> be <a href=https://tc39.github.io/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>
    <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].<li><p>Return <var>script</var>.</ol>
   <li id=validate-requested-module-specifiers>
    <p><a href=https://infra.spec.whatwg.org/#list-iterate id=creating-scripts:list-iterate data-x-internal=list-iterate>For each</a> string <var>requested</var> of
    <var>result</var>.[[RequestedModules]]:</p>

    <ol><li><p>Let <var>url</var> be the result of <a href=#resolve-a-module-specifier id=creating-scripts:resolve-a-module-specifier>resolving
     a module specifier</a> given <var>script</var>'s <a href=#concept-script-base-url id=creating-scripts:concept-script-base-url-3>base
     URL</a> and <var>requested</var>.<li>
      <p>If <var>url</var> is failure, then:</p>

      <ol><li><p>Let <var>error</var> be a new <code id=creating-scripts:typeerror><a data-x-internal=typeerror href=https://tc39.github.io/ecma262/#sec-native-error-types-used-in-this-standard-typeerror>TypeError</a></code> exception.<li><p>Set <var>script</var>'s <a href=#concept-script-parse-error id=creating-scripts:concept-script-parse-error-5>parse error</a>
       to <var>error</var>.<li><p>Return <var>script</var>.</ol>
     </ol>

    <p class=note>This step is essentially validating all of the requested module specifiers. We
    treat a module with unresolvable module specifiers the same as one that cannot be parsed; in
    both cases, a syntactic issue makes it impossible to ever contemplate instantiating the module
    later.</p>
   <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>.<li><p>Return <var>script</var>.</ol>

  <h5 id=calling-scripts><span class=secno>8.1.3.4</span> Calling scripts<a href=#calling-scripts class=self-link></a></h5>

  <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 <var>rethrow errors</var> boolean:</p>

  <ol><li><p>If <var>rethrow errors</var> is not given, let it be false.<li><p>Let <var>settings</var> be the <a href=#settings-object id=calling-scripts:settings-object>settings object</a> of <var>script</var>.<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.github.io/ecma262/#sec-normalcompletion data-x-internal=normalcompletion>NormalCompletion</a>(empty).<li><p><a href=#prepare-to-run-script id=calling-scripts:prepare-to-run-script>Prepare to run script</a> given <var>settings</var>.<li><p>Let <var>evaluationStatus</var> be null.<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 Completion { [[Type]]: throw,
   [[Value]]: <var>script</var>'s <a href=#concept-script-error-to-rethrow id=calling-scripts:concept-script-error-to-rethrow-2>error to
   rethrow</a>, [[Target]]: empty }.<li>
    <p>Otherwise, set <var>evaluationStatus</var> to <a href=https://tc39.github.io/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.github.io/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>
    <p>If <var>evaluationStatus</var> is an <a id=calling-scripts:abrupt-completion href=https://tc39.github.io/ecma262/#sec-completion-record-specification-type data-x-internal=abrupt-completion>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>.<li><p>Rethrow <var>evaluationStatus</var>.[[Value]].</ol>

     <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>.<li><p>Throw a <a id=calling-scripts:networkerror href=https://heycam.github.io/webidl/#networkerror data-x-internal=networkerror>"<code>NetworkError</code>"</a> <code id=calling-scripts:domexception><a data-x-internal=domexception href=https://heycam.github.io/webidl/#dfn-DOMException>DOMException</a></code>.</ol>
     <li>
      <p>Otherwise, <var>rethrow errors</var> is false. Perform the following steps:</p>

      <ol><li><p><a href=#report-the-exception id=calling-scripts:report-the-exception>Report the exception</a> given by <var>evaluationStatus</var>.[[Value]] for
       <var>script</var>.<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>.<li><p>Return <var>evaluationStatus</var>.</ol>
     </ol>
   <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>.<li><p>If <var>evaluationStatus</var> is a normal completion, then return
   <var>evaluationStatus</var>.<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 Completion { [[Type]]: throw, [[Value]]: a new
   <a id=calling-scripts:quotaexceedederror href=https://heycam.github.io/webidl/#quotaexceedederror data-x-internal=quotaexceedederror>"<code>QuotaExceededError</code>"</a> <code id=calling-scripts:domexception-2><a data-x-internal=domexception href=https://heycam.github.io/webidl/#dfn-DOMException>DOMException</a></code>, [[Target]]: empty }.
   </ol>

  <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>, with an optional <var>rethrow errors</var> boolean:</p>

  <ol><li><p>If <var>rethrow errors</var> is not given, let it be false.<li><p>Let <var>settings</var> be the <a href=#settings-object id=calling-scripts:settings-object-2>settings object</a> of <var>script</var>.<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:normalcompletion-2 href=https://tc39.github.io/ecma262/#sec-normalcompletion data-x-internal=normalcompletion>NormalCompletion</a>(empty).<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>.<li><p>Let <var>evaluationStatus</var> be null.<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>evaluationStatus</var> to Completion { [[Type]]: throw,
   [[Value]]: <var>script</var>'s <a href=#concept-script-error-to-rethrow id=calling-scripts:concept-script-error-to-rethrow-4>error to
   rethrow</a>, [[Target]]: empty }.<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>
      <p>Set <var>evaluationStatus</var> to <var>record</var>.<a href=https://tc39.github.io/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.github.io/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>evaluationStatus</var> to Completion { [[Type]]: throw, [[Value]]: a new
      <a id=calling-scripts:quotaexceedederror-2 href=https://heycam.github.io/webidl/#quotaexceedederror data-x-internal=quotaexceedederror>"<code>QuotaExceededError</code>"</a> <code id=calling-scripts:domexception-3><a data-x-internal=domexception href=https://heycam.github.io/webidl/#dfn-DOMException>DOMException</a></code>, [[Target]]: empty
      }.</p>
      </ol>
   <li>
    <p>If <var>evaluationStatus</var> is an <a id=calling-scripts:abrupt-completion-2 href=https://tc39.github.io/ecma262/#sec-completion-record-specification-type data-x-internal=abrupt-completion>abrupt completion</a>, then:</p>

    <ol><li><p>If <var>rethrow errors</var> is true, rethrow the exception given by
     <var>evaluationStatus</var>.[[Value]].<li><p>Otherwise, <a href=#report-the-exception id=calling-scripts:report-the-exception-2>report the exception</a> given by
     <var>evaluationStatus</var>.[[Value]] for <var>script</var>.</ol>
   <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>.<li><p>Return <var>evaluationStatus</var>.</ol>

  <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>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><p>If <a href=#concept-bc-noscript id=calling-scripts:concept-bc-noscript>scripting is disabled</a> for the
   <a href=#responsible-browsing-context id=calling-scripts:responsible-browsing-context>responsible browsing context</a> specified by <var>settings</var>, then return "do
   not run".</p>

   <li><p>Return "run".</ol>

  <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.github.io/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.github.io/ecma262/#running-execution-context data-x-internal=running-javascript-execution-context>running JavaScript execution
   context</a>.</ol>

  <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>Assert: <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.github.io/ecma262/#running-execution-context data-x-internal=running-javascript-execution-context>running
   JavaScript execution context</a>.<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.github.io/ecma262/#execution-context-stack data-x-internal=javascript-execution-context-stack>JavaScript execution context stack</a>.<li><p>If the <a id=calling-scripts:javascript-execution-context-stack-3 href=https://tc39.github.io/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.)</ol>

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

  <p>The <dfn id=running-script>running script</dfn> is the <a href=#the-script-element id=calling-scripts:the-script-element>script</a> in the [[HostDefined]] field in the
  ScriptOrModule component of the <a id=calling-scripts:running-javascript-execution-context-3 href=https://tc39.github.io/ecma262/#running-execution-context data-x-internal=running-javascript-execution-context>running JavaScript execution context</a>.</p>

  <h5 id=realms-settings-objects-global-objects><span class=secno>8.1.3.5</span> Realms, settings objects, and global objects<a href=#realms-settings-objects-global-objects class=self-link></a></h5>

  <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:javascript-realm href=https://tc39.github.io/ecma262/#sec-code-realms data-x-internal=javascript-realm>JavaScript realm</a>.</p>

  <p class=note>In this specification, all <a href=https://tc39.github.io/ecma262/#sec-code-realms id=realms-settings-objects-global-objects:javascript-realm-2 data-x-internal=javascript-realm>JavaScript
  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> or
  <code id=realms-settings-objects-global-objects:workerglobalscope><a href=#workerglobalscope>WorkerGlobalScope</a></code> objects.</p>

  <p>There is always a 1-to-1-to-1 mapping between <a href=https://tc39.github.io/ecma262/#sec-code-realms id=realms-settings-objects-global-objects:javascript-realm-3 data-x-internal=javascript-realm>JavaScript
  realms</a>, <a href=#global-object id=realms-settings-objects-global-objects:global-object-2>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><p>A <a id=realms-settings-objects-global-objects:javascript-realm-4 href=https://tc39.github.io/ecma262/#sec-code-realms data-x-internal=javascript-realm>JavaScript 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>.<li><p>A <a id=realms-settings-objects-global-objects:javascript-realm-5 href=https://tc39.github.io/ecma262/#sec-code-realms data-x-internal=javascript-realm>JavaScript 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>.<li><p>Each <a href=#global-object id=realms-settings-objects-global-objects:global-object-3>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:javascript-realm-6 href=https://tc39.github.io/ecma262/#sec-code-realms data-x-internal=javascript-realm>JavaScript
   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>.<li id=relevant-settings-object-for-a-global-object><p>Each <a href=#global-object id=realms-settings-objects-global-objects:global-object-4>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><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>.<li><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>.</ul>

  <p>To <dfn id=creating-a-new-javascript-realm>create a new JavaScript realm</dfn>,
  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.github.io/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.<li>
    <p>Let <var>realm execution context</var> be the <a id=realms-settings-objects-global-objects:running-javascript-execution-context href=https://tc39.github.io/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.github.io/ecma262/#sec-execution-contexts data-x-internal=javascript-execution-context>JavaScript execution context</a> created in the previous
    step.</p>
   <li><p>Remove <var>realm execution context</var> from the <a id=realms-settings-objects-global-objects:javascript-execution-context-stack href=https://tc39.github.io/ecma262/#execution-context-stack data-x-internal=javascript-execution-context-stack>JavaScript execution context
   stack</a>.<li><p>Return <var>realm execution context</var>.</ol>

  <hr>

  <p>When defining algorithm steps throughout this specification, it is often important to indicate
  what <a id=realms-settings-objects-global-objects:javascript-realm-7 href=https://tc39.github.io/ecma262/#sec-code-realms data-x-internal=javascript-realm>JavaScript realm</a> is to be used—or, equivalently, what <a href=#global-object id=realms-settings-objects-global-objects:global-object-5>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><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.<dt><dfn id=concept-incumbent-everything>Incumbent</dfn><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.<dt><dfn id=concept-current-everything>Current</dfn><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 href=https://tc39.github.io/ecma262/#current-realm id=realms-settings-objects-global-objects:current-realm-record data-x-internal=current-realm-record>current JavaScript realm</a>.)<dt><dfn id=concept-relevant-everything>Relevant</dfn><dd>Every <a id=realms-settings-objects-global-objects:platform-object href=https://heycam.github.io/webidl/#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:javascript-realm-8 href=https://tc39.github.io/ecma262/#sec-code-realms data-x-internal=javascript-realm>JavaScript 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://heycam.github.io/webidl/#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.</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://heycam.github.io/webidl/#dfn-platform-object data-x-internal=platform-object>platform object</a>.</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>&quot;en&quot;</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>&quot;b.html&quot;</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>&quot;frames[0].hello()&quot;</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>&quot;en&quot;</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>&quot;c.html&quot;</c-> <c- e>id</c-><c- o>=</c-><c- s>&quot;c&quot;</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>&quot;d.html&quot;</c-> <c- e>id</c-><c- o>=</c-><c- s>&quot;d&quot;</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- kr>const</c-> c <c- o>=</c-> document<c- p>.</c->querySelector<c- p>(</c-><c- u>&quot;#c&quot;</c-><c- p>).</c->contentWindow<c- p>;</c->
  <c- kr>const</c-> d <c- o>=</c-> document<c- p>.</c->querySelector<c- p>(</c-><c- u>&quot;#d&quot;</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:javascript-realm-9 href=https://tc39.github.io/ecma262/#sec-code-realms data-x-internal=javascript-realm>JavaScript
   realm</a>, <a href=#global-object id=realms-settings-objects-global-objects:global-object-6>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>.<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>.<li><p>The <a href=https://tc39.github.io/ecma262/#current-realm id=realms-settings-objects-global-objects:current-realm-record-2 data-x-internal=current-realm-record>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).<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>.</ul>
  </div>

  <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:javascript-realm-10 href=https://tc39.github.io/ecma262/#sec-code-realms data-x-internal=javascript-realm>JavaScript 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>

  <p>Note that in constructors, where there is no <b>this</b> value yet, the <a href=#concept-current-everything id=realms-settings-objects-global-objects:concept-current-everything-3>current</a> concept is the appropriate default.</p>

  <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-4>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>

   <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>&quot;en&quot;</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- kr>const</c-> promise <c- o>=</c-> navigator<c- p>.</c->getBattery<c- p>.</c->call<c- p>(</c->frames<c- p>[</c-><c- mi>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- mi>0</c-><c- p>].</c->Promise<c- p>);</c-> <c- c1>// logs true</c->

    frames<c- p>[</c-><c- mi>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>&quot;inner.html&quot;</c-> <c- e>onload</c-><c- o>=</c-><c- s>&quot;doTest()&quot;</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>&quot;en&quot;</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- kr>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 href=https://tc39.github.io/ecma262/#current-realm id=realms-settings-objects-global-objects:current-realm-record-3 data-x-internal=current-realm-record>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:javascript-realm-11 href=https://tc39.github.io/ecma262/#sec-code-realms data-x-internal=javascript-realm>JavaScript 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-5>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.5.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.github.io/ecma262/#execution-context-stack data-x-internal=javascript-execution-context-stack>JavaScript
  execution context stack</a>, interspersed with other <a href=https://tc39.github.io/ecma262/#sec-execution-contexts id=entry:javascript-execution-context data-x-internal=javascript-execution-context>execution contexts</a>.</p>

  <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.github.io/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>

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

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

  <h6 id=incumbent><span class=secno>8.1.3.5.2</span> Incumbent<a href=#incumbent class=self-link></a></h6>

  <p>All <a href=https://tc39.github.io/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://heycam.github.io/webidl/#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=#enqueuejob(queuename,-job,-arguments) id=incumbent:enqueuejob(queuename,-job,-arguments)>EnqueueJob</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>

  <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>.<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>.<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>.</ol>

  <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><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>.<li><p>Assert: 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>.<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>.</ol>

  <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.github.io/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.github.io/ecma262/#execution-context-stack data-x-internal=javascript-execution-context-stack>JavaScript execution context stack</a>.</p>

  <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>.<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>Assert: 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://heycam.github.io/webidl/#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><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>.</ol>
   <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>.</ol>

  <p>Then, the <dfn id=concept-incumbent-realm>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>

  <p>Similarly, the <dfn id=concept-incumbent-global>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>

  <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 class=example>
   <p>Consider the following very simple 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- k>new</c-> frames<c- p>[</c-><c- mi>0</c-><c- p>].</c->MessageChannel<c- p>();</c->
<c- p>&lt;/</c-><c- f>script</c-><c- p>&gt;</c-></code></pre>

   <p>When the <code id=incumbent:dom-messagechannel><a href=#dom-messagechannel>MessageChannel()</a></code> constructor looks up the
   <a href=#incumbent-settings-object id=incumbent:incumbent-settings-object-7>incumbent settings object</a> to use as the <a href=#concept-port-owner id=incumbent:concept-port-owner>owner</a> of the new <code id=incumbent:messageport><a href=#messageport>MessagePort</a></code> objects, 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.github.io/ecma262/#execution-context-stack data-x-internal=javascript-execution-context-stack>JavaScript execution context
   stack</a> as part of <a href=https://tc39.github.io/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-8>incumbent settings object</a>; the result is the <a href=#environment-settings-object id=incumbent:environment-settings-object-3>environment
   settings object</a> of <code>window</code>.</p>

   <p>(In this example, the <a href=#environment-settings-object id=incumbent:environment-settings-object-4>environment settings object</a> of <code>frames[0]</code> is not involved at all. It is the <a href=#current-settings-object id=incumbent:current-settings-object>current settings
   object</a>, but the <code id=incumbent:dom-messagechannel-2><a href=#dom-messagechannel>MessageChannel()</a></code> constructor
   cares only about the incumbent, not current.)</p>
  </div>

  <div class=example>
   <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- kr>const</c-> bound <c- o>=</c-> frames<c- p>[</c-><c- mi>0</c-><c- p>].</c->postMessage<c- p>.</c->bind<c- p>(</c->frames<c- p>[</c-><c- mi>0</c-><c- p>],</c-> <c- u>&quot;some data&quot;</c-><c- p>,</c-> <c- u>&quot;*&quot;</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>There are two interesting <a href=#environment-settings-object id=incumbent:environment-settings-object-5>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-9>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>. Another way of capturing the
   intuition here is that invoking algorithms asynchronously (in this case via <code id=incumbent:dom-settimeout><a href=#dom-settimeout>setTimeout()</a></code>) should not change the <a href=#concept-incumbent-everything id=incumbent:concept-incumbent-everything-2>incumbent</a> concept.</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 <code>bound</code> is <a href=https://heycam.github.io/webidl/#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-10>incumbent settings object</a> is that corresponding to <code>window</code> (in the same manner as in our simple example above). Web IDL stores this
   as the resulting callback value's <a id=incumbent:callback-context href=https://heycam.github.io/webidl/#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://heycam.github.io/webidl/#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://heycam.github.io/webidl/#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-2><a href=#dom-window-postmessage>postMessage()</a></code> method of <code>frames[0]</code>. When the <code id=incumbent:dom-window-postmessage-3><a href=#dom-window-postmessage>postMessage()</a></code>
   algorithm looks up the <a href=#incumbent-settings-object id=incumbent:incumbent-settings-object-11>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.github.io/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-4><a href=#dom-window-postmessage>postMessage()</a></code>, with no <a href=https://tc39.github.io/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-2>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-12>incumbent settings
   object</a> while executing the <code id=incumbent:dom-window-postmessage-5><a href=#dom-window-postmessage>postMessage()</a></code>
   algorithm.</p>
  </div>

  <div class=example>
   <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- kr>const</c-> bound <c- o>=</c-> frames<c- p>[</c-><c- mi>0</c-><c- p>].</c->location<c- p>.</c->assign<c- p>.</c->bind<c- p>(</c->frames<c- p>[</c-><c- mi>0</c-><c- p>].</c->location<c- p>,</c-> <c- u>&quot;https://example.com/&quot;</c-><c- p>);</c->
document<c- p>.</c->querySelector<c- p>(</c-><c- u>&quot;button&quot;</c-><c- p>).</c->addEventListener<c- p>(</c-><c- u>&quot;click&quot;</c-><c- p>,</c-> bound<c- p>);</c->
<c- p>&lt;/</c-><c- f>script</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>iframe</c-> <c- e>src</c-><c- o>=</c-><c- s>&quot;a.html&quot;</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- kr>const</c-> iframe <c- o>=</c-> document<c- p>.</c->querySelector<c- p>(</c-><c- u>&quot;iframe&quot;</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>&quot;button&quot;</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-13>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://heycam.github.io/webidl/#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-14>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://heycam.github.io/webidl/#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://heycam.github.io/webidl/#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-15>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 <a href=#source-browsing-context id=incumbent:source-browsing-context>source browsing context</a>, 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.5.3</span> Current<a href=#current class=self-link></a></h6>

  <p>The JavaScript specification defines the <a id=current:current-realm-record href=https://tc39.github.io/ecma262/#current-realm data-x-internal=current-realm-record>current Realm Record</a>, sometimes
  abbreviated to the "current Realm". <a href=#refsJAVASCRIPT>[JAVASCRIPT]</a></p>

  <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-record-2 href=https://tc39.github.io/ecma262/#current-realm data-x-internal=current-realm-record>current
  Realm Record</a>.</p>

  <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-record-3 href=https://tc39.github.io/ecma262/#current-realm data-x-internal=current-realm-record>current Realm Record</a>.</p>

  <h6 id=relevant><span class=secno>8.1.3.5.4</span> Relevant<a href=#relevant class=self-link></a></h6>

  <p>The <dfn id=relevant-settings-object data-export="">relevant settings object</dfn> for a <a id=relevant:platform-object href=https://heycam.github.io/webidl/#dfn-platform-object data-x-internal=platform-object>platform object</a> is
  defined as follows:</p>

  <dl class=switch><dt>If the object is a <a href=#global-object id=relevant:global-object>global object</a><dd>Each <a href=#global-object id=relevant:global-object-2>global object</a> in this specification is created alongside a corresponding
   <a href=#environment-settings-object id=relevant:environment-settings-object>environment settings object</a>; that is its <a href=#relevant-settings-object id=relevant:relevant-settings-object>relevant settings object</a>.<dt>Otherwise<dd>
    <p>The <a href=#relevant-settings-object id=relevant:relevant-settings-object-2>relevant settings object</a> for a non-global <a id=relevant:platform-object-2 href=https://heycam.github.io/webidl/#dfn-platform-object data-x-internal=platform-object>platform object</a>
    <var>o</var> is the <a href=#environment-settings-object id=relevant:environment-settings-object-2>environment settings object</a> whose <a href=#concept-settings-object-global id=relevant:concept-settings-object-global>global object</a> is the global object of the
    <a id=relevant:global-environment-associated-with href=https://heycam.github.io/webidl/#es-platform-objects data-x-internal=global-environment-associated-with>global environment associated with</a> <var>o</var>.</p>

    <p class=note>The "<a id=relevant:global-environment-associated-with-2 href=https://heycam.github.io/webidl/#es-platform-objects data-x-internal=global-environment-associated-with>global environment associated with</a>" concept is from the olden
    days, before the modern JavaScript specification and its concept of <a href=https://tc39.github.io/ecma262/#sec-code-realms id=relevant:javascript-realm data-x-internal=javascript-realm>realms</a>. We expect that as the Web IDL specification gets updated, every
    <a id=relevant:platform-object-3 href=https://heycam.github.io/webidl/#dfn-platform-object data-x-internal=platform-object>platform object</a> will have a <a href=https://tc39.github.io/ecma262/#sec-code-realms id=relevant:javascript-realm-2 data-x-internal=javascript-realm>Realm</a> associated
    with it, and this definition can be re-cast in those terms. <a href=#refsJAVASCRIPT>[JAVASCRIPT]</a> <a href=#refsWEBIDL>[WEBIDL]</a></p>
   </dl>

  <p>Then, the <dfn id=concept-relevant-realm data-export="">relevant Realm</dfn> for a
  <a id=relevant:platform-object-4 href=https://heycam.github.io/webidl/#dfn-platform-object data-x-internal=platform-object>platform object</a> is the <a href="#environment-settings-object's-realm" id="relevant:environment-settings-object's-realm">Realm</a> of its <a href=#relevant-settings-object id=relevant:relevant-settings-object-3>relevant settings object</a>.</p>

  <p>Similarly, the <dfn id=concept-relevant-global data-export="">relevant global object</dfn>
  for a <a id=relevant:platform-object-5 href=https://heycam.github.io/webidl/#dfn-platform-object data-x-internal=platform-object>platform object</a> is the <a href=#concept-settings-object-global id=relevant:concept-settings-object-global-2>global
  object</a> of its <a href=#relevant-settings-object id=relevant:relevant-settings-object-4>relevant settings object</a>.</p>


  <h5 id=killing-scripts><span class=secno>8.1.3.6</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>abort a running script</dfn>. This causes any <a href=https://tc39.github.io/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.github.io/ecma262/#sec-source-text-module-records data-x-internal=source-text-module-record>Source Text Module Record</a>
  <a href=https://tc39.github.io/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.github.io/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 <a id=killing-scripts:quotaexceedederror href=https://heycam.github.io/webidl/#quotaexceedederror data-x-internal=quotaexceedederror>"<code>QuotaExceededError</code>"</a> <code id=killing-scripts:domexception><a data-x-internal=domexception href=https://heycam.github.io/webidl/#dfn-DOMException>DOMException</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=integration-with-the-javascript-job-queue><span class=secno>8.1.3.7</span> Integration with the JavaScript job queue<a href=#integration-with-the-javascript-job-queue class=self-link></a></h5>

  <p>The JavaScript specification defines the JavaScript job and job queue abstractions in order to
  specify certain invariants about how promise operations execute with a clean <a id=integration-with-the-javascript-job-queue:javascript-execution-context-stack href=https://tc39.github.io/ecma262/#execution-context-stack data-x-internal=javascript-execution-context-stack>JavaScript
  execution context stack</a> and in a certain order. However, as of the time of this writing
  the definition of <a href=https://tc39.github.io/ecma262/#sec-enqueuejob id=integration-with-the-javascript-job-queue:js-enqueuejob data-x-internal=js-enqueuejob>EnqueueJob</a> in that specification is not
  sufficiently flexible to integrate with HTML as a host environment. <a href=#refsJAVASCRIPT>[JAVASCRIPT]</a></p>

  <p class=note>This is not strictly true. It is in fact possible, by taking liberal advantage of
  the many "implementation defined" sections of the algorithm, to contort it to our purposes.
  However, the end result is a mass of messy indirection and workarounds that essentially bypasses
  the job queue infrastructure entirely, albeit in a way that is technically sanctioned within the
  bounds of implementation-defined behavior. We do not take this path, and instead introduce the
  following <a href=#willful-violation id=integration-with-the-javascript-job-queue:willful-violation>willful violation</a>.</p>

  <p>As such, user agents must instead use the following definition in place of that in the
  JavaScript specification. These ensure that the promise jobs enqueued by the JavaScript
  specification are properly integrated into the user agent's <a href=#event-loop id=integration-with-the-javascript-job-queue:event-loop>event
  loops</a>.</p>

  <p>The <a id=integration-with-the-javascript-job-queue:runjobs href=https://tc39.github.io/ecma262/#sec-runjobs data-x-internal=runjobs>RunJobs</a> abstract operation from the JavaScript specification must
  not be used by user agents.</p>

  <h6 id=enqueuejob(queuename,-job,-arguments)><span class=secno>8.1.3.7.1</span> <dfn>EnqueueJob</dfn>(<var>queueName</var>, <var>job</var>, <var>arguments</var>)<a href=#enqueuejob(queuename,-job,-arguments) class=self-link></a></h6>

  <p>When the JavaScript specification says to call the EnqueueJob abstract operation, the
  following algorithm must be used in place of JavaScript's <a href=https://tc39.github.io/ecma262/#sec-enqueuejob id=enqueuejob(queuename,-job,-arguments):js-enqueuejob data-x-internal=js-enqueuejob>EnqueueJob</a>:</p>

  <ol><li><p>Assert: <var>queueName</var> is <code>"PromiseJobs"</code>. (<code>"ScriptJobs"</code> must not be used by user agents.)<li>
    <p>Let <var>job settings</var> be some appropriate <a href=#environment-settings-object id=enqueuejob(queuename,-job,-arguments):environment-settings-object>environment settings object</a>.</p>

    <p class=warning>It is not yet clear how to specify the <a href=#environment-settings-object id=enqueuejob(queuename,-job,-arguments):environment-settings-object-2>environment settings
    object</a> that should be used here. In practice, this means that the <a href=#concept-entry-everything id=enqueuejob(queuename,-job,-arguments):concept-entry-everything>entry</a> concept is not correctly specified while
    executing a job. See <a href=https://github.com/whatwg/html/pull/1189#issuecomment-224950188>discussion in issue
    #1189</a>.</p>
   <li><p>Let <var>incumbent settings</var> be the <a href=#incumbent-settings-object id=enqueuejob(queuename,-job,-arguments):incumbent-settings-object>incumbent settings object</a>.<li><p>Let <var>active script</var> be the <a href=#active-script id=enqueuejob(queuename,-job,-arguments):active-script>active script</a>.<li><p>Assert: <var>active script</var> is not null, as jobs are only enqueued by the JavaScript
   specification while a script is active.<li><p>Let <var>script execution context</var> be a new <a id=enqueuejob(queuename,-job,-arguments):javascript-execution-context href=https://tc39.github.io/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=enqueuejob(queuename,-job,-arguments):settings-object>settings object</a>'s <a href="#environment-settings-object's-realm" id="enqueuejob(queuename,-job,-arguments):environment-settings-object's-realm">Realm</a>, and its ScriptOrModule set to <var>active script</var>'s <a href=#concept-script-record id=enqueuejob(queuename,-job,-arguments):concept-script-record>record</a>.<li>
    <p><a href=#queue-a-microtask id=enqueuejob(queuename,-job,-arguments):queue-a-microtask>Queue a microtask</a>, on <var>job settings</var>'s <a href=#responsible-event-loop id=enqueuejob(queuename,-job,-arguments):responsible-event-loop>responsible event
    loop</a>, to perform the following steps:</p>

    <ol><li><p><a href=#check-if-we-can-run-script id=enqueuejob(queuename,-job,-arguments):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.<li>
      <p><a href=#prepare-to-run-script id=enqueuejob(queuename,-job,-arguments):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=enqueuejob(queuename,-job,-arguments):concept-entry-everything-2>entry</a> concept
      while the job runs.</p>
     <li>
      <p><a href=#prepare-to-run-a-callback id=enqueuejob(queuename,-job,-arguments):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=enqueuejob(queuename,-job,-arguments):concept-incumbent-everything>incumbent</a>
      concept while the job runs.</p>
     <li>
      <p><a href=https://infra.spec.whatwg.org/#stack-push id=enqueuejob(queuename,-job,-arguments):stack-push data-x-internal=stack-push>Push</a> <var>script execution context</var> onto the
      <a id=enqueuejob(queuename,-job,-arguments):javascript-execution-context-stack href=https://tc39.github.io/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=enqueuejob(queuename,-job,-arguments):active-script-2>active script</a> while the job runs, in cases like
      <code>Promise.resolve("...").then(eval)</code> where there would otherwise be no
      active script since <code id=enqueuejob(queuename,-job,-arguments):eval()><a data-x-internal=eval() href=https://tc39.github.io/ecma262/#sec-eval-x>eval()</a></code> is a built-in function that does not originate from
      any particular <a href=#concept-script id=enqueuejob(queuename,-job,-arguments):concept-script>script</a>.</p>
     <li><p>Let <var>result</var> be the result of performing the abstract operation specified by
     <var>job</var>, using the elements of <var>arguments</var> as its arguments.<li><p><a href=https://infra.spec.whatwg.org/#stack-pop id=enqueuejob(queuename,-job,-arguments):stack-pop data-x-internal=stack-pop>Pop</a> <var>script execution context</var> from the
     <a id=enqueuejob(queuename,-job,-arguments):javascript-execution-context-stack-2 href=https://tc39.github.io/ecma262/#execution-context-stack data-x-internal=javascript-execution-context-stack>JavaScript execution context stack</a>.<li><p><a href=#clean-up-after-running-a-callback id=enqueuejob(queuename,-job,-arguments):clean-up-after-running-a-callback>Clean up after running a callback</a> with <var>incumbent
     settings</var>.<li><p><a href=#clean-up-after-running-script id=enqueuejob(queuename,-job,-arguments):clean-up-after-running-script>Clean up after running script</a> with <var>job settings</var>.<li><p>If <var>result</var> is an <a id=enqueuejob(queuename,-job,-arguments):abrupt-completion href=https://tc39.github.io/ecma262/#sec-completion-record-specification-type data-x-internal=abrupt-completion>abrupt completion</a>, then <a href=#report-the-exception id=enqueuejob(queuename,-job,-arguments):report-the-exception>report the
     exception</a> given by <var>result</var>.[[Value]].</ol>
   </ol>

  <h5 id=integration-with-the-javascript-module-system><span class=secno>8.1.3.8</span> Integration with the JavaScript module system<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>

  <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> of <a href=https://url.spec.whatwg.org/#concept-url id=integration-with-the-javascript-module-system:url-record data-x-internal=url-record>URL records</a> to values that are either a <a href=#module-script id=integration-with-the-javascript-module-system:module-script-2>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>Module maps</a> are used to ensure that imported JavaScript modules 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-2>module maps</a> are keyed by URL, the following code will
   create three separate entries in the <a href=#module-map id=integration-with-the-javascript-module-system:module-map-3>module map</a>, since it results in three different
   URLs:</p>

   <pre><code class='js'><c- kr>import</c-> <c- u>&quot;https://example.com/module.mjs&quot;</c-><c- p>;</c->
<c- kr>import</c-> <c- u>&quot;https://example.com/module.mjs#map-buster&quot;</c-><c- p>;</c->
<c- kr>import</c-> <c- u>&quot;https://example.com/module.mjs?debug=true&quot;</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-4>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-5>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-2 data-x-internal=url-record>URL records</a> are equal:</p>

   <pre><code class='js'><c- kr>import</c-> <c- u>&quot;https://example.com/module2.mjs&quot;</c-><c- p>;</c->
<c- kr>import</c-> <c- u>&quot;https:example.com/module2.mjs&quot;</c-><c- p>;</c->
<c- kr>import</c-> <c- u>&quot;https://///example.com\\module2.mjs&quot;</c-><c- p>;</c->
<c- kr>import</c-> <c- u>&quot;https://example.com/foo/../module2.mjs&quot;</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>

  <p>To <dfn id=resolve-a-module-specifier>resolve a module specifier</dfn> given a <a id=integration-with-the-javascript-module-system:url href=https://url.spec.whatwg.org/#concept-url data-x-internal=url>URL</a> <var>base URL</var> and a
  <a id=integration-with-the-javascript-module-system:javascript-string href=https://infra.spec.whatwg.org/#javascript-string data-x-internal=javascript-string>JavaScript string</a> <var>specifier</var>, perform the following steps. It will return
  either a <a id=integration-with-the-javascript-module-system:url-record-3 href=https://url.spec.whatwg.org/#concept-url data-x-internal=url-record>URL record</a> or failure.</p>

  <ol><li><p>Apply the <a id=integration-with-the-javascript-module-system:url-parser-2 href=https://url.spec.whatwg.org/#concept-url-parser data-x-internal=url-parser>URL parser</a> to <var>specifier</var>. If the result is not failure,
   return the result.<li>
    <p>If <var>specifier</var> does not start with the character U+002F SOLIDUS (<code>/</code>), the two-character sequence U+002E FULL STOP, U+002F SOLIDUS (<code>./</code>), or the three-character sequence U+002E FULL STOP, U+002E FULL STOP,
    U+002F SOLIDUS (<code>../</code>), return failure.</p>

    <p class=note>This restriction is in place so that in the future we can allow custom module
    loaders to give special meaning to "bare" import specifiers, like <code>import "jquery"</code> or <code>import "web/crypto"</code>. For now any
    such imports will fail, instead of being treated as relative URLs.</p>
   <li><p>Return the result of applying the <a id=integration-with-the-javascript-module-system:url-parser-3 href=https://url.spec.whatwg.org/#concept-url-parser data-x-internal=url-parser>URL parser</a> to <var>specifier</var> with
   <var>base URL</var> as the base URL.</ol>

  <div id=module-specifier-examples class=example>
   <p>The following are valid module specifiers according to the above algorithm:</p>

   <ul class=brief><li><code>https://example.com/apples.mjs</code><li><code>http:example.com\pears.js</code> (becomes <code>http://example.com/pears.js</code> as step 1 parses with no base URL)<li><code>//example.com/bananas</code><li><code>./strawberries.mjs.cgi</code><li><code>../lychees</code><li><code>/limes.jsx</code><li><code>data:text/javascript,export default 'grapes';</code><li><code>blob:https://whatwg.org/d0360e2f-caee-469f-9a2f-87d5b0456f6f</code></ul>

   <p>The following are valid module specifiers according to the above algorithm, but will
   invariably cause failures when they are <a href=#fetch-a-single-module-script id=integration-with-the-javascript-module-system:fetch-a-single-module-script>fetched</a>:</p>

   <ul class=brief><li><code>javascript:export default 'artichokes';</code><li><code>data:text/plain,export default 'kale';</code><li><code>about:legumes</code><li><code>wss://example.com/celery</code></ul>

   <p>The following are not valid module specifiers according to the above algorithm:</p>

   <ul class=brief><li><code>https://eggplant:b/c</code><li><code>pumpkins.js</code><li><code>.tomato</code><li><code>..zucchini.mjs</code><li><code>.\yam.es</code></ul>
  </div>

  <h6 id=hostresolveimportedmodule(referencingscriptormodule,-specifier)><span class=secno>8.1.3.8.1</span> <dfn>HostResolveImportedModule</dfn>(<var>referencingScriptOrModule</var>,
  <var>specifier</var>)<a href=#hostresolveimportedmodule(referencingscriptormodule,-specifier) class=self-link></a></h6>

  <p>JavaScript contains an implementation-defined <a href=https://tc39.github.io/ecma262/#sec-hostresolveimportedmodule id=hostresolveimportedmodule(referencingscriptormodule,-specifier):js-hostresolveimportedmodule data-x-internal=js-hostresolveimportedmodule>HostResolveImportedModule</a> abstract operation, very
  slightly updated by the <cite>import()</cite> proposal. User agents must use the following
  implementation: <a href=#refsJAVASCRIPT>[JAVASCRIPT]</a> <a href=#refsJSIMPORT>[JSIMPORT]</a></p>

  <ol><li><p>Let <var>referencing script</var> be
   <var>referencingScriptOrModule</var>.[[HostDefined]].<li><p>Let <var>moduleMap</var> be <var>referencing script</var>'s <a href=#settings-object id=hostresolveimportedmodule(referencingscriptormodule,-specifier):settings-object>settings object</a>'s
   <a href=#concept-settings-object-module-map id=hostresolveimportedmodule(referencingscriptormodule,-specifier):concept-settings-object-module-map>module map</a>.<li><p>Let <var>url</var> be the result of <a href=#resolve-a-module-specifier id=hostresolveimportedmodule(referencingscriptormodule,-specifier):resolve-a-module-specifier>resolving a
   module specifier</a> given <var>referencing script</var>'s <a href=#concept-script-base-url id=hostresolveimportedmodule(referencingscriptormodule,-specifier):concept-script-base-url>base URL</a> and <var>specifier</var>.<li><p>Assert: <var>url</var> is never failure, because <a href=#resolve-a-module-specifier id=hostresolveimportedmodule(referencingscriptormodule,-specifier):resolve-a-module-specifier-2>resolving a module specifier</a> must have been <a href=#validate-requested-module-specifiers>previously successful</a> with these
   same two arguments.<li><p>Let <var>resolved module script</var> be <var>moduleMap</var>[<var>url</var>]. (This entry
   must <a href=https://infra.spec.whatwg.org/#map-exists id=hostresolveimportedmodule(referencingscriptormodule,-specifier):map-exists data-x-internal=map-exists>exist</a> for us to have gotten to this point.)<li><p>Assert: <var>resolved module script</var> is a <a href=#module-script id=hostresolveimportedmodule(referencingscriptormodule,-specifier):module-script>module script</a> (i.e., is not
   null or "<code>fetching</code>").<li><p>Assert: <var>resolved module script</var>'s <a href=#concept-script-record id=hostresolveimportedmodule(referencingscriptormodule,-specifier):concept-script-record>record</a> is not null.</p>

   <li><p>Return <var>resolved module script</var>'s <a href=#concept-script-record id=hostresolveimportedmodule(referencingscriptormodule,-specifier):concept-script-record-2>record</a>.</ol>

  <h6 id=hostimportmoduledynamically(referencingscriptormodule,-specifier,-promisecapability)><span class=secno>8.1.3.8.2</span> <dfn>HostImportModuleDynamically</dfn>(<var>referencingScriptOrModule</var>,
  <var>specifier</var>, <var>promiseCapability</var>)<a href=#hostimportmoduledynamically(referencingscriptormodule,-specifier,-promisecapability) class=self-link></a></h6>

  <p>The <cite>import()</cite> proposal contains an implementation-defined <a href=https://tc39.github.io/proposal-dynamic-import/#sec-hostimportmoduledynamically id=hostimportmoduledynamically(referencingscriptormodule,-specifier,-promisecapability):js-hostimportmoduledynamically data-x-internal=js-hostimportmoduledynamically>HostImportModuleDynamically</a> abstract operation.
  User agents must use the following implementation: <a href=#refsJSIMPORT>[JSIMPORT]</a></p>

  <ol><li><p>Let <var>referencing script</var> be
   <var>referencingScriptOrModule</var>.[[HostDefined]].<li>
    <p>Run the following steps <a href=#in-parallel id=hostimportmoduledynamically(referencingscriptormodule,-specifier,-promisecapability):in-parallel>in parallel</a>:</p>

    <ol><li><p>Let <var>url</var> be the result of <a href=#resolve-a-module-specifier id=hostimportmoduledynamically(referencingscriptormodule,-specifier,-promisecapability):resolve-a-module-specifier>resolving a
     module specifier</a> given <var>referencing script</var>'s <a href=#concept-script-base-url id=hostimportmoduledynamically(referencingscriptormodule,-specifier,-promisecapability):concept-script-base-url>base URL</a> and <var>specifier</var>.<li>
      <p>If <var>url</var> is failure, then:</p>

      <ol><li><p>Let <var>completion</var> be Completion { [[Type]]: throw, [[Value]]: a new
       <code id=hostimportmoduledynamically(referencingscriptormodule,-specifier,-promisecapability):typeerror><a data-x-internal=typeerror href=https://tc39.github.io/ecma262/#sec-native-error-types-used-in-this-standard-typeerror>TypeError</a></code>, [[Target]]: empty }.<li><p>Perform <a id=hostimportmoduledynamically(referencingscriptormodule,-specifier,-promisecapability):finishdynamicimport href=https://tc39.github.io/proposal-dynamic-import/#sec-finishdynamicimport data-x-internal=finishdynamicimport>FinishDynamicImport</a>(<var>referencingScriptOrModule</var>,
       <var>specifier</var>, <var>promiseCapability</var>, <var>completion</var>).<li><p>Return.</ol>
     <li><p>Let <var>options</var> be the <a href=#descendant-script-fetch-options id=hostimportmoduledynamically(referencingscriptormodule,-specifier,-promisecapability):descendant-script-fetch-options>descendant script fetch options</a> for
     <var>referencing script</var>'s <a href=#concept-script-script-fetch-options id=hostimportmoduledynamically(referencingscriptormodule,-specifier,-promisecapability):concept-script-script-fetch-options>fetch
     options</a>.<li><p><a href=#fetch-a-module-script-tree id=hostimportmoduledynamically(referencingscriptormodule,-specifier,-promisecapability):fetch-a-module-script-tree>Fetch a module script graph</a> given <var>url</var>, <var>referencing
     script</var>'s <a href=#settings-object id=hostimportmoduledynamically(referencingscriptormodule,-specifier,-promisecapability):settings-object>settings object</a>, "<code>script</code>", and
     <var>options</var>. Wait until the algorithm asynchronously completes with
     <var>result</var>.<li>
      <p>If <var>result</var> is null, then:</p>

      <ol><li><p>Let <var>completion</var> be Completion { [[Type]]: throw, [[Value]]: a new
       <code id=hostimportmoduledynamically(referencingscriptormodule,-specifier,-promisecapability):typeerror-2><a data-x-internal=typeerror href=https://tc39.github.io/ecma262/#sec-native-error-types-used-in-this-standard-typeerror>TypeError</a></code>, [[Target]]: empty }.<li><p>Perform <a id=hostimportmoduledynamically(referencingscriptormodule,-specifier,-promisecapability):finishdynamicimport-2 href=https://tc39.github.io/proposal-dynamic-import/#sec-finishdynamicimport data-x-internal=finishdynamicimport>FinishDynamicImport</a>(<var>referencingScriptOrModule</var>,
       <var>specifier</var>, <var>promiseCapability</var>, <var>completion</var>).<li><p>Return.</ol>
     <li><p><a href=#run-a-module-script id=hostimportmoduledynamically(referencingscriptormodule,-specifier,-promisecapability):run-a-module-script>Run the module script</a> <var>result</var>, with
     the rethrow errors boolean set to true.<li><p>If running the module script throws an exception, then perform
     <a id=hostimportmoduledynamically(referencingscriptormodule,-specifier,-promisecapability):finishdynamicimport-3 href=https://tc39.github.io/proposal-dynamic-import/#sec-finishdynamicimport data-x-internal=finishdynamicimport>FinishDynamicImport</a>(<var>referencingScriptOrModule</var>, <var>specifier</var>,
     <var>promiseCapability</var>, the thrown exception completion).<li><p>Otherwise, perform
     <a id=hostimportmoduledynamically(referencingscriptormodule,-specifier,-promisecapability):finishdynamicimport-4 href=https://tc39.github.io/proposal-dynamic-import/#sec-finishdynamicimport data-x-internal=finishdynamicimport>FinishDynamicImport</a>(<var>referencingScriptOrModule</var>, <var>specifier</var>,
     <var>promiseCapability</var>, <a id=hostimportmoduledynamically(referencingscriptormodule,-specifier,-promisecapability):normalcompletion href=https://tc39.github.io/ecma262/#sec-normalcompletion data-x-internal=normalcompletion>NormalCompletion</a>(undefined)).</ol>
   <li><p>Return undefined.</ol>

  <h6 id=hostgetimportmetaproperties><span class=secno>8.1.3.8.3</span> <dfn>HostGetImportMetaProperties</dfn>(<var>moduleRecord</var>)<a href=#hostgetimportmetaproperties class=self-link></a></h6>

  <p>The <cite>import.meta</cite> proposal contains an implementation-defined <a href=https://tc39.github.io/proposal-import-meta/#sec-hostgetimportmetaproperties id=hostgetimportmetaproperties:js-hostgetimportmetaproperties data-x-internal=js-hostgetimportmetaproperties>HostGetImportMetaProperties</a> abstract operation.
  User agents must use the following implementation: <a href=#refsJSIMPORTMETA>[JSIMPORTMETA]</a></p>

  <ol><li><p>Let <var>module script</var> be <var>moduleRecord</var>.[[HostDefined]].<li><p>Let <var>urlString</var> be <var>module script</var>'s <a href=#concept-script-base-url id=hostgetimportmetaproperties:concept-script-base-url>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>.<li><p>Return « Record { [[Key]]: "url", [[Value]]: <var>urlString</var> } ».</ol>

  <h5 id=integration-with-the-javascript-agent-formalism><span class=secno>8.1.3.9</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.github.io/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>

  <p class=XXX>JavaScript is expected to define <a href=https://tc39.github.io/ecma262/#sec-agents id=integration-with-the-javascript-agent-formalism:agent-2 data-x-internal=agent>agents</a> in more detail; in particular that they hold a set of <a href=#concept-global-object-realm id=integration-with-the-javascript-agent-formalism:concept-global-object-realm>realms</a>: <a href=https://github.com/tc39/ecma262/issues/882>tc39/ecma262 issue #882</a>.</p>

  <p class=note>Conceptually, the <a id=integration-with-the-javascript-agent-formalism:agent-3 href=https://tc39.github.io/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-2>realms</a> that can synchronously access each other, and
  thus need to run in a single execution thread.</p>

  <p>Until such a time that this standard has a better handle on lifetimes, it defines five types of
  <a href=https://tc39.github.io/ecma262/#sec-agents id=integration-with-the-javascript-agent-formalism:agent-4 data-x-internal=agent>agents</a> that user agents must allocate at the appropriate time.</p>

  <p class=note>In the future, this standard hopes to define exactly when <a href=https://tc39.github.io/ecma262/#sec-agents id=integration-with-the-javascript-agent-formalism:agent-5 data-x-internal=agent>agents</a> and <a href=https://tc39.github.io/ecma262/#sec-agent-clusters id=integration-with-the-javascript-agent-formalism:agent-cluster data-x-internal=agent-cluster>agent clusters</a> are
  created.</p>

  <dl><dt><dfn id=similar-origin-window-agent data-export="">Similar-origin window agent</dfn><dd>
    <p>An <a id=integration-with-the-javascript-agent-formalism:agent-6 href=https://tc39.github.io/ecma262/#sec-agents data-x-internal=agent>agent</a> whose [[CanBlock]] is false and whose set of <a href=https://tc39.github.io/ecma262/#sec-code-realms id=integration-with-the-javascript-agent-formalism:javascript-realm data-x-internal=javascript-realm>realms</a> consists of all <a href=#concept-global-object-realm id=integration-with-the-javascript-agent-formalism:concept-global-object-realm-3>realms</a> of <code id=integration-with-the-javascript-agent-formalism:window><a href=#window>Window</a></code> objects whose
    <a href=#relevant-settings-object id=integration-with-the-javascript-agent-formalism:relevant-settings-object>relevant settings object</a>'s <a href=#responsible-browsing-context id=integration-with-the-javascript-agent-formalism:responsible-browsing-context>responsible browsing context</a> is in the same
    <a href=#unit-of-related-similar-origin-browsing-contexts id=integration-with-the-javascript-agent-formalism:unit-of-related-similar-origin-browsing-contexts>unit of related similar-origin browsing contexts</a>.</p>

    <p class=note>Two <code id=integration-with-the-javascript-agent-formalism:window-2><a href=#window>Window</a></code> objects that are <a href=#same-origin id=integration-with-the-javascript-agent-formalism:same-origin>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=#unit-of-related-similar-origin-browsing-contexts id=integration-with-the-javascript-agent-formalism:unit-of-related-similar-origin-browsing-contexts-2>unit of related similar-origin browsing
    contexts</a>.</p>
   <dt><dfn id=dedicated-worker-agent data-export="">Dedicated worker agent</dfn><dd><p>An <a id=integration-with-the-javascript-agent-formalism:agent-7 href=https://tc39.github.io/ecma262/#sec-agents data-x-internal=agent>agent</a> whose [[CanBlock]] is true and whose set of <a href=https://tc39.github.io/ecma262/#sec-code-realms id=integration-with-the-javascript-agent-formalism:javascript-realm-2 data-x-internal=javascript-realm>realms</a> consists of a single <code id=integration-with-the-javascript-agent-formalism:dedicatedworkerglobalscope><a href=#dedicatedworkerglobalscope>DedicatedWorkerGlobalScope</a></code> object's <a href=#concept-global-object-realm id=integration-with-the-javascript-agent-formalism:concept-global-object-realm-4>Realm</a>.<dt><dfn id=shared-worker-agent data-export="">Shared worker agent</dfn><dd><p>An <a id=integration-with-the-javascript-agent-formalism:agent-8 href=https://tc39.github.io/ecma262/#sec-agents data-x-internal=agent>agent</a> whose [[CanBlock]] is true and whose set of <a href=https://tc39.github.io/ecma262/#sec-code-realms id=integration-with-the-javascript-agent-formalism:javascript-realm-3 data-x-internal=javascript-realm>realms</a> consists a single <code id=integration-with-the-javascript-agent-formalism:sharedworkerglobalscope><a href=#sharedworkerglobalscope>SharedWorkerGlobalScope</a></code> object's <a href=#concept-global-object-realm id=integration-with-the-javascript-agent-formalism:concept-global-object-realm-5>Realm</a>.<dt><dfn id=service-worker-agent data-export="">Service worker agent</dfn><dd><p>An <a id=integration-with-the-javascript-agent-formalism:agent-9 href=https://tc39.github.io/ecma262/#sec-agents data-x-internal=agent>agent</a> whose [[CanBlock]] is false and whose set of <a href=https://tc39.github.io/ecma262/#sec-code-realms id=integration-with-the-javascript-agent-formalism:javascript-realm-4 data-x-internal=javascript-realm>realms</a> consists of 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> object's <a href=#concept-global-object-realm id=integration-with-the-javascript-agent-formalism:concept-global-object-realm-6>Realm</a>.<dt><dfn id=worklet-agent data-export="">Worklet agent</dfn><dd>
    <p>An <a id=integration-with-the-javascript-agent-formalism:agent-10 href=https://tc39.github.io/ecma262/#sec-agents data-x-internal=agent>agent</a> whose [[CanBlock]] is false and whose set of <a href=https://tc39.github.io/ecma262/#sec-code-realms id=integration-with-the-javascript-agent-formalism:javascript-realm-5 data-x-internal=javascript-realm>realms</a> consists of a single <code id=integration-with-the-javascript-agent-formalism:workletglobalscope><a data-x-internal=workletglobalscope href=https://drafts.css-houdini.org/worklets/#workletglobalscope>WorkletGlobalScope</a></code>
    object's <a href=#concept-global-object-realm id=integration-with-the-javascript-agent-formalism:concept-global-object-realm-7>Realm</a>.</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>
   </dl>

  <h5 id=integration-with-the-javascript-agent-cluster-formalism><span class=secno>8.1.3.10</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.github.io/ecma262/#sec-agent-clusters data-x-internal=agent-cluster>agent cluster</a>, which this standard maps
  to the web platform using the <dfn id=can-share-memory-with>can share memory with</dfn> equivalence relation detailed
  below. On the web platform, an <a id=integration-with-the-javascript-agent-cluster-formalism:agent-cluster-2 href=https://tc39.github.io/ecma262/#sec-agent-clusters data-x-internal=agent-cluster>agent cluster</a> consists of all <a href=https://tc39.github.io/ecma262/#sec-agents id=integration-with-the-javascript-agent-cluster-formalism:agent data-x-internal=agent>agents</a> in the same equivalence class with respect to the <a href=#can-share-memory-with id=integration-with-the-javascript-agent-cluster-formalism:can-share-memory-with>can share
  memory with</a> equivalence relation.</p>

  <p>The <a id=integration-with-the-javascript-agent-cluster-formalism:agent-cluster-3 href=https://tc39.github.io/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.github.io/ecma262/#sec-agents id=integration-with-the-javascript-agent-cluster-formalism:agent-2 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.github.io/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-4 href=https://tc39.github.io/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.github.io/ecma262/#sec-agents id=integration-with-the-javascript-agent-cluster-formalism:agent-3 data-x-internal=agent>agents</a>). The <a href=https://tc39.github.io/ecma262/#sec-agent-clusters id=integration-with-the-javascript-agent-cluster-formalism:agent-cluster-5 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>A <a href=#similar-origin-window-agent id=integration-with-the-javascript-agent-cluster-formalism:similar-origin-window-agent>similar-origin window agent</a>, <a href=#dedicated-worker-agent id=integration-with-the-javascript-agent-cluster-formalism:dedicated-worker-agent>dedicated worker agent</a>, <a href=#shared-worker-agent id=integration-with-the-javascript-agent-cluster-formalism:shared-worker-agent>shared
  worker agent</a>, or <a href=#service-worker-agent id=integration-with-the-javascript-agent-cluster-formalism:service-worker-agent>service worker agent</a>, <var>agent</var>, <a href=#can-share-memory-with id=integration-with-the-javascript-agent-cluster-formalism:can-share-memory-with-2>can share
  memory with</a> any <a href=#dedicated-worker-agent id=integration-with-the-javascript-agent-cluster-formalism:dedicated-worker-agent-2>dedicated worker agent</a> whose single <a href=https://tc39.github.io/ecma262/#sec-code-realms id=integration-with-the-javascript-agent-cluster-formalism:javascript-realm data-x-internal=javascript-realm>realm</a>'s <a href=#concept-realm-global id=integration-with-the-javascript-agent-cluster-formalism:concept-realm-global>global object</a>'s <a href=#concept-WorkerGlobalScope-owner-set id=integration-with-the-javascript-agent-cluster-formalism:concept-WorkerGlobalScope-owner-set>owner
  set</a> contains an item whose <a href=#concept-relevant-realm id=integration-with-the-javascript-agent-cluster-formalism:concept-relevant-realm>relevant Realm</a>
  belongs to <var>agent</var>.</p>

  <p class=note>"Item" is used above as an <a href=#concept-WorkerGlobalScope-owner-set id=integration-with-the-javascript-agent-cluster-formalism:concept-WorkerGlobalScope-owner-set-2>owner set</a> can contain
  <code id=integration-with-the-javascript-agent-cluster-formalism:document><a href=#document>Document</a></code> objects.</p>

  <p class=XXX>A <a href=#worklet-agent id=integration-with-the-javascript-agent-cluster-formalism:worklet-agent>worklet agent</a> … currently worklets have
  no clearly defined owner, see: <a href=https://github.com/w3c/css-houdini-drafts/issues/224>w3c/css-houdini-drafts issue
  #224</a>.</p>

  <p>In addition, any <a id=integration-with-the-javascript-agent-cluster-formalism:agent-4 href=https://tc39.github.io/ecma262/#sec-agents data-x-internal=agent>agent</a> <var>A</var> <a href=#can-share-memory-with id=integration-with-the-javascript-agent-cluster-formalism:can-share-memory-with-3>can share memory with</a>:</p>

  <ul class=brief><li><var>A</var>,<li>any <a id=integration-with-the-javascript-agent-cluster-formalism:agent-5 href=https://tc39.github.io/ecma262/#sec-agents data-x-internal=agent>agent</a> <var>B</var> such that <var>B</var> <a href=#can-share-memory-with id=integration-with-the-javascript-agent-cluster-formalism:can-share-memory-with-4>can share memory with</a>
   <var>A</var>, and<li>any <a id=integration-with-the-javascript-agent-cluster-formalism:agent-6 href=https://tc39.github.io/ecma262/#sec-agents data-x-internal=agent>agent</a> <var>B</var> such that there exists an <a id=integration-with-the-javascript-agent-cluster-formalism:agent-7 href=https://tc39.github.io/ecma262/#sec-agents data-x-internal=agent>agent</a>
   <var>C</var>, where <var>A</var> <a href=#can-share-memory-with id=integration-with-the-javascript-agent-cluster-formalism:can-share-memory-with-5>can share memory with</a> <var>C</var> and <var>C</var>
   <a href=#can-share-memory-with id=integration-with-the-javascript-agent-cluster-formalism:can-share-memory-with-6>can share memory with</a> <var>B</var>.</ul>

  <div class=example>
   <p>The following pairs of global objects are each within the same <a id=integration-with-the-javascript-agent-cluster-formalism:agent-cluster-6 href=https://tc39.github.io/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.github.io/ecma262/#sec-sharedarraybuffer-objects>SharedArrayBuffer</a></code> instances to share memory with each other:</p>

   <ul class=brief><li>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.<li>A worker (of any type) and a dedicated worker it created.<li>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>.<li>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.</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-7 href=https://tc39.github.io/ecma262/#sec-agent-clusters data-x-internal=agent-cluster>agent
   cluster</a>, and thus cannot share memory:</p>

   <ul class=brief><li>A <code id=integration-with-the-javascript-agent-cluster-formalism:window-6><a href=#window>Window</a></code> object and a shared worker it created.<li>A worker (of any type) and a shared worker it created.<li>A <code id=integration-with-the-javascript-agent-cluster-formalism:window-7><a href=#window>Window</a></code> object and a service worker it created.<li>A <code id=integration-with-the-javascript-agent-cluster-formalism:window-8><a href=#window>Window</a></code> object <var></var> and the <code id=integration-with-the-javascript-agent-cluster-formalism:window-9><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>.<li>Any two <code id=integration-with-the-javascript-agent-cluster-formalism:window-10><a href=#window>Window</a></code> objects whose <a href=#browsing-context id=integration-with-the-javascript-agent-cluster-formalism:browsing-context>browsing
    contexts</a> do not have an <a href=#opener-browsing-context id=integration-with-the-javascript-agent-cluster-formalism:opener-browsing-context>opener</a> or <a href=#ancestor-browsing-context id=integration-with-the-javascript-agent-cluster-formalism:ancestor-browsing-context>ancestor</a> relationship. This holds even if the two
    <code id=integration-with-the-javascript-agent-cluster-formalism:window-11><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>.</ul>
  </div>

  


  <h5 id=runtime-script-errors><span class=secno>8.1.3.11</span> Runtime script errors<a href=#runtime-script-errors class=self-link></a></h5>

  

  <p>When the user agent is required to <dfn id=report-the-error>report an error</dfn> for a
  particular <a href=#concept-script id=runtime-script-errors:concept-script>script</a> <var>script</var> with a particular
  position <var>line</var>:<var>col</var>, using a particular target <var>target</var>, it must run these steps, after which the error is either <dfn id=concept-error-handled><i>handled</i></dfn> or <dfn id=concept-error-nothandled><i>not
  handled</i></dfn>:</p>

  <ol><li><p>If <var>target</var> is <a href=#in-error-reporting-mode id=runtime-script-errors:in-error-reporting-mode>in error reporting mode</a>, then return; the error is <i id=runtime-script-errors:concept-error-nothandled><a href=#concept-error-nothandled>not handled</a></i>.<li><p>Let <var>target</var> be <dfn id=in-error-reporting-mode>in error reporting mode</dfn>.<li><p>Let <var>message</var> be a user-agent-defined string describing the error in a
   helpful manner.
   <a href=#fingerprinting-vector id=runtime-script-errors:fingerprinting-vector class=fingerprint title="There is a potential fingerprinting vector here."><img alt="(This is a fingerprinting vector.)" src=/images/fingerprint.png width=46 height=64></a>
   <li><p>Let <var>errorValue</var> be the value that represents the error: in the case of an
   uncaught exception, that would be the value that was thrown; in the case of a JavaScript error
   that would be an <code id=runtime-script-errors:idl-error><a data-x-internal=idl-error href=https://heycam.github.io/webidl/#idl-Error>Error</a></code> object. If there is no corresponding
   value, then the null value must be used instead.<li>

    <p>Let <var>urlString</var> be the result of applying the <a href=https://url.spec.whatwg.org/#concept-url-serializer id=runtime-script-errors:concept-url-serializer data-x-internal=concept-url-serializer>URL serializer</a> to the <a id=runtime-script-errors:url-record href=https://url.spec.whatwg.org/#concept-url data-x-internal=url-record>URL record</a> that
    corresponds to the resource from which <var>script</var> was obtained.</p>

    <p class=note>The resource containing the script will typically be the file from which the
    <code id=runtime-script-errors:document><a href=#document>Document</a></code> was parsed, e.g. for inline <code id=runtime-script-errors:the-script-element><a href=#the-script-element>script</a></code> elements or <a href=#event-handler-content-attributes id=runtime-script-errors:event-handler-content-attributes>event
    handler content attributes</a>; or the JavaScript file that the script was in, for external
    scripts. Even for dynamically-generated scripts, user agents are strongly encouraged to attempt
    to keep track of the original source of a script. For example, if an external script uses the
    <code id=runtime-script-errors:dom-document-write><a href=#dom-document-write>document.write()</a></code> API to insert an inline
    <code id=runtime-script-errors:the-script-element-2><a href=#the-script-element>script</a></code> element during parsing, the URL of the resource containing the script would
    ideally be reported as being the external script, and the line number might ideally be reported
    as the line with the <code id=runtime-script-errors:dom-document-write-2><a href=#dom-document-write>document.write()</a></code> call or where the
    string passed to that call was first constructed. Naturally, implementing this can be somewhat
    non-trivial.</p>

    <p class=note>User agents are similarly encouraged to keep careful track of the original line
    numbers, even in the face of <code id=runtime-script-errors:dom-document-write-3><a href=#dom-document-write>document.write()</a></code> calls
    mutating the document as it is parsed, or <a href=#event-handler-content-attributes id=runtime-script-errors:event-handler-content-attributes-2>event handler content attributes</a> spanning
    multiple lines.</p>

   <li><p>If <var>script</var>'s <a href=#muted-errors id=runtime-script-errors:muted-errors>muted errors</a> is true, then set <var>message</var> to
   "<code>Script error.</code>", <var>urlString</var> to the empty string, <var>line</var>
   and <var>col</var> to 0, and <var>errorValue</var> to null.<li><p>Let <var>notHandled</var> be 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><a href=#event-error>error</a></code> at <var>target</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, the <code id=runtime-script-errors:dom-errorevent-message><a href=#dom-errorevent-message>message</a></code> attribute
   initialized to <var>message</var>, the <code id=runtime-script-errors:dom-errorevent-filename><a href=#dom-errorevent-filename>filename</a></code>
   attribute initialized to <var>urlString</var>, the <code id=runtime-script-errors:dom-errorevent-lineno><a href=#dom-errorevent-lineno>lineno</a></code> attribute initialized to <var>line</var>, the <code id=runtime-script-errors:dom-errorevent-colno><a href=#dom-errorevent-colno>colno</a></code> attribute initialized to <var>col</var>, and the <code id=runtime-script-errors:dom-errorevent-error><a href=#dom-errorevent-error>error</a></code> attribute initialized to
   <var>errorValue</var>.<li><p>Let <var>target</var> no longer be <a href=#in-error-reporting-mode id=runtime-script-errors:in-error-reporting-mode-2>in error reporting mode</a>.<li>
    <p>If <var>notHandled</var> is false, then the error is <i id=runtime-script-errors:concept-error-handled><a href=#concept-error-handled>handled</a></i>. Otherwise, the error is <i id=runtime-script-errors:concept-error-nothandled-2><a href=#concept-error-nothandled>not handled</a></i>.</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>
   </ol>


  <h6 id=runtime-script-errors-in-documents><span class=secno>8.1.3.11.1</span> Runtime script errors in documents<a href=#runtime-script-errors-in-documents class=self-link></a></h6>

  <p>When the user agent is to <dfn id=report-the-exception data-lt="report the
  exception|report an exception" data-export="">report an exception</dfn> <var>E</var>, the user
  agent must <a href=#report-the-error id=runtime-script-errors-in-documents:report-the-error>report the error</a> for the relevant <a href=#concept-script id=runtime-script-errors-in-documents:concept-script>script</a>, with the problematic position (line number and column
  number) in the resource containing the script, using the <a href=#concept-settings-object-global id=runtime-script-errors-in-documents:concept-settings-object-global>global object</a> specified by the script's
  <a href=#settings-object id=runtime-script-errors-in-documents:settings-object>settings object</a> as the target. If the error is still <i id=runtime-script-errors-in-documents:concept-error-nothandled><a href=#concept-error-nothandled>not handled</a></i> after this, then the error may be reported to a
  developer console.</p>


  <h6 id=the-errorevent-interface><span class=secno>8.1.3.11.2</span> The <code id=the-errorevent-interface:errorevent><a href=#errorevent>ErrorEvent</a></code> interface<a href=#the-errorevent-interface class=self-link></a></h6>

  

  <pre><code class='idl'>[<c- g>Constructor</c->(<c- b>DOMString</c-> <c- g>type</c->, <c- b>optional</c-> <a href='#erroreventinit' id='the-errorevent-interface:erroreventinit'><c- n>ErrorEventInit</c-></a> <c- g>eventInitDict</c->), <c- g>Exposed</c->=(<c- n>Window</c->,<c- n>Worker</c->)]
<c- b>interface</c-> <dfn id='errorevent'><c- g>ErrorEvent</c-></dfn> : <a href='https://dom.spec.whatwg.org/#interface-event' data-x-internal='event' id='the-errorevent-interface:event'><c- n>Event</c-></a> {
  <c- b>readonly</c-> <c- b>attribute</c-> <c- b>DOMString</c-> <a href='#dom-errorevent-message' id='the-errorevent-interface:dom-errorevent-message'><c- g>message</c-></a>;
  <c- b>readonly</c-> <c- b>attribute</c-> <c- b>USVString</c-> <a href='#dom-errorevent-filename' id='the-errorevent-interface:dom-errorevent-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-errorevent-lineno' id='the-errorevent-interface:dom-errorevent-lineno'><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='the-errorevent-interface:dom-errorevent-colno'><c- g>colno</c-></a>;
  <c- b>readonly</c-> <c- b>attribute</c-> <c- b>any</c-> <a href='#dom-errorevent-error' id='the-errorevent-interface:dom-errorevent-error'><c- g>error</c-></a>;
};

<c- b>dictionary</c-> <dfn id='erroreventinit'><c- g>ErrorEventInit</c-></dfn> : <a href='https://dom.spec.whatwg.org/#dictdef-eventinit' data-x-internal='eventinit' id='the-errorevent-interface:eventinit'><c- n>EventInit</c-></a> {
  <c- b>DOMString</c-> <c- g>message</c-> = &quot;&quot;;
  <c- b>USVString</c-> <c- g>filename</c-> = &quot;&quot;;
  <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-> = <c- b>null</c->;
};</code></pre>

  <p>The <dfn id=dom-errorevent-message><code>message</code></dfn> attribute must return the
  value it was initialized to. It represents the error message.</p>

  <p>The <dfn id=dom-errorevent-filename><code>filename</code></dfn> attribute must return the
  value it was initialized to. It represents the <a id=the-errorevent-interface: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>

  <p>The <dfn id=dom-errorevent-lineno><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>

  <p>The <dfn id=dom-errorevent-colno><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>

  <p>The <dfn id=dom-errorevent-error><code>error</code></dfn> attribute must return the value
  it was initialized to. Where appropriate, it is set to the object representing the error (e.g.,
  the exception object in the case of an uncaught DOM exception).</p>

  <h5 id=unhandled-promise-rejections><span class=secno>8.1.3.12</span> Unhandled promise rejections<a href=#unhandled-promise-rejections class=self-link></a></h5>

  <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.<div class=status><input onclick=toggleStatus(this) value=⋰ type=button><p class=support><strong>Support:</strong> unhandledrejection<span class="and_chr yes"><span>Chrome for Android</span> <span>67+</span></span><span class="chrome yes"><span>Chrome</span> <span>49+</span></span><span class="ios_saf no"><span>iOS Safari</span> <span>None</span></span><span class="and_uc yes"><span>UC Browser for Android</span> <span>11.8+</span></span><span class="firefox no"><span>Firefox</span> <span>None</span></span><span class="ie no"><span>IE</span> <span>None</span></span><span class="op_mini no"><span>Opera Mini</span> <span>None</span></span><span class="safari yes"><span>Safari</span> <span>11+</span></span><span class="edge no"><span>Edge</span> <span>None</span></span><span class="samsung yes"><span>Samsung Internet</span> <span>5+</span></span><span class="opera yes"><span>Opera</span> <span>36+</span></span><span class="android yes"><span>Android Browser</span> <span>67+</span></span><p class=caniuse>Source: <a href="https://caniuse.com/#feat=unhandledrejection">caniuse.com</a></div>

  <p>When the user agent is to <dfn id=notify-about-rejected-promises>notify about rejected promises</dfn> on a given
  <a href=#environment-settings-object id=unhandled-promise-rejections:environment-settings-object>environment settings object</a> <var>settings object</var>, it must run these steps:</p>

  <ol><li><p>Let <var>list</var> be a copy of <var>settings object</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>.<li><p>If <var>list</var> is empty, return.<li><p>Clear <var>settings object</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>.<li>

    <p><a href=#queue-a-task id=unhandled-promise-rejections:queue-a-task>Queue a task</a> to run the following substep:</p>

    <ol><li><p>For each promise <var>p</var> in <var>list</var>:</p>

      <ol><li><p>If <var>p</var>'s [[PromiseIsHandled]] internal slot is true, continue to the next
       iteration of the loop.<li><p>Let <var>notHandled</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>settings object</var>'s <a href=#concept-settings-object-global id=unhandled-promise-rejections:concept-settings-object-global>global
       object</a>, 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 the value of <var>p</var>'s [[PromiseResult]] internal slot.<li><p>If <var>notHandled</var> is false, then the promise rejection is <i id=unhandled-promise-rejections:concept-promise-rejection-handled><a href=#concept-promise-rejection-handled>handled</a></i>. Otherwise, the promise rejection is
       <i id=unhandled-promise-rejections:concept-promise-rejection-nothandled><a href=#concept-promise-rejection-nothandled>not handled</a></i>.<li><p>If <var>p</var>'s [[PromiseIsHandled]] internal slot is false, add <var>p</var> to
       <var>settings object</var>'s <a href=#outstanding-rejected-promises-weak-set id=unhandled-promise-rejections:outstanding-rejected-promises-weak-set>outstanding rejected promises weak set</a>.

      </ol>
     </ol>
   </ol>

  <p>This algorithm results in promise rejections being marked as <dfn id=concept-promise-rejection-handled><i>handled</i></dfn> or <dfn id=concept-promise-rejection-nothandled><i>not handled</i></dfn>. These concepts parallel
  <i id=unhandled-promise-rejections:concept-error-handled><a href=#concept-error-handled>handled</a></i> and <i id=unhandled-promise-rejections:concept-error-nothandled><a href=#concept-error-nothandled>not
  handled</a></i> script errors. If a rejection is still <i id=unhandled-promise-rejections:concept-promise-rejection-nothandled-2><a href=#concept-promise-rejection-nothandled>not handled</a></i> after this, then the rejection may
  be reported to a developer console.</p>


  <h6 id=the-hostpromiserejectiontracker-implementation><span class=secno>8.1.3.12.1</span> <dfn>HostPromiseRejectionTracker</dfn>(<var>promise</var>, <var>operation</var>)<a href=#the-hostpromiserejectiontracker-implementation class=self-link></a></h6>

  <p>JavaScript contains an implementation-defined <a href=https://tc39.github.io/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>.<li><p>If <var>script</var>'s <a href=#muted-errors id=the-hostpromiserejectiontracker-implementation:muted-errors>muted errors</a> is true, terminate these steps.<li><p>Let <var>settings object</var> be <var>script</var>'s <a href=#settings-object id=the-hostpromiserejectiontracker-implementation:settings-object>settings object</a>.</p>
   <li>
    <p>If <var>operation</var> is <code>"reject"</code>,

    <ol><li><p>Add <var>promise</var> to <var>settings object</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>.</ol>
   <li>
    <p>If <var>operation</var> is <code>"handle"</code>,

    <ol><li><p>If <var>settings object</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> contains <var>promise</var>, then remove <var>promise</var> from that list and
     return.<li><p>If <var>settings object</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 contain <var>promise</var>, then return.<li><p>Remove <var>promise</var> from <var>settings object</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>.<li><p><a href=#queue-a-task id=the-hostpromiserejectiontracker-implementation:queue-a-task>Queue a task</a> 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>settings
     object</var>'s <a href=#concept-settings-object-global id=the-hostpromiserejectiontracker-implementation:concept-settings-object-global>global object</a>, 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 the value of <var>promise</var>'s [[PromiseResult]] internal
     slot.</ol>
   </ol>

  <h6 id=the-promiserejectionevent-interface><span class=secno>8.1.3.12.2</span> The <code id=the-promiserejectionevent-interface:promiserejectionevent><a href=#promiserejectionevent>PromiseRejectionEvent</a></code> interface<a href=#the-promiserejectionevent-interface class=self-link></a></h6>

  <pre><code class='idl'>[<c- g>Constructor</c->(<c- b>DOMString</c-> <c- g>type</c->, <a href='#promiserejectioneventinit' id='the-promiserejectionevent-interface:promiserejectioneventinit'><c- n>PromiseRejectionEventInit</c-></a> <c- g>eventInitDict</c->), <c- g>Exposed</c->=(<c- n>Window</c->,<c- n>Worker</c->)]
<c- b>interface</c-> <dfn id='promiserejectionevent'><c- g>PromiseRejectionEvent</c-></dfn> : <a href='https://dom.spec.whatwg.org/#interface-event' data-x-internal='event' id='the-promiserejectionevent-interface:event'><c- n>Event</c-></a> {
  <c- b>readonly</c-> <c- b>attribute</c-> <c- b>Promise</c->&lt;<c- b>any</c->&gt; <a href='#dom-promiserejectionevent-promise' id='the-promiserejectionevent-interface:dom-promiserejectionevent-promise'><c- g>promise</c-></a>;
  <c- b>readonly</c-> <c- b>attribute</c-> <c- b>any</c-> <a href='#dom-promiserejectionevent-reason' id='the-promiserejectionevent-interface:dom-promiserejectionevent-reason'><c- g>reason</c-></a>;
};

<c- b>dictionary</c-> <dfn id='promiserejectioneventinit'><c- g>PromiseRejectionEventInit</c-></dfn> : <a href='https://dom.spec.whatwg.org/#dictdef-eventinit' data-x-internal='eventinit' id='the-promiserejectionevent-interface:eventinit'><c- n>EventInit</c-></a> {
  <c- b>required</c-> <c- b>Promise</c->&lt;<c- b>any</c->&gt; <c- g>promise</c->;
  <c- b>any</c-> <c- g>reason</c->;
};</code></pre>

  <p>The <dfn id=dom-promiserejectionevent-promise><code>promise</code></dfn> attribute must
  return the value it was initialized to. It represents the promise which this notification is about.</p>

  <p>The <dfn id=dom-promiserejectionevent-reason><code>reason</code></dfn> attribute must
  return the value it was initialized to. It represents the rejection reason for the promise.</p>

  <h5 id=hostensurecancompilestrings(callerrealm,-calleerealm)><span class=secno>8.1.3.13</span> <dfn>HostEnsureCanCompileStrings</dfn>(<var>callerRealm</var>, <var>calleeRealm</var>)<a href=#hostensurecancompilestrings(callerrealm,-calleerealm) class=self-link></a></h5>

  <p>JavaScript contains an implementation-defined <a href=https://tc39.github.io/ecma262/#sec-hostensurecancompilestrings id=hostensurecancompilestrings(callerrealm,-calleerealm):js-hostensurecancompilestrings data-x-internal=js-hostensurecancompilestrings>HostEnsureCanCompileStrings</a>(<var>callerRealm</var>,
  <var>calleeRealm</var>) abstract operation. User agents must use the following implementation:
  <a href=#refsJAVASCRIPT>[JAVASCRIPT]</a>

  <ol><li><p>Perform ? <a href=https://w3c.github.io/webappsec-csp/#can-compile-strings id=hostensurecancompilestrings(callerrealm,-calleerealm):csp-ensurecspdoesnotblockstringcompilation data-x-internal=csp-ensurecspdoesnotblockstringcompilation>EnsureCSPDoesNotBlockStringCompilation</a>(<var>callerRealm</var>,
   <var>calleeRealm</var>). <a href=#refsCSP>[CSP]</a></ol>

  

  <h4 id=event-loops><span class=secno>8.1.4</span> Event loops<a href=#event-loops class=self-link></a></h4> 

  <h5 id=definitions-3><span class=secno>8.1.4.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. There are two kinds of event loops: those for <a href=#browsing-context id=definitions-3:browsing-context>browsing contexts</a>, and those for <a href=#workers>workers</a>.</p>

  <p>There must be at least one <a href=#browsing-context id=definitions-3:browsing-context-2>browsing context</a> <a href=#event-loop id=definitions-3:event-loop>event loop</a> per user
  agent, and at most one per <a href=#unit-of-related-similar-origin-browsing-contexts id=definitions-3:unit-of-related-similar-origin-browsing-contexts>unit of related similar-origin browsing contexts</a>.</p>

  <p class=note>When there is more than one <a href=#event-loop id=definitions-3:event-loop-2>event loop</a> for a <a href=#unit-of-related-browsing-contexts id=definitions-3:unit-of-related-browsing-contexts>unit of related
  browsing contexts</a>, complications arise when a <a href=#browsing-context id=definitions-3:browsing-context-3>browsing context</a> in that group
  is <a href=#navigate id=definitions-3:navigate>navigated</a> such that it switches from one <a href=#unit-of-related-similar-origin-browsing-contexts id=definitions-3:unit-of-related-similar-origin-browsing-contexts-2>unit of related
  similar-origin browsing contexts</a> to another. This specification does not currently describe
  how to handle these complications.</p>

  <p>A <a href=#browsing-context id=definitions-3:browsing-context-4>browsing context</a> <a href=#event-loop id=definitions-3:event-loop-3>event loop</a> always has at least one <a href=#browsing-context id=definitions-3:browsing-context-5>browsing
  context</a>. If such an <a href=#event-loop id=definitions-3:event-loop-4>event loop</a>'s <a href=#browsing-context id=definitions-3:browsing-context-6>browsing
  contexts</a> all go away, then the <a href=#event-loop id=definitions-3:event-loop-5>event loop</a> goes away as well. A <a href=#browsing-context id=definitions-3:browsing-context-7>browsing
  context</a> always has an <a href=#event-loop id=definitions-3:event-loop-6>event loop</a> coordinating its activities.</p>

  <p><a href=#worker-event-loop>Worker event loops</a> are simpler: each worker has one
  <a href=#event-loop id=definitions-3:event-loop-7>event loop</a>, and the <a href=#run-a-worker id=definitions-3:run-a-worker>worker processing model</a>
  manages the <a href=#event-loop id=definitions-3:event-loop-8>event loop</a>'s lifetime.</p>

  <hr>

  <p>An <a href=#event-loop id=definitions-3:event-loop-9>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 an ordered list of <dfn id=concept-task data-lt=task data-export="">tasks</dfn>, which are algorithms that are responsible for such work as:</p>

  <dl><dt>Events<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-2>task queue</a>, many are
    dispatched during other tasks.</p>

   <dt>Parsing<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.<dt>Callbacks<dd><p>Calling a callback is often done by a dedicated task.<dt>Using a resource<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.<dt>Reacting to DOM manipulation<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>

  </dl>

  <p>Each <a href=#concept-task id=definitions-3:concept-task>task</a> in a <a href=#browsing-context id=definitions-3:browsing-context-8>browsing context</a> <a href=#event-loop id=definitions-3:event-loop-10>event
  loop</a> is associated with a <code id=definitions-3:document><a href=#document>Document</a></code>; if the task was queued in the context of
  an element, then it is the element's <a id=definitions-3:node-document href=https://dom.spec.whatwg.org/#concept-node-document data-x-internal=node-document>node document</a>; if the task was queued in the context
  of a <a href=#browsing-context id=definitions-3:browsing-context-9>browsing context</a>, then it is the <a href=#browsing-context id=definitions-3:browsing-context-10>browsing context</a>'s <a href=#active-document id=definitions-3:active-document>active
  document</a> at the time the task was queued; if the task was queued by or for a <a href=#concept-script id=definitions-3:concept-script>script</a> then the document is the <a href=#responsible-document id=definitions-3:responsible-document>responsible document</a>
  specified by the script's <a href=#settings-object id=definitions-3:settings-object>settings object</a>.</p>

  <p>A <a href=#concept-task id=definitions-3:concept-task-2>task</a> is intended for a specific <a href=#event-loop id=definitions-3:event-loop-11>event loop</a>:
  the <a href=#event-loop id=definitions-3:event-loop-12>event loop</a> that is handling <a href=#concept-task id=definitions-3:concept-task-3>tasks</a> for the
  <a href=#concept-task id=definitions-3:concept-task-4>task</a>'s associated <code id=definitions-3:document-2><a href=#document>Document</a></code> or <a href=#workers>worker</a>.</p>

  <p>When a user agent is to <dfn id=queue-a-task data-export="">queue a task</dfn>, it must add the given task to
  one of the <a href=#task-queue id=definitions-3:task-queue-3>task queues</a> of the relevant <a href=#event-loop id=definitions-3:event-loop-13>event
  loop</a>.</p>

  <p>Each <a href=#concept-task id=definitions-3:concept-task-5>task</a> is defined as coming from a specific <dfn id=task-source data-export="">task source</dfn>. All the tasks from one particular <a href=#task-source id=definitions-3:task-source>task source</a> and
  destined to a particular <a href=#event-loop id=definitions-3:event-loop-14>event loop</a> (e.g. the callbacks generated by timers of a
  <code id=definitions-3:document-3><a href=#document>Document</a></code>, the events fired for mouse movements over that <code id=definitions-3:document-4><a href=#document>Document</a></code>, the
  tasks queued for the parser of that <code id=definitions-3:document-5><a href=#document>Document</a></code>) must always be added to the same
  <a href=#task-queue id=definitions-3:task-queue-4>task queue</a>, but <a href=#concept-task id=definitions-3:concept-task-6>tasks</a> from different <a href=#task-source id=definitions-3:task-source-2>task sources</a> may be placed in different <a href=#task-queue id=definitions-3:task-queue-5>task
  queues</a>.</p>

  <p class=example>For example, a user agent could have one <a href=#task-queue id=definitions-3:task-queue-6>task queue</a> for mouse and
  key events (the <a href=#user-interaction-task-source id=definitions-3:user-interaction-task-source>user interaction task source</a>), and another for everything else. The
  user agent could then give keyboard and mouse events preference over other tasks three quarters of
  the time, keeping the interface responsive but not starving other task queues, and never
  processing events from any one <a href=#task-source id=definitions-3:task-source-3>task source</a> out of order.</p>

  <p>Each <a href=#event-loop id=definitions-3:event-loop-15>event loop</a> has a <dfn id=currently-running-task>currently running task</dfn>. Initially, this is null.
  It is used to handle reentrancy. Each <a href=#event-loop id=definitions-3:event-loop-16>event loop</a> also has a <dfn id=performing-a-microtask-checkpoint>performing a
  microtask checkpoint</dfn> flag, which must initially be 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>

  <h5 id=event-loop-processing-model data-dfn-type=dfn data-lt="event loop processing model" data-export=""><span class=secno>8.1.4.2</span> <span id=processing-model-8></span>Processing model<a href=#event-loop-processing-model class=self-link></a></h5>
  

  <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><li id=step1><p>Let <var>oldestTask</var> be the oldest <a href=#concept-task id=event-loop-processing-model:concept-task>task</a>
   on one of the <a href=#event-loop id=event-loop-processing-model:event-loop-2>event loop</a>'s <a href=#task-queue id=event-loop-processing-model:task-queue>task queues</a>, if any,
   ignoring, in the case of a <a href=#browsing-context id=event-loop-processing-model:browsing-context>browsing context</a> <a href=#event-loop id=event-loop-processing-model:event-loop-3>event loop</a>, tasks whose
   associated <code id=event-loop-processing-model:document><a href=#document>Document</a></code>s are not <a href=#fully-active id=event-loop-processing-model:fully-active>fully active</a>. The user agent may pick any
   <a href=#task-queue id=event-loop-processing-model:task-queue-2>task queue</a>. If there is no task to select, then jump to the <i>microtasks</i> step
   below.<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>currently running task</a> to
   <var>oldestTask</var>.<li><p>Run <var>oldestTask</var>.<li><p>Set the <a href=#event-loop id=event-loop-processing-model:event-loop-5>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.<li><p>Remove <var>oldestTask</var> from its <a href=#task-queue id=event-loop-processing-model:task-queue-3>task queue</a>.<li><p><i>Microtasks</i>: <a href=#perform-a-microtask-checkpoint id=event-loop-processing-model:perform-a-microtask-checkpoint>Perform a microtask checkpoint</a>.<li>
    <p><dfn id=update-the-rendering data-export="">Update the rendering</dfn>: If this <a href=#event-loop id=event-loop-processing-model:event-loop-6>event loop</a> is a
    <a href=#browsing-context id=event-loop-processing-model:browsing-context-2>browsing context</a> <a href=#event-loop id=event-loop-processing-model:event-loop-7>event loop</a> (as opposed to a <a href=#workers>worker</a> <a href=#event-loop id=event-loop-processing-model:event-loop-8>event loop</a>), then run the following substeps.</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>. <a href=#refsHRT>[HRT]</a><li>
      <p>Let <var>docs</var> be the list of <code id=event-loop-processing-model:document-2><a href=#document>Document</a></code> objects associated with the
      <a href=#event-loop id=event-loop-processing-model:event-loop-9>event loop</a> in question, sorted arbitrarily except that the following conditions
      must be met:</p>

      <ul><li><p>Any <code id=event-loop-processing-model:document-3><a href=#document>Document</a></code> <var>B</var> that is <a href=#browsing-context-nested-through id=event-loop-processing-model:browsing-context-nested-through>nested through</a> a <code id=event-loop-processing-model:document-4><a href=#document>Document</a></code> <var>A</var> must be listed after
       <var>A</var> in the list.<li><p>If there are two documents <var>A</var> and <var>B</var> whose <a href=#concept-document-bc id=event-loop-processing-model:concept-document-bc>browsing contexts</a> are both <a href=#nested-browsing-context id=event-loop-processing-model:nested-browsing-context>nested browsing contexts</a> and their <a href=#browsing-context-container id=event-loop-processing-model:browsing-context-container>browsing context containers</a> are both elements in the same
       <code id=event-loop-processing-model:document-5><a href=#document>Document</a></code> <var>C</var>, then the order of <var>A</var> and <var>B</var> in the
       list must match the relative <a id=event-loop-processing-model:tree-order href=https://dom.spec.whatwg.org/#concept-tree-order data-x-internal=tree-order>tree order</a> of their respective <a href=#browsing-context-container id=event-loop-processing-model:browsing-context-container-2>browsing context containers</a> in
       <var>C</var>.</ul>

      <p>In the steps below that iterate over <var>docs</var>, each <code id=event-loop-processing-model:document-6><a href=#document>Document</a></code> must be
      processed in the order it is found in the list.</p>
     <li>
      <p><i>Rendering opportunites</i>: If there are <a href=#browsing-context id=event-loop-processing-model:browsing-context-3>browsing
      contexts</a> <var>browsingContexts</var> that do not have a <a href=#rendering-opportunity id=event-loop-processing-model:rendering-opportunity>rendering
      opportunity</a>, then remove from <var>docs</var> all <code id=event-loop-processing-model:document-7><a href=#document>Document</a></code> objects whose
      <a href=#concept-document-bc id=event-loop-processing-model:concept-document-bc-2>browsing context</a> is in
      <var>browsingContexts</var>.</p>

      <p>A <a href=#browsing-context id=event-loop-processing-model:browsing-context-4>browsing context</a> has a <dfn id=rendering-opportunity>rendering opportunity</dfn> if the user agent is
      currently able to present the contents of the <a href=#browsing-context id=event-loop-processing-model:browsing-context-5>browsing context</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>

      <p><a href=#browsing-context id=event-loop-processing-model:browsing-context-6>Browsing context</a> <a href=#rendering-opportunity id=event-loop-processing-model:rendering-opportunity-2>rendering
      opportunities</a> are determined based on hardware constraints such as display refresh
      rates and other factors such as page performance or whether the page is in the background.
      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=#browsing-context id=event-loop-processing-model:browsing-context-7>browsing context</a> is not able to sustain this
      rate, it might drop to a more sustainable 30 rendering opportunities per second for that
      <a href=#browsing-context id=event-loop-processing-model:browsing-context-8>browsing context</a>, rather than occasionally dropping frames. Similarly, if a
      <a href=#browsing-context id=event-loop-processing-model:browsing-context-9>browsing context</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>
     <li><p><i>Unnecessary rendering</i>: If there are <a href=#browsing-context id=event-loop-processing-model:browsing-context-10>browsing
     contexts</a> <var>browsingContexts</var> for which the user agent believes updating the
     rendering would have no visible effect and which possess no <code id=event-loop-processing-model:document-8><a href=#document>Document</a></code> objects with
     a non-empty <a href=#list-of-animation-frame-callbacks id=event-loop-processing-model:list-of-animation-frame-callbacks>map of animation frame callbacks</a>, then remove from <var>docs</var>
     all <code id=event-loop-processing-model:document-9><a href=#document>Document</a></code> objects whose <a href=#concept-document-bc id=event-loop-processing-model:concept-document-bc-3>browsing
     context</a> is in <var>browsingContexts</var>. Invoke the <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>
     algorithm for each <code id=event-loop-processing-model:document-10><a href=#document>Document</a></code> object removed.<li>
      <p>If there are <a href=#browsing-context id=event-loop-processing-model:browsing-context-11>browsing contexts</a>
      <var>browsingContexts</var> for which the user agent believes it's preferrable to skip
      updating the rendering for other reasons, then remove from <var>docs</var> all
      <code id=event-loop-processing-model:document-11><a href=#document>Document</a></code> objects whose <a href=#concept-document-bc id=event-loop-processing-model:concept-document-bc-4>browsing context</a>
      is in <var>browsingContexts</var>.</p>

      <div class=note>
       <p>The step labeled <i>Rendering opportunities</i> prevents the user agent from updating the
       rendering when it is unable to present new content to the user (there's no <a href=#rendering-opportunity id=event-loop-processing-model:rendering-opportunity-3>rendering
       opportunity</a>).</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-2>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>animation frame callbacks</a> interleaved). Concretely, a
       user agent might wish to coalesce timer callbacks together, with no intermediate rendering
       updates.</p>
      </div>
     <li><p>For each <a href=#fully-active id=event-loop-processing-model:fully-active-2>fully active</a> <code id=event-loop-processing-model:document-12><a href=#document>Document</a></code> in <var>docs</var>, <a id=event-loop-processing-model:run-the-resize-steps href=https://drafts.csswg.org/cssom-view/#run-the-resize-steps data-x-internal=run-the-resize-steps>run
     the resize steps</a> for that <code id=event-loop-processing-model:document-13><a href=#document>Document</a></code>, passing in <var>now</var> as the
     timestamp. <a href=#refsCSSOMVIEW>[CSSOMVIEW]</a><li><p>For each <a href=#fully-active id=event-loop-processing-model:fully-active-3>fully active</a> <code id=event-loop-processing-model:document-14><a href=#document>Document</a></code> in <var>docs</var>, <a id=event-loop-processing-model:run-the-scroll-steps href=https://drafts.csswg.org/cssom-view/#run-the-scroll-steps data-x-internal=run-the-scroll-steps>run
     the scroll steps</a> for that <code id=event-loop-processing-model:document-15><a href=#document>Document</a></code>, passing in <var>now</var> as the
     timestamp. <a href=#refsCSSOMVIEW>[CSSOMVIEW]</a><li><p>For each <a href=#fully-active id=event-loop-processing-model:fully-active-4>fully active</a> <code id=event-loop-processing-model:document-16><a href=#document>Document</a></code> in <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 that <code id=event-loop-processing-model:document-17><a href=#document>Document</a></code>, passing
     in <var>now</var> as the timestamp. <a href=#refsCSSOMVIEW>[CSSOMVIEW]</a><li><p>For each <a href=#fully-active id=event-loop-processing-model:fully-active-5>fully active</a> <code id=event-loop-processing-model:document-18><a href=#document>Document</a></code> in <var>docs</var>,
     <a id=event-loop-processing-model:update-animations-and-send-events href=https://drafts.csswg.org/web-animations/#update-animations-and-send-events data-x-internal=update-animations-and-send-events>update animations and send events</a> for that <code id=event-loop-processing-model:document-19><a href=#document>Document</a></code>, passing in
     <var>now</var> as the timestamp. <a href=#refsWEBANIMATIONS>[WEBANIMATIONS]</a><li><p>For each <a href=#fully-active id=event-loop-processing-model:fully-active-6>fully active</a> <code id=event-loop-processing-model:document-20><a href=#document>Document</a></code> in <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 that <code id=event-loop-processing-model:document-21><a href=#document>Document</a></code>, passing in <var>now</var> as the
     timestamp. <a href=#refsFULLSCREEN>[FULLSCREEN]</a><li><p>For each <a href=#fully-active id=event-loop-processing-model:fully-active-7>fully active</a> <code id=event-loop-processing-model:document-22><a href=#document>Document</a></code> in <var>docs</var>, <a href=#run-the-animation-frame-callbacks id=event-loop-processing-model:run-the-animation-frame-callbacks-2>run
     the animation frame callbacks</a> for that <code id=event-loop-processing-model:document-23><a href=#document>Document</a></code>, passing in <var>now</var>
     as the timestamp.<li><p>For each <a href=#fully-active id=event-loop-processing-model:fully-active-8>fully active</a> <code id=event-loop-processing-model:document-24><a href=#document>Document</a></code> in <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 that <code id=event-loop-processing-model:document-25><a href=#document>Document</a></code>, passing in
     <var>now</var> as the timestamp. <a href=#refsINTERSECTIONOBSERVER>[INTERSECTIONOBSERVER]</a><li><p>Invoke the <a id=event-loop-processing-model:mark-paint-timing-2 href=https://w3c.github.io/paint-timing/#mark-paint-timing data-x-internal=mark-paint-timing>mark paint timing</a> algorithm for each <code id=event-loop-processing-model:document-26><a href=#document>Document</a></code>
     object in <var>docs</var>.<li><p>For each <a href=#fully-active id=event-loop-processing-model:fully-active-9>fully active</a> <code id=event-loop-processing-model:document-27><a href=#document>Document</a></code> in <var>docs</var>, update the
     rendering or user interface of that <code id=event-loop-processing-model:document-28><a href=#document>Document</a></code> and its <a href=#concept-document-bc id=event-loop-processing-model:concept-document-bc-5>browsing context</a> to reflect the current state.</ol>
   <li>
    <p>If this is a <a href=#workers>worker</a> <a href=#event-loop id=event-loop-processing-model:event-loop-10>event loop</a> (i.e., one running for
    a <code id=event-loop-processing-model:workerglobalscope><a href=#workerglobalscope>WorkerGlobalScope</a></code>):</p>

    <ol><li>
      <p>If this 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-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>. <a href=#refsHRT>[HRT]</a><li><p><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 that
       <code id=event-loop-processing-model:dedicatedworkerglobalscope-2><a href=#dedicatedworkerglobalscope>DedicatedWorkerGlobalScope</a></code>, passing in <var>now</var> as the
       timestamp.<li><p>Update the rendering of that dedicated worker to reflect the current state.</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=#browsing-context id=event-loop-processing-model:browsing-context-12>browsing context</a> <a href=#event-loop id=event-loop-processing-model:event-loop-11>event loop</a>, a user agent can
      determine the rate of rendering in the dedicated worker.</p>
     <li><p>If there are no <a href=#concept-task id=event-loop-processing-model:concept-task-3>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-4>task queues</a> and the
     <code id=event-loop-processing-model:workerglobalscope-2><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.</ol>
   </ol>

  <hr>

  <p>Each <a href=#event-loop id=event-loop-processing-model:event-loop-14>event loop</a> has a <dfn id=microtask-queue>microtask queue</dfn>. A <dfn id=microtask data-export="">microtask</dfn> is a <a href=#concept-task id=event-loop-processing-model:concept-task-4>task</a> that is originally to
  be queued on the <a href=#microtask-queue id=event-loop-processing-model:microtask-queue>microtask queue</a> rather than a <a href=#task-queue id=event-loop-processing-model:task-queue-5>task queue</a>. There are two
  kinds of <a href=#microtask id=event-loop-processing-model:microtask>microtasks</a>: <dfn id=solitary-callback-microtask data-lt="solitary callback microtask" data-export="">solitary callback
  microtasks</dfn>, and <dfn id=compound-microtask data-lt="compound microtask" data-export="">compound microtasks</dfn>.</p>

  <p class=note>This specification only has <a href=#solitary-callback-microtask id=event-loop-processing-model:solitary-callback-microtask>solitary
  callback microtasks</a>. Specifications that use <a href=#compound-microtask id=event-loop-processing-model:compound-microtask>compound
  microtasks</a> have to take extra care to <a href=#execute-a-compound-microtask-subtask id=event-loop-processing-model:execute-a-compound-microtask-subtask>wrap callbacks</a> to handle <a href=#spin-the-event-loop id=event-loop-processing-model:spin-the-event-loop>spinning the event
  loop</a>.</p>

  <p>When an algorithm requires a <a href=#microtask id=event-loop-processing-model:microtask-2>microtask</a> to be <dfn id=queue-a-microtask data-lt="queue a microtask" data-export="">queued</dfn>, it must be appended to the
  relevant <a href=#event-loop id=event-loop-processing-model:event-loop-15>event loop</a>'s <a href=#microtask-queue id=event-loop-processing-model:microtask-queue-2>microtask queue</a>; the <a href=#task-source id=event-loop-processing-model:task-source>task source</a> of
  such a <a href=#microtask id=event-loop-processing-model:microtask-3>microtask</a> is the <dfn id=microtask-task-source>microtask task source</dfn>.</p>

  <p class=note>It is possible for a <a href=#microtask id=event-loop-processing-model:microtask-4>microtask</a> to be moved to a regular <a href=#task-queue id=event-loop-processing-model:task-queue-6>task
  queue</a>, if, during its initial execution, it <a href=#spin-the-event-loop id=event-loop-processing-model:spin-the-event-loop-2>spins the
  event loop</a>. In that case, the <a href=#microtask-task-source id=event-loop-processing-model:microtask-task-source>microtask task source</a> is the <a href=#task-source id=event-loop-processing-model:task-source-2>task
  source</a> used. Normally, the <a href=#task-source id=event-loop-processing-model:task-source-3>task source</a> of a <a href=#microtask id=event-loop-processing-model:microtask-5>microtask</a> is
  irrelevant.</p>

  <p>When a user agent is to <dfn id=perform-a-microtask-checkpoint data-export="">perform a microtask checkpoint</dfn>, if the
  <a href=#performing-a-microtask-checkpoint id=event-loop-processing-model:performing-a-microtask-checkpoint>performing a microtask checkpoint</a> flag is false, then the user agent must run the
  following steps:</p>

  <ol><li><p>Set the <a href=#performing-a-microtask-checkpoint id=event-loop-processing-model:performing-a-microtask-checkpoint-2>performing a microtask checkpoint</a> flag to true.<li>
    <p>While the <a href=#event-loop id=event-loop-processing-model:event-loop-16>event loop</a>'s <a href=#microtask-queue id=event-loop-processing-model:microtask-queue-3>microtask queue</a> is not empty:</p>

    <ol><li><p>Let <var>oldestMicrotask</var> be the oldest <a href=#microtask id=event-loop-processing-model:microtask-6>microtask</a> on 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-4>microtask queue</a>.<li><p>Set the <a href=#event-loop id=event-loop-processing-model:event-loop-18>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>.<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><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-4>currently running task</a> back to
     null.<li><p>Remove <var>oldestMicrotask</var> from the <a href=#microtask-queue id=event-loop-processing-model:microtask-queue-5>microtask queue</a>.</ol>
   <li><p>For each <a href=#environment-settings-object id=event-loop-processing-model:environment-settings-object>environment settings object</a> 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-20>event loop</a>, <a href=#notify-about-rejected-promises id=event-loop-processing-model:notify-about-rejected-promises>notify about rejected promises</a> on that
   <a href=#environment-settings-object id=event-loop-processing-model:environment-settings-object-2>environment settings object</a>.<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>.<li><p>Set the <a href=#performing-a-microtask-checkpoint id=event-loop-processing-model:performing-a-microtask-checkpoint-4>performing a microtask checkpoint</a> flag to false.</ol>

  <p>If, while a <a href=#compound-microtask id=event-loop-processing-model:compound-microtask-2>compound microtask</a> is running, the user agent is required to
  <dfn id=execute-a-compound-microtask-subtask data-export="">execute a compound microtask subtask</dfn> to run a series of steps, the user
  agent must run the following steps:</p>

  <ol><li><p>Let <var>parent</var> be the <a href=#event-loop id=event-loop-processing-model:event-loop-21>event loop</a>'s <a href=#currently-running-task id=event-loop-processing-model:currently-running-task-5>currently running
   task</a> (the currently running <a href=#compound-microtask id=event-loop-processing-model:compound-microtask-3>compound microtask</a>).<li><p>Let <var>subtask</var> be a new <a href=#concept-task id=event-loop-processing-model:concept-task-5>task</a> that
   consists of running the given series of steps. The <a href=#task-source id=event-loop-processing-model:task-source-4>task source</a> of such a
   <a href=#microtask id=event-loop-processing-model:microtask-7>microtask</a> is the <a href=#microtask-task-source id=event-loop-processing-model:microtask-task-source-2>microtask task source</a>. This is a <dfn id=compound-microtask-subtask>compound
   microtask subtask</dfn>.<li><p>Set the <a href=#event-loop id=event-loop-processing-model:event-loop-22>event loop</a>'s <a href=#currently-running-task id=event-loop-processing-model:currently-running-task-6>currently running task</a> to <var>subtask</var>.<li><p>Run <var>subtask</var>.<li><p>Set 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-7>currently running task</a> back to <var>parent</var>.</ol>

  <hr>

  <p>When an algorithm running <a href=#in-parallel id=event-loop-processing-model:in-parallel>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>.<li><p>Resumes execution of the algorithm <a href=#in-parallel id=event-loop-processing-model:in-parallel-2>in parallel</a>, if appropriate, as described
   in the algorithm's steps.</ol>

  <p class=note>Steps in <a href=#synchronous-section id=event-loop-processing-model:synchronous-section>synchronous sections</a> are marked
  with ⌛.</p>

  <hr>

  <p>When an algorithm says to <dfn id=spin-the-event-loop>spin the event loop</dfn> until a condition <var>goal</var> is met, the user agent must run the following steps:</p>

  <ol><li>

    <p>Let <var>task</var> be the <a href=#event-loop id=event-loop-processing-model:event-loop-24>event loop</a>'s <a href=#currently-running-task id=event-loop-processing-model:currently-running-task-8>currently running
    task</a>.</p>

    <p class=note>This might be a <a href=#microtask id=event-loop-processing-model:microtask-8>microtask</a>, in which case it is a <a href=#solitary-callback-microtask id=event-loop-processing-model:solitary-callback-microtask-2>solitary
    callback microtask</a>. It could also be a <a href=#compound-microtask-subtask id=event-loop-processing-model:compound-microtask-subtask>compound microtask subtask</a>, or a
    regular <a href=#concept-task id=event-loop-processing-model:concept-task-6>task</a> that is not a <a href=#microtask id=event-loop-processing-model:microtask-9>microtask</a>. It will
    <em>not</em> be a <a href=#compound-microtask id=event-loop-processing-model:compound-microtask-4>compound microtask</a>.</p> 

   <li><p>Let <var>task source</var> be <var>task</var>'s <a href=#task-source id=event-loop-processing-model:task-source-5>task
   source</a>.<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.github.io/ecma262/#execution-context-stack data-x-internal=javascript-execution-context-stack>JavaScript execution context
   stack</a>.<li><p>Empty the <a id=event-loop-processing-model:javascript-execution-context-stack-2 href=https://tc39.github.io/ecma262/#execution-context-stack data-x-internal=javascript-execution-context-stack>JavaScript execution context stack</a>.<li><p><a href=#perform-a-microtask-checkpoint id=event-loop-processing-model:perform-a-microtask-checkpoint-4>Perform a microtask checkpoint</a>.<li>

    <p>Stop <var>task</var>, allowing whatever algorithm that invoked it to resume, but
    continue these steps <a href=#in-parallel id=event-loop-processing-model:in-parallel-3>in parallel</a>.</p>

    <p class=note>This causes one of the following algorithms to continue: the <a href=#event-loop id=event-loop-processing-model:event-loop-25>event
    loop</a>'s main set of steps, the <a href=#perform-a-microtask-checkpoint id=event-loop-processing-model:perform-a-microtask-checkpoint-5>perform a microtask checkpoint</a> algorithm, or
    the <a href=#execute-a-compound-microtask-subtask id=event-loop-processing-model:execute-a-compound-microtask-subtask-2>execute a compound microtask subtask</a> algorithm.</p>

   <li><p>Wait until the condition <var>goal</var> is met.<li><p><a href=#queue-a-task id=event-loop-processing-model:queue-a-task>Queue a task</a> to continue running these steps, using the <a href=#task-source id=event-loop-processing-model:task-source-6>task
   source</a> <var>task source</var>. Wait until this new task runs before continuing
   these steps.<li><p>Replace the <a id=event-loop-processing-model:javascript-execution-context-stack-3 href=https://tc39.github.io/ecma262/#execution-context-stack data-x-internal=javascript-execution-context-stack>JavaScript execution context stack</a> with the <var>old
   stack</var>.<li><p>Return to the caller.</ol>

  <hr>

  <p>Some of the algorithms in this specification, for historical reasons, require the user agent to
  <dfn id=pause>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>If necessary, update the rendering or user interface of any <code id=event-loop-processing-model:document-29><a href=#document>Document</a></code> or
   <a href=#browsing-context id=event-loop-processing-model:browsing-context-13>browsing context</a> to reflect the current state.<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-26>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-27>event loop</a> will not be
   doing anything.</ol>

  <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-28>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-3>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-29>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-10>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.4.3</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-dfn-type=dfn data-export="">DOM manipulation task source</dfn><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>

   <dt>The <dfn id=user-interaction-task-source data-export="">user interaction task source</dfn><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> 

   <dt>The <dfn id=networking-task-source data-export="">networking task source</dfn><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>

   <dt>The <dfn id=history-traversal-task-source data-export="">history traversal task source</dfn><dd>

    <p>This <a href=#task-source id=generic-task-sources:task-source-5>task source</a> is used to queue calls to <code id=generic-task-sources:dom-history-back><a href=#dom-history-back>history.back()</a></code> and similar APIs.</p>

   </dl>

  <h5 id=event-loop-for-spec-authors><span class=secno>8.1.4.4</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;<li><p>displaying a user-facing prompt;<li><p>performing operations which could require involving outside systems (i.e. "going out of
   process").</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:javascript-realm href=https://tc39.github.io/ecma262/#sec-code-realms data-x-internal=javascript-realm>JavaScript 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>You can, however, manipulate specification-level data structures and values from the WHATWG
  Infra Standard, as those are realm-agnostic. They are never directly exposed to JavaScript without
  a specific conversion taking place (often <a href=https://heycam.github.io/webidl/#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-task id=event-loop-for-spec-authors:queue-a-task-2>queue a 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-task id=event-loop-for-spec-authors:queue-a-task-3>queuing a 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.</p>

  <p>Most invocations of <a href=#queue-a-task id=event-loop-for-spec-authors:queue-a-task-4>queue a task</a> implicitly use "the relevant <a href=#event-loop id=event-loop-for-spec-authors:event-loop-6>event
  loop</a>", i.e., the one that is obvious from context. That is because it is very rare for
  algorithms to be invoked in contexts involving multiple event loops. (Unlike contexts involving
  multiple global objects, which happen all the time!) So unless you are writing a specification
  which, e.g., deals with manipulating <a href=#workers>workers</a>, you can omit this argument
  when <a href=#queue-a-task id=event-loop-for-spec-authors:queue-a-task-5>queuing a task</a>.</p>

  <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 href=https://tc39.github.io/ecma262/#sec-code-realms id=event-loop-for-spec-authors:javascript-realm-2 data-x-internal=javascript-realm>realm</a>-specific JavaScript values into
   realm-agnostic specification-level values.<li><p>Perform a set of potentially-expensive steps <a href=#in-parallel id=event-loop-for-spec-authors:in-parallel-5>in parallel</a>, operating entirely on
   realm-agnostic values, and producing a realm-agnostic result.<li><p><a href=#queue-a-task id=event-loop-for-spec-authors:queue-a-task-6>Queue a task</a>, on a specified <a href=#task-source id=event-loop-for-spec-authors:task-source-3>task source</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>.</ol>

  <div id=example-event-loop-using-algorithm class=example>

   <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>.<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=#parse-a-url id=event-loop-for-spec-authors:parse-a-url>parsing</a>
      <var>string</var> relative to the <a href=#current-settings-object id=event-loop-for-spec-authors:current-settings-object>current settings object</a>.<li><p>If <var>parsed</var> is failure, return a promise rejected with a
      <a id=event-loop-for-spec-authors:syntaxerror href=https://heycam.github.io/webidl/#syntaxerror data-x-internal=syntaxerror>"<code>SyntaxError</code>"</a> <code id=event-loop-for-spec-authors:domexception><a data-x-internal=domexception href=https://heycam.github.io/webidl/#dfn-DOMException>DOMException</a></code>.<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>.<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>.</ol>
    <li><p>Let <var>realm</var> be the <a id=event-loop-for-spec-authors:current-realm-record href=https://tc39.github.io/ecma262/#current-realm data-x-internal=current-realm-record>current Realm Record</a>.<li><p>Let <var>p</var> be a new promise.<li>
     <p>Run the following steps <a href=#in-parallel id=event-loop-for-spec-authors:in-parallel-6>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>.<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.<li><p>Let <var>encrypted</var> be a new <a id=event-loop-for-spec-authors:javascript-string href=https://infra.spec.whatwg.org/#javascript-string data-x-internal=javascript-string>JavaScript 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.<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>
       </ol>
      <li>
       <p><a href=#queue-a-task id=event-loop-for-spec-authors:queue-a-task-7>Queue a task</a>, on the <a href=#networking-task-source id=event-loop-for-spec-authors:networking-task-source>networking task source</a>, to perform the
       following steps:</p>

       <ol><li><p>Let <var>array</var> be the result of <a href=https://heycam.github.io/webidl/#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>.<li><p>Resolve <var>p</var> with <var>array</var>.</ol>
      </ol>
    <li><p>Return <var>p</var>.</ol>

   <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-7>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-8>in
    parallel</a>.<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-9>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.<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/#javascript-string id=event-loop-for-spec-authors:javascript-string-2 data-x-internal=javascript-string>JavaScript
    strings</a> from the initial steps to the <a href=#in-parallel id=event-loop-for-spec-authors:in-parallel-10>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/#javascript-string id=event-loop-for-spec-authors:javascript-string-3 data-x-internal=javascript-string>JavaScript
    strings</a> are <a href=https://tc39.github.io/ecma262/#sec-code-realms id=event-loop-for-spec-authors:javascript-realm-3 data-x-internal=javascript-realm>realm</a>-agnostic.<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-11>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>.<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-12>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-task id=event-loop-for-spec-authors:queue-a-task-8>queued</a> specifically for that purpose.<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.</ul>

   <p>(On these last two points, see also <a href=https://github.com/w3ctag/promises-guide/issues/52>w3ctag/promises-guide#52</a>, <a href=https://github.com/heycam/webidl/issues/135>heycam/webidl#135</a>, and <a href=https://github.com/heycam/webidl/issues/371>heycam/webidl#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://heycam.github.io/webidl/#idl-USVString>USVString</a></code>>, there was an automatic conversion from <a href=https://tc39.github.io/ecma262/#sec-code-realms id=event-loop-for-spec-authors:javascript-realm-4 data-x-internal=javascript-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://heycam.github.io/webidl/#idl-USVString>USVString</a></code>> 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-13>in parallel</a>.</p>

  </div>


  

  <h4 id=events><span class=secno>8.1.5</span> Events<a href=#events class=self-link></a></h4>

  <h5 id=event-handler-attributes><span class=secno>8.1.5.1</span> Event handlers<a href=#event-handler-attributes class=self-link></a></h5>

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

  <ul><li><p>a <dfn id=event-handler-value>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.<li><p>a <dfn id=event-handler-listener>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.</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>

  

  <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>.<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>.<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><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>.</ol>

  <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 id=event-handler-map>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>

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

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

  

  <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>.<li><p>If <var>eventTarget</var> is null, then return null.<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>
  </ol>

  <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>.<li><p>If <var>eventTarget</var> is null, then return.<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>.<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>.<li><p>Let <var>eventHandler</var> be <var>handlerMap</var>[<var>name</var>].<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.<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>.</ol>
   </ol>

  <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-messageport-onmessage><a href=#handler-messageport-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.github.io/ecma262/#prod-FunctionBody>FunctionBody</a></i>
  production after <a id=event-handler-attributes:automatic-semicolon-insertion href=https://tc39.github.io/ecma262/#sec-automatic-semicolon-insertion data-x-internal=automatic-semicolon-insertion>automatic semicolon insertion</a>.</p>

  

  <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.<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>.<li><p>If <var>eventTarget</var> is null, then return.<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>.<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><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>.<li><p>Let <var>eventHandler</var> be <var>handlerMap</var>[<var>localName</var>].<li><p>Let <var>location</var> be the script location that triggered the execution of these
     steps.<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>.<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>.</ol>
   </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>

  <hr>

  <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>.<li><p>Let <var>eventHandler</var> be <var>handlerMap</var>[<var>name</var>].<li><p>Set <var>eventHandler</var>'s <a href=#event-handler-value id=event-handler-attributes:event-handler-value-4>value</a> to
   null.<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>.<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>.<li><p>Set <var>eventHandler</var>'s <a href=#event-handler-listener id=event-handler-attributes:event-handler-listener-3>listener</a> to
   null.</ol>

  <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>.<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>.</ol>

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

  <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>.<li><p>Let <var>eventHandler</var> be <var>handlerMap</var>[<var>name</var>].<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.<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://heycam.github.io/webidl/#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>
    <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><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>.<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>.</ol>

  <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<li><p>then the callback to which it is currently set, if any<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.</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>&quot;test&quot;</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>&apos;test&apos;</c-><c- p>);</c->
 button<c- p>.</c->addEventListener<c- p>(</c-><c- t>&apos;click&apos;</c-><c- p>,</c-> <c- a>function</c-> <c- p>()</c-> <c- p>{</c-> alert<c- p>(</c-><c- t>&apos;ONE&apos;</c-><c- p>)</c-> <c- p>},</c-> <c- kc>false</c-><c- p>);</c->
 button<c- p>.</c->setAttribute<c- p>(</c-><c- t>&apos;onclick&apos;</c-><c- p>,</c-> <c- u>&quot;alert(&apos;NOT CALLED&apos;)&quot;</c-><c- p>);</c-> <c- c1>// event handler listener is registered here</c->
 button<c- p>.</c->addEventListener<c- p>(</c-><c- t>&apos;click&apos;</c-><c- p>,</c-> <c- a>function</c-> <c- p>()</c-> <c- p>{</c-> alert<c- p>(</c-><c- t>&apos;THREE&apos;</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>&apos;TWO&apos;</c-><c- p>);</c-> <c- p>};</c->
 button<c- p>.</c->addEventListener<c- p>(</c-><c- t>&apos;click&apos;</c-><c- p>,</c-> <c- a>function</c-> <c- p>()</c-> <c- p>{</c-> alert<c- p>(</c-><c- t>&apos;FOUR&apos;</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>&quot;test&quot;</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>&apos;test&apos;</c-><c- p>);</c->
 button<c- p>.</c->addEventListener<c- p>(</c-><c- t>&apos;click&apos;</c-><c- p>,</c-> <c- a>function</c-> <c- p>()</c-> <c- p>{</c-> alert<c- p>(</c-><c- t>&apos;ONE&apos;</c-><c- p>)</c-> <c- p>},</c-> <c- kc>false</c-><c- p>);</c->
 button<c- p>.</c->setAttribute<c- p>(</c-><c- t>&apos;onclick&apos;</c-><c- p>,</c-> <c- u>&quot;alert(&apos;NOT CALLED&apos;)&quot;</c-><c- p>);</c-> <c- c1>// event handler is activated here</c->
 button<c- p>.</c->addEventListener<c- p>(</c-><c- t>&apos;click&apos;</c-><c- p>,</c-> <c- a>function</c-> <c- p>()</c-> <c- p>{</c-> alert<c- p>(</c-><c- t>&apos;TWO&apos;</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>&apos;click&apos;</c-><c- p>,</c-> <c- a>function</c-> <c- p>()</c-> <c- p>{</c-> alert<c- p>(</c-><c- t>&apos;THREE&apos;</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>&apos;FOUR&apos;</c-><c- p>);</c-> <c- p>};</c->       <c- c1>// and re-activated here</c->
 button<c- p>.</c->addEventListener<c- p>(</c-><c- t>&apos;click&apos;</c-><c- p>,</c-> <c- a>function</c-> <c- p>()</c-> <c- p>{</c-> alert<c- p>(</c-><c- t>&apos;FIVE&apos;</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>

  <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>.<li><p>If <var>callback</var> is null, then return.<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.<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<dd>

      <p><a href=https://heycam.github.io/webidl/#invoke-a-callback-function id=event-handler-attributes:es-invoking-callback-functions data-x-internal=es-invoking-callback-functions>Invoke</a> <var>callback</var> with five
      arguments, the first one having the value of <var>event</var>'s <code id=event-handler-attributes:dom-errorevent-message><a href=#dom-errorevent-message>message</a></code> attribute, the second having the value of
      <var>event</var>'s <code id=event-handler-attributes:dom-errorevent-filename><a href=#dom-errorevent-filename>filename</a></code> attribute, the third
      having the value of <var>event</var>'s <code id=event-handler-attributes:dom-errorevent-lineno><a href=#dom-errorevent-lineno>lineno</a></code>
      attribute, the fourth having the value of <var>event</var>'s <code id=event-handler-attributes:dom-errorevent-colno><a href=#dom-errorevent-colno>colno</a></code> attribute, the fifth having the value of
      <var>event</var>'s <code id=event-handler-attributes:dom-errorevent-error><a href=#dom-errorevent-error>error</a></code> attribute, and with the <i id=event-handler-attributes:dfn-callback-this-value><a data-x-internal=dfn-callback-this-value href=https://heycam.github.io/webidl/#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>. Let <var>return value</var> be the
      callback's return value. <a href=#refsWEBIDL>[WEBIDL]</a></p>

     <dt>Otherwise<dd>

      <p><a href=https://heycam.github.io/webidl/#invoke-a-callback-function id=event-handler-attributes:es-invoking-callback-functions-2 data-x-internal=es-invoking-callback-functions>Invoke</a> <var>callback</var>
      with one argument, the value of which is the <code id=event-handler-attributes:event-3><a data-x-internal=event href=https://dom.spec.whatwg.org/#interface-event>Event</a></code> object <var>event</var>,
      with the <i id=event-handler-attributes:dfn-callback-this-value-2><a data-x-internal=dfn-callback-this-value href=https://heycam.github.io/webidl/#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>. Let <var>return value</var> be
      the callback's return value. <a href=#refsWEBIDL>[WEBIDL]</a></p>

     </dl>

    <p>If an exception gets thrown by the callback, end these steps and allow the exception to
    propagate. (It 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-the-exception id=event-handler-attributes:report-the-exception>report the exception</a>.)</p>

   <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><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://heycam.github.io/webidl/#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>.<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>.</ol>
     <dt>If <var>special error event handling</var> is true<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>.<dt>Otherwise<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://heycam.github.io/webidl/#idl-DOMString>DOMString</a></code>.</p>
     </dl>

   </ol>

  

  <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'>[<c- g>TreatNonObjectAsNull</c->]
<c- b>callback</c-> <dfn id='eventhandlernonnull'><c- g>EventHandlerNonNull</c-></dfn> = <c- b>any</c-> (<a href='https://dom.spec.whatwg.org/#interface-event' data-x-internal='event' id='event-handler-attributes:event-4'><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'><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://heycam.github.io/webidl/#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>&quot;alert(this)&quot;</c-> <c- e>onclick</c-><c- o>=</c-><c- s>&quot;alert(this)&quot;</c-><c- p>&gt;</c-></code></pre>

   <p>...leads to an alert saying "<code>[object Window]</code>" when the document is
   loaded, and an alert saying "<code>[object 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<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.</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'>[<c- g>TreatNonObjectAsNull</c->]
<c- b>callback</c-> <dfn id='onerroreventhandlernonnull'><c- g>OnErrorEventHandlerNonNull</c-></dfn> = <c- b>any</c-> ((<a href='https://dom.spec.whatwg.org/#interface-event' data-x-internal='event' id='event-handler-attributes:event-5'><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'><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'>[<c- g>TreatNonObjectAsNull</c->]
<c- b>callback</c-> <dfn id='onbeforeunloadeventhandlernonnull'><c- g>OnBeforeUnloadEventHandlerNonNull</c-></dfn> = <c- b>DOMString</c->? (<a href='https://dom.spec.whatwg.org/#interface-event' data-x-internal='event' id='event-handler-attributes:event-6'><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'><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 class=brief><li>An uncompiled script body

   <li>A location where the script body originated, in case an error needs to be reported

  </ul>

  <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>.<li><p>Let <var>eventHandler</var> be <var>handlerMap</var>[<var>name</var>].<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>.<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.<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>.<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>.<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.<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>.<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.github.io/ecma262/#prod-FunctionBody>FunctionBody</a></i>
      or if parsing detects an <a id=event-handler-attributes:early-error href=https://tc39.github.io/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><p><a href=#report-the-error id=event-handler-attributes:report-the-error>Report the error</a> for the appropriate <a href=#concept-script id=event-handler-attributes:concept-script>script</a> and with the appropriate position (line number and
       column number) given by <var>location</var>, using <var>settings object</var>'s <a href=#concept-settings-object-global id=event-handler-attributes:concept-settings-object-global>global object</a>. If the error is still <i id=event-handler-attributes:concept-error-nothandled><a href=#concept-error-nothandled>not handled</a></i> after this, then the error may be reported
       to a developer console.<li><p>Return null.</ol>

     <li>

      <p>If <var>body</var> begins with a <a id=event-handler-attributes:directive-prologue href=https://tc39.github.io/ecma262/#directive-prologue data-x-internal=directive-prologue>Directive Prologue</a> that contains a <a id=event-handler-attributes:use-strict-directive href=https://tc39.github.io/ecma262/#use-strict-directive data-x-internal=use-strict-directive>Use
      Strict Directive</a> then let <var>strict</var> be true, otherwise let <var>strict</var>
      be false.</p> 

     <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.github.io/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.github.io/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.github.io/ecma262/#sec-functioncreate id=event-handler-attributes:js-functioncreate data-x-internal=js-functioncreate>FunctionCreate</a> takes place in the correct <a id=event-handler-attributes:javascript-realm href=https://tc39.github.io/ecma262/#sec-code-realms data-x-internal=javascript-realm>JavaScript
      Realm</a>.</p>
     <li>

      <p>Let <var>function</var> be the result of calling <a href=https://tc39.github.io/ecma262/#sec-functioncreate id=event-handler-attributes:js-functioncreate-2 data-x-internal=js-functioncreate>FunctionCreate</a>, with arguments:</p>

      <dl><dt><var>kind</var><dd>Normal<dt><var>ParameterList</var><dd>

        <dl class=switch><dt>If <var>eventHandler</var> is an <code id=event-handler-attributes:handler-onerror-3><a href=#handler-onerror>onerror</a></code> <a href=#event-handlers id=event-handler-attributes:event-handlers-33>event handler</a> of a <code id=event-handler-attributes:window-6><a href=#window>Window</a></code> object<dd>Let the function have five arguments, named <code>event</code>, <code>source</code>, <code>lineno</code>, <code>colno</code>, and
         <code>error</code>.<dt>Otherwise<dd>Let the function have a single argument called <code>event</code>.</dl>

       <dt><var>Body</var><dd>The result of parsing <var>body</var> above.<dt><var>Scope</var><dd>

        <ol><li>

          <p>If <var>eventHandler</var> is an element's <a href=#event-handlers id=event-handler-attributes:event-handlers-34>event
          handler</a>, then let <var>Scope</var> be <a href=https://tc39.github.io/ecma262/#sec-newobjectenvironment id=event-handler-attributes:js-newobjectenvironment data-x-internal=js-newobjectenvironment>NewObjectEnvironment</a>(<var>document</var>,
          the <var>global environment</var>).</p>

          <p>Otherwise, <var>eventHandler</var> is a <code id=event-handler-attributes:window-7><a href=#window>Window</a></code> object's <a href=#event-handlers id=event-handler-attributes:event-handlers-35>event handler</a>: let <var>Scope</var> be the <var>global environment</var>.</p>

         <li><p>If <var>form owner</var> is not null, let <var>Scope</var> be
         <a href=https://tc39.github.io/ecma262/#sec-newobjectenvironment id=event-handler-attributes:js-newobjectenvironment-2 data-x-internal=js-newobjectenvironment>NewObjectEnvironment</a>(<var>form owner</var>,
         <var>Scope</var>).<li><p>If <var>element</var> is not null, let <var>Scope</var> be <a href=https://tc39.github.io/ecma262/#sec-newobjectenvironment id=event-handler-attributes:js-newobjectenvironment-3 data-x-internal=js-newobjectenvironment>NewObjectEnvironment</a>(<var>element</var>,
         <var>Scope</var>).</ol>

       <dt><var>Strict</var><dd>The value of <var>strict</var>.</dl>

     <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.github.io/ecma262/#execution-context-stack data-x-internal=javascript-execution-context-stack>JavaScript execution context stack</a>.<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://heycam.github.io/webidl/#dfn-callback-context data-x-internal=callback-context>callback context</a> is <var>settings
     object</var>.</ol>

   <li><p>Return <var>eventHandler</var>'s <a href=#event-handler-value id=event-handler-attributes:event-handler-value-13>value</a>.</ol>

  



  <h5 id=event-handlers-on-elements,-document-objects,-and-window-objects><span class=secno>8.1.5.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><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>
   <tbody><tr><td><dfn data-dfn-for=HTMLElement,Document,Window,GlobalEventHandlers id=handler-onabort data-dfn-type=attribute data-export=""><code>onabort</code></dfn> <td> <code id=event-handlers-on-elements,-document-objects,-and-window-objects:event-abort><a href=#event-abort>abort</a></code>
    <tr><td><dfn data-dfn-for=HTMLElement,Document,Window,GlobalEventHandlers id=handler-onauxclick data-dfn-type=attribute data-export=""><code>onauxclick</code></dfn> <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>
    <tr><td><dfn data-dfn-for=HTMLElement,Document,Window,GlobalEventHandlers id=handler-oncancel data-dfn-type=attribute data-export=""><code>oncancel</code></dfn> <td> <code id=event-handlers-on-elements,-document-objects,-and-window-objects:event-cancel><a href=#event-cancel>cancel</a></code>
    <tr><td><dfn data-dfn-for=HTMLElement,Document,Window,GlobalEventHandlers id=handler-oncanplay data-dfn-type=attribute data-export=""><code>oncanplay</code></dfn> <td> <code id=event-handlers-on-elements,-document-objects,-and-window-objects:event-media-canplay><a href=#event-media-canplay>canplay</a></code>
    <tr><td><dfn data-dfn-for=HTMLElement,Document,Window,GlobalEventHandlers id=handler-oncanplaythrough data-dfn-type=attribute data-export=""><code>oncanplaythrough</code></dfn> <td> <code id=event-handlers-on-elements,-document-objects,-and-window-objects:event-media-canplaythrough><a href=#event-media-canplaythrough>canplaythrough</a></code>
    <tr><td><dfn data-dfn-for=HTMLElement,Document,Window,GlobalEventHandlers id=handler-onchange data-dfn-type=attribute data-export=""><code>onchange</code></dfn> <td> <code id=event-handlers-on-elements,-document-objects,-and-window-objects:event-change><a href=#event-change>change</a></code> 
    <tr><td><dfn data-dfn-for=HTMLElement,Document,Window,GlobalEventHandlers id=handler-onclick data-dfn-type=attribute data-export=""><code>onclick</code></dfn> <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> 
    <tr><td><dfn data-dfn-for=HTMLElement,Document,Window,GlobalEventHandlers id=handler-onclose data-dfn-type=attribute data-export=""><code>onclose</code></dfn> <td> <code id=event-handlers-on-elements,-document-objects,-and-window-objects:event-close><a href=#event-close>close</a></code> 
    <tr><td><dfn data-dfn-for=HTMLElement,Document,Window,GlobalEventHandlers id=handler-oncontextmenu data-dfn-type=attribute data-export=""><code>oncontextmenu</code></dfn> <td> <code id=event-handlers-on-elements,-document-objects,-and-window-objects:event-contextmenu><a href=#event-contextmenu>contextmenu</a></code> 
    <tr><td><dfn data-dfn-for=HTMLElement,Document,Window,GlobalEventHandlers id=handler-oncuechange data-dfn-type=attribute data-export=""><code>oncuechange</code></dfn> <td> <code id=event-handlers-on-elements,-document-objects,-and-window-objects:event-media-cuechange><a href=#event-media-cuechange>cuechange</a></code>
    <tr><td><dfn data-dfn-for=HTMLElement,Document,Window,GlobalEventHandlers id=handler-ondblclick data-dfn-type=attribute data-export=""><code>ondblclick</code></dfn> <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> 
    <tr><td><dfn data-dfn-for=HTMLElement,Document,Window,GlobalEventHandlers id=handler-ondrag data-dfn-type=attribute data-export=""><code>ondrag</code></dfn> <td> <code id=event-handlers-on-elements,-document-objects,-and-window-objects:event-dnd-drag><a href=#event-dnd-drag>drag</a></code>
    <tr><td><dfn data-dfn-for=HTMLElement,Document,Window,GlobalEventHandlers id=handler-ondragend data-dfn-type=attribute data-export=""><code>ondragend</code></dfn> <td> <code id=event-handlers-on-elements,-document-objects,-and-window-objects:event-dnd-dragend><a href=#event-dnd-dragend>dragend</a></code>
    <tr><td><dfn data-dfn-for=HTMLElement,Document,Window,GlobalEventHandlers id=handler-ondragenter data-dfn-type=attribute data-export=""><code>ondragenter</code></dfn> <td> <code id=event-handlers-on-elements,-document-objects,-and-window-objects:event-dnd-dragenter><a href=#event-dnd-dragenter>dragenter</a></code>
    <tr><td><dfn data-dfn-for=HTMLElement,Document,Window,GlobalEventHandlers id=handler-ondragexit data-dfn-type=attribute data-export=""><code>ondragexit</code></dfn> <td> <code id=event-handlers-on-elements,-document-objects,-and-window-objects:event-dnd-dragexit><a href=#event-dnd-dragexit>dragexit</a></code>
    <tr><td><dfn data-dfn-for=HTMLElement,Document,Window,GlobalEventHandlers id=handler-ondragleave data-dfn-type=attribute data-export=""><code>ondragleave</code></dfn> <td> <code id=event-handlers-on-elements,-document-objects,-and-window-objects:event-dnd-dragleave><a href=#event-dnd-dragleave>dragleave</a></code>
    <tr><td><dfn data-dfn-for=HTMLElement,Document,Window,GlobalEventHandlers id=handler-ondragover data-dfn-type=attribute data-export=""><code>ondragover</code></dfn> <td> <code id=event-handlers-on-elements,-document-objects,-and-window-objects:event-dnd-dragover><a href=#event-dnd-dragover>dragover</a></code>
    <tr><td><dfn data-dfn-for=HTMLElement,Document,Window,GlobalEventHandlers id=handler-ondragstart data-dfn-type=attribute data-export=""><code>ondragstart</code></dfn> <td> <code id=event-handlers-on-elements,-document-objects,-and-window-objects:event-dnd-dragstart><a href=#event-dnd-dragstart>dragstart</a></code> 
    <tr><td><dfn data-dfn-for=HTMLElement,Document,Window,GlobalEventHandlers id=handler-ondrop data-dfn-type=attribute data-export=""><code>ondrop</code></dfn> <td> <code id=event-handlers-on-elements,-document-objects,-and-window-objects:event-dnd-drop><a href=#event-dnd-drop>drop</a></code>
    <tr><td><dfn data-dfn-for=HTMLElement,Document,Window,GlobalEventHandlers id=handler-ondurationchange data-dfn-type=attribute data-export=""><code>ondurationchange</code></dfn> <td> <code id=event-handlers-on-elements,-document-objects,-and-window-objects:event-media-durationchange><a href=#event-media-durationchange>durationchange</a></code>
    <tr><td><dfn data-dfn-for=HTMLElement,Document,Window,GlobalEventHandlers id=handler-onemptied data-dfn-type=attribute data-export=""><code>onemptied</code></dfn> <td> <code id=event-handlers-on-elements,-document-objects,-and-window-objects:event-media-emptied><a href=#event-media-emptied>emptied</a></code>
    <tr><td><dfn data-dfn-for=HTMLElement,Document,Window,GlobalEventHandlers id=handler-onended data-dfn-type=attribute data-export=""><code>onended</code></dfn> <td> <code id=event-handlers-on-elements,-document-objects,-and-window-objects:event-media-ended><a href=#event-media-ended>ended</a></code>
    <tr><td><dfn data-dfn-for=HTMLElement,Document,Window,GlobalEventHandlers id=handler-oninput data-dfn-type=attribute data-export=""><code>oninput</code></dfn> <td> <code id=event-handlers-on-elements,-document-objects,-and-window-objects:event-input><a href=#event-input>input</a></code>
    <tr><td><dfn data-dfn-for=HTMLElement,Document,Window,GlobalEventHandlers id=handler-oninvalid data-dfn-type=attribute data-export=""><code>oninvalid</code></dfn> <td> <code id=event-handlers-on-elements,-document-objects,-and-window-objects:event-invalid><a href=#event-invalid>invalid</a></code>
    <tr><td><dfn data-dfn-for=HTMLElement,Document,Window,GlobalEventHandlers id=handler-onkeydown data-dfn-type=attribute data-export=""><code>onkeydown</code></dfn> <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> 
    <tr><td><dfn data-dfn-for=HTMLElement,Document,Window,GlobalEventHandlers id=handler-onkeypress data-dfn-type=attribute data-export=""><code>onkeypress</code></dfn> <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> 
    <tr><td><dfn data-dfn-for=HTMLElement,Document,Window,GlobalEventHandlers id=handler-onkeyup data-dfn-type=attribute data-export=""><code>onkeyup</code></dfn> <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> 
    <tr><td><dfn data-dfn-for=HTMLElement,Document,Window,GlobalEventHandlers id=handler-onloadeddata data-dfn-type=attribute data-export=""><code>onloadeddata</code></dfn> <td> <code id=event-handlers-on-elements,-document-objects,-and-window-objects:event-media-loadeddata><a href=#event-media-loadeddata>loadeddata</a></code>
    <tr><td><dfn data-dfn-for=HTMLElement,Document,Window,GlobalEventHandlers id=handler-onloadedmetadata data-dfn-type=attribute data-export=""><code>onloadedmetadata</code></dfn> <td> <code id=event-handlers-on-elements,-document-objects,-and-window-objects:event-media-loadedmetadata><a href=#event-media-loadedmetadata>loadedmetadata</a></code>
    <tr><td><dfn data-dfn-for=HTMLElement,Document,Window,GlobalEventHandlers id=handler-onloadend data-dfn-type=attribute data-export=""><code>onloadend</code></dfn> <td> <code id=event-handlers-on-elements,-document-objects,-and-window-objects:event-loadend><a href=#event-loadend>loadend</a></code>
    <tr><td><dfn data-dfn-for=HTMLElement,Document,Window,GlobalEventHandlers id=handler-onloadstart data-dfn-type=attribute data-export=""><code>onloadstart</code></dfn> <td> <code id=event-handlers-on-elements,-document-objects,-and-window-objects:event-media-loadstart><a href=#event-media-loadstart>loadstart</a></code>
    <tr><td><dfn data-dfn-for=HTMLElement,Document,Window,GlobalEventHandlers id=handler-onmousedown data-dfn-type=attribute data-export=""><code>onmousedown</code></dfn> <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> 
    <tr><td><dfn data-dfn-for=HTMLElement,Document,Window,GlobalEventHandlers id=handler-onmouseenter data-dfn-type=attribute data-export=""><code>onmouseenter</code></dfn> <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> 
    <tr><td><dfn data-dfn-for=HTMLElement,Document,Window,GlobalEventHandlers id=handler-onmouseleave data-dfn-type=attribute data-export=""><code>onmouseleave</code></dfn> <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> 
    <tr><td><dfn data-dfn-for=HTMLElement,Document,Window,GlobalEventHandlers id=handler-onmousemove data-dfn-type=attribute data-export=""><code>onmousemove</code></dfn> <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> 
    <tr><td><dfn data-dfn-for=HTMLElement,Document,Window,GlobalEventHandlers id=handler-onmouseout data-dfn-type=attribute data-export=""><code>onmouseout</code></dfn> <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> 
    <tr><td><dfn data-dfn-for=HTMLElement,Document,Window,GlobalEventHandlers id=handler-onmouseover data-dfn-type=attribute data-export=""><code>onmouseover</code></dfn> <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> 
    <tr><td><dfn data-dfn-for=HTMLElement,Document,Window,GlobalEventHandlers id=handler-onmouseup data-dfn-type=attribute data-export=""><code>onmouseup</code></dfn> <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> 
    <tr><td><dfn data-dfn-for=HTMLElement,Document,Window,GlobalEventHandlers id=handler-onwheel data-dfn-type=attribute data-export=""><code>onwheel</code></dfn> <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> 
    <tr><td><dfn data-dfn-for=HTMLElement,Document,Window,GlobalEventHandlers id=handler-onpause data-dfn-type=attribute data-export=""><code>onpause</code></dfn> <td> <code id=event-handlers-on-elements,-document-objects,-and-window-objects:event-media-pause><a href=#event-media-pause>pause</a></code>
    <tr><td><dfn data-dfn-for=HTMLElement,Document,Window,GlobalEventHandlers id=handler-onplay data-dfn-type=attribute data-export=""><code>onplay</code></dfn> <td> <code id=event-handlers-on-elements,-document-objects,-and-window-objects:event-media-play><a href=#event-media-play>play</a></code>
    <tr><td><dfn data-dfn-for=HTMLElement,Document,Window,GlobalEventHandlers id=handler-onplaying data-dfn-type=attribute data-export=""><code>onplaying</code></dfn> <td> <code id=event-handlers-on-elements,-document-objects,-and-window-objects:event-media-playing><a href=#event-media-playing>playing</a></code>
    <tr><td><dfn data-dfn-for=HTMLElement,Document,Window,GlobalEventHandlers id=handler-onprogress data-dfn-type=attribute data-export=""><code>onprogress</code></dfn> <td> <code id=event-handlers-on-elements,-document-objects,-and-window-objects:event-media-progress><a href=#event-media-progress>progress</a></code>
    <tr><td><dfn data-dfn-for=HTMLElement,Document,Window,GlobalEventHandlers id=handler-onratechange data-dfn-type=attribute data-export=""><code>onratechange</code></dfn> <td> <code id=event-handlers-on-elements,-document-objects,-and-window-objects:event-media-ratechange><a href=#event-media-ratechange>ratechange</a></code>
    <tr><td><dfn data-dfn-for=HTMLElement,Document,Window,GlobalEventHandlers id=handler-onreset data-dfn-type=attribute data-export=""><code>onreset</code></dfn> <td> <code id=event-handlers-on-elements,-document-objects,-and-window-objects:event-reset><a href=#event-reset>reset</a></code>
    <tr><td><dfn data-dfn-for=HTMLElement,Document,Window,GlobalEventHandlers id=handler-onsecuritypolicyviolation data-dfn-type=attribute data-export=""><code>onsecuritypolicyviolation</code></dfn> <td> <code id=event-handlers-on-elements,-document-objects,-and-window-objects:event-securitypolicyviolation><a href=#event-securitypolicyviolation>securitypolicyviolation</a></code>
    <tr><td><dfn data-dfn-for=HTMLElement,Document,Window,GlobalEventHandlers id=handler-onseeked data-dfn-type=attribute data-export=""><code>onseeked</code></dfn> <td> <code id=event-handlers-on-elements,-document-objects,-and-window-objects:event-media-seeked><a href=#event-media-seeked>seeked</a></code>
    <tr><td><dfn data-dfn-for=HTMLElement,Document,Window,GlobalEventHandlers id=handler-onseeking data-dfn-type=attribute data-export=""><code>onseeking</code></dfn> <td> <code id=event-handlers-on-elements,-document-objects,-and-window-objects:event-media-seeking><a href=#event-media-seeking>seeking</a></code>
    <tr><td><dfn data-dfn-for=HTMLElement,Document,Window,GlobalEventHandlers id=handler-onselect data-dfn-type=attribute data-export=""><code>onselect</code></dfn> <td> <code id=event-handlers-on-elements,-document-objects,-and-window-objects:event-select><a href=#event-select>select</a></code>  
    <tr><td><dfn data-dfn-for=HTMLElement,Document,Window,GlobalEventHandlers id=handler-onstalled data-dfn-type=attribute data-export=""><code>onstalled</code></dfn> <td> <code id=event-handlers-on-elements,-document-objects,-and-window-objects:event-media-stalled><a href=#event-media-stalled>stalled</a></code>
    <tr><td><dfn data-dfn-for=HTMLElement,Document,Window,GlobalEventHandlers id=handler-onsubmit data-dfn-type=attribute data-export=""><code>onsubmit</code></dfn> <td> <code id=event-handlers-on-elements,-document-objects,-and-window-objects:event-submit><a href=#event-submit>submit</a></code> 
    <tr><td><dfn data-dfn-for=HTMLElement,Document,Window,GlobalEventHandlers id=handler-onsuspend data-dfn-type=attribute data-export=""><code>onsuspend</code></dfn> <td> <code id=event-handlers-on-elements,-document-objects,-and-window-objects:event-media-suspend><a href=#event-media-suspend>suspend</a></code>
    <tr><td><dfn data-dfn-for=HTMLElement,Document,Window,GlobalEventHandlers id=handler-ontimeupdate data-dfn-type=attribute data-export=""><code>ontimeupdate</code></dfn> <td> <code id=event-handlers-on-elements,-document-objects,-and-window-objects:event-media-timeupdate><a href=#event-media-timeupdate>timeupdate</a></code>
    <tr><td><dfn data-dfn-for=HTMLElement,Document,Window,GlobalEventHandlers id=handler-ontoggle data-dfn-type=attribute data-export=""><code>ontoggle</code></dfn> <td> <code id=event-handlers-on-elements,-document-objects,-and-window-objects:event-toggle><a href=#event-toggle>toggle</a></code>
    <tr><td><dfn data-dfn-for=HTMLElement,Document,Window,GlobalEventHandlers id=handler-onvolumechange data-dfn-type=attribute data-export=""><code>onvolumechange</code></dfn> <td> <code id=event-handlers-on-elements,-document-objects,-and-window-objects:event-media-volumechange><a href=#event-media-volumechange>volumechange</a></code>
    <tr><td><dfn data-dfn-for=HTMLElement,Document,Window,GlobalEventHandlers id=handler-onwaiting data-dfn-type=attribute data-export=""><code>onwaiting</code></dfn> <td> <code id=event-handlers-on-elements,-document-objects,-and-window-objects:event-media-waiting><a href=#event-media-waiting>waiting</a></code>


 
 
 

 
  </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><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>
   <tbody><tr><td><dfn id=handler-onblur><code>onblur</code></dfn> <td> <code id=event-handlers-on-elements,-document-objects,-and-window-objects:event-blur><a href=#event-blur>blur</a></code> 
    <tr><td><dfn id=handler-onerror><code>onerror</code></dfn> <td> <code id=event-handlers-on-elements,-document-objects,-and-window-objects:event-error><a href=#event-error>error</a></code>
    <tr><td><dfn id=handler-onfocus><code>onfocus</code></dfn> <td> <code id=event-handlers-on-elements,-document-objects,-and-window-objects:event-focus><a href=#event-focus>focus</a></code> 
    <tr><td><dfn id=handler-onload><code>onload</code></dfn> <td> <code id=event-handlers-on-elements,-document-objects,-and-window-objects:event-load><a href=#event-load>load</a></code>
    <tr><td><dfn id=handler-onresize><code>onresize</code></dfn> <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>
    <tr><td><dfn id=handler-onscroll><code>onscroll</code></dfn> <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>
  </table>

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

  <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><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>
   <tbody><tr><td><dfn id=handler-window-onafterprint><code>onafterprint</code></dfn> <td> <code id=event-handlers-on-elements,-document-objects,-and-window-objects:event-afterprint><a href=#event-afterprint>afterprint</a></code>
    <tr><td><dfn id=handler-window-onbeforeprint><code>onbeforeprint</code></dfn> <td> <code id=event-handlers-on-elements,-document-objects,-and-window-objects:event-beforeprint><a href=#event-beforeprint>beforeprint</a></code>
    <tr><td><dfn id=handler-window-onbeforeunload><code>onbeforeunload</code></dfn> <td> <code id=event-handlers-on-elements,-document-objects,-and-window-objects:event-beforeunload><a href=#event-beforeunload>beforeunload</a></code>
    <tr><td><dfn id=handler-window-onhashchange><code>onhashchange</code></dfn> <td> <code id=event-handlers-on-elements,-document-objects,-and-window-objects:event-hashchange><a href=#event-hashchange>hashchange</a></code> 
    <tr><td><dfn id=handler-window-onlanguagechange><code>onlanguagechange</code></dfn> <td> <code id=event-handlers-on-elements,-document-objects,-and-window-objects:event-languagechange><a href=#event-languagechange>languagechange</a></code> 
    <tr><td><dfn id=handler-window-onmessage><code>onmessage</code></dfn> <td> <code id=event-handlers-on-elements,-document-objects,-and-window-objects:event-message><a href=#event-message>message</a></code> 
    <tr><td><dfn id=handler-window-onmessageerror><code>onmessageerror</code></dfn> <td> <code id=event-handlers-on-elements,-document-objects,-and-window-objects:event-messageerror><a href=#event-messageerror>messageerror</a></code> 
    <tr><td><dfn id=handler-window-onoffline><code>onoffline</code></dfn> <td> <code id=event-handlers-on-elements,-document-objects,-and-window-objects:event-offline><a href=#event-offline>offline</a></code> 
    <tr><td><dfn id=handler-window-ononline><code>ononline</code></dfn> <td> <code id=event-handlers-on-elements,-document-objects,-and-window-objects:event-online><a href=#event-online>online</a></code> 
    <tr><td><dfn id=handler-window-onpagehide><code>onpagehide</code></dfn> <td> <code id=event-handlers-on-elements,-document-objects,-and-window-objects:event-pagehide><a href=#event-pagehide>pagehide</a></code> 
    <tr><td><dfn id=handler-window-onpageshow><code>onpageshow</code></dfn> <td> <code id=event-handlers-on-elements,-document-objects,-and-window-objects:event-pageshow><a href=#event-pageshow>pageshow</a></code> 
    <tr><td><dfn id=handler-window-onpopstate><code>onpopstate</code></dfn> <td> <code id=event-handlers-on-elements,-document-objects,-and-window-objects:event-popstate><a href=#event-popstate>popstate</a></code> 
    <tr><td><dfn id=handler-window-onrejectionhandled><code>onrejectionhandled</code></dfn> <td> <code id=event-handlers-on-elements,-document-objects,-and-window-objects:event-rejectionhandled><a href=#event-rejectionhandled>rejectionhandled</a></code>
    <tr><td><dfn id=handler-window-onstorage><code>onstorage</code></dfn> <td> <code id=event-handlers-on-elements,-document-objects,-and-window-objects:event-storage><a href=#event-storage>storage</a></code> 
    <tr><td><dfn id=handler-window-onunhandledrejection><code>onunhandledrejection</code></dfn> <td> <code id=event-handlers-on-elements,-document-objects,-and-window-objects:event-unhandledrejection><a href=#event-unhandledrejection>unhandledrejection</a></code>
    <tr><td><dfn id=handler-window-onunload><code>onunload</code></dfn> <td> <code id=event-handlers-on-elements,-document-objects,-and-window-objects:event-unload><a href=#event-unload>unload</a></code> 
  </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 by all <a href=#html-elements id=event-handlers-on-elements,-document-objects,-and-window-objects:html-elements-3>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-5>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-10>event handler IDL attributes</a>; and that must be
  supported by all <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-11>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><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>
   <tbody><tr><td><dfn id=handler-oncut><code>oncut</code></dfn> <td> <code id=event-handlers-on-elements,-document-objects,-and-window-objects:event-cut><a href=#event-cut>cut</a></code>
    <tr><td><dfn id=handler-oncopy><code>oncopy</code></dfn> <td> <code id=event-handlers-on-elements,-document-objects,-and-window-objects:event-copy><a href=#event-copy>copy</a></code>
    <tr><td><dfn id=handler-onpaste><code>onpaste</code></dfn> <td> <code id=event-handlers-on-elements,-document-objects,-and-window-objects:event-paste><a href=#event-paste>paste</a></code>
  </table>

  <p>This list of <a href=#event-handlers id=event-handlers-on-elements,-document-objects,-and-window-objects:event-handlers-11>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-12>event handler IDL
  attributes</a> through the <code id=event-handlers-on-elements,-document-objects,-and-window-objects:documentandelementeventhandlers><a href=#documentandelementeventhandlers>DocumentAndElementEventHandlers</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-12>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-9>event handler event types</a>) that must be
  supported on <code id=event-handlers-on-elements,-document-objects,-and-window-objects:document-5><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-13>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-13>Event handler</a> <th><a href=#event-handler-event-type id=event-handlers-on-elements,-document-objects,-and-window-objects:event-handler-event-type-10>Event handler event type</a>
   <tbody><tr><td><dfn data-dfn-for=Document id=handler-onreadystatechange data-dfn-type=attribute data-export=""><code>onreadystatechange</code></dfn> <td> <code id=event-handlers-on-elements,-document-objects,-and-window-objects:event-readystatechange><a href=#event-readystatechange>readystatechange</a></code>
  </table>


  

  <h6 id=idl-definitions><span class=secno>8.1.5.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'><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-onblur' id='idl-definitions:handler-onblur'><c- g>onblur</c-></a>;
  <c- b>attribute</c-> <a href='#eventhandler' id='idl-definitions:eventhandler-4'><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-5'><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-6'><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-7'><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-8'><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-9'><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-10'><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-11'><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-12'><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-13'><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-14'><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-15'><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-16'><c- n>EventHandler</c-></a> <a href='#handler-ondragexit' id='idl-definitions:handler-ondragexit'><c- g>ondragexit</c-></a>;
  <c- b>attribute</c-> <a href='#eventhandler' id='idl-definitions:eventhandler-17'><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-18'><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-19'><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-20'><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-21'><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-22'><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-23'><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-24'><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-25'><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-26'><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-27'><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-28'><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-29'><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-30'><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-31'><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-32'><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-33'><c- n>EventHandler</c-></a> <a href='#handler-onloadend' id='idl-definitions:handler-onloadend'><c- g>onloadend</c-></a>;
  <c- b>attribute</c-> <a href='#eventhandler' id='idl-definitions:eventhandler-34'><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-35'><c- n>EventHandler</c-></a> <a href='#handler-onmousedown' id='idl-definitions:handler-onmousedown'><c- g>onmousedown</c-></a>;
  [<c- g>LenientThis</c->] <c- b>attribute</c-> <a href='#eventhandler' id='idl-definitions:eventhandler-36'><c- n>EventHandler</c-></a> <a href='#handler-onmouseenter' id='idl-definitions:handler-onmouseenter'><c- g>onmouseenter</c-></a>;
  [<c- g>LenientThis</c->] <c- b>attribute</c-> <a href='#eventhandler' id='idl-definitions:eventhandler-37'><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-38'><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-39'><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-40'><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-41'><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-42'><c- n>EventHandler</c-></a> <a href='#handler-onwheel' id='idl-definitions:handler-onwheel'><c- g>onwheel</c-></a>;
  <c- b>attribute</c-> <a href='#eventhandler' id='idl-definitions:eventhandler-43'><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-44'><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-45'><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-46'><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-47'><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-48'><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-49'><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-50'><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-51'><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-52'><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-53'><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-54'><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-55'><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-56'><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-57'><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-58'><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-59'><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-60'><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-61'><c- n>EventHandler</c-></a> <a href='#handler-onwaiting' id='idl-definitions:handler-onwaiting'><c- g>onwaiting</c-></a>;
};

<c- b>interface</c-> <c- b>mixin</c-> <dfn id='windoweventhandlers'><c- g>WindowEventHandlers</c-></dfn> {
  <c- b>attribute</c-> <a href='#eventhandler' id='idl-definitions:eventhandler-62'><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-63'><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-64'><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-65'><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-66'><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-67'><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-68'><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-69'><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-70'><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-71'><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-72'><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-73'><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-74'><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-75'><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-76'><c- n>EventHandler</c-></a> <a href='#handler-window-onunload' id='idl-definitions:handler-window-onunload'><c- g>onunload</c-></a>;
};

<c- b>interface</c-> <c- b>mixin</c-> <dfn id='documentandelementeventhandlers'><c- g>DocumentAndElementEventHandlers</c-></dfn> {
  <c- b>attribute</c-> <a href='#eventhandler' id='idl-definitions:eventhandler-77'><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-78'><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-79'><c- n>EventHandler</c-></a> <a href='#handler-onpaste' id='idl-definitions:handler-onpaste'><c- g>onpaste</c-></a>;
};</code></pre>

  <h5 id=event-firing><span class=secno>8.1.5.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>

  <p><dfn id=fire-a-synthetic-mouse-event>Firing a synthetic mouse 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:mouseevent><a data-x-internal=mouseevent href=https://w3c.github.io/uievents/#mouseevent>MouseEvent</a></code>.<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>.<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.<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>.<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.<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).<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.<li><p><var>event</var>'s <code>getModifierState()</code> method is to return values
   appropriately describing the current state of the key input device.<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>.</ol>

  <p><dfn id=fire-a-click-event>Firing a <code>click</code> event</dfn>
  at <var>target</var> means <a href=#fire-a-synthetic-mouse-event id=event-firing:fire-a-synthetic-mouse-event>firing a synthetic mouse
  event named <code>click</code></a> at <var>target</var>.</p>

  


  <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://heycam.github.io/webidl/#common-Function' data-x-internal='idl-function' id='windoworworkerglobalscope-mixin:idl-function'><c- n>Function</c-></a>) <dfn id='timerhandler'><c- g>TimerHandler</c-></dfn>;

<c- b>interface</c-> <c- b>mixin</c-> <dfn id='windoworworkerglobalscope'><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>;

  // 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>void</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>handle</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>void</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>handle</c-> = 0);

  // microtask queuing
  <c- b>void</c-> <a href='#dom-queuemicrotask' id='windoworworkerglobalscope-mixin:dom-queuemicrotask'><c- g>queueMicrotask</c-></a>(<a href='https://heycam.github.io/webidl/#VoidFunction' data-x-internal='idl-voidfunction' id='windoworworkerglobalscope-mixin:idl-voidfunction'><c- n>VoidFunction</c-></a> <var><c- g>callback</c-></var>);

  // ImageBitmap
  <c- b>Promise</c->&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->);
  <c- b>Promise</c->&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->);
};
<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><var>origin</var> = self . <code id=dom-origin-dev><a href=#dom-origin>origin</a></code><dd><p>Returns the global object's <a href=#concept-origin id=windoworworkerglobalscope-mixin:concept-origin>origin</a>, serialized as string.</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>&quot;iframe&quot;</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>// &quot;null&quot;</c->
  console<c- p>.</c->log<c- p>(</c->frameWin<c- p>.</c->origin<c- p>)</c-> <c- c1>// &quot;https://stargate.example&quot;</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>

  <p>The <dfn id=dom-origin><code>origin</code></dfn> attribute's getter must return this
  object's <a href=#relevant-settings-object id=windoworworkerglobalscope-mixin:relevant-settings-object>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>


  <h3 id=atob><span class=secno>8.3</span> Base64 utility methods<a href=#atob class=self-link></a></h3><div class=status><input onclick=toggleStatus(this) value=⋰ type=button><p class=support><strong>Support:</strong> atob-btoa<span class="and_chr yes"><span>Chrome for Android</span> <span>67+</span></span><span class="chrome yes"><span>Chrome</span> <span>4+</span></span><span class="ios_saf yes"><span>iOS Safari</span> <span>3.2+</span></span><span class="and_uc yes"><span>UC Browser for Android</span> <span>11.8+</span></span><span class="firefox yes"><span>Firefox</span> <span>2+</span></span><span class="ie yes"><span>IE</span> <span>10+</span></span><span class="op_mini yes"><span>Opera Mini</span> <span>all+</span></span><span class="safari yes"><span>Safari</span> <span>3.1+</span></span><span class="edge yes"><span>Edge</span> <span>12+</span></span><span class="samsung yes"><span>Samsung Internet</span> <span>4+</span></span><span class="opera yes"><span>Opera</span> <span>10.6+</span></span><span class="android yes"><span>Android Browser</span> <span>2.1+</span></span><p class=caniuse>Source: <a href="https://caniuse.com/#feat=atob-btoa">caniuse.com</a></div>

  <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><var>result</var> = self . <code id=dom-btoa-dev><a href=#dom-btoa>btoa</a></code>( <var>data</var> )<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://heycam.github.io/webidl/#invalidcharactererror data-x-internal=invalidcharactererror>"<code>InvalidCharacterError</code>"</a> <code id=atob:domexception><a data-x-internal=domexception href=https://heycam.github.io/webidl/#dfn-DOMException>DOMException</a></code>
    exception if the input string contains any out-of-range characters.</p>

   <dt><var>result</var> = self . <code id=dom-atob-dev><a href=#dom-atob>atob</a></code>( <var>data</var> )<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://heycam.github.io/webidl/#invalidcharactererror data-x-internal=invalidcharactererror>"<code>InvalidCharacterError</code>"</a> <code id=atob:domexception-2><a data-x-internal=domexception href=https://heycam.github.io/webidl/#dfn-DOMException>DOMException</a></code> if the
    input string is not valid base64 data.</p>

   </dl>

  

  <p>The <dfn id=dom-btoa><code id=dom-windowbase64-btoa>btoa(<var>data</var>)</code></dfn>
  method must throw an <a id=atob:invalidcharactererror-3 href=https://heycam.github.io/webidl/#invalidcharactererror data-x-internal=invalidcharactererror>"<code>InvalidCharacterError</code>"</a> <code id=atob:domexception-3><a data-x-internal=domexception href=https://heycam.github.io/webidl/#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>

  <p>The <dfn id=dom-atob><code id=dom-windowbase64-atob>atob(<var>data</var>)</code></dfn>
  method, when invoked, must run the following steps:</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>.<li><p>If <var>decodedData</var> is failure, then throw an
   <a id=atob:invalidcharactererror-4 href=https://heycam.github.io/webidl/#invalidcharactererror data-x-internal=invalidcharactererror>"<code>InvalidCharacterError</code>"</a> <code id=atob:domexception-4><a data-x-internal=domexception href=https://heycam.github.io/webidl/#dfn-DOMException>DOMException</a></code>.<li><p>Return <var>decodedData</var>.</ol>

  


  <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><var>document</var> = <var>document</var> . <code id=dom-document-open-dev><a href=#dom-document-open>open</a></code>( )<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://heycam.github.io/webidl/#invalidstateerror data-x-internal=invalidstateerror>"<code>InvalidStateError</code>"</a> <code id=opening-the-input-stream:domexception><a data-x-internal=domexception href=https://heycam.github.io/webidl/#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://heycam.github.io/webidl/#invalidstateerror data-x-internal=invalidstateerror>"<code>InvalidStateError</code>"</a> <code id=opening-the-input-stream:domexception-2><a data-x-internal=domexception href=https://heycam.github.io/webidl/#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>
   <dt><var>window</var> = <var>document</var> . <code id=opening-the-input-stream:dom-document-open-window><a href=#dom-document-open-window>open</a></code>( <var>url</var>, <var>name</var>, <var>features</var> )<dd><p>Works like the <code id=opening-the-input-stream:dom-open><a href=#dom-open>window.open()</a></code> method.</dl>

  

  <p><code id=opening-the-input-stream:document-6><a href=#document>Document</a></code> objects have an <dfn id=ignore-opens-during-unload-counter>ignore-opens-during-unload counter</dfn>, 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>
  method (directly or indirectly) while the document is <a href=#unload-a-document id=opening-the-input-stream:unload-a-document>being
  unloaded</a>. Initially, the counter must be set to zero.</p>

  <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://heycam.github.io/webidl/#invalidstateerror data-x-internal=invalidstateerror>"<code>InvalidStateError</code>"</a> <code id=opening-the-input-stream:domexception-3><a data-x-internal=domexception href=https://heycam.github.io/webidl/#dfn-DOMException>DOMException</a></code> exception.<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://heycam.github.io/webidl/#invalidstateerror data-x-internal=invalidstateerror>"<code>InvalidStateError</code>"</a>
   <code id=opening-the-input-stream:domexception-4><a data-x-internal=domexception href=https://heycam.github.io/webidl/#dfn-DOMException>DOMException</a></code>.<li><p>Let <var>entryDocument</var> be the <a href=#responsible-document id=opening-the-input-stream:responsible-document>responsible document</a> specified by the
   <a href=#entry-settings-object id=opening-the-input-stream:entry-settings-object>entry settings object</a>.<li><p>If <var>document</var>'s <a href=#concept-origin id=opening-the-input-stream:concept-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=#concept-origin id=opening-the-input-stream:concept-origin-2>origin</a>, then throw a
   <a id=opening-the-input-stream:securityerror href=https://heycam.github.io/webidl/#securityerror data-x-internal=securityerror>"<code>SecurityError</code>"</a> <code id=opening-the-input-stream:domexception-5><a data-x-internal=domexception href=https://heycam.github.io/webidl/#dfn-DOMException>DOMException</a></code>.<li>
    <p>If <var>document</var> has an <a href=#active-parser id=opening-the-input-stream:active-parser>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>
    <p>Similarly, if <var>document</var>'s <a href=#ignore-opens-during-unload-counter id=opening-the-input-stream:ignore-opens-during-unload-counter>ignore-opens-during-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>
    <p>If <var>document</var> has a <a href=#concept-document-bc id=opening-the-input-stream:concept-document-bc>browsing context</a> and
    there is an existing attempt to <a href=#navigate id=opening-the-input-stream:navigate>navigate</a> <var>document</var>'s <a href=#concept-document-bc id=opening-the-input-stream:concept-document-bc-2>browsing context</a>, then <a href=#stop-document-loading id=opening-the-input-stream:stop-document-loading>stop document loading</a>
    given <var>document</var>.</p>

    <p class=XXX>Issue <a href=https://github.com/whatwg/html/issues/3447>#3447</a> looks into the distinction between
    an ongoing instance of the <a href=#navigate id=opening-the-input-stream:navigate-2>navigate</a> algorithm versus tasks to <a href=#navigate id=opening-the-input-stream:navigate-3>navigate</a>
    that are still queued. For the purpose of implementing this step, both an ongoing instance of
    the <a href=#navigate id=opening-the-input-stream:navigate-4>navigate</a> algorithm and tasks queued to <a href=#navigate id=opening-the-input-stream:navigate-5>navigate</a> should be counted
    towards "an existing attempt to <a href=#navigate id=opening-the-input-stream:navigate-6>navigate</a>," before that issue is resolved.</p>
   <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>.<li><p>If <var>document</var> is the <a href=#concept-document-window id=opening-the-input-stream:concept-document-window>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>.<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>, without firing any mutation events.<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>.<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.<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>.</ol>
   <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.<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>.<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-4><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>.<li><p>Set the <a href=#current-document-readiness id=opening-the-input-stream:current-document-readiness>current document readiness</a> of <var>document</var> to "<code>loading</code>".<li><p>Finally, 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).<li><p>Return <var>document</var>.</ol>

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

  <p>The <dfn id=dom-document-open><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 this <code id=opening-the-input-stream:document-9><a href=#document>Document</a></code> object.

  <p id=dom-document-open-unused-arguments class=note>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://heycam.github.io/webidl/#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.github.io/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/heycam/webidl/issues/581>heycam/webidl#581</a> investigates changing the
  algorithm to allow for their removal. <a href=#refsWEBIDL>[WEBIDL]</a></p>

  <p>The <dfn id=dom-document-open-window><code>open(<var>url</var>, <var>name</var>,
  <var>features</var>)</code></dfn> method must run these steps:</p>

  <ol><li><p>If this <code id=opening-the-input-stream:document-10><a href=#document>Document</a></code> object is not an <a href=#active-document id=opening-the-input-stream:active-document>active document</a>, then throw an
   <a id=opening-the-input-stream:invalidstateerror-5 href=https://heycam.github.io/webidl/#invalidstateerror data-x-internal=invalidstateerror>"<code>InvalidStateError</code>"</a> <code id=opening-the-input-stream:domexception-6><a data-x-internal=domexception href=https://heycam.github.io/webidl/#dfn-DOMException>DOMException</a></code> exception.<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>.</ol>

  



  <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><var>document</var> . <code id=dom-document-close-dev><a href=#dom-document-close>close</a></code>()<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://heycam.github.io/webidl/#invalidstateerror data-x-internal=invalidstateerror>"<code>InvalidStateError</code>"</a> <code id=closing-the-input-stream:domexception><a data-x-internal=domexception href=https://heycam.github.io/webidl/#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://heycam.github.io/webidl/#invalidstateerror data-x-internal=invalidstateerror>"<code>InvalidStateError</code>"</a> <code id=closing-the-input-stream:domexception-2><a data-x-internal=domexception href=https://heycam.github.io/webidl/#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>

   </dl>

  

  <p>The <dfn id=dom-document-close><code>close()</code></dfn> method must run the following
  steps:</p>

  <ol><li><p>If the <code id=closing-the-input-stream:document-2><a href=#document>Document</a></code> object 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://heycam.github.io/webidl/#invalidstateerror data-x-internal=invalidstateerror>"<code>InvalidStateError</code>"</a>
   <code id=closing-the-input-stream:domexception-3><a data-x-internal=domexception href=https://heycam.github.io/webidl/#dfn-DOMException>DOMException</a></code>.<li><p>If the <code id=closing-the-input-stream:document-3><a href=#document>Document</a></code> object'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://heycam.github.io/webidl/#invalidstateerror data-x-internal=invalidstateerror>"<code>InvalidStateError</code>"</a>
   <code id=closing-the-input-stream:domexception-4><a data-x-internal=domexception href=https://heycam.github.io/webidl/#dfn-DOMException>DOMException</a></code>.<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 the document, then
   return.<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>.<li><p>If there is a <a href=#pending-parsing-blocking-script id=closing-the-input-stream:pending-parsing-blocking-script>pending parsing-blocking script</a>, then return.<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>.</ol>

  



  <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><var>document</var> . <code id=dom-document-write-dev><a href=#dom-document-write>write</a></code>(<var>text</var>...)<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></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. Users 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://heycam.github.io/webidl/#invalidstateerror data-x-internal=invalidstateerror>"<code>InvalidStateError</code>"</a> <code id=document.write():domexception><a data-x-internal=domexception href=https://heycam.github.io/webidl/#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://heycam.github.io/webidl/#invalidstateerror data-x-internal=invalidstateerror>"<code>InvalidStateError</code>"</a> <code id=document.write():domexception-2><a data-x-internal=domexception href=https://heycam.github.io/webidl/#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>

   </dl>

  

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

  <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>
  and a string <var>input</var>, are as follows:</p>

  <ol><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://heycam.github.io/webidl/#invalidstateerror data-x-internal=invalidstateerror>"<code>InvalidStateError</code>"</a> <code id=document.write():domexception-3><a data-x-internal=domexception href=https://heycam.github.io/webidl/#dfn-DOMException>DOMException</a></code>.<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://heycam.github.io/webidl/#invalidstateerror data-x-internal=invalidstateerror>"<code>InvalidStateError</code>"</a>
   <code id=document.write():domexception-4><a data-x-internal=domexception href=https://heycam.github.io/webidl/#dfn-DOMException>DOMException</a></code>.<li>
    <p>If the <a href=#insertion-point id=document.write():insertion-point>insertion point</a> is undefined, then:

    <ol><li><p>If <var>document</var>'s <a href=#ignore-opens-during-unload-counter id=document.write():ignore-opens-during-unload-counter>ignore-opens-during-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.<li><p>Run the <a href=#document-open-steps id=document.write():document-open-steps>document open steps</a> with <var>document</var>.</ol>
   <li><p>Insert <var>input</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>.<li>
    <p>If there is no <a href=#pending-parsing-blocking-script id=document.write():pending-parsing-blocking-script>pending parsing-blocking script</a>, have the <a href=#html-parser id=document.write():html-parser-2>HTML
    parser</a> process <var>input</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-2><a href=#the-script-element>script</a></code> end tag token is emitted by the tokenizer).

    <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-3><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>
   </ol>

  <p>The <dfn id=dom-document-write><code>document.write(...)</code></dfn> method, when
  invoked, must run the <a href=#document-write-steps id=document.write():document-write-steps>document write steps</a> with this <code id=document.write():document-4><a href=#document>Document</a></code> object and
  a string that is the concatanation of all arguments passed.</p>


  


  <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><var>document</var> . <code id=dom-document-writeln-dev><a href=#dom-document-writeln>writeln</a></code>(<var>text</var>...)<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>Throws an <a id=document.writeln():invalidstateerror href=https://heycam.github.io/webidl/#invalidstateerror data-x-internal=invalidstateerror>"<code>InvalidStateError</code>"</a> <code id=document.writeln():domexception><a data-x-internal=domexception href=https://heycam.github.io/webidl/#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://heycam.github.io/webidl/#invalidstateerror data-x-internal=invalidstateerror>"<code>InvalidStateError</code>"</a> <code id=document.writeln():domexception-2><a data-x-internal=domexception href=https://heycam.github.io/webidl/#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>

   </dl>

  

  <p>The <dfn id=dom-document-writeln><code>document.writeln(...)</code></dfn> method, when
  invoked, must run the <a href=#document-write-steps id=document.writeln():document-write-steps>document write steps</a> with this <code id=document.writeln():document-2><a href=#document>Document</a></code> object and
  a string that is the concatanation of all arguments passed and U+000A LINE FEED.</p>

  



  <h3 id=timers><span class=secno>8.5</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><var>handle</var> = self . <code id=dom-settimeout-dev><a href=#dom-settimeout>setTimeout</a></code>( <var>handler</var> [, <var>timeout</var> [, <var>arguments</var>... ] ] )<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>

   <dt><var>handle</var> = self . <code id=timers:dom-settimeout-2><a href=#dom-settimeout>setTimeout</a></code>( <var>code</var> [, <var>timeout</var> ] )<dd>

    <p>Schedules a timeout to compile and run <var>code</var> after <var>timeout</var> milliseconds.</p>

   <dt>self . <code id=dom-cleartimeout-dev><a href=#dom-cleartimeout>clearTimeout</a></code>( <var>handle</var> )<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>handle</var>.</p>

   <dt><var>handle</var> = self . <code id=dom-setinterval-dev><a href=#dom-setinterval>setInterval</a></code>( <var>handler</var> [, <var>timeout</var> [, <var>arguments</var>... ] ] )<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>

   <dt><var>handle</var> = self . <code id=timers:dom-setinterval-3><a href=#dom-setinterval>setInterval</a></code>( <var>code</var> [, <var>timeout</var> ] )<dd>

    <p>Schedules a timeout to compile and run <var>code</var> every <var>timeout</var> milliseconds.</p>

   <dt>self . <code id=dom-clearinterval-dev><a href=#dom-clearinterval>clearInterval</a></code>( <var>handle</var> )<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>handle</var>.</p>

   </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 id=list-of-active-timers data-export="">list of active timers</dfn>. Each entry in this lists is identified by a number,
  which must be unique within the list for the lifetime of the object that implements the
  <code id=timers:windoworworkerglobalscope-2><a href=#windoworworkerglobalscope>WindowOrWorkerGlobalScope</a></code> mixin.</p>

  <hr>

  <p>The <dfn id=dom-settimeout><code id=dom-windowtimers-setTimeout>setTimeout()</code></dfn> method must return the value returned
  by the <a href=#timer-initialisation-steps id=timers:timer-initialisation-steps>timer initialization steps</a>, passing them the method's arguments, the object on
  which the method for which the algorithm is running is implemented (a <code id=timers:window><a href=#window>Window</a></code> or
  <code id=timers:workerglobalscope><a href=#workerglobalscope>WorkerGlobalScope</a></code> object) as the <var>method context</var>, and the <var>repeat</var>
  flag set to false.</p>

  <p>The <dfn id=dom-setinterval><code id=dom-windowtimers-setInterval>setInterval()</code></dfn> method must return the value returned
  by the <a href=#timer-initialisation-steps id=timers:timer-initialisation-steps-2>timer initialization steps</a>, passing them the method's arguments, the object on
  which the method for which the algorithm is running is implemented (a <code id=timers:window-2><a href=#window>Window</a></code> or
  <code id=timers:workerglobalscope-2><a href=#workerglobalscope>WorkerGlobalScope</a></code> object) as the <var>method context</var>, and the <var>repeat</var>
  flag set to true.</p>

  <p>The <dfn id=dom-cleartimeout><code id=dom-windowtimers-clearTimeout>clearTimeout()</code></dfn> and <dfn id=dom-clearinterval><code id=dom-windowtimers-clearInterval>clearInterval()</code></dfn>
  methods must clear the entry identified as <var>handle</var> from the <a href=#list-of-active-timers id=timers:list-of-active-timers>list of active
  timers</a> of the <code id=timers:windoworworkerglobalscope-3><a href=#windoworworkerglobalscope>WindowOrWorkerGlobalScope</a></code> object on which the method was
  invoked, if any, where <var>handle</var> is the argument passed to the method. (If
  <var>handle</var> does not identify an entry in the <a href=#list-of-active-timers id=timers:list-of-active-timers-2>list of active timers</a> of the
  <code id=timers:windoworworkerglobalscope-4><a href=#windoworworkerglobalscope>WindowOrWorkerGlobalScope</a></code> object on which the method was invoked, the method does
  nothing.)</p>

  <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 list, either method
  can be used to clear timers created by <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>.</p>

  <hr>

  <p>The <dfn id=timer-initialisation-steps>timer initialization steps</dfn>, which
  are invoked with some method arguments, a <var>method context</var>, a <var>repeat</var> flag
  which can be true or false, and optionally (and only if the <var>repeat</var> flag is true) a
  <var>previous handle</var>, are as follows:</p>

  <ol><li><p>Let <var>method context proxy</var> be <var>method context</var> if that
   is a <code id=timers:workerglobalscope-3><a href=#workerglobalscope>WorkerGlobalScope</a></code> object, or else the <code id=timers:windowproxy><a href=#windowproxy>WindowProxy</a></code> that corresponds
   to <var>method context</var>.<li><p>If <var>previous handle</var> was provided, let <var>handle</var> be
   <var>previous handle</var>; otherwise, let <var>handle</var> be a
   user-agent-defined integer that is greater than zero that will identify the timeout to be set by
   this call in the <a href=#list-of-active-timers id=timers:list-of-active-timers-3>list of active timers</a>.<li><p>If <var>previous handle</var> was not provided, add an entry to the <a href=#list-of-active-timers id=timers:list-of-active-timers-4>list of
   active timers</a> for <var>handle</var>.<li><p>Let <var>callerRealm</var> be the <a id=timers:current-realm-record href=https://tc39.github.io/ecma262/#current-realm data-x-internal=current-realm-record>current Realm Record</a>, and
   <var>calleeRealm</var> be <var>method context</var>'s <a id=timers:javascript-realm href=https://tc39.github.io/ecma262/#sec-code-realms data-x-internal=javascript-realm>JavaScript realm</a>.<li><p>Let <var>initiating script</var> be the <a href=#active-script id=timers:active-script>active script</a>.<li><p>Assert: <var>initiating script</var> is not null, since this algorithm is always called
   from some script.<li>

    <p>Let <var>task</var> be a <a href=#concept-task id=timers:concept-task>task</a> that runs the
    following substeps:</p>

    <ol><li><p>If the entry for <var>handle</var> in the <a href=#list-of-active-timers id=timers:list-of-active-timers-5>list of active timers</a> has been
     cleared, then abort these steps.<li>

      <p>Run the appropriate set of steps from the following list:</p>

      <dl class=switch><dt>If the first method argument is a <code id=timers:idl-function><a data-x-internal=idl-function href=https://heycam.github.io/webidl/#common-Function>Function</a></code><dd>

        <p><a href=https://heycam.github.io/webidl/#invoke-a-callback-function id=timers:es-invoking-callback-functions data-x-internal=es-invoking-callback-functions>Invoke</a> the <code id=timers:idl-function-2><a data-x-internal=idl-function href=https://heycam.github.io/webidl/#common-Function>Function</a></code>. Use the third and subsequent method
        arguments (if any) as the arguments for invoking the <code id=timers:idl-function-3><a data-x-internal=idl-function href=https://heycam.github.io/webidl/#common-Function>Function</a></code>. Use <var>method context proxy</var> as the
        <a href=https://heycam.github.io/webidl/#dfn-callback-this-value id=timers:dfn-callback-this-value data-x-internal=dfn-callback-this-value>callback this value</a>.</p>

       <dt>Otherwise<dd>

        <ol><li><p>Perform <a href=#hostensurecancompilestrings(callerrealm,-calleerealm) id=timers:hostensurecancompilestrings(callerrealm,-calleerealm)>HostEnsureCanCompileStrings</a>(<var>callerRealm</var>,
         <var>calleeRealm</var>). If this throws an exception, catch it, <a href=#report-the-exception id=timers:report-the-exception>report the
         exception</a>, and abort these steps.<li><p>Let <var>script source</var> be the first method argument.<li><p>Let <var>settings object</var> be <var>method context</var>'s <a href=#environment-settings-object id=timers:environment-settings-object>environment
         settings object</a>.<li><p>Let <var>base URL</var> be <var>initiating script</var>'s <a href=#concept-script-base-url id=timers:concept-script-base-url>base URL</a>.<li>
          <p>Let <var>fetch options</var> be 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>, and <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>.</p>

          <p class=note>The effect of these options ensures that the string compilation done by
          <code id=timers:dom-settimeout-6><a href=#dom-settimeout>setTimeout()</a></code> and <code id=timers:dom-setinterval-6><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.github.io/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.github.io/proposal-dynamic-import/#sec-import-calls>import()</a></code>
          will behave the same in both contexts.</p>
         <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>script source</var>, <var>settings object</var>, <var>base URL</var>, and <var>fetch
         options</var>.<li><p><a href=#run-a-classic-script id=timers:run-a-classic-script>Run the classic script</a>
         <var>script</var>.</ol>

       </dl>

     <li><p>If the <var>repeat</var> flag is true, then call <a href=#timer-initialisation-steps id=timers:timer-initialisation-steps-3>timer initialization
     steps</a> again, passing them the same method arguments, the same <var>method
     context</var>, with the <var>repeat</var> flag still set to true, and with the <var>previous handle</var> set to <var>handler</var>.</ol>

   <li><p>Let <var>timeout</var> be the second method argument.<li>
    <p>If the currently running <a href=#concept-task id=timers:concept-task-2>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-3>task</a>'s <a href=#timer-nesting-level id=timers:timer-nesting-level>timer nesting level</a>. Otherwise, let
    <var>nesting level</var> be zero.</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><p>If <var>timeout</var> is less than 0, then set <var>timeout</var> to 0.<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.<li><p>Increment <var>nesting level</var> by one.<li><p>Let <var>task</var>'s <dfn id=timer-nesting-level>timer nesting level</dfn> be <var>nesting
   level</var>.<li><p>Return <var>handle</var>, and then continue running this algorithm
   <a href=#in-parallel id=timers:in-parallel>in parallel</a>.<li>

    <p>If <var>method context</var> is a <code id=timers:window-3><a href=#window>Window</a></code> object, wait until the
    <code id=timers:document><a href=#document>Document</a></code> associated with <var>method context</var> has been <a href=#fully-active id=timers:fully-active>fully
    active</a> for a further <var>timeout</var> milliseconds (not necessarily
    consecutively).</p>

    <p>Otherwise, <var>method context</var> is a <code id=timers:workerglobalscope-4><a href=#workerglobalscope>WorkerGlobalScope</a></code> object;
    wait until <var>timeout</var> milliseconds have passed with the worker not suspended
    (not necessarily consecutively).</p>

   <li>

    <p>Wait until any invocations of this algorithm that had the same <var>method
    context</var>, that started before this one, and whose <var>timeout</var> is equal to
    or less than this one's, have completed.</p>

    <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 TWO </code>":</p>

     <pre><code class='js'><c- a>var</c-> log <c- o>=</c-> <c- t>&apos;&apos;</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>&apos; &apos;</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>&quot;logger(&apos;ONE&apos;)&quot;</c-><c- p>,</c-> <c- mi>100</c-><c- p>);</c->
  <c- k>return</c-> <c- u>&quot;logger(&apos;TWO&apos;)&quot;</c-><c- p>;</c->
<c- p>}</c-> <c- p>},</c-> <c- mi>100</c-><c- p>);</c-></code></pre>

    </div>

   <li>

    <p>Optionally, wait a further user-agent defined 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>

    <p><a href=#queue-a-task id=timers:queue-a-task>Queue</a> the <a href=#concept-task id=timers:concept-task-4>task</a> <var>task</var>.</p>

    <p class=note>Once the task has been processed, if the <var>repeat</var> flag is
    false, it is safe to remove the entry for <var>handle</var> from the <a href=#list-of-active-timers id=timers:list-of-active-timers-6>list of
    active timers</a> (there is no way for the entry's existence to be detected past this point,
    so it does not technically matter one way or the other).</p>

   </ol>

  <p>The <a href=#task-source id=timers:task-source>task source</a> for these <a href=#concept-task id=timers:concept-task-5>tasks</a> is the
  <dfn id=timer-task-source>timer task source</dfn>.</p>

  

  <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&apos;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-> handle <c- o>=</c-> setTimeout<c- p>(</c->rescheduleWork<c- p>,</c-> <c- mi>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->handle<c- p>);</c-> <c- c1>// clear the timeout if we don&apos;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- mi>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>


  <h3 id=microtask-queuing><span class=secno>8.6</span> Microtask queuing<a href=#microtask-queuing class=self-link></a></h3>

  <dl class=domintro><dt><var>self</var> . <code id=dom-queuemicrotask-dev><a href=#dom-queuemicrotask>queueMicrotask</a></code>(<var>callback</var>)<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>.</dl>

  <p>The <dfn id=dom-queuemicrotask><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://heycam.github.io/webidl/#invoke-a-callback-function id=microtask-queuing:es-invoking-callback-functions data-x-internal=es-invoking-callback-functions>invoke</a>
  <var>callback</var>, and if <var>callback</var> throws an exception, <a href=#report-the-exception id=microtask-queuing:report-the-exception>report the
  exception</a>.</p>

  <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 after the
  currently-executing <a href=#concept-task id=microtask-queuing:concept-task>task</a> has run to completion and the
  <a id=microtask-queuing:javascript-execution-context-stack href=https://tc39.github.io/ecma262/#execution-context-stack data-x-internal=javascript-execution-context-stack>JavaScript execution context stack</a> is empty, but without yielding control back to the
  browser's <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>, 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 or scrolling. 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 current task's worth of non-queued
  JavaScript.</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>&quot;load&quot;</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>&quot;load&quot;</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>&quot;load&quot;</c-><c- p>,</c-> <c- p>()</c-> <c- p>=&gt;</c-> console<c- p>.</c->log<c- p>(</c-><c- u>&quot;loaded&quot;</c-><c- p>));</c->
console<c- p>.</c->log<c- p>(</c-><c- u>&quot;1&quot;</c-><c- p>);</c->
element<c- p>.</c->loadData<c- p>();</c->
console<c- p>.</c->log<c- p>(</c-><c- u>&quot;2&quot;</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>&quot;load&quot;</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>&quot;load&quot;</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 currently-executing task, 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- kr>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- mi>1</c-><c- p>)</c-> <c- p>{</c->
    queueMicrotask<c- p>(()</c-> <c- p>=&gt;</c-> <c- p>{</c->
      <c- kr>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- mi>0</c-><c- p>;</c->

      fetch<c- p>(</c-><c- u>&quot;/endpoint&quot;</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 same turn of the event loop 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.7</span> User prompts<a href=#user-prompts class=self-link></a></h3>

  

  <h4 id=simple-dialogs><span class=secno>8.7.1</span> Simple dialogs<a href=#simple-dialogs class=self-link></a></h4>

  <dl class=domintro><dt><var>window</var> . <code id=dom-alert-dev><a href=#dom-alert>alert</a></code>(<var>message</var>)<dd>

    <p>Displays a modal alert with the given message, and waits for the user to dismiss it.</p>

   <dt><var>result</var> = <var>window</var> . <code id=dom-confirm-dev><a href=#dom-confirm>confirm</a></code>(<var>message</var>)<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>

   <dt><var>result</var> = <var>window</var> . <code id=dom-prompt-dev><a href=#dom-prompt>prompt</a></code>(<var>message</var> [, <var>default</var>] )<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>

   </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>

  

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

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

  <p>The <dfn id=dom-alert><code>alert(<var>message</var>)</code></dfn> method, when
  invoked, must run the following steps:</p>

  <ol><li><p>If the <a href=#event-loop id=simple-dialogs:event-loop>event loop</a>'s <a href=#termination-nesting-level id=simple-dialogs:termination-nesting-level>termination nesting level</a> is nonzero,
   optionally return.<li><p>If the <a href=#active-sandboxing-flag-set id=simple-dialogs:active-sandboxing-flag-set>active sandboxing flag set</a> of this <code id=simple-dialogs:window><a href=#window>Window</a></code> object'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.<li><p>Optionally, return. (For example, the user agent might give the user the option
   to ignore all alerts, and would thus abort at this step whenever the method was
   invoked.)<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.<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>.<li><p>Show <var>message</var> to the user.<li><p>Optionally, <a href=#pause id=simple-dialogs:pause>pause</a> while waiting for the user to acknowledge the
   message.</ol>

  <p>The <dfn id=dom-confirm><code>confirm(<var>message</var>)</code></dfn> method,
  when invoked, must run the following steps:</p>

  <ol><li><p>If the <a href=#event-loop id=simple-dialogs:event-loop-2>event loop</a>'s <a href=#termination-nesting-level id=simple-dialogs:termination-nesting-level-2>termination nesting level</a> is nonzero,
   optionally return false.<li><p>If the <a href=#active-sandboxing-flag-set id=simple-dialogs:active-sandboxing-flag-set-2>active sandboxing flag set</a> of this <code id=simple-dialogs:window-2><a href=#window>Window</a></code> object's <a href=#concept-document-window id=simple-dialogs:concept-document-window-2>associated <code>Document</code></a> has the <a href=#sandboxed-modals-flag id=simple-dialogs:sandboxed-modals-flag-2>sandboxed
   modals flag</a> set, then return.<li><p>Optionally, return false. (For example, the user agent might give
   the user the option to ignore all prompts, and would thus abort at this step whenever the method
   was invoked.)<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>.<li><p>Show <var>message</var> to the user, and ask the user to respond with a positive or
   negative response.<li><p><a href=#pause id=simple-dialogs:pause-2>Pause</a> until the user responds either positively or negatively.<li><p>If the user responded positively, return true; otherwise, the user responded negatively:
   return false.</ol>

  <p>The <dfn id=dom-prompt><code>prompt(<var>message</var>, <var>default</var>)</code></dfn>
  method, when invoked, must run the following steps:</p>

  <ol><li><p>If the <a href=#event-loop id=simple-dialogs:event-loop-3>event loop</a>'s <a href=#termination-nesting-level id=simple-dialogs:termination-nesting-level-3>termination nesting level</a> is nonzero,
   optionally return null.<li><p>If the <a href=#active-sandboxing-flag-set id=simple-dialogs:active-sandboxing-flag-set-3>active sandboxing flag set</a> of this <code id=simple-dialogs:window-3><a href=#window>Window</a></code> object's <a href=#concept-document-window id=simple-dialogs:concept-document-window-3>associated <code>Document</code></a> has the <a href=#sandboxed-modals-flag id=simple-dialogs:sandboxed-modals-flag-3>sandboxed
   modals flag</a> set, then return.<li><p>Optionally, return null. (For example, the user agent might give the
   user the option to ignore all prompts, and would thus abort at this step whenever the method was
   invoked.)<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>.<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>.<li><p>Show <var>message</var> to the user, 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>.<li><p><a href=#pause id=simple-dialogs:pause-3>Pause</a> while waiting for the user's response.<li><p>If the user aborts, then return null; otherwise, return the string that the user responded
   with.</ol>

  


  <h4 id=printing><span class=secno>8.7.2</span> Printing<a href=#printing class=self-link></a></h4>

  <dl class=domintro><dt><var>window</var> . <code id=dom-print-dev><a href=#dom-print>print</a></code>()<dd>

    <p>Prompts the user to print the page.</p>

   </dl>

  

  <p>When the <dfn id=dom-print><code>print()</code></dfn> method is invoked, if the
  <code id=printing:document><a href=#document>Document</a></code> is <a href=#ready-for-post-load-tasks id=printing:ready-for-post-load-tasks>ready for post-load tasks</a>, then the user agent must
  run the <a href=#printing-steps id=printing:printing-steps>printing steps</a> <a href=#in-parallel id=printing:in-parallel>in parallel</a>. Otherwise, the user agent must only set the
  <dfn id=print-when-loaded>print when loaded</dfn> flag on the <code id=printing:document-2><a href=#document>Document</a></code>.</p>


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

  <p>The <dfn id=printing-steps>printing steps</dfn> are as follows:</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>

    <p>If the <a href=#active-sandboxing-flag-set id=printing:active-sandboxing-flag-set>active sandboxing flag set</a> of this <code id=printing:window><a href=#window>Window</a></code> object's <a href=#concept-document-window id=printing:concept-document-window>associated <code>Document</code></a> 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-3><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>

    <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 the
    <code id=printing:document-4><a href=#document>Document</a></code> that is being printed, as well as any <a href=#nested-browsing-context id=printing:nested-browsing-context>nested browsing contexts</a> in it.</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>

    <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 the document. 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>

    <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 the
    <code id=printing:document-5><a href=#document>Document</a></code> that is being printed, as well as any <a href=#nested-browsing-context id=printing:nested-browsing-context-2>nested browsing contexts</a> in it.</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>

   </ol>

  


  <h3 id=system-state-and-capabilities><span class=secno>8.8</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.8.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>

  

  <p>The <dfn id=dom-navigator><code>navigator</code></dfn> attribute of the
  <code id=the-navigator-object:window><a href=#window>Window</a></code> interface must return an instance of the <code id=the-navigator-object:navigator-2><a href=#navigator>Navigator</a></code> interface,
  which represents the identity and state of the user agent (the client), and allows Web pages to
  register themselves as potential protocol handlers:</p>

  

  <pre><code class='idl'>[<c- g>Exposed</c->=<c- n>Window</c->]
<c- b>interface</c-> <dfn id='navigator'><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>These interface mixins are defined separately so that <code id=the-navigator-object:workernavigator><a href=#workernavigator>WorkerNavigator</a></code> can re-use
  parts of the <code id=the-navigator-object:navigator-10><a href=#navigator>Navigator</a></code> interface.</p>

  


  <h5 id=client-identification><span class=secno>8.8.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'><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 &quot;Mozilla&quot;
  <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 &quot;Netscape&quot;
  <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 &quot;Gecko&quot;
  [<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 &quot;&quot;
};</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 <a href=#navigatorid id=client-identification:navigatorid>NavigatorID</a> interface 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><var>self</var> . <code id=client-identification:dom-navigator><a href=#dom-navigator>navigator</a></code> . <code id=dom-navigator-appcodename-dev><a href=#dom-navigator-appcodename>appCodeName</a></code><dd><p>Returns the string "<code>Mozilla</code>".<dt><var>self</var> . <code id=client-identification:dom-navigator-2><a href=#dom-navigator>navigator</a></code> . <code id=dom-navigator-appname-dev><a href=#dom-navigator-appname>appName</a></code><dd><p>Returns the string "<code>Netscape</code>".<dt><var>self</var> . <code id=client-identification:dom-navigator-3><a href=#dom-navigator>navigator</a></code> . <code id=dom-navigator-appversion-dev><a href=#dom-navigator-appversion>appVersion</a></code><dd><p>Returns the version of the browser.<dt><var>self</var> . <code id=client-identification:dom-navigator-4><a href=#dom-navigator>navigator</a></code> . <code id=dom-navigator-platform-dev><a href=#dom-navigator-platform>platform</a></code><dd><p>Returns the name of the platform.<dt><var>self</var> . <code id=client-identification:dom-navigator-5><a href=#dom-navigator>navigator</a></code> . <code id=dom-navigator-product-dev><a href=#dom-navigator-product>product</a></code><dd><p>Returns the string "<code>Gecko</code>".<dt><var>window</var> . <code id=client-identification:dom-navigator-6><a href=#dom-navigator>navigator</a></code> . <code id=dom-navigator-productsub-dev><a href=#dom-navigator-productsub>productSub</a></code><dd><p>Returns either the string "<code>20030107</code>", or the string "<code>20100101</code>".<dt><var>self</var> . <code id=client-identification:dom-navigator-7><a href=#dom-navigator>navigator</a></code> . <code id=dom-navigator-useragent-dev><a href=#dom-navigator-useragent>userAgent</a></code><dd><p>Returns the complete `<code>User-Agent</code>` header.<dt><var>window</var> . <code id=client-identification:dom-navigator-8><a href=#dom-navigator>navigator</a></code> . <code id=dom-navigator-vendor-dev><a href=#dom-navigator-vendor>vendor</a></code><dd><p>Returns either the empty string, the string "<code>Apple Computer, Inc.</code>",
   or the string "<code>Google Inc.</code>".<dt><var>window</var> . <code id=client-identification:dom-navigator-9><a href=#dom-navigator>navigator</a></code> . <code id=dom-navigator-vendorsub-dev><a href=#dom-navigator-vendorsub>vendorSub</a></code><dd><p>Returns the empty string.</dl>

  

  <dl><dt><dfn id=dom-navigator-appcodename><code>appCodeName</code></dfn><dd><p>Must return the string "<code>Mozilla</code>".<dt><dfn id=dom-navigator-appname><code>appName</code></dfn><dd><p>Must return the string "<code>Netscape</code>".<dt><dfn id=dom-navigator-appversion><code>appVersion</code></dfn><dd><p>Must return either the string "<code>4.0</code>" or a string representing the
   version of the browser in detail, e.g. "<code>1.0 (VMS; en-US)
   Mellblomenator/9000</code>".<dt><dfn id=dom-navigator-platform><code>platform</code></dfn><dd><p>Must return either the empty string or a string representing the platform on which the
   browser is executing, e.g. "<code>MacIntel</code>", "<code>Win32</code>",
   "<code>FreeBSD i386</code>", "<code>WebTV OS</code>".<dt><dfn id=dom-navigator-product><code>product</code></dfn><dd><p>Must return the string "<code>Gecko</code>".<dt><dfn id=dom-navigator-productsub><code>productSub</code></dfn><dd>

    <p>Must 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-2>navigator compatibility
     mode</a> is <i>Chrome</i> or <i>WebKit</i><dd><p>The string "<code>20030107</code>".<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><dd><p>The string "<code>20100101</code>".</dl>

   <dt><dfn id=dom-navigator-useragent><code>userAgent</code></dfn><dd><p>Must return the <a href=https://fetch.spec.whatwg.org/#default-user-agent-value id=client-identification:default-user-agent-value data-x-internal=default-user-agent-value>default `<code>User-Agent</code>`
   value</a>.<dt><dfn id=dom-navigator-vendor><code>vendor</code></dfn><dd>

    <p>Must 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><dd><p>The string "<code>Google Inc.</code>".<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><dd><p>The empty string.<dt>If the <a href=#concept-navigator-compatibility-mode id=client-identification:concept-navigator-compatibility-mode-6>navigator compatibility
     mode</a> is <i>WebKit</i><dd><p>The string "<code>Apple Computer, Inc.</code>".</dl>

   <dt><dfn id=dom-navigator-vendorsub><code>vendorSub</code></dfn><dd><p>Must return the empty string.</dl>

  <p>If the <a href=#concept-navigator-compatibility-mode id=client-identification:concept-navigator-compatibility-mode-7>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-> <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>

  <p>The <dfn id=dom-navigator-taintenabled><code>taintEnabled()</code></dfn> method must
  return false.</p>

  <p>The <dfn id=dom-navigator-oscpu><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>

  
  <p class=warning>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.
  <a href=#fingerprinting-vector id=client-identification:fingerprinting-vector class=fingerprint title="There is a potential fingerprinting vector here."><img alt="(This is a fingerprinting vector.)" src=/images/fingerprint.png width=46 height=64></a>
  </p>

  

  

  <h5 id=language-preferences><span class=secno>8.8.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'><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><var>self</var> . <code id=language-preferences:dom-navigator><a href=#dom-navigator>navigator</a></code> . <code id=dom-navigator-language-dev><a href=#dom-navigator-language>language</a></code><dd><p>Returns a language tag representing the user's preferred language.<dt><var>self</var> . <code id=language-preferences:dom-navigator-2><a href=#dom-navigator>navigator</a></code> . <code id=dom-navigator-languages-dev><a href=#dom-navigator-languages>languages</a></code><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>
   </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>

  

  <dl><dt><dfn id=dom-navigator-language><code>language</code></dfn><dd><p>Must 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><dt><dfn id=dom-navigator-languages><code>languages</code></dfn><dd>

    <p>Must return a <a id=language-preferences:frozen-array href=https://heycam.github.io/webidl/#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>

    <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 return a new set of language tags, the user agent must
    <a href=#queue-a-task id=language-preferences:queue-a-task>queue a task</a> 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 the <code id=language-preferences:window-3><a href=#window>Window</a></code> or
    <code id=language-preferences:workerglobalscope-3><a href=#workerglobalscope>WorkerGlobalScope</a></code> object and wait until that task begins to be executed before
    actually returning a new value.</p>

    <p>The <a href=#task-source id=language-preferences:task-source>task source</a> for this <a href=#concept-task id=language-preferences:concept-task>task</a> is the
    <a href=#dom-manipulation-task-source id=language-preferences:dom-manipulation-task-source>DOM manipulation task source</a>.</p>

   </dl>

  <p>To determine <dfn id=a-plausible-language>a plausible language</dfn>, the user agent should bear in mind the following:</p>

  <ul><li>Any information in this API that varies from user to user can be used to profile or identify
   the user.
   <a href=#fingerprinting-vector id=language-preferences:fingerprinting-vector class=fingerprint title="There is a potential fingerprinting vector here."><img alt="(This is a fingerprinting vector.)" src=/images/fingerprint.png width=46 height=64></a>
   <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>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.</ul>

  <p>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://tools.ietf.org/html/rfc7231#section-5.3.5>Accept-Language</a></code>` header.
  <a href=#fingerprinting-vector id=language-preferences:fingerprinting-vector-2 class=fingerprint title="There is a potential fingerprinting vector here."><img alt="(This is a fingerprinting vector.)" src=/images/fingerprint.png width=46 height=64></a>
  </p>

  



  <h5 id=custom-handlers><span class=secno>8.8.1.3</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=status><input onclick=toggleStatus(this) value=⋰ type=button><p class=support><strong>Support:</strong> registerprotocolhandler<span class="and_chr no"><span>Chrome for Android</span> <span>None</span></span><span class="chrome yes"><span>Chrome</span> <span>13+</span></span><span class="ios_saf no"><span>iOS Safari</span> <span>None</span></span><span class="and_uc no"><span>UC Browser for Android</span> <span>None</span></span><span class="firefox yes"><span>Firefox</span> <span>3+</span></span><span class="ie no"><span>IE</span> <span>None</span></span><span class="op_mini no"><span>Opera Mini</span> <span>None</span></span><span class="safari no"><span>Safari</span> <span>None</span></span><span class="edge no"><span>Edge</span> <span>None</span></span><span class="samsung no"><span>Samsung Internet</span> <span>None</span></span><span class="opera yes"><span>Opera</span> <span>11.6+</span></span><span class="android no"><span>Android Browser</span> <span>None</span></span><p class=caniuse>Source: <a href="https://caniuse.com/#feat=registerprotocolhandler">caniuse.com</a></div>

  <pre><code class='idl'><c- b>interface</c-> <c- b>mixin</c-> <dfn id='navigatorcontentutils'><c- g>NavigatorContentUtils</c-></dfn> {
  <c- b>void</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- b>DOMString</c-> <c- g>title</c->);
  <c- b>void</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>

  <p>The <dfn id=dom-navigator-registerprotocolhandler><code>registerProtocolHandler()</code></dfn> method
  allows Web sites to register themselves as possible handlers for particular schemes. 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://tools.ietf.org/html/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>

  <dl class=domintro><dt><var>window</var> . <code id=custom-handlers:dom-navigator><a href=#dom-navigator>navigator</a></code> . <code id=dom-navigator-registerprotocolhandler-dev><a href=#dom-navigator-registerprotocolhandler>registerProtocolHandler</a></code>(<var>scheme</var>, <var>url</var>, <var>title</var>)<dd>
    <p>Registers a handler for the given scheme, at the given URL, with the given title.</p>

    <p>The string "<code>%s</code>" in the URL 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://heycam.github.io/webidl/#securityerror data-x-internal=securityerror>"<code>SecurityError</code>"</a> <code id=custom-handlers:domexception><a data-x-internal=domexception href=https://heycam.github.io/webidl/#dfn-DOMException>DOMException</a></code> if the user
    agent blocks the registration (this might happen if trying to register as a handler for "http",
    for instance).</p>

    <p>Throws a <a id=custom-handlers:syntaxerror href=https://heycam.github.io/webidl/#syntaxerror data-x-internal=syntaxerror>"<code>SyntaxError</code>"</a> <code id=custom-handlers:domexception-2><a data-x-internal=domexception href=https://heycam.github.io/webidl/#dfn-DOMException>DOMException</a></code> if the "<code>%s</code>" string is missing in the URL.</p>
   </dl>

  

  <p>User agents may, within the constraints described in this section, do whatever they like when
  the method is called. A UA 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. UAs could provide such a UI through modal UI or through a non-modal transient
  notification interface. UAs could also simply 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>The arguments to the method have the following meanings and corresponding implementation
  requirements. The requirements that involve throwing exceptions must be processed in the order
  given below, stopping at the first exception thrown. (So the exceptions for the first argument
  take precedence over the exceptions for the second argument.)</p>

  <dl><dt><var>scheme</var><dd>
    <p>A scheme, such as "<code>mailto</code>" or "<code>web+auth</code>". The
    scheme must be compared in an <a id=custom-handlers:ascii-case-insensitive href=https://infra.spec.whatwg.org/#ascii-case-insensitive data-x-internal=ascii-case-insensitive>ASCII case-insensitive</a> manner by user agents for the
    purposes of comparing with the scheme part of URLs that they consider against the list of
    registered handlers.</p>

    <p>The <var>scheme</var> value, if it contains a colon (as in "<code>mailto:</code>"),
    will never match anything, since schemes don't contain colons.</p>

    <p>If the <code id=custom-handlers:dom-navigator-registerprotocolhandler-3><a href=#dom-navigator-registerprotocolhandler>registerProtocolHandler()</a></code>
    method is invoked with a scheme that is neither a <a href=#safelisted-scheme id=custom-handlers:safelisted-scheme>safelisted scheme</a> nor a scheme
    whose value starts with the substring "<code>web+</code>" and otherwise contains only
    <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>, and whose length is at least five
    characters (including the "<code>web+</code>" prefix), the user agent must throw a
    <a id=custom-handlers:securityerror-2 href=https://heycam.github.io/webidl/#securityerror data-x-internal=securityerror>"<code>SecurityError</code>"</a> <code id=custom-handlers:domexception-3><a data-x-internal=domexception href=https://heycam.github.io/webidl/#dfn-DOMException>DOMException</a></code>.</p>

    <p>The following schemes are the <dfn id=safelisted-scheme>safelisted schemes</dfn>:</p>

    <ul class=brief><li><code>bitcoin</code><li><code>geo</code><li><code>im</code><li><code>irc</code><li><code>ircs</code><li><code>magnet</code><li><code>mailto</code><li><code>mms</code><li><code>news</code><li><code>nntp</code><li><code>openpgp4fpr</code><li><code>sip</code><li><code>sms</code><li><code>smsto</code><li><code>ssh</code><li><code>tel</code><li><code>urn</code><li><code>webcal</code><li><code>wtai</code><li><code>xmpp</code></ul>

    <p class=note>This list can be changed. If there are schemes that ought to be added, please
    send feedback.</p>

    <p class=note>This list excludes any schemes that could reasonably be expected to be supported
    inline, e.g. in an <code id=custom-handlers:the-iframe-element><a href=#the-iframe-element>iframe</a></code>, such as <code>http</code> or (more
    theoretically) <code>gopher</code>. If those were supported, they could potentially be
    used in man-in-the-middle attacks, by replacing pages that have frames with such content with
    content under the control of the protocol handler. If the user agent has native support for the
    schemes, this could further be used for cookie-theft attacks.</p>

   <dt><var>url</var><dd>

    <p>A string used to build the <a id=custom-handlers:url href=https://url.spec.whatwg.org/#concept-url data-x-internal=url>URL</a> of the page that will handle the requests.</p>

    <p>User agents must throw a <a id=custom-handlers:syntaxerror-2 href=https://heycam.github.io/webidl/#syntaxerror data-x-internal=syntaxerror>"<code>SyntaxError</code>"</a> <code id=custom-handlers:domexception-4><a data-x-internal=domexception href=https://heycam.github.io/webidl/#dfn-DOMException>DOMException</a></code> if
    the <var>url</var> argument passed to one of these methods does not contain the exact literal
    string "<code>%s</code>".</p>

    <p>User agents must throw a <a id=custom-handlers:syntaxerror-3 href=https://heycam.github.io/webidl/#syntaxerror data-x-internal=syntaxerror>"<code>SyntaxError</code>"</a> <code id=custom-handlers:domexception-5><a data-x-internal=domexception href=https://heycam.github.io/webidl/#dfn-DOMException>DOMException</a></code> if
    <a href=#parse-a-url id=custom-handlers:parse-a-url>parsing</a> the <var>url</var> argument relative to the
    <a href=#relevant-settings-object id=custom-handlers:relevant-settings-object>relevant settings object</a> of this <code id=custom-handlers:navigatorcontentutils><a href=#navigatorcontentutils>NavigatorContentUtils</a></code> object is not
    successful.</p>

    <p class=note>The <a href=#resulting-url-string id=custom-handlers:resulting-url-string>resulting URL string</a> would 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 would include the string "<code>%s</code>" which is not a
    valid component in a URL.</p>

    <p>User agents must throw a <a id=custom-handlers:securityerror-3 href=https://heycam.github.io/webidl/#securityerror data-x-internal=securityerror>"<code>SecurityError</code>"</a> <code id=custom-handlers:domexception-6><a data-x-internal=domexception href=https://heycam.github.io/webidl/#dfn-DOMException>DOMException</a></code>
    if the <a href=#resulting-url-record id=custom-handlers:resulting-url-record>resulting URL record</a> has an <a href=https://url.spec.whatwg.org/#concept-url-origin id=custom-handlers:concept-url-origin data-x-internal=concept-url-origin>origin</a>
    that differs from the <a href=#concept-settings-object-origin id=custom-handlers:concept-settings-object-origin>origin</a> specified by
    the <a href=#relevant-settings-object id=custom-handlers:relevant-settings-object-2>relevant settings object</a> of this <code id=custom-handlers:navigatorcontentutils-2><a href=#navigatorcontentutils>NavigatorContentUtils</a></code> object.</p>

    <p class=note>This is forcibly the case if the <code>%s</code> placeholder is in the
    scheme, host, or port parts of the URL.</p>

    <p>The <a href=#resulting-url-string id=custom-handlers:resulting-url-string-2>resulting URL string</a> is the <dfn id=proto-url>proto-URL</dfn>. It identifies the
    handler for the purposes of the methods described below.</p>

    <p>When the user agent uses this handler, it must replace the first occurrence of the exact
    literal string "<code>%s</code>" in the <var>url</var> argument with an
    escaped version of the <a id=custom-handlers:absolute-url href=https://url.spec.whatwg.org/#syntax-url-absolute data-x-internal=absolute-url>absolute URL</a> of the content in question (as defined below),
    then <a href=#parse-a-url id=custom-handlers:parse-a-url-2>parse</a> the resulting URL, relative to the <a href=#relevant-settings-object id=custom-handlers:relevant-settings-object-3>relevant
    settings object</a> of the <code id=custom-handlers:navigatorcontentutils-3><a href=#navigatorcontentutils>NavigatorContentUtils</a></code> object on which the <code id=custom-handlers:dom-navigator-registerprotocolhandler-4><a href=#dom-navigator-registerprotocolhandler>registerProtocolHandler()</a></code> method was
    invoked, and then <a href=#navigate id=custom-handlers:navigate>navigate</a> an appropriate <a href=#browsing-context id=custom-handlers:browsing-context>browsing
    context</a> to the resulting URL.</p>

    <p>To get the escaped version of the <a id=custom-handlers:absolute-url-2 href=https://url.spec.whatwg.org/#syntax-url-absolute data-x-internal=absolute-url>absolute URL</a> of the content in question, the
    user agent must replace every character in that <a id=custom-handlers:absolute-url-3 href=https://url.spec.whatwg.org/#syntax-url-absolute data-x-internal=absolute-url>absolute URL</a> that is not a
    character in the URL <a id=custom-handlers:default-encode-set href=https://url.spec.whatwg.org/#default-encode-set data-x-internal=default-encode-set>default encode set</a> with the result of <a href=https://url.spec.whatwg.org/#utf-8-percent-encode id=custom-handlers:utf-8-percent-encode data-x-internal=utf-8-percent-encode>UTF-8 percent encoding</a> that character.</p>

    <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>&apos;web+soup&apos;</c-><c- p>,</c-> <c- t>&apos;soup?url=%s&apos;</c-><c- p>,</c-> <c- t>&apos;SoupWeb™&apos;</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>&quot;web+soup:chicken-kïwi&quot;</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>

   <dt><var>title</var><dd>

    <p>A descriptive title of the handler, which the UA might use to remind the user what the site
    in question is.</p>

   </dl>

  <p>This section does not define how the pages registered by this method are used, beyond the
  requirements on how to process the <var>url</var> value (see above). To some extent, the
  <a href=#navigate id=custom-handlers:navigate-2>processing model for navigating across documents</a> defines some cases
  where these methods are relevant, but in general UAs may use this information wherever they would
  otherwise consider handing content to native plugins or helper applications.</p>

  <hr>

  

  <p>In addition to the registration method, there is also a method for unregistering handlers.</p>

  <dl class=domintro><dt><var>window</var> . <code id=custom-handlers:dom-navigator-2><a href=#dom-navigator>navigator</a></code> . <code id=dom-navigator-unregisterprotocolhandler-dev><a href=#dom-navigator-unregisterprotocolhandler>unregisterProtocolHandler</a></code>(<var>scheme</var>, <var>url</var>)<dd>

    <p>Unregisters the handler given by the arguments.</p>

   </dl>

  

  <p>The <dfn id=dom-navigator-unregisterprotocolhandler><code>unregisterProtocolHandler()</code></dfn>
  method must unregister the handler described by the two arguments to the method, where the first
  argument gives the scheme and the second gives the string used to build the <a id=custom-handlers:url-2 href=https://url.spec.whatwg.org/#concept-url data-x-internal=url>URL</a> of
  the page that will handle the requests.</p>

  <p>The first argument must be compared to the schemes for which custom protocol handlers are
  registered in an <a id=custom-handlers:ascii-case-insensitive-2 href=https://infra.spec.whatwg.org/#ascii-case-insensitive data-x-internal=ascii-case-insensitive>ASCII case-insensitive</a> manner to find the relevant handlers.</p>

  <p>The second argument must be preprocessed as described below, and if that is successful, must
  then be matched against the <a href=#proto-url id=custom-handlers:proto-url>proto-URLs</a> of the relevant handlers to
  find the described handler.</p>

  <p>The second argument must be preprocessed as follows:</p>

  <ol><li><p>If the string does not contain the substring "<code>%s</code>", then return.
   There's no matching handler.<li><p><a href=#parse-a-url id=custom-handlers:parse-a-url-3>Parse</a> the string relative to the <a href=#relevant-settings-object id=custom-handlers:relevant-settings-object-4>relevant settings
   object</a> of this <code id=custom-handlers:navigatorcontentutils-4><a href=#navigatorcontentutils>NavigatorContentUtils</a></code> object. If this fails, then throw a
   <a id=custom-handlers:syntaxerror-4 href=https://heycam.github.io/webidl/#syntaxerror data-x-internal=syntaxerror>"<code>SyntaxError</code>"</a> <code id=custom-handlers:domexception-7><a data-x-internal=domexception href=https://heycam.github.io/webidl/#dfn-DOMException>DOMException</a></code>.<li><p>If the <a href=#resulting-url-record id=custom-handlers:resulting-url-record-2>resulting URL record</a>'s <a href=https://url.spec.whatwg.org/#concept-url-origin id=custom-handlers:concept-url-origin-2 data-x-internal=concept-url-origin>origin</a>
   is not the <a href=#same-origin id=custom-handlers:same-origin>same origin</a> as the <a href=#concept-settings-object-origin id=custom-handlers:concept-settings-object-origin-2>origin</a> of the <a href=#relevant-settings-object id=custom-handlers:relevant-settings-object-5>relevant settings
   object</a> of this <code id=custom-handlers:navigatorcontentutils-5><a href=#navigatorcontentutils>NavigatorContentUtils</a></code> object, then throw a
   <a id=custom-handlers:securityerror-4 href=https://heycam.github.io/webidl/#securityerror data-x-internal=securityerror>"<code>SecurityError</code>"</a> <code id=custom-handlers:domexception-8><a data-x-internal=domexception href=https://heycam.github.io/webidl/#dfn-DOMException>DOMException</a></code>.<li><p>Return the <a href=#resulting-url-string id=custom-handlers:resulting-url-string-3>resulting URL string</a> as the result of preprocessing the
   argument.</ol>

  




  

  <h6 id=security-and-privacy><span class=secno>8.8.1.3.1</span> Security and privacy<a href=#security-and-privacy class=self-link></a></h6>

  <p>These mechanisms 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>Misleading titles.</strong> User agents should not rely wholly on the <var>title</var>
  argument to the methods when presenting the registered handlers to the user, since sites could
  easily lie. For example, a site <code>hostile.example.net</code> could claim that it was
  registering the "Cuddly Bear Happy Scheme Handler". User agents should therefore use the handler's
  origin in any UI along with any title.</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 Intranet URLs.</strong> The mechanism described in this section can result in
  secret Intranet URLs being leaked, in the following manner:</p>

  <ol><li>The user registers a third-party scheme handler as the default handler for a scheme.<li>The user then browses their corporate Intranet site and accesses a URL that uses that
   scheme.<li>The user agent contacts the third party and hands the third party the URL to the Intranet
   content.</ol>

  <p>No actual confidential file data is leaked in this manner, but the URLs themselves could
  contain confidential information. For example, the URL could be <code>https://www.corp.example.com/upcoming-aquisitions/the-sample-company.egf</code>, which
  might tell the third party that Example Corporation is intending to merge with The Sample Company.
  Implementors might wish to consider allowing administrators to disable this feature for certain
  subdomains, content types, or schemes.</p>

  <p><strong>Leaking credentials.</strong> User agents must never send username or password
  information in the URLs that are escaped and included sent to the handler sites. User agents may
  even avoid attempting to pass to Web-based handlers the URLs of resources that are known to
  require authentication to access, as such sites would be unable to access the resources in
  question without prompting the user for credentials themselves (a practice that would require the
  user to know whether to trust the third-party handler, a decision many users are unable to make or
  even understand).</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>

  



  <h5 id=cookies><span class=secno>8.8.1.4</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'><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><var>window</var> . <code id=cookies:dom-navigator><a href=#dom-navigator>navigator</a></code> . <code id=dom-navigator-cookieenabled-dev><a href=#dom-navigator-cookieenabled>cookieEnabled</a></code><dd>

    <p>Returns false if setting a cookie will be ignored, and true otherwise.</p>

   </dl>

  

   <p>The <dfn id=dom-navigator-cookieenabled><code>cookieEnabled</code></dfn> attribute must
   return true if the user agent attempts to handle cookies according to the cookie specification,
   and false if it ignores cookie change requests. <a href=#refsCOOKIES>[COOKIES]</a></p>

  



  <h5 id=plugins-2><span class=secno>8.8.1.5</span> Plugins<a href=#plugins-2 class=self-link></a></h5>

  <pre><code class='idl'><c- b>interface</c-> <c- b>mixin</c-> <dfn id='navigatorplugins'><c- g>NavigatorPlugins</c-></dfn> {
  [<c- g>SameObject</c->] <c- b>readonly</c-> <c- b>attribute</c-> <a href='#pluginarray' id='plugins-2:pluginarray'><c- n>PluginArray</c-></a> <a href='#dom-navigator-plugins' id='plugins-2:dom-navigator-plugins'><c- g>plugins</c-></a>;
  [<c- g>SameObject</c->] <c- b>readonly</c-> <c- b>attribute</c-> <a href='#mimetypearray' id='plugins-2:mimetypearray'><c- n>MimeTypeArray</c-></a> <a href='#dom-navigator-mimetypes' id='plugins-2:dom-navigator-mimetypes'><c- g>mimeTypes</c-></a>;
  <c- b>boolean</c-> <a href='#dom-navigator-javaenabled' id='plugins-2:dom-navigator-javaenabled'><c- g>javaEnabled</c->()</a>;
};

[<c- g>Exposed</c->=<c- n>Window</c->,
 <c- g>LegacyUnenumerableNamedProperties</c->]
<c- b>interface</c-> <dfn id='pluginarray'><c- g>PluginArray</c-></dfn> {
  <c- b>void</c-> <a href='#dom-pluginarray-refresh' id='plugins-2:dom-pluginarray-refresh'><c- g>refresh</c-></a>(<c- b>optional</c-> <c- b>boolean</c-> <c- g>reload</c-> = <c- b>false</c->);
  <c- b>readonly</c-> <c- b>attribute</c-> <c- b>unsigned</c-> <c- b>long</c-> <a href='#dom-pluginarray-length' id='plugins-2:dom-pluginarray-length'><c- g>length</c-></a>;
  <c- b>getter</c-> <a href='#dom-plugin' id='plugins-2:dom-plugin'><c- n>Plugin</c-></a>? <a href='#dom-pluginarray-item' id='plugins-2: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='#dom-plugin' id='plugins-2:dom-plugin-2'><c- n>Plugin</c-></a>? <a href='#dom-pluginarray-nameditem' id='plugins-2:dom-pluginarray-nameditem'><c- g>namedItem</c-></a>(<c- b>DOMString</c-> <c- g>name</c->);
};

[<c- g>Exposed</c->=<c- n>Window</c->,
 <c- g>LegacyUnenumerableNamedProperties</c->]
<c- b>interface</c-> <dfn id='mimetypearray'><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='plugins-2:dom-mimetypearray-length'><c- g>length</c-></a>;
  <c- b>getter</c-> <a href='#mimetype' id='plugins-2:mimetype'><c- n>MimeType</c-></a>? <a href='#dom-mimetypearray-item' id='plugins-2: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='plugins-2:mimetype-2'><c- n>MimeType</c-></a>? <a href='#dom-mimetypearray-nameditem' id='plugins-2:dom-mimetypearray-nameditem'><c- g>namedItem</c-></a>(<c- b>DOMString</c-> <c- g>name</c->);
};

[<c- g>Exposed</c->=<c- n>Window</c->,
 <c- g>LegacyUnenumerableNamedProperties</c->]
<c- b>interface</c-> <dfn id='dom-plugin'><c- g>Plugin</c-></dfn> {
  <c- b>readonly</c-> <c- b>attribute</c-> <c- b>DOMString</c-> <a href='#dom-plugin-name' id='plugins-2: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='plugins-2: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='plugins-2: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='plugins-2:dom-plugin-length'><c- g>length</c-></a>;
  <c- b>getter</c-> <a href='#mimetype' id='plugins-2:mimetype-3'><c- n>MimeType</c-></a>? <a href='#dom-plugin-item' id='plugins-2: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='plugins-2:mimetype-4'><c- n>MimeType</c-></a>? <a href='#dom-plugin-nameditem' id='plugins-2: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'><c- g>MimeType</c-></dfn> {
  <c- b>readonly</c-> <c- b>attribute</c-> <c- b>DOMString</c-> <a href='#dom-mimetype-type' id='plugins-2: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='plugins-2: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='plugins-2:dom-mimetype-suffixes'><c- g>suffixes</c-></a>; // comma-separated
  <c- b>readonly</c-> <c- b>attribute</c-> <a href='#dom-plugin' id='plugins-2:dom-plugin-3'><c- n>Plugin</c-></a> <a href='#dom-mimetype-enabledplugin' id='plugins-2:dom-mimetype-enabledplugin'><c- g>enabledPlugin</c-></a>;
};</code></pre>

  <dl class=domintro><dt><var>window</var> . <code id=plugins-2:dom-navigator><a href=#dom-navigator>navigator</a></code> . <code id=dom-navigator-plugins-dev><a href=#dom-navigator-plugins>plugins</a></code> . <code id=dom-pluginarray-refresh-dev><a href=#dom-pluginarray-refresh>refresh</a></code>( [ <var>refresh</var> ] )<dd>
    <p>Updates the lists of supported plugins and MIME types for this page, and reloads the page if the lists have changed.</p>
    
   <dt><var>window</var> . <code id=plugins-2:dom-navigator-2><a href=#dom-navigator>navigator</a></code> . <code id=plugins-2:dom-navigator-plugins-2><a href=#dom-navigator-plugins>plugins</a></code> . <code id=dom-pluginarray-length-dev><a href=#dom-pluginarray-length>length</a></code><dd>
    <p>Returns the number of plugins, represented by <code id=plugins-2:dom-plugin-4><a href=#dom-plugin>Plugin</a></code> objects, that the user agent reports.</p>
   <dt><var>plugin</var> = <var>window</var> . <code id=plugins-2:dom-navigator-3><a href=#dom-navigator>navigator</a></code> . <code id=plugins-2:dom-navigator-plugins-3><a href=#dom-navigator-plugins>plugins</a></code> . <code id=dom-pluginarray-item-dev><a href=#dom-pluginarray-item>item</a></code>(<var>index</var>)<dt><var>window</var> . <code id=plugins-2:dom-navigator-4><a href=#dom-navigator>navigator</a></code> . <code id=plugins-2:dom-navigator-plugins-4><a href=#dom-navigator-plugins>plugins</a></code>[<var>index</var>]<dd>
    <p>Returns the specified <code id=plugins-2:dom-plugin-5><a href=#dom-plugin>Plugin</a></code> object.</p>
   <dt><var>plugin</var> = <var>window</var> . <code id=plugins-2:dom-navigator-5><a href=#dom-navigator>navigator</a></code> . <code id=plugins-2:dom-navigator-plugins-5><a href=#dom-navigator-plugins>plugins</a></code> . <code id=plugins-2:dom-pluginarray-item-2><a href=#dom-pluginarray-item>item</a></code>(<var>name</var>)<dt><var>window</var> . <code id=plugins-2:dom-navigator-6><a href=#dom-navigator>navigator</a></code> . <code id=plugins-2:dom-navigator-plugins-6><a href=#dom-navigator-plugins>plugins</a></code>[<var>name</var>]<dd>
    <p>Returns the <code id=plugins-2:dom-plugin-6><a href=#dom-plugin>Plugin</a></code> object for the plugin with the given name.</p>
   <dt><var>window</var> . <code id=plugins-2:dom-navigator-7><a href=#dom-navigator>navigator</a></code> . <code id=dom-navigator-mimetypes-dev><a href=#dom-navigator-mimetypes>mimeTypes</a></code> . <code id=dom-mimetypearray-length-dev><a href=#dom-mimetypearray-length>length</a></code><dd>
    <p>Returns the number of MIME types, represented by <code id=plugins-2:mimetype-5><a href=#mimetype>MimeType</a></code> objects, supported by the plugins that the user agent reports.</p>
   <dt><var>mimeType</var> = <var>window</var> . <code id=plugins-2:dom-navigator-8><a href=#dom-navigator>navigator</a></code> . <code id=plugins-2:dom-navigator-mimetypes-2><a href=#dom-navigator-mimetypes>mimeTypes</a></code> . <code id=dom-mimetypearray-item-dev><a href=#dom-mimetypearray-item>item</a></code>(<var>index</var>)<dt><var>window</var> . <code id=plugins-2:dom-navigator-9><a href=#dom-navigator>navigator</a></code> . <code id=plugins-2:dom-navigator-mimetypes-3><a href=#dom-navigator-mimetypes>mimeTypes</a></code>[<var>index</var>]<dd>
    <p>Returns the specified <code id=plugins-2:mimetype-6><a href=#mimetype>MimeType</a></code> object.</p>
   <dt><var>mimeType</var> = <var>window</var> . <code id=plugins-2:dom-navigator-10><a href=#dom-navigator>navigator</a></code> . <code id=plugins-2:dom-navigator-mimetypes-4><a href=#dom-navigator-mimetypes>mimeTypes</a></code> . <code id=plugins-2:dom-mimetypearray-item-2><a href=#dom-mimetypearray-item>item</a></code>(<var>name</var>)<dt><var>window</var> . <code id=plugins-2:dom-navigator-11><a href=#dom-navigator>navigator</a></code> . <code id=plugins-2:dom-navigator-mimetypes-5><a href=#dom-navigator-mimetypes>mimeTypes</a></code>[<var>name</var>]<dd>
    <p>Returns the <code id=plugins-2:mimetype-7><a href=#mimetype>MimeType</a></code> object for the given MIME type.</p>
   <dt><var>plugin</var> . <code id=dom-plugin-name-dev><a href=#dom-plugin-name>name</a></code>
   <dd>
    <p>Returns the plugin's name.</p>
   <dt><var>plugin</var> . <code id=dom-plugin-description-dev><a href=#dom-plugin-description>description</a></code>
   <dd>
    <p>Returns the plugin's description.</p>
   <dt><var>plugin</var> . <code id=dom-plugin-filename-dev><a href=#dom-plugin-filename>filename</a></code>
   <dd>
    <p>Returns the plugin library's filename, if applicable on the current platform.</p>
   <dt><var>plugin</var> . <code id=dom-plugin-length-dev><a href=#dom-plugin-length>length</a></code><dd>
    <p>Returns the number of MIME types, represented by <code id=plugins-2:mimetype-8><a href=#mimetype>MimeType</a></code> objects, supported by the plugin.</p>
   <dt><var>mimeType</var> = <var>plugin</var> . <code id=dom-plugin-item-dev><a href=#dom-plugin-item>item</a></code>(<var>index</var>)<dt><var>plugin</var>[<var>index</var>]<dd>
    <p>Returns the specified <code id=plugins-2:mimetype-9><a href=#mimetype>MimeType</a></code> object.</p>
   <dt><var>mimeType</var> = <var>plugin</var> . <code id=plugins-2:dom-plugin-item-2><a href=#dom-plugin-item>item</a></code>(<var>name</var>)<dt><var>plugin</var>[<var>name</var>]<dd>
    <p>Returns the <code id=plugins-2:mimetype-10><a href=#mimetype>MimeType</a></code> object for the given MIME type.</p>
   <dt><var>mimeType</var> . <code id=dom-mimetype-type-dev><a href=#dom-mimetype-type>type</a></code>
   <dd>
    <p>Returns the MIME type.</p>
   <dt><var>mimeType</var> . <code id=dom-mimetype-description-dev><a href=#dom-mimetype-description>description</a></code>
   <dd>
    <p>Returns the MIME type's description.</p>
   <dt><var>mimeType</var> . <code id=dom-mimetype-suffixes-dev><a href=#dom-mimetype-suffixes>suffixes</a></code>
   <dd>
    <p>Returns the MIME type's typical file extensions, in a comma-separated list.</p>
   <dt><var>mimeType</var> . <code id=dom-mimetype-enabledplugin-dev><a href=#dom-mimetype-enabledplugin>enabledPlugin</a></code>
   <dd>
    <p>Returns the <code id=plugins-2:dom-plugin-7><a href=#dom-plugin>Plugin</a></code> object that implements this MIME type.</p>
   <dt><var>window</var> . <code id=plugins-2:dom-navigator-12><a href=#dom-navigator>navigator</a></code> . <code id=dom-navigator-javaenabled-dev><a href=#dom-navigator-javaenabled>javaEnabled()</a></code><dd>
    <p>Returns true if there's a plugin that supports the MIME type "<code>application/x-java-vm</code>".</p>
   </dl>

  

  <p>The <dfn id=dom-navigator-plugins><code>navigator.plugins</code></dfn> attribute must
  return a <code id=plugins-2:pluginarray-2><a href=#pluginarray>PluginArray</a></code> object.</p>

  <p>The <dfn id=dom-navigator-mimetypes><code>navigator.mimeTypes</code></dfn> attribute must
  return a <code id=plugins-2:mimetypearray-2><a href=#mimetypearray>MimeTypeArray</a></code> object.</p>

  <hr>

  <p>A <code id=plugins-2:pluginarray-3><a href=#pluginarray>PluginArray</a></code> object represents none, some, or all of the <a href=#plugin id=plugins-2:plugin>plugins</a> supported by the user agent, each of which is represented by a <code id=plugins-2:dom-plugin-8><a href=#dom-plugin>Plugin</a></code> object. Each of these <code id=plugins-2:dom-plugin-9><a href=#dom-plugin>Plugin</a></code>
  objects may be <dfn id=hidden-plugin>hidden plugins</dfn>. A <a href=#hidden-plugin id=plugins-2:hidden-plugin>hidden plugin</a> can't
  be enumerated, but can still be inspected by using its name.</p>

  <p class=note>The fewer <a href=#plugin id=plugins-2:plugin-2>plugins</a> are represented by the
  <code id=plugins-2:pluginarray-4><a href=#pluginarray>PluginArray</a></code> object, and of those, the more that are <a href=#hidden-plugin id=plugins-2:hidden-plugin-2>hidden</a>, the more the user's privacy will be protected. Each exposed plugin
  increases the number of bits that can be derived for fingerprinting. Hiding a plugin helps, but
  unless it is an extremely rare plugin, it is likely that a site attempting to derive the list of
  plugins can still determine whether the plugin is supported or not by probing for it by name (the
  names of popular plugins are widely known). Therefore not exposing a plugin at all is preferred.
  Unfortunately, many legacy sites use this feature to determine, for example, which plugin to use
  to play video. Not exposing any plugins at all might therefore not be entirely plausible.</p>

  <p>The <code id=plugins-2:pluginarray-5><a href=#pluginarray>PluginArray</a></code> objects created by a user agent must not be <a href=#live id=plugins-2:live>live</a>. The
  set of plugins represented by the objects must not change once an object is created, except when
  it is updated by the <code id=plugins-2:dom-pluginarray-refresh-2><a href=#dom-pluginarray-refresh>refresh()</a></code> method.</p>

  <p>Each <a href=#plugin id=plugins-2:plugin-3>plugin</a> represented by a <code id=plugins-2:pluginarray-6><a href=#pluginarray>PluginArray</a></code> can support a number of
  <a href=https://mimesniff.spec.whatwg.org/#mime-type id=plugins-2:mime-type data-x-internal=mime-type>MIME types</a>. For each such <a href=#plugin id=plugins-2:plugin-4>plugin</a>, the user agent must
  pick one or more of these <a href=https://mimesniff.spec.whatwg.org/#mime-type id=plugins-2:mime-type-2 data-x-internal=mime-type>MIME types</a> to be those that are
  <dfn id=explicitly-supported>explicitly supported</dfn>.</p>

  <p class=note>The <a href=#explicitly-supported id=plugins-2:explicitly-supported>explicitly supported</a> <a href=https://mimesniff.spec.whatwg.org/#mime-type id=plugins-2:mime-type-3 data-x-internal=mime-type>MIME types</a> of
  a <a href=#plugin id=plugins-2:plugin-5>plugin</a> are those that are exposed through the <code id=plugins-2:dom-plugin-10><a href=#dom-plugin>Plugin</a></code> and <code id=plugins-2:mimetypearray-3><a href=#mimetypearray>MimeTypeArray</a></code> interfaces. As with <a href=#plugin id=plugins-2:plugin-6>plugins</a> themselves, any variation between users regarding what is exposed
  allows sites to fingerprint users. User agents are therefore encouraged to expose the same <a href=https://mimesniff.spec.whatwg.org/#mime-type id=plugins-2:mime-type-4 data-x-internal=mime-type>MIME types</a> for all users of a <a href=#plugin id=plugins-2:plugin-7>plugin</a>, regardless of the
  actual types supported... at least, within the constraints imposed by compatibility with legacy
  content.</p>

  <p>The <a id=plugins-2:supported-property-indices href=https://heycam.github.io/webidl/#dfn-supported-property-indices data-x-internal=supported-property-indices>supported property indices</a> of a <code id=plugins-2:pluginarray-7><a href=#pluginarray>PluginArray</a></code> object are the
  numbers from zero to the number of non-<a href=#hidden-plugin id=plugins-2:hidden-plugin-3>hidden</a> <a href=#plugin id=plugins-2:plugin-8>plugins</a> represented by the object, if any.
  <a href=#fingerprinting-vector id=plugins-2:fingerprinting-vector class=fingerprint title="There is a potential fingerprinting vector here."><img alt="(This is a fingerprinting vector.)" src=/images/fingerprint.png width=46 height=64></a>
  </p>

  <p>The <dfn id=dom-pluginarray-length><code>length</code></dfn> attribute must return the
  number of non-<a href=#hidden-plugin id=plugins-2:hidden-plugin-4>hidden</a> <a href=#plugin id=plugins-2:plugin-9>plugins</a>
  represented by the object.
  <a href=#fingerprinting-vector id=plugins-2:fingerprinting-vector-2 class=fingerprint title="There is a potential fingerprinting vector here."><img alt="(This is a fingerprinting vector.)" src=/images/fingerprint.png width=46 height=64></a>
  </p>

  <p>The <dfn id=dom-pluginarray-item><code>item()</code></dfn> method of a
  <code id=plugins-2:pluginarray-8><a href=#pluginarray>PluginArray</a></code> object must return null if the argument is not one of the object's
  <a id=plugins-2:supported-property-indices-2 href=https://heycam.github.io/webidl/#dfn-supported-property-indices data-x-internal=supported-property-indices>supported property indices</a>, and otherwise must return the result of running the
  following steps, using the method's argument as <var>index</var>:</p>

  <ol><li><p>Let <var>list</var> be the <code id=plugins-2:dom-plugin-11><a href=#dom-plugin>Plugin</a></code> objects
   representing the non-<a href=#hidden-plugin id=plugins-2:hidden-plugin-5>hidden</a> <a href=#plugin id=plugins-2:plugin-10>plugins</a> represented by the <code id=plugins-2:pluginarray-9><a href=#pluginarray>PluginArray</a></code> object.<li><p>Sort <var>list</var> alphabetically by the <code id=plugins-2:dom-plugin-name-2><a href=#dom-plugin-name>name</a></code> of each <code id=plugins-2:dom-plugin-12><a href=#dom-plugin>Plugin</a></code>.<li><p>Return the <var>index</var>th entry in <var>list</var>.</ol>

  <p class=note>It is important <a href=#fingerprinting-vector id=plugins-2:fingerprinting-vector-3 class=no-backref>for
  privacy</a> that the order of plugins not leak additional information, e.g. the order in which
  plugins were installed.</p>

  <p>The <a id=plugins-2:supported-property-names href=https://heycam.github.io/webidl/#dfn-supported-property-names data-x-internal=supported-property-names>supported property names</a> of a <code id=plugins-2:pluginarray-10><a href=#pluginarray>PluginArray</a></code> object are the values
  of the <code id=plugins-2:dom-plugin-name-3><a href=#dom-plugin-name>name</a></code> attributes of all the <code id=plugins-2:dom-plugin-13><a href=#dom-plugin>Plugin</a></code> objects represented by the <code id=plugins-2:pluginarray-11><a href=#pluginarray>PluginArray</a></code> object.
  <a href=#fingerprinting-vector id=plugins-2:fingerprinting-vector-4 class=fingerprint title="There is a potential fingerprinting vector here."><img alt="(This is a fingerprinting vector.)" src=/images/fingerprint.png width=46 height=64></a>
  </p>

  <p>The <dfn id=dom-pluginarray-nameditem><code>namedItem()</code></dfn> method of a
  <code id=plugins-2:pluginarray-12><a href=#pluginarray>PluginArray</a></code> object must return null if the argument is not one of the object's
  <a id=plugins-2:supported-property-names-2 href=https://heycam.github.io/webidl/#dfn-supported-property-names data-x-internal=supported-property-names>supported property names</a>, and otherwise must return the <code id=plugins-2:dom-plugin-14><a href=#dom-plugin>Plugin</a></code> object, of those represented by the <code id=plugins-2:pluginarray-13><a href=#pluginarray>PluginArray</a></code>
  object, that has a <code id=plugins-2:dom-plugin-name-4><a href=#dom-plugin-name>name</a></code> equal to the method's argument.</p>

  <p>The <dfn id=dom-pluginarray-refresh><code>refresh()</code></dfn> method of the
  <code id=plugins-2:pluginarray-14><a href=#pluginarray>PluginArray</a></code> object of a <code id=plugins-2:navigator><a href=#navigator>Navigator</a></code> object, when invoked, must check to
  see if any <a href=#plugin id=plugins-2:plugin-11>plugins</a> have been installed or reconfigured since the user
  agent created the <code id=plugins-2:pluginarray-15><a href=#pluginarray>PluginArray</a></code> object. If so, and the method's argument is true, then
  the user agent must act as if the <code id=plugins-2:dom-location-reload><a href=#dom-location-reload>location.reload()</a></code>
  method was called instead. Otherwise, the user agent must update the <code id=plugins-2:pluginarray-16><a href=#pluginarray>PluginArray</a></code>
  object and <code id=plugins-2:mimetypearray-4><a href=#mimetypearray>MimeTypeArray</a></code> object created for attributes of that <code id=plugins-2:navigator-2><a href=#navigator>Navigator</a></code>
  object, and the <code id=plugins-2:dom-plugin-15><a href=#dom-plugin>Plugin</a></code> and <code id=plugins-2:mimetype-11><a href=#mimetype>MimeType</a></code> objects created
  for those <code id=plugins-2:pluginarray-17><a href=#pluginarray>PluginArray</a></code> and <code id=plugins-2:mimetypearray-5><a href=#mimetypearray>MimeTypeArray</a></code> objects, using the same <code id=plugins-2:dom-plugin-16><a href=#dom-plugin>Plugin</a></code> objects for cases where the <code id=plugins-2:dom-plugin-name-5><a href=#dom-plugin-name>name</a></code> is the same, and the same <code id=plugins-2:mimetype-12><a href=#mimetype>MimeType</a></code> objects for
  cases where the <code id=plugins-2:dom-mimetype-type-2><a href=#dom-mimetype-type>type</a></code> is the same, and creating new objects
  for cases where there were no matching objects immediately prior to the <code id=plugins-2:dom-pluginarray-refresh-3><a href=#dom-pluginarray-refresh>refresh()</a></code> call. Old <code id=plugins-2:dom-plugin-17><a href=#dom-plugin>Plugin</a></code>
  and <code id=plugins-2:mimetype-13><a href=#mimetype>MimeType</a></code> objects must continue to return the same values that they had prior to
  the update, though naturally now the data is stale and may appear inconsistent (for example, an
  old <code id=plugins-2:mimetype-14><a href=#mimetype>MimeType</a></code> entry might list as its <code id=plugins-2:dom-mimetype-enabledplugin-2><a href=#dom-mimetype-enabledplugin>enabledPlugin</a></code> a <code id=plugins-2:dom-plugin-18><a href=#dom-plugin>Plugin</a></code>
  object that no longer lists that <code id=plugins-2:mimetype-15><a href=#mimetype>MimeType</a></code> as a supported <code id=plugins-2:mimetype-16><a href=#mimetype>MimeType</a></code>).</p>

  <hr>

  <p>A <code id=plugins-2:mimetypearray-6><a href=#mimetypearray>MimeTypeArray</a></code> object represents the <a href=https://mimesniff.spec.whatwg.org/#mime-type id=plugins-2:mime-type-5 data-x-internal=mime-type>MIME types</a>
  <a href=#explicitly-supported id=plugins-2:explicitly-supported-2>explicitly supported</a> by <a href=#plugin id=plugins-2:plugin-12>plugins</a> supported by the user
  agent, each of which is represented by a <code id=plugins-2:mimetype-17><a href=#mimetype>MimeType</a></code> object.</p>

  <p>The <code id=plugins-2:mimetypearray-7><a href=#mimetypearray>MimeTypeArray</a></code> objects created by a user agent must not be <a href=#live id=plugins-2:live-2>live</a>.
  The set of MIME types represented by the objects must not change once an object is created, except
  when it is updated by the <code id=plugins-2:pluginarray-18><a href=#pluginarray>PluginArray</a></code> object's <code id=plugins-2:dom-pluginarray-refresh-4><a href=#dom-pluginarray-refresh>refresh()</a></code> method.</p>

  <p>The <a id=plugins-2:supported-property-indices-3 href=https://heycam.github.io/webidl/#dfn-supported-property-indices data-x-internal=supported-property-indices>supported property indices</a> of a <code id=plugins-2:mimetypearray-8><a href=#mimetypearray>MimeTypeArray</a></code> object are the
  numbers from zero to the number of <a href=https://mimesniff.spec.whatwg.org/#mime-type id=plugins-2:mime-type-6 data-x-internal=mime-type>MIME types</a> <a href=#explicitly-supported id=plugins-2:explicitly-supported-3>explicitly
  supported</a> by non-<a href=#hidden-plugin id=plugins-2:hidden-plugin-6>hidden</a> <a href=#plugin id=plugins-2:plugin-13>plugins</a> represented by the corresponding <code id=plugins-2:pluginarray-19><a href=#pluginarray>PluginArray</a></code> object, if
  any.
  <a href=#fingerprinting-vector id=plugins-2:fingerprinting-vector-5 class=fingerprint title="There is a potential fingerprinting vector here."><img alt="(This is a fingerprinting vector.)" src=/images/fingerprint.png width=46 height=64></a>
  </p>

  <p>The <dfn id=dom-mimetypearray-length><code>length</code></dfn> attribute must return the
  number of <a href=https://mimesniff.spec.whatwg.org/#mime-type id=plugins-2:mime-type-7 data-x-internal=mime-type>MIME types</a> <a href=#explicitly-supported id=plugins-2:explicitly-supported-4>explicitly supported</a> by non-<a href=#hidden-plugin id=plugins-2:hidden-plugin-7>hidden</a> <a href=#plugin id=plugins-2:plugin-14>plugins</a> represented by the
  corresponding <code id=plugins-2:pluginarray-20><a href=#pluginarray>PluginArray</a></code> object, if any.
  <a href=#fingerprinting-vector id=plugins-2:fingerprinting-vector-6 class=fingerprint title="There is a potential fingerprinting vector here."><img alt="(This is a fingerprinting vector.)" src=/images/fingerprint.png width=46 height=64></a>
  </p>

  <p>The <dfn id=dom-mimetypearray-item><code>item()</code></dfn> method of a
  <code id=plugins-2:mimetypearray-9><a href=#mimetypearray>MimeTypeArray</a></code> object must return null if the argument is not one of the object's
  <a id=plugins-2:supported-property-indices-4 href=https://heycam.github.io/webidl/#dfn-supported-property-indices data-x-internal=supported-property-indices>supported property indices</a>, and otherwise must return the result of running the
  following steps, using the method's argument as <var>index</var>:</p>

  <ol><li><p>Let <var>list</var> be the <code id=plugins-2:mimetype-18><a href=#mimetype>MimeType</a></code> objects representing the <a href=https://mimesniff.spec.whatwg.org/#mime-type id=plugins-2:mime-type-8 data-x-internal=mime-type>MIME types</a> <a href=#explicitly-supported id=plugins-2:explicitly-supported-5>explicitly supported</a> by non-<a href=#hidden-plugin id=plugins-2:hidden-plugin-8>hidden</a> <a href=#plugin id=plugins-2:plugin-15>plugins</a> represented by the corresponding
   <code id=plugins-2:pluginarray-21><a href=#pluginarray>PluginArray</a></code> object, if any.<li><p>Sort <var>list</var> alphabetically by the <code id=plugins-2:dom-mimetype-type-3><a href=#dom-mimetype-type>type</a></code> of each <code id=plugins-2:mimetype-19><a href=#mimetype>MimeType</a></code>.<li><p>Return the <var>index</var>th entry in <var>list</var>.</ol>

  <p class=note>It is important <a href=#fingerprinting-vector id=plugins-2:fingerprinting-vector-7 class=no-backref>for
  privacy</a> that the order of MIME types not leak additional information, e.g. the order in
  which plugins were installed.</p>

  <p>The <a id=plugins-2:supported-property-names-3 href=https://heycam.github.io/webidl/#dfn-supported-property-names data-x-internal=supported-property-names>supported property names</a> of a <code id=plugins-2:mimetypearray-10><a href=#mimetypearray>MimeTypeArray</a></code> object are the values
  of the <code id=plugins-2:dom-mimetype-type-4><a href=#dom-mimetype-type>type</a></code> attributes of all the <code id=plugins-2:mimetype-20><a href=#mimetype>MimeType</a></code>
  objects represented by the <code id=plugins-2:mimetypearray-11><a href=#mimetypearray>MimeTypeArray</a></code> object.
  <a href=#fingerprinting-vector id=plugins-2:fingerprinting-vector-8 class=fingerprint title="There is a potential fingerprinting vector here."><img alt="(This is a fingerprinting vector.)" src=/images/fingerprint.png width=46 height=64></a>
  </p>

  <p>The <dfn id=dom-mimetypearray-nameditem><code>namedItem()</code></dfn> method of a
  <code id=plugins-2:mimetypearray-12><a href=#mimetypearray>MimeTypeArray</a></code> object must return null if the argument is not one of the object's
  <a id=plugins-2:supported-property-names-4 href=https://heycam.github.io/webidl/#dfn-supported-property-names data-x-internal=supported-property-names>supported property names</a>, and otherwise must return the <code id=plugins-2:mimetype-21><a href=#mimetype>MimeType</a></code> object
  that has a <code id=plugins-2:dom-mimetype-type-5><a href=#dom-mimetype-type>type</a></code> equal to the method's argument.</p>

  <hr>

  <p>A <code id=plugins-2:dom-plugin-19><a href=#dom-plugin>Plugin</a></code> object represents a <a href=#plugin id=plugins-2:plugin-16>plugin</a>. It has
  several attributes to provide details about the plugin, and can be enumerated to obtain the list
  of <a href=https://mimesniff.spec.whatwg.org/#mime-type id=plugins-2:mime-type-9 data-x-internal=mime-type>MIME types</a> that it <a href=#explicitly-supported id=plugins-2:explicitly-supported-6>explicitly
  supports</a>.</p>

  <p>The <code id=plugins-2:dom-plugin-20><a href=#dom-plugin>Plugin</a></code> objects created by a user agent must not be
  <a href=#live id=plugins-2:live-3>live</a>. The set of MIME types represented by the objects, and the values of the
  objects' attributes, must not change once an object is created, except when updated by the
  <code id=plugins-2:pluginarray-22><a href=#pluginarray>PluginArray</a></code> object's <code id=plugins-2:dom-pluginarray-refresh-5><a href=#dom-pluginarray-refresh>refresh()</a></code>
  method.</p>

  <p>The <dfn id=reported-mime-types>reported MIME types</dfn> for a <code id=plugins-2:dom-plugin-21><a href=#dom-plugin>Plugin</a></code> object are the
  <a href=https://mimesniff.spec.whatwg.org/#mime-type id=plugins-2:mime-type-10 data-x-internal=mime-type>MIME types</a> <a href=#explicitly-supported id=plugins-2:explicitly-supported-7>explicitly supported</a> by the corresponding
  <a href=#plugin id=plugins-2:plugin-17>plugin</a> when this object was last created or updated by <code id=plugins-2:dom-pluginarray-refresh-6><a href=#dom-pluginarray-refresh>PluginArray.refresh()</a></code>, whichever happened most
  recently.</p>

  <p>The <a id=plugins-2:supported-property-indices-5 href=https://heycam.github.io/webidl/#dfn-supported-property-indices data-x-internal=supported-property-indices>supported property indices</a> of a <code id=plugins-2:dom-plugin-22><a href=#dom-plugin>Plugin</a></code> object
  are the numbers from zero to the number of <a href=#reported-mime-types id=plugins-2:reported-mime-types>reported MIME types</a>.
  <a href=#fingerprinting-vector id=plugins-2:fingerprinting-vector-9 class=fingerprint title="There is a potential fingerprinting vector here."><img alt="(This is a fingerprinting vector.)" src=/images/fingerprint.png width=46 height=64></a>
  </p>

  <p>The <dfn id=dom-plugin-length><code>length</code></dfn> attribute must return the number
  of <a href=#reported-mime-types id=plugins-2:reported-mime-types-2>reported MIME types</a>.
  <a href=#fingerprinting-vector id=plugins-2:fingerprinting-vector-10 class=fingerprint title="There is a potential fingerprinting vector here."><img alt="(This is a fingerprinting vector.)" src=/images/fingerprint.png width=46 height=64></a>
  </p>

  <p>The <dfn id=dom-plugin-item><code>item()</code></dfn> method of a <code id=plugins-2:dom-plugin-23><a href=#dom-plugin>Plugin</a></code> object must return null if the argument is not one of the
  object's <a id=plugins-2:supported-property-indices-6 href=https://heycam.github.io/webidl/#dfn-supported-property-indices data-x-internal=supported-property-indices>supported property indices</a>, and otherwise must return the result of running
  the following steps, using the method's argument as <var>index</var>:</p>

  <ol><li><p>Let <var>list</var> be the <code id=plugins-2:mimetype-22><a href=#mimetype>MimeType</a></code> objects representing the
   <a href=#reported-mime-types id=plugins-2:reported-mime-types-3>reported MIME types</a>.<li><p>Sort <var>list</var> alphabetically by the <code id=plugins-2:dom-mimetype-type-6><a href=#dom-mimetype-type>type</a></code> of each <code id=plugins-2:mimetype-23><a href=#mimetype>MimeType</a></code>.<li><p>Return the <var>index</var>th entry in <var>list</var>.</ol>

  <p class=note>It is important <a href=#fingerprinting-vector id=plugins-2:fingerprinting-vector-11 class=no-backref>for
  privacy</a> that the order of MIME types not leak additional information, e.g. the order in
  which plugins were installed.</p>

  <p>The <a id=plugins-2:supported-property-names-5 href=https://heycam.github.io/webidl/#dfn-supported-property-names data-x-internal=supported-property-names>supported property names</a> of a <code id=plugins-2:dom-plugin-24><a href=#dom-plugin>Plugin</a></code> object
  are the values of the <code id=plugins-2:dom-mimetype-type-7><a href=#dom-mimetype-type>type</a></code> attributes of the
  <code id=plugins-2:mimetype-24><a href=#mimetype>MimeType</a></code> objects representing the <a href=#reported-mime-types id=plugins-2:reported-mime-types-4>reported MIME types</a>.
  <a href=#fingerprinting-vector id=plugins-2:fingerprinting-vector-12 class=fingerprint title="There is a potential fingerprinting vector here."><img alt="(This is a fingerprinting vector.)" src=/images/fingerprint.png width=46 height=64></a>
  </p>

  <p>The <dfn id=dom-plugin-nameditem><code>namedItem()</code></dfn> method of a <code id=plugins-2:dom-plugin-25><a href=#dom-plugin>Plugin</a></code> object must return null if the argument is not one of the
  object's <a id=plugins-2:supported-property-names-6 href=https://heycam.github.io/webidl/#dfn-supported-property-names data-x-internal=supported-property-names>supported property names</a>, and otherwise must return the
  <code id=plugins-2:mimetype-25><a href=#mimetype>MimeType</a></code> object that has a <code id=plugins-2:dom-mimetype-type-8><a href=#dom-mimetype-type>type</a></code> equal to the
  method's argument.</p>

  <p>The <dfn id=dom-plugin-name><code>name</code></dfn> attribute must return the
  <a href=#plugin id=plugins-2:plugin-18>plugin</a>'s name.</p>

  <p>The <dfn id=dom-plugin-description><code>description</code></dfn> and <dfn id=dom-plugin-filename><code>filename</code></dfn> attributes must return user-agent-defined
  (or, in all likelihood, <a href=#plugin id=plugins-2:plugin-19>plugin</a>-defined) strings. In each case, the same string must
  be returned each time, except that the strings returned may change when the <code id=plugins-2:dom-pluginarray-refresh-7><a href=#dom-pluginarray-refresh>PluginArray.refresh()</a></code> method updates the object.</p>

  <p class=warning>If the values returned by the <code id=plugins-2:dom-plugin-description-2><a href=#dom-plugin-description>description</a></code> or <code id=plugins-2:dom-plugin-filename-2><a href=#dom-plugin-filename>filename</a></code> attributes vary between versions of a
  <a href=#plugin id=plugins-2:plugin-20>plugin</a>, they can be used both as a fingerprinting vector and, even more importantly,
  as a trivial way to determine what security vulnerabilities a <a href=#plugin id=plugins-2:plugin-21>plugin</a> (and thus a
  browser) may have. It is thus highly recommended that the <code id=plugins-2:dom-plugin-description-3><a href=#dom-plugin-description>description</a></code> attribute just return the same value as the
  <code id=plugins-2:dom-plugin-name-6><a href=#dom-plugin-name>name</a></code> attribute, and that the <code id=plugins-2:dom-plugin-filename-3><a href=#dom-plugin-filename>filename</a></code> attribute return the empty string.
  <a href=#fingerprinting-vector id=plugins-2:fingerprinting-vector-13 class=fingerprint title="There is a potential fingerprinting vector here."><img alt="(This is a fingerprinting vector.)" src=/images/fingerprint.png width=46 height=64></a>
  </p>

  <hr>

  <p>A <code id=plugins-2:mimetype-26><a href=#mimetype>MimeType</a></code> object represents a <a id=plugins-2:mime-type-11 href=https://mimesniff.spec.whatwg.org/#mime-type data-x-internal=mime-type>MIME type</a> that is, or was,
  <a href=#explicitly-supported id=plugins-2:explicitly-supported-8>explicitly supported</a> by a <a href=#plugin id=plugins-2:plugin-22>plugin</a>.</p>

  <p>The <code id=plugins-2:mimetype-27><a href=#mimetype>MimeType</a></code> objects created by a user agent must not be <a href=#live id=plugins-2:live-4>live</a>. The
  values of the objects' attributes must not change once an object is created, except when updated
  by the <code id=plugins-2:pluginarray-23><a href=#pluginarray>PluginArray</a></code> object's <code id=plugins-2:dom-pluginarray-refresh-8><a href=#dom-pluginarray-refresh>refresh()</a></code>
  method.</p>

  <p>The <dfn id=dom-mimetype-type><code>type</code></dfn> attribute must return the
  <a id=plugins-2: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> describing the <a id=plugins-2:mime-type-12 href=https://mimesniff.spec.whatwg.org/#mime-type data-x-internal=mime-type>MIME type</a>.</p>

  <p>The <dfn id=dom-mimetype-description><code>description</code></dfn> and <dfn id=dom-mimetype-suffixes><code>suffixes</code></dfn> attributes must return
  user-agent-defined (or, in all likelihood, <a href=#plugin id=plugins-2:plugin-23>plugin</a>-defined) strings. In each case, the
  same string must be returned each time, except that the strings returned may change when the <code id=plugins-2:dom-pluginarray-refresh-9><a href=#dom-pluginarray-refresh>PluginArray.refresh()</a></code> method updates the object.</p>

  <p class=warning>If the values returned by the <code id=plugins-2:dom-mimetype-description-2><a href=#dom-mimetype-description>description</a></code> or <code id=plugins-2:dom-mimetype-suffixes-2><a href=#dom-mimetype-suffixes>suffixes</a></code> attributes vary between versions of a
  <a href=#plugin id=plugins-2:plugin-24>plugin</a>, they can be used both as a fingerprinting vector and, even more importantly,
  as a trivial way to determine what security vulnerabilities a <a href=#plugin id=plugins-2:plugin-25>plugin</a> (and thus a
  browser) may have. It is thus highly recommended that the <code id=plugins-2:dom-mimetype-description-3><a href=#dom-mimetype-description>description</a></code> attribute just return the same value as the
  <code id=plugins-2:dom-mimetype-type-9><a href=#dom-mimetype-type>type</a></code> attribute, and that the <code id=plugins-2:dom-mimetype-suffixes-3><a href=#dom-mimetype-suffixes>suffixes</a></code> attribute return the empty string.
  <a href=#fingerprinting-vector id=plugins-2:fingerprinting-vector-14 class=fingerprint title="There is a potential fingerprinting vector here."><img alt="(This is a fingerprinting vector.)" src=/images/fingerprint.png width=46 height=64></a>
  </p>

  <p class=note>Commas in the <code id=plugins-2:dom-mimetype-suffixes-4><a href=#dom-mimetype-suffixes>suffixes</a></code> attribute are
  interpreted as separating subsequent filename extensions, as in "<code>htm,html</code>".</p>

  <p>The <dfn id=dom-mimetype-enabledplugin><code>enabledPlugin</code></dfn> attribute must
  return the <code id=plugins-2:dom-plugin-26><a href=#dom-plugin>Plugin</a></code> object that represents the <a href=#plugin id=plugins-2:plugin-26>plugin</a>
  that <a href=#explicitly-supported id=plugins-2:explicitly-supported-9>explicitly supported</a> the <a id=plugins-2:mime-type-13 href=https://mimesniff.spec.whatwg.org/#mime-type data-x-internal=mime-type>MIME type</a> that this <code id=plugins-2:mimetype-28><a href=#mimetype>MimeType</a></code>
  object represents when this object was last created or updated by <code id=plugins-2:dom-pluginarray-refresh-10><a href=#dom-pluginarray-refresh>PluginArray.refresh()</a></code>, whichever happened most
  recently.</p>

  <hr>

  <p>The <dfn id=dom-navigator-javaenabled><code>navigator.javaEnabled()</code></dfn> method
  must return true if the user agent supports a <a href=#plugin id=plugins-2:plugin-27>plugin</a> that supports the <a id=plugins-2:mime-type-14 href=https://mimesniff.spec.whatwg.org/#mime-type data-x-internal=mime-type>MIME
  type</a> "<code>application/x-java-vm</code>"; otherwise it must return false.
  <a href=#fingerprinting-vector id=plugins-2:fingerprinting-vector-15 class=fingerprint title="There is a potential fingerprinting vector here."><img alt="(This is a fingerprinting vector.)" src=/images/fingerprint.png width=46 height=64></a>
  </p>

  



  <h3 id=images-2><span class=secno>8.9</span> Images<a href=#images-2 class=self-link></a></h3>

  <pre><code class='idl'>[<c- g>Exposed</c->=(<c- n>Window</c->,<c- n>Worker</c->), <a href='#serializable' id='images-2:serializable'><c- g>Serializable</c-></a>, <a href='#transferable' id='images-2:transferable'><c- g>Transferable</c-></a>]
<c- b>interface</c-> <dfn id='imagebitmap'><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='images-2: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='images-2:dom-imagebitmap-height'><c- g>height</c-></a>;
  <c- b>void</c-> <a href='#dom-imagebitmap-close' id='images-2:dom-imagebitmap-close'><c- g>close</c-></a>();
};

<c- b>typedef</c-> (<a href='#canvasimagesource' id='images-2:canvasimagesource'><c- n>CanvasImageSource</c-></a> <c- b>or</c->
         <a href='https://w3c.github.io/FileAPI/#dfn-Blob' data-x-internal='blob' id='images-2:blob'><c- n>Blob</c-></a> <c- b>or</c->
         <a href='#imagedata' id='images-2:imagedata'><c- n>ImageData</c-></a>) <dfn id='imagebitmapsource'><c- g>ImageBitmapSource</c-></dfn>;

<c- b>enum</c-> <dfn id='imageorientation'><c- g>ImageOrientation</c-></dfn> { <c- s>&quot;</c-><a href='#dom-imageorientation-none' id='images-2:dom-imageorientation-none'><c- s>none</c-></a><c- s>&quot;</c->, <c- s>&quot;</c-><a href='#dom-imageorientation-flipy' id='images-2:dom-imageorientation-flipy'><c- s>flipY</c-></a><c- s>&quot;</c-> };
<c- b>enum</c-> <dfn id='premultiplyalpha'><c- g>PremultiplyAlpha</c-></dfn> { <c- s>&quot;</c-><a href='#dom-premultiplyalpha-none' id='images-2:dom-premultiplyalpha-none'><c- s>none</c-></a><c- s>&quot;</c->, <c- s>&quot;</c-><a href='#dom-premultiplyalpha-premultiply' id='images-2:dom-premultiplyalpha-premultiply'><c- s>premultiply</c-></a><c- s>&quot;</c->, <c- s>&quot;</c-><a href='#dom-premultiplyalpha-default' id='images-2:dom-premultiplyalpha-default'><c- s>default</c-></a><c- s>&quot;</c-> };
<c- b>enum</c-> <dfn id='colorspaceconversion'><c- g>ColorSpaceConversion</c-></dfn> { <c- s>&quot;</c-><a href='#dom-colorspaceconversion-none' id='images-2:dom-colorspaceconversion-none'><c- s>none</c-></a><c- s>&quot;</c->, <c- s>&quot;</c-><a href='#dom-colorspaceconversion-default' id='images-2:dom-colorspaceconversion-default'><c- s>default</c-></a><c- s>&quot;</c-> };
<c- b>enum</c-> <dfn id='resizequality'><c- g>ResizeQuality</c-></dfn> { <c- s>&quot;</c-><a href='#dom-resizequality-pixelated' id='images-2:dom-resizequality-pixelated'><c- s>pixelated</c-></a><c- s>&quot;</c->, <c- s>&quot;</c-><a href='#dom-resizequality-low' id='images-2:dom-resizequality-low'><c- s>low</c-></a><c- s>&quot;</c->, <c- s>&quot;</c-><a href='#dom-resizequality-medium' id='images-2:dom-resizequality-medium'><c- s>medium</c-></a><c- s>&quot;</c->, <c- s>&quot;</c-><a href='#dom-resizequality-high' id='images-2:dom-resizequality-high'><c- s>high</c-></a><c- s>&quot;</c-> };

<c- b>dictionary</c-> <dfn id='imagebitmapoptions'><c- g>ImageBitmapOptions</c-></dfn> {
  <a href='#imageorientation' id='images-2:imageorientation'><c- n>ImageOrientation</c-></a> <a href='#dom-imagebitmapoptions-imageorientation' id='images-2:dom-imagebitmapoptions-imageorientation'><c- g>imageOrientation</c-></a> = &quot;<a href='#dom-imageorientation-none' id='images-2:dom-imageorientation-none-2'>none</a>&quot;;
  <a href='#premultiplyalpha' id='images-2:premultiplyalpha'><c- n>PremultiplyAlpha</c-></a> <a href='#dom-imagebitmapoptions-premultiplyalpha' id='images-2:dom-imagebitmapoptions-premultiplyalpha'><c- g>premultiplyAlpha</c-></a> = &quot;<a href='#dom-premultiplyalpha-default' id='images-2:dom-premultiplyalpha-default-2'>default</a>&quot;;
  <a href='#colorspaceconversion' id='images-2:colorspaceconversion'><c- n>ColorSpaceConversion</c-></a> <a href='#dom-imagebitmapoptions-colorspaceconversion' id='images-2:dom-imagebitmapoptions-colorspaceconversion'><c- g>colorSpaceConversion</c-></a> = &quot;<a href='#dom-colorspaceconversion-default' id='images-2:dom-colorspaceconversion-default-2'>default</a>&quot;;
  [<c- g>EnforceRange</c->] <c- b>unsigned</c-> <c- b>long</c-> <a href='#dom-imagebitmapoptions-resizewidth' id='images-2: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='images-2:dom-imagebitmapoptions-resizeheight'><c- g>resizeHeight</c-></a>;
  <a href='#resizequality' id='images-2:resizequality'><c- n>ResizeQuality</c-></a> <a href='#dom-imagebitmapoptions-resizequality' id='images-2:dom-imagebitmapoptions-resizequality'><c- g>resizeQuality</c-></a> = &quot;<a href='#dom-resizequality-low' id='images-2:dom-resizequality-low-2'>low</a>&quot;;
};</code></pre>

  <p>An <code id=images-2:imagebitmap><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><var>promise</var> = self . <code id=dom-createimagebitmap-dev><a href=#dom-createimagebitmap>createImageBitmap</a></code>(<var>image</var> [, <var>options</var> ])<dt><var>promise</var> = self . <code id=images-2:dom-createimagebitmap><a href=#dom-createimagebitmap>createImageBitmap</a></code>(<var>image</var>, <var>sx</var>, <var>sy</var>, <var>sw</var>, <var>sh</var> [, <var>options</var> ])<dd>

    <p>Takes <var>image</var>, which can be an <code id=images-2:the-img-element><a href=#the-img-element>img</a></code> element, an <a id=images-2: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=images-2:the-video-element><a href=#the-video-element>video</a></code> element, a <code id=images-2:the-canvas-element><a href=#the-canvas-element>canvas</a></code>
    element, a <code id=images-2:blob-2><a data-x-internal=blob href=https://w3c.github.io/FileAPI/#dfn-Blob>Blob</a></code> object, an <code id=images-2:imagedata-2><a href=#imagedata>ImageData</a></code> object, or another
    <code id=images-2:imagebitmap-2><a href=#imagebitmap>ImageBitmap</a></code> object, and returns a promise that is resolved when a new
    <code id=images-2:imagebitmap-3><a href=#imagebitmap>ImageBitmap</a></code> is created.</p>

    <p>If no <code id=images-2:imagebitmap-4><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=images-2: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="images-2:'px'" data-x-internal="'px'">CSS pixels</a>.</p>

    <p>If <var>options</var> is provided, the <code id=images-2:imagebitmap-5><a href=#imagebitmap>ImageBitmap</a></code> object's bitmap
    data is modified according to <var>options</var>. For example,
    if the <code id=images-2:dom-imagebitmapoptions-premultiplyalpha-2><a href=#dom-imagebitmapoptions-premultiplyalpha>premultiplyAlpha</a></code>
    option is set to "<code id=images-2:dom-premultiplyalpha-premultiply-2><a href=#dom-premultiplyalpha-premultiply>premultiply</a></code>",
    the <a href=#concept-imagebitmap-bitmap-data id=images-2:concept-imagebitmap-bitmap-data>bitmap data</a>'s color channels are
    premultiplied by its alpha channel.

    <p>Rejects the promise with an <a id=images-2:invalidstateerror href=https://heycam.github.io/webidl/#invalidstateerror data-x-internal=invalidstateerror>"<code>InvalidStateError</code>"</a>
    <code id=images-2:domexception><a data-x-internal=domexception href=https://heycam.github.io/webidl/#dfn-DOMException>DOMException</a></code> if the source image is not in a valid state (e.g., an <code id=images-2:the-img-element-2><a href=#the-img-element>img</a></code>
    element that hasn't loaded successfully, an <code id=images-2:imagebitmap-6><a href=#imagebitmap>ImageBitmap</a></code> object whose
    <a href=#detached id=images-2:detached>[[Detached]]</a> internal slot value is true, an <code id=images-2:imagedata-3><a href=#imagedata>ImageData</a></code> object whose
    <code id=images-2:dom-imagedata-data><a href=#dom-imagedata-data>data</a></code> attribute value's [[ViewedArrayBuffer]] internal
    slot is detached, or a <code id=images-2: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=images-2:securityerror href=https://heycam.github.io/webidl/#securityerror data-x-internal=securityerror>"<code>SecurityError</code>"</a>
    <code id=images-2:domexception-2><a data-x-internal=domexception href=https://heycam.github.io/webidl/#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=images-2:the-video-element-2><a href=#the-video-element>video</a></code> that is <a href=#cors-cross-origin id=images-2:cors-cross-origin>CORS-cross-origin</a>, or a
    <code id=images-2: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=images-2:concept-origin>origin</a>).</p>

   <dt><var>imageBitmap</var> . <code id=dom-imagebitmap-close-dev><a href=#dom-imagebitmap-close>close</a></code>()<dd>

    <p>Releases <var>imageBitmap</var>'s underlying <a href=#concept-imagebitmap-bitmap-data id=images-2:concept-imagebitmap-bitmap-data-2>bitmap data</a>.</p>

   <dt><var>imageBitmap</var> . <code id=dom-imagebitmap-width-dev><a href=#dom-imagebitmap-width>width</a></code><dd>

    <p>Returns the <a href=#intrinsic-width id=images-2:intrinsic-width>intrinsic width</a> of the image, in <a href=https://drafts.csswg.org/css-values/#px id="images-2:'px'-2" data-x-internal="'px'">CSS
    pixels</a>.</p>

   <dt><var>imageBitmap</var> . <code id=dom-imagebitmap-height-dev><a href=#dom-imagebitmap-height>height</a></code><dd>

    <p>Returns the <a href=#intrinsic-height id=images-2:intrinsic-height>intrinsic height</a> of the image, in <a href=https://drafts.csswg.org/css-values/#px id="images-2:'px'-3" data-x-internal="'px'">CSS
    pixels</a>.</p>

   </dl>

  

  <p>An <code id=images-2:imagebitmap-7><a href=#imagebitmap>ImageBitmap</a></code> object whose <a href=#detached id=images-2: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=images-2:imagebitmap-8><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=images-2:imagebitmap-9><a href=#imagebitmap>ImageBitmap</a></code> object's bitmap has an <a href=#concept-canvas-origin-clean id=images-2: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=images-2:concept-origin-2>origin</a>. The flag is initially set to
  true and may be changed to false by the steps of <code id=images-2:dom-createimagebitmap-2><a href=#dom-createimagebitmap>createImageBitmap()</a></code>.</p>

  <hr>

  <p><code id=images-2:imagebitmap-10><a href=#imagebitmap>ImageBitmap</a></code> objects are <a href=#serializable-objects id=images-2:serializable-objects>serializable objects</a> and <a href=#transferable-objects id=images-2:transferable-objects>transferable
  objects</a>.</p>

  <p>Their <a href=#serialization-steps id=images-2:serialization-steps>serialization steps</a>, given <var>value</var> and <var>serialized</var>,
  are:</p>

  <ol><li><p>Set <var>serialized</var>.[[BitmapData]] to a copy of <var>value</var>'s <a href=#concept-imagebitmap-bitmap-data id=images-2:concept-imagebitmap-bitmap-data-3>bitmap data</a>.<li><p>Set <var>serialized</var>.[[OriginClean]] to true if <var>value</var>'s <a href=#concept-canvas-origin-clean id=images-2:concept-canvas-origin-clean-2>origin-clean</a> flag is set, and false
   otherwise.</ol>

  <p>Their <a href=#deserialization-steps id=images-2:deserialization-steps>deserialization steps</a>, given <var>serialized</var> and <var>value</var>,
  are:</p>

  <ol><li><p>Set <var>value</var>'s <a href=#concept-imagebitmap-bitmap-data id=images-2:concept-imagebitmap-bitmap-data-4>bitmap data</a>
   to <var>serialized</var>.[[BitmapData]].<li><p>If <var>serialized</var>.[[OriginClean]] is true, set <var>value</var>'s <a href=#concept-canvas-origin-clean id=images-2:concept-canvas-origin-clean-3>origin-clean</a> flag.</ol>

  <p>Their <a href=#transfer-steps id=images-2:transfer-steps>transfer steps</a>, given <var>value</var> and <var>dataHolder</var>, are:</p>

  <ol><li><p>Set <var>dataHolder</var>.[[BitmapData]] to <var>value</var>'s <a href=#concept-imagebitmap-bitmap-data id=images-2:concept-imagebitmap-bitmap-data-5>bitmap data</a>.<li><p>Set <var>dataHolder</var>.[[OriginClean]] to true if <var>value</var>'s <a href=#concept-canvas-origin-clean id=images-2:concept-canvas-origin-clean-4>origin-clean</a> flag is set, and false
   otherwise.<li><p>Unset <var>value</var>'s <a href=#concept-imagebitmap-bitmap-data id=images-2:concept-imagebitmap-bitmap-data-6>bitmap
   data</a>.</ol>

  <p>Their <a href=#transfer-receiving-steps id=images-2: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=images-2:concept-imagebitmap-bitmap-data-7>bitmap data</a>
   to <var>dataHolder</var>.[[BitmapData]].<li><p>If <var>dataHolder</var>.[[OriginClean]] is true, set <var>value</var>'s <a href=#concept-canvas-origin-clean id=images-2:concept-canvas-origin-clean-5>origin-clean</a> flag.</ol>

  <hr>

  <p>The <dfn id=dom-createimagebitmap><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:<div class=status><input onclick=toggleStatus(this) value=⋰ type=button><p class=support><strong>Support:</strong> createimagebitmap<span class="and_chr yes"><span>Chrome for Android</span> <span>67+</span></span><span class="chrome yes"><span>Chrome</span> <span>59+</span></span><span class="ios_saf no"><span>iOS Safari</span> <span>None</span></span><span class="and_uc yes"><span>UC Browser for Android</span> <span>11.8+</span></span><span class="firefox yes"><span>Firefox</span> <span>42+</span></span><span class="ie no"><span>IE</span> <span>None</span></span><span class="op_mini no"><span>Opera Mini</span> <span>None</span></span><span class="safari no"><span>Safari</span> <span>None</span></span><span class="edge no"><span>Edge</span> <span>None</span></span><span class="samsung yes"><span>Samsung Internet</span> <span>6.2+</span></span><span class="opera yes"><span>Opera</span> <span>46+</span></span><span class="android yes"><span>Android Browser</span> <span>67+</span></span><p class=caniuse>Source: <a href="https://caniuse.com/#feat=createimagebitmap">caniuse.com</a></div>

  <ol><li><p>Let <var>p</var> be a new promise.<li><p>If either <var>sw</var> or <var>sh</var> is given and is 0, then return <var>p</var>
   rejected with a <code id=images-2:js-rangeerror><a data-x-internal=js-rangeerror href=https://tc39.github.io/ecma262/#sec-native-error-types-used-in-this-standard-rangeerror>RangeError</a></code>.<li><p>If either <var>options</var>'s <dfn id=dom-imagebitmapoptions-resizewidth><code>resizeWidth</code></dfn> or <var>options</var>'s
   <dfn id=dom-imagebitmapoptions-resizeheight><code>resizeHeight</code></dfn> is present and
   is 0, then return <var>p</var> rejected with an <a id=images-2:invalidstateerror-2 href=https://heycam.github.io/webidl/#invalidstateerror data-x-internal=invalidstateerror>"<code>InvalidStateError</code>"</a>
   <code id=images-2:domexception-3><a data-x-internal=domexception href=https://heycam.github.io/webidl/#dfn-DOMException>DOMException</a></code>.<li><p><a href=#check-the-usability-of-the-image-argument id=images-2: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 <var>p</var> rejected with an
   <a id=images-2:invalidstateerror-3 href=https://heycam.github.io/webidl/#invalidstateerror data-x-internal=invalidstateerror>"<code>InvalidStateError</code>"</a> <code id=images-2:domexception-4><a data-x-internal=domexception href=https://heycam.github.io/webidl/#dfn-DOMException>DOMException</a></code>.

   <li><p>Let <var>imageBitmap</var> be a new <code id=images-2:imagebitmap-11><a href=#imagebitmap>ImageBitmap</a></code> object.<li>
    <p>Switch on <var>image</var>:</p>

    <dl class=switch><dt><code id=images-2:the-img-element-3><a href=#the-img-element>img</a></code>
     <dt><a id=images-2:svg-image-2 href=https://svgwg.org/svg2-draft/embedded.html#ImageElement data-x-internal=svg-image>SVG <code>image</code></a>
     <dd>
      <ol><li><p>If <var>image</var>'s media data has no <a id=images-2:intrinsic-dimensions href=https://drafts.csswg.org/css2/conform.html#intrinsic data-x-internal=intrinsic-dimensions>intrinsic dimensions</a> (e.g., it's
       a vector graphic with no specified content size) and either <var>options</var>'s <code id=images-2:dom-imagebitmapoptions-resizewidth-2><a href=#dom-imagebitmapoptions-resizewidth>resizeWidth</a></code> or <var>options</var>'s <code id=images-2:dom-imagebitmapoptions-resizeheight-2><a href=#dom-imagebitmapoptions-resizeheight>resizeHeight</a></code> is not present, then return
       <var>p</var> rejected with an <a id=images-2:invalidstateerror-4 href=https://heycam.github.io/webidl/#invalidstateerror data-x-internal=invalidstateerror>"<code>InvalidStateError</code>"</a>
       <code id=images-2:domexception-5><a data-x-internal=domexception href=https://heycam.github.io/webidl/#dfn-DOMException>DOMException</a></code>.<li><p>If <var>image</var>'s media data has no <a id=images-2:intrinsic-dimensions-2 href=https://drafts.csswg.org/css2/conform.html#intrinsic data-x-internal=intrinsic-dimensions>intrinsic dimensions</a> (e.g., it's
       a vector graphics with no specified content size), it should be rendered to a bitmap of the
       size specified by the <code id=images-2:dom-imagebitmapoptions-resizewidth-3><a href=#dom-imagebitmapoptions-resizewidth>resizeWidth</a></code>
       and the <code id=images-2:dom-imagebitmapoptions-resizeheight-3><a href=#dom-imagebitmapoptions-resizeheight>resizeHeight</a></code>
       options.<li><p>Set <var>imageBitmap</var>'s <a href=#concept-imagebitmap-bitmap-data id=images-2: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=images-2: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=images-2: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.<li><p>If the <a href=#concept-origin id=images-2:concept-origin-3>origin</a> of <var>image</var>'s image is not <a href=#same-origin id=images-2:same-origin>same origin</a>
       with <a href=#entry-settings-object id=images-2:entry-settings-object>entry settings object</a>'s <a href=#concept-settings-object-origin id=images-2:concept-settings-object-origin>origin</a>, then set the <a href=#concept-canvas-origin-clean id=images-2:concept-canvas-origin-clean-6>origin-clean</a> flag of <var>imageBitmap</var>'s
       bitmap to false.<li>
        <p>Run this step <a href=#in-parallel id=images-2:in-parallel>in parallel</a>:</p>

        <ol><li><p>Resolve <var>p</var> with <var>imageBitmap</var>.</ol>
       </ol>
     <dt><code id=images-2:the-video-element-3><a href=#the-video-element>video</a></code>
     <dd>
      <ol><li><p>If <var>image</var>'s <code id=images-2:dom-media-networkstate><a href=#dom-media-networkstate>networkState</a></code>
       attribute is <code id=images-2:dom-media-network_empty><a href=#dom-media-network_empty>NETWORK_EMPTY</a></code>, then return
       <var>p</var> rejected with an <a id=images-2:invalidstateerror-5 href=https://heycam.github.io/webidl/#invalidstateerror data-x-internal=invalidstateerror>"<code>InvalidStateError</code>"</a>
       <code id=images-2:domexception-6><a data-x-internal=domexception href=https://heycam.github.io/webidl/#dfn-DOMException>DOMException</a></code>.<li><p>Set <var>imageBitmap</var>'s <a href=#concept-imagebitmap-bitmap-data id=images-2:concept-imagebitmap-bitmap-data-10>bitmap
       data</a> to a copy of the frame at the <a href=#current-playback-position id=images-2:current-playback-position>current playback position</a>, at the
       <a href=#media-resource id=images-2:media-resource>media resource</a>'s <a href=#concept-video-intrinsic-width id=images-2:concept-video-intrinsic-width>intrinsic
       width</a> and <a href=#concept-video-intrinsic-height id=images-2:concept-video-intrinsic-height>intrinsic height</a> (i.e.,
       after any aspect-ratio correction has been applied), <a href=#cropped-to-the-source-rectangle-with-formatting id=images-2:cropped-to-the-source-rectangle-with-formatting-2>cropped to the source rectangle
       with formatting</a>.</p>

       <li><p>If the <a href=#concept-origin id=images-2:concept-origin-4>origin</a> of <var>image</var>'s video is not <a href=#same-origin id=images-2:same-origin-2>same origin</a>
       with <a href=#entry-settings-object id=images-2:entry-settings-object-2>entry settings object</a>'s <a href=#concept-settings-object-origin id=images-2:concept-settings-object-origin-2>origin</a>, then set the <a href=#concept-canvas-origin-clean id=images-2:concept-canvas-origin-clean-7>origin-clean</a> flag of <var>imageBitmap</var>'s
       bitmap to false.<li>
        <p>Run this step <a href=#in-parallel id=images-2:in-parallel-2>in parallel</a>:</p>

        <ol><li><p>Resolve <var>p</var> with <var>imageBitmap</var>.</ol>
       </ol>
     <dt><code id=images-2:the-canvas-element-3><a href=#the-canvas-element>canvas</a></code>
     <dd>
      <ol><li><p>Set <var>imageBitmap</var>'s <a href=#concept-imagebitmap-bitmap-data id=images-2:concept-imagebitmap-bitmap-data-11>bitmap
       data</a> to a copy of <var>image</var>'s <a href=#concept-imagebitmap-bitmap-data id=images-2:concept-imagebitmap-bitmap-data-12>bitmap data</a>, <a href=#cropped-to-the-source-rectangle-with-formatting id=images-2:cropped-to-the-source-rectangle-with-formatting-3>cropped to the source
       rectangle with formatting</a>.<li><p>Set the <a href=#concept-canvas-origin-clean id=images-2:concept-canvas-origin-clean-8>origin-clean</a> flag of the
       <var>imageBitmap</var>'s bitmap to the same value as the <a href=#concept-canvas-origin-clean id=images-2:concept-canvas-origin-clean-9>origin-clean</a> flag of <var>image</var>'s
       bitmap.<li>
        <p>Run this step <a href=#in-parallel id=images-2:in-parallel-3>in parallel</a>:</p>

        <ol><li><p>Resolve <var>p</var> with <var>imageBitmap</var>.</ol>
       </ol>
     <dt><code id=images-2:blob-4><a data-x-internal=blob href=https://w3c.github.io/FileAPI/#dfn-Blob>Blob</a></code>
     <dd>
      <p>Run these step <a href=#in-parallel id=images-2:in-parallel-4>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=images-2:file-error-read>error occurs during reading of the object</a>, then reject
       <var>p</var> with an <a id=images-2:invalidstateerror-6 href=https://heycam.github.io/webidl/#invalidstateerror data-x-internal=invalidstateerror>"<code>InvalidStateError</code>"</a> <code id=images-2:domexception-7><a data-x-internal=domexception href=https://heycam.github.io/webidl/#dfn-DOMException>DOMException</a></code>
       and abort these steps.<li><p>Apply the <a href=https://mimesniff.spec.whatwg.org/#rules-for-sniffing-images-specifically id=images-2: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=images-2: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.<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 intrinsic size), then reject
       <var>p</var> with an <a id=images-2:invalidstateerror-7 href=https://heycam.github.io/webidl/#invalidstateerror data-x-internal=invalidstateerror>"<code>InvalidStateError</code>"</a> <code id=images-2:domexception-8><a data-x-internal=domexception href=https://heycam.github.io/webidl/#dfn-DOMException>DOMException</a></code>
       and abort these steps.<li><p>Set <var>imageBitmap</var>'s <a href=#concept-imagebitmap-bitmap-data id=images-2:concept-imagebitmap-bitmap-data-13>bitmap
       data</a> to <var>imageData</var>, <a href=#cropped-to-the-source-rectangle-with-formatting id=images-2: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=images-2: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.<li><p>Resolve <var>p</var> with <var>imageBitmap</var>.</ol>
     <dt><code id=images-2:imagedata-4><a href=#imagedata>ImageData</a></code>
     <dd>
      <ol><li><p>Let <var>buffer</var> be <var>image</var>'s <code id=images-2:dom-imagedata-data-2><a href=#dom-imagedata-data>data</a></code> attribute value's [[ViewedArrayBuffer]] internal
       slot.<li><p>If <a id=images-2:isdetachedbuffer href=https://tc39.github.io/ecma262/#sec-isdetachedbuffer data-x-internal=isdetachedbuffer>IsDetachedBuffer</a>(<var>buffer</var>) is true, then return <var>p</var>
       rejected with an <a id=images-2:invalidstateerror-8 href=https://heycam.github.io/webidl/#invalidstateerror data-x-internal=invalidstateerror>"<code>InvalidStateError</code>"</a>
       <code id=images-2:domexception-9><a data-x-internal=domexception href=https://heycam.github.io/webidl/#dfn-DOMException>DOMException</a></code>.<li><p>Set <var>imageBitmap</var>'s <a href=#concept-imagebitmap-bitmap-data id=images-2: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=images-2:cropped-to-the-source-rectangle-with-formatting-5>cropped to the source rectangle with
       formatting</a>.<li>
        <p>Run this step <a href=#in-parallel id=images-2:in-parallel-5>in parallel</a>:</p>

        <ol><li><p>Resolve <var>p</var> with <var>imageBitmap</var>.</ol>
       </ol>
     <dt><code id=images-2:imagebitmap-12><a href=#imagebitmap>ImageBitmap</a></code>
     <dd>
      <ol><li><p>Set <var>imageBitmap</var>'s <a href=#concept-imagebitmap-bitmap-data id=images-2:concept-imagebitmap-bitmap-data-16>bitmap
       data</a> to a copy of <var>image</var>'s <a href=#concept-imagebitmap-bitmap-data id=images-2:concept-imagebitmap-bitmap-data-17>bitmap data</a>, <a href=#cropped-to-the-source-rectangle-with-formatting id=images-2:cropped-to-the-source-rectangle-with-formatting-6>cropped to the source
       rectangle with formatting</a>.<li><p>Set the <a href=#concept-canvas-origin-clean id=images-2:concept-canvas-origin-clean-10>origin-clean</a> flag of
       <var>imageBitmap</var>'s bitmap to the same value as the <a href=#concept-canvas-origin-clean id=images-2:concept-canvas-origin-clean-11>origin-clean</a> flag of <var>image</var>'s
       bitmap.<li>
        <p>Run this step <a href=#in-parallel id=images-2:in-parallel-6>in parallel</a>:</p>

        <ol><li><p>Resolve <var>p</var> with <var>imageBitmap</var>.</ol>
       </ol>
     </dl>
   <li><p>Return <var>p</var>.</ol>

  <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=images-2:concept-imagebitmap-bitmap-data-18>bitmap
   data</a> being transformed.<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><p>Clip <var>sourceRectangle</var> to the dimensions of <var>input</var>.<li>
    <p>Let <var>outputWidth</var> be determined as follows:</p>

    <dl class=switch><dt>If the <code id=images-2:dom-imagebitmapoptions-resizewidth-4><a href=#dom-imagebitmapoptions-resizewidth>resizeWidth</a></code> member of
     <var>options</var> is specified<dd>the value of the <code id=images-2:dom-imagebitmapoptions-resizewidth-5><a href=#dom-imagebitmapoptions-resizewidth>resizeWidth</a></code>
     member of <var>options</var><dt>If the <code id=images-2:dom-imagebitmapoptions-resizewidth-6><a href=#dom-imagebitmapoptions-resizewidth>resizeWidth</a></code> member of
     <var>options</var> is not specified, but the <code id=images-2:dom-imagebitmapoptions-resizeheight-4><a href=#dom-imagebitmapoptions-resizeheight>resizeHeight</a></code> member is specified<dd>the width of <var>sourceRectangle</var>, times the value of the <code id=images-2: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<dt>If neither <code id=images-2:dom-imagebitmapoptions-resizewidth-7><a href=#dom-imagebitmapoptions-resizewidth>resizeWidth</a></code> nor <code id=images-2:dom-imagebitmapoptions-resizeheight-6><a href=#dom-imagebitmapoptions-resizeheight>resizeHeight</a></code> are specified<dd>the width of <var>sourceRectangle</var></dl>
   <li>
    <p>Let <var>outputHeight</var> be determined as follows:</p>

    <dl class=switch><dt>If the <code id=images-2:dom-imagebitmapoptions-resizeheight-7><a href=#dom-imagebitmapoptions-resizeheight>resizeHeight</a></code> member of
     <var>options</var> is specified<dd>the value of the <code id=images-2:dom-imagebitmapoptions-resizeheight-8><a href=#dom-imagebitmapoptions-resizeheight>resizeHeight</a></code>
     member of <var>options</var><dt>If the <code id=images-2:dom-imagebitmapoptions-resizeheight-9><a href=#dom-imagebitmapoptions-resizeheight>resizeHeight</a></code> member of
     <var>options</var> is not specified, but the <code id=images-2:dom-imagebitmapoptions-resizewidth-8><a href=#dom-imagebitmapoptions-resizewidth>resizeWidth</a></code> member is specified<dd>the height of <var>sourceRectangle</var>, times the value of the <code id=images-2: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<dt>If neither <code id=images-2:dom-imagebitmapoptions-resizewidth-10><a href=#dom-imagebitmapoptions-resizewidth>resizeWidth</a></code> nor <code id=images-2:dom-imagebitmapoptions-resizeheight-10><a href=#dom-imagebitmapoptions-resizeheight>resizeHeight</a></code> are specified<dd>the height of <var>sourceRectangle</var></dl>
   <li><p>Place <var>input</var> on an infinite <a id=images-2: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.<li><p>Let <var>output</var> be the rectangle on the plane denoted by
   <var>sourceRectangle</var>.<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 id=dom-imagebitmapoptions-resizequality><code>resizeQuality</code></dfn> option to guide the
   choice of scaling algorithm.<li>

    <p>If the value of the <dfn id=dom-imagebitmapoptions-imageorientation><code>imageOrientation</code></dfn> member of
    <var>options</var> is "<dfn id=dom-imageorientation-flipy><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 id=dom-imageorientation-none><code>none</code></dfn>", no extra step is required.</p>

   <li>

    <p>If <var>image</var> is an <code id=images-2:the-img-element-4><a href=#the-img-element>img</a></code> element or a <code id=images-2: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 id=dom-imagebitmapoptions-colorspaceconversion><code>colorSpaceConversion</code></dfn> member
    of <var>options</var>, and then run these substeps:</p>

    <ol><li><p>If <var>val</var> is "<dfn id=dom-colorspaceconversion-default><code>default</code></dfn>",
     the color space conversion behavior is implementation-specific, and should be chosen according
     to the color space that the implementation uses for drawing images onto the canvas.<li><p>If <var>val</var> is "<dfn id=dom-colorspaceconversion-none><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.</ol>

    <p class=note>The native color space of canvas is currently unspecified, but this is expected
    to change in the future.</p>

   <li>

    <p>Let <var>val</var> be the value of <dfn id=dom-imagebitmapoptions-premultiplyalpha><code>premultiplyAlpha</code></dfn> member of
    <var>options</var>, and then run these substeps:</p>

    <ol><li><p>If <var>val</var> is "<dfn id=dom-premultiplyalpha-default><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.<li><p>If <var>val</var> is "<dfn id=dom-premultiplyalpha-premultiply><code>premultiply</code></dfn>", the <var>output</var>
     that is not premultiplied by alpha must have its color components multiplied by alpha and
     that is premultiplied by alpha must be left untouched.<li><p>If <var>val</var> is "<dfn id=dom-premultiplyalpha-none><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 divided by alpha.</ol>

   <li><p>Return <var>output</var>.</ol>

  <p>When the <dfn id=dom-imagebitmap-close><code>close()</code></dfn> method is called, the
  user agent must run these steps:</p>

  <ol><li><p>Set this <code id=images-2:imagebitmap-13><a href=#imagebitmap>ImageBitmap</a></code> object's <a href=#detached id=images-2:detached-3>[[Detached]]</a> internal slot value
   to true.<li><p>Unset this <code id=images-2:imagebitmap-14><a href=#imagebitmap>ImageBitmap</a></code> object's <a href=#concept-imagebitmap-bitmap-data id=images-2:concept-imagebitmap-bitmap-data-19>bitmap data</a>.</ol>

  <p>The <dfn id=dom-imagebitmap-width><code>width</code></dfn> attribute's getter must run
  these steps:</p>

  <ol><li><p>If this <code id=images-2:imagebitmap-15><a href=#imagebitmap>ImageBitmap</a></code> object's <a href=#detached id=images-2:detached-4>[[Detached]]</a> internal slot's
   value is true, then return 0.<li><p>Return this <code id=images-2:imagebitmap-16><a href=#imagebitmap>ImageBitmap</a></code> object's width, in <a href=https://drafts.csswg.org/css-values/#px id="images-2:'px'-4" data-x-internal="'px'">CSS
   pixels</a>.</ol>

  <p>The <dfn id=dom-imagebitmap-height><code>height</code></dfn> attribute's getter must run
  these steps:</p>

  <ol><li><p>If this <code id=images-2:imagebitmap-17><a href=#imagebitmap>ImageBitmap</a></code> object's <a href=#detached id=images-2:detached-5>[[Detached]]</a> internal slot's
   value is true, then return 0.<li><p>Return this <code id=images-2:imagebitmap-18><a href=#imagebitmap>ImageBitmap</a></code> object's height, in <a href=https://drafts.csswg.org/css-values/#px id="images-2:'px'-5" data-x-internal="'px'">CSS
   pixels</a>.</ol>

  <p>The <a href=#resizequality id=images-2:resizequality-2>ResizeQuality</a> enumeration is used to express a preference for the
  interpolation quality to use when scaling images.</p>

  <p>The "<dfn id=dom-resizequality-pixelated><code>pixelated</code></dfn>" value indicates
  a preference to scale the image that maximizes the appearance. Scaling algorithms that "smooth"
  colors are acceptable, such as bilinear interpolation.</p>

  <p>The "<dfn id=dom-resizequality-low><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 id=dom-resizequality-medium><code>medium</code></dfn>" value indicates
  a preference for a medium level of image interpolation quality.</p>

  <p>The "<dfn id=dom-resizequality-high><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 unless the value is "<a href=#dom-resizequality-pixelated id=images-2:dom-resizequality-pixelated-2>pixelated</a>".</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>&apos;mysprites.png&apos;</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- mi>0</c-><c- p>,</c->  <c- mi>0</c-><c- p>,</c-> <c- mi>40</c-><c- p>,</c-> <c- mi>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- mi>40</c-><c- p>,</c->  <c- mi>0</c-><c- p>,</c-> <c- mi>40</c-><c- p>,</c-> <c- mi>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- mi>80</c-><c- p>,</c->  <c- mi>0</c-><c- p>,</c-> <c- mi>40</c-><c- p>,</c-> <c- mi>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- mi>0</c-><c- p>,</c-> <c- mi>40</c-><c- p>,</c-> <c- mi>40</c-><c- p>,</c-> <c- mi>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- mi>40</c-><c- p>,</c-> <c- mi>40</c-><c- p>,</c-> <c- mi>40</c-><c- p>,</c-> <c- mi>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- mi>80</c-><c- p>,</c-> <c- mi>40</c-><c- p>,</c-> <c- mi>40</c-><c- p>,</c-> <c- mi>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>&apos;canvas#demo&apos;</c-><c- p>);</c->
  <c- a>var</c-> context <c- o>=</c-> canvas<c- p>.</c->getContext<c- p>(</c-><c- t>&apos;2d&apos;</c-><c- p>);</c->
  context<c- p>.</c->drawImage<c- p>(</c->sprites<c- p>.</c->tree<c- p>,</c-> <c- mi>30</c-><c- p>,</c-> <c- mi>10</c-><c- p>);</c->
  context<c- p>.</c->drawImage<c- p>(</c->sprites<c- p>.</c->snake<c- p>,</c-> <c- mi>70</c-><c- p>,</c-> <c- mi>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.10</span> Animation frames<a href=#animation-frames class=self-link></a></h3><div class=status><input onclick=toggleStatus(this) value=⋰ type=button><p class=support><strong>Support:</strong> requestanimationframe<span class="and_chr yes"><span>Chrome for Android</span> <span>67+</span></span><span class="chrome yes"><span>Chrome</span> <span>24+</span></span><span class="ios_saf yes"><span>iOS Safari</span> <span>7.0+</span></span><span class="and_uc yes"><span>UC Browser for Android</span> <span>11.8+</span></span><span class="firefox yes"><span>Firefox</span> <span>23+</span></span><span class="ie yes"><span>IE</span> <span>10+</span></span><span class="op_mini no"><span>Opera Mini</span> <span>None</span></span><span class="safari yes"><span>Safari</span> <span>6.1+</span></span><span class="edge yes"><span>Edge</span> <span>12+</span></span><span class="samsung yes"><span>Samsung Internet</span> <span>4+</span></span><span class="opera yes"><span>Opera</span> <span>15+</span></span><span class="android yes"><span>Android Browser</span> <span>4.4+</span></span><p class=caniuse>Source: <a href="https://caniuse.com/#feat=requestanimationframe">caniuse.com</a></div>

  <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'><c- g>FrameRequestCallback</c-></dfn> = <c- b>void</c-> (<a href='https://w3c.github.io/hr-time/#dom-domhighrestimestamp' data-x-internal='domhighrestimestamp' id='animation-frames:domhighrestimestamp'><c- n>DOMHighResTimeStamp</c-></a> <c- g>time</c->);

<c- b>interface</c-> <c- b>mixin</c-> <dfn id='animationframeprovider'><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>void</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>

  <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><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><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><dd>The <code id=animation-frames:dedicatedworkerglobalscope-3><a href=#dedicatedworkerglobalscope>DedicatedWorkerGlobalScope</a></code></dl>

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

  <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
  hold:</p>

  <ul class=brief><li><var>provider</var> is a <code id=animation-frames:window-4><a href=#window>Window</a></code>.<li><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.<li>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>.</ul>

  <hr>

  <p>The <dfn id=dom-animationframeprovider-requestanimationframe><code>requestAnimationFrame(<var>callback</var>)</code></dfn>
  method must run the following steps:</p>

  <ol><li><p>If this <code id=animation-frames:animationframeprovider-8><a href=#animationframeprovider>AnimationFrameProvider</a></code> 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://heycam.github.io/webidl/#notsupportederror data-x-internal=notsupportederror>"<code>NotSupportedError</code>"</a> <code id=animation-frames:domexception><a data-x-internal=domexception href=https://heycam.github.io/webidl/#dfn-DOMException>DOMException</a></code>.<li><p>Let <var>target</var> be this <code id=animation-frames:animationframeprovider-9><a href=#animationframeprovider>AnimationFrameProvider</a></code>'s <a href=#concept-animationframeprovider-target-object id=animation-frames:concept-animationframeprovider-target-object-2>target object</a>.<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.<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>.<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>.<li><p>Return <var>handle</var>.</ol>

  <p>The <dfn id=animationframeprovider-cancelanimationframe><code>cancelAnimationFrame(<var>handle</var>)</code></dfn>
  method must run the following steps:</p>

  <ol><li><p>If this <code id=animation-frames:animationframeprovider-10><a href=#animationframeprovider>AnimationFrameProvider</a></code> 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://heycam.github.io/webidl/#notsupportederror data-x-internal=notsupportederror>"<code>NotSupportedError</code>"</a> <code id=animation-frames:domexception-2><a data-x-internal=domexception href=https://heycam.github.io/webidl/#dfn-DOMException>DOMException</a></code>.<li><p>Let <var>callbacks</var> be this <code id=animation-frames:animationframeprovider-11><a href=#animationframeprovider>AnimationFrameProvider</a></code>'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>.<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>].</ol>

  <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 a clone of <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>.<li><p>Set <var>target</var>'s <a href=#list-of-animation-frame-callbacks id=animation-frames:list-of-animation-frame-callbacks-4>map of animation frame callbacks</a> to a new empty
   <a id=animation-frames:ordered-map-2 href=https://infra.spec.whatwg.org/#ordered-map data-x-internal=ordered-map>ordered map</a>.<li><p><a href=https://infra.spec.whatwg.org/#map-iterate id=animation-frames:map-iterate data-x-internal=map-iterate>For each</a> <var>handle</var> → <var>callback</var> of
   <var>callbacks</var>, <a href=https://heycam.github.io/webidl/#invoke-a-callback-function id=animation-frames:es-invoking-callback-functions data-x-internal=es-invoking-callback-functions>invoke</a>
   <var>callback</var>, passing <var>now</var> as the only argument, and if an exception is thrown,
   <a href=#report-the-exception id=animation-frames:report-the-exception>report the exception</a>.</ol>

  <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- kr>const</c-> offscreenCanvas <c- o>=</c-> document<c- p>.</c->getElementById<c- p>(</c-><c- u>&quot;c&quot;</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- mi>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- mi>0</c-><c- p>,</c-> <c- mi>0</c-><c- p>,</c-> <c- mi>100</c-><c- p>,</c-> <c- mi>100</c-><c- p>);</c->
  ctx<c- p>.</c->fillRect<c- p>(</c->pos<c- p>,</c-> <c- mi>0</c-><c- p>,</c-> <c- mi>10</c-><c- p>,</c-> <c- mi>10</c-><c- p>);</c->
  pos <c- o>+=</c-> <c- mi>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- kr>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>&quot;2d&quot;</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>

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

  <p>Messages in <a href=#server-sent-events id=the-messageevent-interface:server-sent-events>server-sent events</a>, <a href=#network id=the-messageevent-interface:network>Web sockets</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>, and <a href=#broadcasting-to-other-browsing-contexts id=the-messageevent-interface:broadcasting-to-other-browsing-contexts>broadcast channels</a> 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:</p>

  <pre><code class='idl'>[<c- g>Constructor</c->(<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- g>Exposed</c->=(<c- n>Window</c->,<c- n>Worker</c->,<c- n>AudioWorklet</c->)]
<c- b>interface</c-> <dfn id='messageevent'><c- g>MessageEvent</c-></dfn> : <a href='https://dom.spec.whatwg.org/#interface-event' data-x-internal='event' id='the-messageevent-interface:event'><c- n>Event</c-></a> {
  <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>void</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-> = &quot;&quot;, <c- b>optional</c-> <c- b>DOMString</c-> <c- g>lastEventId</c-> = &quot;&quot;, <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'><c- g>MessageEventInit</c-></dfn> : <a href='https://dom.spec.whatwg.org/#dictdef-eventinit' data-x-internal='eventinit' id='the-messageevent-interface:eventinit'><c- n>EventInit</c-></a> {
  <c- b>any</c-> <c- g>data</c-> = <c- b>null</c->;
  <c- b>USVString</c-> <c- g>origin</c-> = &quot;&quot;;
  <c- b>DOMString</c-> <c- g>lastEventId</c-> = &quot;&quot;;
  <a href='#messageeventsource' id='the-messageevent-interface:messageeventsource-3'><c- n>MessageEventSource</c-></a>? <c- g>source</c-> = <c- b>null</c->;
  <c- b>sequence</c->&lt;<a href='#messageport' id='the-messageevent-interface:messageport-3'><c- n>MessagePort</c-></a>&gt; <c- g>ports</c-> = [];
};

<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 href='https://w3c.github.io/ServiceWorker/#serviceworker' data-x-internal='serviceworker' id='the-messageevent-interface:serviceworker'><c- n>ServiceWorker</c-></a>) <dfn id='messageeventsource'><c- g>MessageEventSource</c-></dfn>;</code></pre>

  <dl class=domintro><dt><var>event</var> . <code id=dom-messageevent-data-dev><a href=#dom-messageevent-data>data</a></code><dd>

    <p>Returns the data of the message.</p>

   <dt><var>event</var> . <code id=dom-messageevent-origin-dev><a href=#dom-messageevent-origin>origin</a></code><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>

   <dt><var>event</var> . <code id=dom-messageevent-lasteventid-dev><a href=#dom-messageevent-lasteventid>lastEventId</a></code><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>

   <dt><var>event</var> . <code id=dom-messageevent-source-dev><a href=#dom-messageevent-source>source</a></code><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>

   <dt><var>event</var> . <code id=dom-messageevent-ports-dev><a href=#dom-messageevent-ports>ports</a></code><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>

   </dl>

  

  <p>The <dfn id=dom-messageevent-data><code>data</code></dfn> attribute must return the value
  it was initialized to. It represents the message being sent.</p>

  <p>The <dfn id=dom-messageevent-origin><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=#concept-origin id=the-messageevent-interface:concept-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>

  <p>The <dfn id=dom-messageevent-lasteventid><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>

  <p>The <dfn id=dom-messageevent-source><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>

  <p>The <dfn id=dom-messageevent-ports><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>

  
  <p>The <dfn id=dom-messageevent-initmessageevent><code>initMessageEvent()</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>

  

  <p class=note>Various APIs (e.g., <code id=the-messageevent-interface:websocket><a href=#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=status><input onclick=toggleStatus(this) value=⋰ type=button><p class=support><strong>Support:</strong> eventsource<span class="and_chr yes"><span>Chrome for Android</span> <span>67+</span></span><span class="chrome yes"><span>Chrome</span> <span>6+</span></span><span class="ios_saf yes"><span>iOS Safari</span> <span>4.0+</span></span><span class="and_uc yes"><span>UC Browser for Android</span> <span>11.8+</span></span><span class="firefox yes"><span>Firefox</span> <span>6+</span></span><span class="ie no"><span>IE</span> <span>None</span></span><span class="op_mini no"><span>Opera Mini</span> <span>None</span></span><span class="safari yes"><span>Safari</span> <span>5+</span></span><span class="edge no"><span>Edge</span> <span>None</span></span><span class="samsung yes"><span>Samsung Internet</span> <span>4+</span></span><span class="opera yes"><span>Opera</span> <span>11+</span></span><span class="android yes"><span>Android Browser</span> <span>4.4+</span></span><p class=caniuse>Source: <a href="https://caniuse.com/#feat=eventsource">caniuse.com</a></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>&apos;updates.cgi&apos;</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>&apos;updates.cgi&apos;</c-><c- p>);</c->
source<c- p>.</c->addEventListener<c- p>(</c-><c- t>&apos;add&apos;</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>&apos;remove&apos;</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>

  <pre><code class='idl'>[<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- g>Exposed</c->=(<c- n>Window</c->,<c- n>Worker</c->)]
<c- b>interface</c-> <dfn id='eventsource'><c- g>EventSource</c-></dfn> : <a href='https://dom.spec.whatwg.org/#interface-eventtarget' data-x-internal='eventtarget' id='the-eventsource-interface:eventtarget'><c- n>EventTarget</c-></a> {
  <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>void</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'><c- g>EventSourceInit</c-></dfn> {
  <c- b>boolean</c-> <dfn id='dom-eventsourceinit-withcredentials'><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.<li><p>A <dfn id=concept-event-stream-request>request</dfn>. This must initially be
   null.<li><p>A <dfn id=concept-event-stream-reconnection-time>reconnection time</dfn>, in
   milliseconds. This must initially be a user-agent-defined value, probably in the region of a few
   seconds.<li><p>A <dfn id=concept-event-stream-last-event-id>last event ID string</dfn>. This must
   initially be the empty string.</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><var>source</var> = new <code id=dom-eventsource-dev><a href=#dom-eventsource>EventSource</a></code>(
   <var>url</var> [, { <code id=the-eventsource-interface:dom-eventsourceinit-withcredentials><a href=#dom-eventsourceinit-withcredentials>withCredentials</a></code>:
   true } ])<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>
   <dt><var>source</var> . <code id=dom-eventsource-close-dev><a href=#dom-eventsource-close>close</a></code>()<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>
   <dt><var>source</var> . <code id=dom-eventsource-url-dev><a href=#dom-eventsource-url>url</a></code><dd>
    <p>Returns the <a href=#concept-eventsource-url id=the-eventsource-interface:concept-eventsource-url-2>URL providing the event stream</a>.
   <dt><var>source</var> . <code id=dom-eventsource-withcredentials-dev><a href=#dom-eventsource-withcredentials>withCredentials</a></code><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>
   <dt><var>source</var> . <code id=dom-eventsource-readystate-dev><a href=#dom-eventsource-readystate>readyState</a></code><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>
   </dl>

  

  <p>The <dfn id=dom-eventsource><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.<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>.

   <li><p>Let <var>urlRecord</var> be the result of <a href=https://url.spec.whatwg.org/#concept-url-parser id=the-eventsource-interface:url-parser data-x-internal=url-parser>parsing</a>
   <var>url</var> with <var>settings</var>'s <a href=#api-base-url id=the-eventsource-interface:api-base-url>API base URL</a> and <var>settings</var>'s
   <a href=#api-url-character-encoding id=the-eventsource-interface:api-url-character-encoding>API URL character encoding</a>.<li><p>If <var>urlRecord</var> is failure, then throw a <a id=the-eventsource-interface:syntaxerror href=https://heycam.github.io/webidl/#syntaxerror data-x-internal=syntaxerror>"<code>SyntaxError</code>"</a>
   <code id=the-eventsource-interface:domexception><a data-x-internal=domexception href=https://heycam.github.io/webidl/#dfn-DOMException>DOMException</a></code>.<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><p>Let <var>corsAttributeState</var> be <a href=#attr-crossorigin-anonymous id=the-eventsource-interface:attr-crossorigin-anonymous>Anonymous</a>.<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.<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>, and with the
   <i>same-origin fallback flag</i> set.<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>.<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://tools.ietf.org/html/rfc7231#section-5.3.2>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>.<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>".<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>.<li>
    <p>Run this step <a href=#in-parallel id=the-eventsource-interface:in-parallel>in parallel</a>:</p>

    <ol><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>.</ol>

   <li><p>Return <var>ev</var>.</ol>

  <hr>

  <p>The <dfn id=dom-eventsource-url><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>

  <p>The <dfn id=dom-eventsource-withcredentials><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>

  <p>The <dfn id=dom-eventsource-readystate><code>readyState</code></dfn> attribute represents
  the state of the connection. It can have the following values:</p>

  

  <dl><dt><dfn id=dom-eventsource-connecting><code>CONNECTING</code></dfn> (numeric value 0)<dd>The connection has not yet been established, or it was closed and the user agent is
   reconnecting.<dt><dfn id=dom-eventsource-open><code>OPEN</code></dfn> (numeric value 1)<dd>The user agent has an open connection and is dispatching events as it receives them.<dt><dfn id=dom-eventsource-closed><code>CLOSED</code></dfn> (numeric value 2)<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.</dl>

  

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

  <p>The <dfn id=dom-eventsource-close><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> 

  

  <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><a href=#event-handler-event-type id=the-eventsource-interface:event-handler-event-type-2>Event handler event type</a>
   <tbody><tr><td><dfn id=handler-eventsource-onopen><code>onopen</code></dfn> <td> <code id=the-eventsource-interface:event-open><a href=#event-open>open</a></code>
    <tr><td><dfn id=handler-eventsource-onmessage><code>onmessage</code></dfn> <td> <code id=the-eventsource-interface:event-message><a href=#event-message>message</a></code>
    <tr><td><dfn id=handler-eventsource-onerror><code>onerror</code></dfn> <td> <code id=the-eventsource-interface:event-error><a href=#event-error>error</a></code>
  </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>

  <p>The resource indicated in the argument to the <code id=sse-processing-model:dom-eventsource><a href=#dom-eventsource>EventSource</a></code>
  constructor is fetched when the constructor is run.</p>

  <p>As data is received, the <a href=#concept-task id=sse-processing-model:concept-task>tasks</a> queued by the <a href=#networking-task-source id=sse-processing-model:networking-task-source>networking
  task source</a> to handle the data must act as follows.</p>

  <p>HTTP 200 OK responses with a `<a href=#content-type id=sse-processing-model:content-type>Content-Type</a>` header specifying the type
  `<code id=sse-processing-model:text/event-stream><a href=#text/event-stream>text/event-stream</a></code>`, ignoring any <a id=sse-processing-model:mime-type href=https://mimesniff.spec.whatwg.org/#mime-type data-x-internal=mime-type>MIME type</a> parameters, must be
  processed line by line <a href=#event-stream-interpretation>as described below</a>.</p>

  <p>When a successful response with a supported <a id=sse-processing-model:mime-type-2 href=https://mimesniff.spec.whatwg.org/#mime-type data-x-internal=mime-type>MIME type</a> is received, such that the
  user agent begins parsing the contents of the stream, the user agent must <a href=#announce-the-connection id=sse-processing-model:announce-the-connection>announce the
  connection</a>.</p>

  <p>The <a href=#concept-task id=sse-processing-model:concept-task-2>task</a> that the <a href=#networking-task-source id=sse-processing-model:networking-task-source-2>networking task source</a> places
  on the <a href=#task-queue id=sse-processing-model:task-queue>task queue</a> once fetching for such a resource (with the correct <a id=sse-processing-model:mime-type-3 href=https://mimesniff.spec.whatwg.org/#mime-type data-x-internal=mime-type>MIME
  type</a>) has completed must cause the user agent to <a href=#reestablish-the-connection id=sse-processing-model:reestablish-the-connection>reestablish the connection</a>
  <a href=#in-parallel id=sse-processing-model:in-parallel>in parallel</a>. This applies whether the connection is closed gracefully or unexpectedly
  (but does not apply when fetching is canceled by the user agent, e.g., in response to <code id=sse-processing-model:dom-window-stop><a href=#dom-window-stop>window.stop()</a></code>, since in those cases the final <a href=#concept-task id=sse-processing-model:concept-task-3>task</a> is actually discarded). It doesn't apply for the error
  conditions listed below except where explicitly specified.</p>

  <p>HTTP 200 OK responses that have a <a href=#content-type id=sse-processing-model:content-type-2>Content-Type</a> specifying an unsupported type, or
  that have no <a href=#content-type id=sse-processing-model:content-type-3>Content-Type</a> at all, must cause the user agent to <a href=#fail-the-connection id=sse-processing-model:fail-the-connection>fail the
  connection</a>.</p> 

  <p id=event-source-network-errors-reconnect>Network errors that prevents the connection from
  being established in the first place (e.g. DNS errors), should cause the user agent to
  <a href=#reestablish-the-connection id=sse-processing-model:reestablish-the-connection-2>reestablish the connection</a> <a href=#in-parallel id=sse-processing-model:in-parallel-2>in parallel</a>, unless the user agent knows that
  to be futile, in which case the user agent may <a href=#fail-the-connection id=sse-processing-model:fail-the-connection-2>fail the connection</a>.</p>

  <p id=event-source-fail-reasons>Any other HTTP response code not listed here, as well as the
  cancelation of the fetch algorithm by the user agent (e.g. in response to <code id=sse-processing-model:dom-window-stop-2><a href=#dom-window-stop>window.stop()</a></code> or the user canceling the network connection
  manually) must cause the user agent to <a href=#fail-the-connection id=sse-processing-model:fail-the-connection-3>fail the connection</a>.</p>  

  <hr>

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

  <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-3>in parallel</a>, not as part of a <a href=#concept-task id=sse-processing-model:concept-task-4>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-4>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.<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>.<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.</ol>

   <li><p>Wait a delay equal to the reconnection time of the event source.<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.<li><p>Wait until the aforementioned task has run, if it has not yet run.<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>, return.<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>.

     <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, <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>`/<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>, 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>.<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.</ol>

   </ol>

  <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-6><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-4>failed the connection</a>,
  it does <em>not</em> attempt to reconnect!</strong></p>

  <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-5>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-7><a href=#eventsource>EventSource</a></code> objects is the <dfn id=remote-event-task-source>remote event
  task source</dfn>.</p>

  


  <h4 id=parsing-an-event-stream><span class=secno>9.2.4</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 href='https://infra.spec.whatwg.org/#scalar-value' data-x-internal='scalar-value' id='parsing-an-event-stream: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 href='https://infra.spec.whatwg.org/#scalar-value' data-x-internal='scalar-value' id='parsing-an-event-stream:scalar-value-2'><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.5</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>

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

  <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)<dd><p><a href=#dispatchMessage id=event-stream-interpretation:dispatchMessage>Dispatch the event</a>, as defined below.<dt>If the line starts with a U+003A COLON character (:)<dd><p>Ignore the line.<dt>If the line contains a U+003A COLON character (:)<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>

   <dt>Otherwise, the string is not empty but does not contain a U+003A COLON character (:)<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>

   </dl>

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

  <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"<dd><p>Set the <var>event type</var> buffer to field value.<dt>If the field name is "data"<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.<dt>If the field name is "id"<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.<dt>If the field name is "retry"<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.<dt>Otherwise<dd><p>The field is ignored.</dl>


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

  <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.<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.<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.<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.<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.<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.<li><p>Set the <var>data</var> buffer and the <var>event type</var> buffer to
   the empty string.<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.</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>

  <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 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:
   <pre><code class='js'><c- a>var</c-> stocks <c- o>=</c-> <c- k>new</c-> EventSource<c- p>(</c-><c- u>&quot;https://stocks.example.com/ticker.php&quot;</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>&apos;\n&apos;</c-><c- p>);</c->
  updateStocks<c- p>(</c->data<c- p>[</c-><c- mi>0</c-><c- p>],</c-> data<c- p>[</c-><c- mi>1</c-><c- p>],</c-> data<c- p>[</c-><c- mi>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 "1". 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
   " third 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:  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: 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.6</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.7</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>The server sends occasional messages.<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>The browser disconnects from the server.<li>The browser contacts a service on the network, and requests that the service, a "push
    proxy", maintain the connection instead.<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>The browser allows the mobile device to go to sleep.<li>The server sends another message.<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.</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-2><span class=secno>9.2.8</span> Garbage collection<a href=#garbage-collection-2 class=self-link></a></h4>

  <p>While an <code id=garbage-collection-2:eventsource><a href=#eventsource>EventSource</a></code> object's <code id=garbage-collection-2:dom-eventsource-readystate><a href=#dom-eventsource-readystate>readyState</a></code> is <code id=garbage-collection-2: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-2:event-open><a href=#event-open>open</a></code>, <code id=garbage-collection-2:event-message><a href=#event-message>message</a></code> or <code id=garbage-collection-2:event-error><a href=#event-error>error</a></code> events, there must
  be a strong reference from the <code id=garbage-collection-2:window><a href=#window>Window</a></code> or <code id=garbage-collection-2:workerglobalscope><a href=#workerglobalscope>WorkerGlobalScope</a></code> object that
  the <code id=garbage-collection-2:eventsource-2><a href=#eventsource>EventSource</a></code> object's constructor was invoked from to the <code id=garbage-collection-2:eventsource-3><a href=#eventsource>EventSource</a></code>
  object itself.</p>

  <p>While an <code id=garbage-collection-2:eventsource-4><a href=#eventsource>EventSource</a></code> object's <code id=garbage-collection-2:dom-eventsource-readystate-2><a href=#dom-eventsource-readystate>readyState</a></code> is <code id=garbage-collection-2: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-2:event-message-2><a href=#event-message>message</a></code> or <code id=garbage-collection-2:event-error-2><a href=#event-error>error</a></code> events, there must be a strong reference from the
  <code id=garbage-collection-2:window-2><a href=#window>Window</a></code> or <code id=garbage-collection-2:workerglobalscope-2><a href=#workerglobalscope>WorkerGlobalScope</a></code> object that the <code id=garbage-collection-2:eventsource-5><a href=#eventsource>EventSource</a></code>
  object's constructor was invoked from to the <code id=garbage-collection-2:eventsource-6><a href=#eventsource>EventSource</a></code> object itself.</p>

  <p>While there is a task queued by an <code id=garbage-collection-2:eventsource-7><a href=#eventsource>EventSource</a></code> object on the <a href=#remote-event-task-source id=garbage-collection-2:remote-event-task-source>remote event
  task source</a>, there must be a strong reference from the <code id=garbage-collection-2:window-3><a href=#window>Window</a></code> or
  <code id=garbage-collection-2:workerglobalscope-3><a href=#workerglobalscope>WorkerGlobalScope</a></code> object that the <code id=garbage-collection-2:eventsource-8><a href=#eventsource>EventSource</a></code> object's constructor was
  invoked from to that <code id=garbage-collection-2:eventsource-9><a href=#eventsource>EventSource</a></code> object.</p>

  <p>If a user agent is to <dfn id=concept-eventsource-forcibly-close>forcibly close</dfn> an
  <code id=garbage-collection-2:eventsource-10><a href=#eventsource>EventSource</a></code> object (this happens when a <code id=garbage-collection-2: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-2:concept-fetch data-x-internal=concept-fetch>fetch</a> algorithm started for this <code id=garbage-collection-2:eventsource-11><a href=#eventsource>EventSource</a></code> object,
  and must set the <code id=garbage-collection-2:dom-eventsource-readystate-3><a href=#dom-eventsource-readystate>readyState</a></code> attribute to <code id=garbage-collection-2:dom-eventsource-closed><a href=#dom-eventsource-closed>CLOSED</a></code>.</p> 

  <p>If an <code id=garbage-collection-2: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-2:concept-fetch-2 data-x-internal=concept-fetch>fetch</a> algorithm
  opened by this <code id=garbage-collection-2:eventsource-13><a href=#eventsource>EventSource</a></code>.</p> 


  <h4 id=implementation-advice><span class=secno>9.2.9</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=network><span class=secno>9.3</span> <dfn>Web sockets</dfn><a href=#network class=self-link></a></h3><div class=status><input onclick=toggleStatus(this) value=⋰ type=button><p class=support><strong>Support:</strong> websockets<span class="and_chr yes"><span>Chrome for Android</span> <span>67+</span></span><span class="chrome yes"><span>Chrome</span> <span>16+</span></span><span class="ios_saf yes"><span>iOS Safari</span> <span>6.0+</span></span><span class="and_uc yes"><span>UC Browser for Android</span> <span>11.8+</span></span><span class="firefox yes"><span>Firefox</span> <span>11+</span></span><span class="ie yes"><span>IE</span> <span>10+</span></span><span class="op_mini no"><span>Opera Mini</span> <span>None</span></span><span class="safari yes"><span>Safari</span> <span>7+</span></span><span class="edge yes"><span>Edge</span> <span>12+</span></span><span class="samsung yes"><span>Samsung Internet</span> <span>4+</span></span><span class="opera yes"><span>Opera</span> <span>12.1+</span></span><span class="android yes"><span>Android Browser</span> <span>4.4+</span></span><p class=caniuse>Source: <a href="https://caniuse.com/#feat=websockets">caniuse.com</a></div>

  <h4 id=network-intro><span class=secno>9.3.1</span> Introduction<a href=#network-intro class=self-link></a></h4>

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

  <p>To enable Web applications to maintain bidirectional communications with server-side processes,
  this specification introduces the <code id=network-intro:websocket><a href=#websocket>WebSocket</a></code> interface.</p>

  <p class=note>This interface does not allow for raw access to the underlying network. For
  example, this interface could not be used to implement an IRC client without proxying messages
  through a custom server.</p>


  <h4 id=the-websocket-interface><span class=secno>9.3.2</span> The <code id=the-websocket-interface:websocket><a href=#websocket>WebSocket</a></code> interface<a href=#the-websocket-interface class=self-link></a></h4>

  <pre><code class='idl'><c- b>enum</c-> <dfn id='binarytype'><c- g>BinaryType</c-></dfn> { <c- s>&quot;</c-><a href='#dom-binarytype-blob' id='the-websocket-interface:dom-binarytype-blob'><c- s>blob</c-></a><c- s>&quot;</c->, <c- s>&quot;</c-><a href='#dom-binarytype-arraybuffer' id='the-websocket-interface:dom-binarytype-arraybuffer'><c- s>arraybuffer</c-></a><c- s>&quot;</c-> };
[<a href='#dom-websocket' id='the-websocket-interface:dom-websocket'><c- g>Constructor</c-></a>(<c- b>USVString</c-> <c- g>url</c->, <c- b>optional</c-> (<c- b>DOMString</c-> <c- b>or</c-> <c- b>sequence</c->&lt;<c- b>DOMString</c->&gt;) <c- g>protocols</c-> = []), <c- g>Exposed</c->=(<c- n>Window</c->,<c- n>Worker</c->)]
<c- b>interface</c-> <dfn id='websocket'><c- g>WebSocket</c-></dfn> : <a href='https://dom.spec.whatwg.org/#interface-eventtarget' data-x-internal='eventtarget' id='the-websocket-interface:eventtarget'><c- n>EventTarget</c-></a> {
  <c- b>readonly</c-> <c- b>attribute</c-> <c- b>USVString</c-> <a href='#dom-websocket-url' id='the-websocket-interface:dom-websocket-url'><c- g>url</c-></a>;

  // ready state
  <c- b>const</c-> <c- b>unsigned</c-> <c- b>short</c-> <a href='#dom-websocket-connecting' id='the-websocket-interface:dom-websocket-connecting'><c- g>CONNECTING</c-></a> = 0;
  <c- b>const</c-> <c- b>unsigned</c-> <c- b>short</c-> <a href='#dom-websocket-open' id='the-websocket-interface:dom-websocket-open'><c- g>OPEN</c-></a> = 1;
  <c- b>const</c-> <c- b>unsigned</c-> <c- b>short</c-> <a href='#dom-websocket-closing' id='the-websocket-interface:dom-websocket-closing'><c- g>CLOSING</c-></a> = 2;
  <c- b>const</c-> <c- b>unsigned</c-> <c- b>short</c-> <a href='#dom-websocket-closed' id='the-websocket-interface:dom-websocket-closed'><c- g>CLOSED</c-></a> = 3;
  <c- b>readonly</c-> <c- b>attribute</c-> <c- b>unsigned</c-> <c- b>short</c-> <a href='#dom-websocket-readystate' id='the-websocket-interface:dom-websocket-readystate'><c- g>readyState</c-></a>;
  <c- b>readonly</c-> <c- b>attribute</c-> <c- b>unsigned</c-> <c- b>long</c-> <c- b>long</c-> <a href='#dom-websocket-bufferedamount' id='the-websocket-interface:dom-websocket-bufferedamount'><c- g>bufferedAmount</c-></a>;

  // networking
  <c- b>attribute</c-> <a href='#eventhandler' id='the-websocket-interface:eventhandler'><c- n>EventHandler</c-></a> <a href='#handler-websocket-onopen' id='the-websocket-interface:handler-websocket-onopen'><c- g>onopen</c-></a>;
  <c- b>attribute</c-> <a href='#eventhandler' id='the-websocket-interface:eventhandler-2'><c- n>EventHandler</c-></a> <a href='#handler-websocket-onerror' id='the-websocket-interface:handler-websocket-onerror'><c- g>onerror</c-></a>;
  <c- b>attribute</c-> <a href='#eventhandler' id='the-websocket-interface:eventhandler-3'><c- n>EventHandler</c-></a> <a href='#handler-websocket-onclose' id='the-websocket-interface:handler-websocket-onclose'><c- g>onclose</c-></a>;
  <c- b>readonly</c-> <c- b>attribute</c-> <c- b>DOMString</c-> <a href='#dom-websocket-extensions' id='the-websocket-interface:dom-websocket-extensions'><c- g>extensions</c-></a>;
  <c- b>readonly</c-> <c- b>attribute</c-> <c- b>DOMString</c-> <a href='#dom-websocket-protocol' id='the-websocket-interface:dom-websocket-protocol'><c- g>protocol</c-></a>;
  <c- b>void</c-> <a href='#dom-websocket-close' id='the-websocket-interface:dom-websocket-close'><c- g>close</c-></a>(<c- b>optional</c-> [<c- g>Clamp</c->] <c- b>unsigned</c-> <c- b>short</c-> <c- g>code</c->, <c- b>optional</c-> <a href='https://heycam.github.io/webidl/#idl-USVString' data-x-internal='idl-usvstring' id='the-websocket-interface:idl-usvstring'><c- b>USVString</c-></a> <c- g>reason</c->);

  // messaging
  <c- b>attribute</c-> <a href='#eventhandler' id='the-websocket-interface:eventhandler-4'><c- n>EventHandler</c-></a> <a href='#handler-websocket-onmessage' id='the-websocket-interface:handler-websocket-onmessage'><c- g>onmessage</c-></a>;
  <c- b>attribute</c-> <a href='#binarytype' id='the-websocket-interface:binarytype'><c- n>BinaryType</c-></a> <a href='#dom-websocket-binarytype' id='the-websocket-interface:dom-websocket-binarytype'><c- g>binaryType</c-></a>;
  <c- b>void</c-> <a href='#dom-websocket-send' id='the-websocket-interface:dom-websocket-send'><c- g>send</c-></a>(<a href='https://heycam.github.io/webidl/#idl-USVString' data-x-internal='idl-usvstring' id='the-websocket-interface:idl-usvstring-2'><c- b>USVString</c-></a> <c- g>data</c->);
  <c- b>void</c-> <a href='#dom-websocket-send' id='the-websocket-interface:dom-websocket-send-2'><c- g>send</c-></a>(<a href='https://w3c.github.io/FileAPI/#dfn-Blob' data-x-internal='blob' id='the-websocket-interface:blob'><c- n>Blob</c-></a> <c- g>data</c->);
  <c- b>void</c-> <a href='#dom-websocket-send' id='the-websocket-interface:dom-websocket-send-3'><c- g>send</c-></a>(<a href='https://heycam.github.io/webidl/#idl-ArrayBuffer' data-x-internal='idl-arraybuffer' id='the-websocket-interface:idl-arraybuffer'><c- b>ArrayBuffer</c-></a> <c- g>data</c->);
  <c- b>void</c-> <a href='#dom-websocket-send' id='the-websocket-interface:dom-websocket-send-4'><c- g>send</c-></a>(<a href='https://heycam.github.io/webidl/#common-ArrayBufferView' data-x-internal='idl-arraybufferview' id='the-websocket-interface:idl-arraybufferview'><c- n>ArrayBufferView</c-></a> <c- g>data</c->);
};</code></pre>

  <p>Each <code id=the-websocket-interface:websocket-2><a href=#websocket>WebSocket</a></code> object has an associated <dfn id=concept-websocket-url>url</dfn> (a <a id=the-websocket-interface:url-record href=https://url.spec.whatwg.org/#concept-url data-x-internal=url-record>URL record</a>).

  <dl class=domintro><dt><var>socket</var> = new <code id=dom-websocket-dev><a href=#dom-websocket>WebSocket</a></code>(<var>url</var> [, <var>protocols</var> ] )<dd>
    <p>Creates a new <code id=the-websocket-interface:websocket-3><a href=#websocket>WebSocket</a></code> object, immediately establishing the associated
    WebSocket connection.</p>

    <p><var>url</var> is a string giving the <a id=the-websocket-interface:url href=https://url.spec.whatwg.org/#concept-url data-x-internal=url>URL</a> over which the connection is
    established. Only "<code>ws</code>" or "<code>wss</code>" schemes are
    allowed; others will cause a <a id=the-websocket-interface:syntaxerror href=https://heycam.github.io/webidl/#syntaxerror data-x-internal=syntaxerror>"<code>SyntaxError</code>"</a>
    <code id=the-websocket-interface:domexception><a data-x-internal=domexception href=https://heycam.github.io/webidl/#dfn-DOMException>DOMException</a></code>. URLs with <a href=https://url.spec.whatwg.org/#concept-url-fragment id=the-websocket-interface:concept-url-fragment data-x-internal=concept-url-fragment>fragments</a>
    will also cause such an exception.</p>

    <p><var>protocols</var> is either a string or an array of strings. If it is a string, it
    is equivalent to an array consisting of just that string; if it is omitted, it is equivalent to
    the empty array. Each string in the array is a subprotocol name. The connection will only be
    established if the server reports that it has selected one of these subprotocols. The subprotocol
    names have to match the requirements for elements that comprise the value of <code id=the-websocket-interface:http-sec-websocket-protocol><a href=#http-sec-websocket-protocol>Sec-WebSocket-Protocol</a></code> fields as defined by the
    WebSocket protocol specification. <a href=#refsWSP>[WSP]</a></p>
   <dt><var>socket</var> . <code id=dom-websocket-send-dev><a href=#dom-websocket-send>send</a></code>( <var>data</var> )<dd>
    <p>Transmits <var>data</var> using the WebSocket connection. <var>data</var> can be a string, a
    <code id=the-websocket-interface:blob-2><a data-x-internal=blob href=https://w3c.github.io/FileAPI/#dfn-Blob>Blob</a></code>, an <code id=the-websocket-interface:idl-arraybuffer-2><a data-x-internal=idl-arraybuffer href=https://heycam.github.io/webidl/#idl-ArrayBuffer>ArrayBuffer</a></code>, or an <code id=the-websocket-interface:idl-arraybufferview-2><a data-x-internal=idl-arraybufferview href=https://heycam.github.io/webidl/#common-ArrayBufferView>ArrayBufferView</a></code>.</p>
  <dt><var>socket</var> . <code id=dom-websocket-close-dev><a href=#dom-websocket-close>close</a></code>( [ <var>code</var> ] [, <var>reason</var> ] )<dd>
    <p>Closes the WebSocket connection, optionally using <var>code</var> as the <a href=#concept-websocket-close-code id=the-websocket-interface:concept-websocket-close-code>the WebSocket connection close code</a> and
    <var>reason</var> as the <a href=#concept-websocket-close-reason id=the-websocket-interface:concept-websocket-close-reason>the WebSocket connection
    close reason</a>.</p>
   <dt><var>socket</var> . <code id=dom-websocket-url-dev><a href=#dom-websocket-url>url</a></code><dd>
    <p>Returns the <a href=#concept-websocket-url id=the-websocket-interface:concept-websocket-url>URL that was used</a> to establish the
    WebSocket connection.</p>
   <dt><var>socket</var> . <code id=dom-websocket-readystate-dev><a href=#dom-websocket-readystate>readyState</a></code><dd>
    <p>Returns the state of the <code id=the-websocket-interface:websocket-4><a href=#websocket>WebSocket</a></code> object's connection. It can have the values
    described below.</p>
   <dt><var>socket</var> . <code id=dom-websocket-bufferedamount-dev><a href=#dom-websocket-bufferedamount>bufferedAmount</a></code><dd>
    <p>Returns the number of bytes of application data (UTF-8 text and binary data) that have been
    queued using <code id=the-websocket-interface:dom-websocket-send-5><a href=#dom-websocket-send>send()</a></code> but not yet been transmitted to the
    network.</p>

    <p>If the WebSocket connection is closed, this attribute's value will only increase with each
    call to the <code id=the-websocket-interface:dom-websocket-send-6><a href=#dom-websocket-send>send()</a></code> method. (The number does not reset
    to zero once the connection closes.)</p>
   <dt><var>socket</var> . <code id=dom-websocket-extensions-dev><a href=#dom-websocket-extensions>extensions</a></code><dd>
    <p>Returns the extensions selected by the server, if any.</p>
   <dt><var>socket</var> . <code id=dom-websocket-protocol-dev><a href=#dom-websocket-protocol>protocol</a></code><dd>
    <p>Returns the subprotocol selected by the server, if any. It can be used in conjunction with
    the array form of the constructor's second argument to perform subprotocol negotiation.</p>
   <dt><var>socket</var> . <code id=dom-websocket-binarytype-dev><a href=#dom-websocket-binarytype>binaryType</a></code> [ = <var>value</var> ]<dd>
    <p>Returns a string that indicates how binary data from the <code id=the-websocket-interface:websocket-5><a href=#websocket>WebSocket</a></code> object is
    exposed to scripts:</p>

    <dl><dt>"<code id=the-websocket-interface:dom-binarytype-blob-2><a href=#dom-binarytype-blob>blob</a></code>"<dd>
       <p>Binary data is returned in <code id=the-websocket-interface:blob-3><a data-x-internal=blob href=https://w3c.github.io/FileAPI/#dfn-Blob>Blob</a></code> form.</p>
     <dt>"<code id=the-websocket-interface:dom-binarytype-arraybuffer-2><a href=#dom-binarytype-arraybuffer>arraybuffer</a></code>"<dd>
      <p>Binary data is returned in <code id=the-websocket-interface:idl-arraybuffer-3><a data-x-internal=idl-arraybuffer href=https://heycam.github.io/webidl/#idl-ArrayBuffer>ArrayBuffer</a></code> form.</p>
     </dl>

    <p>Can be set, to change how binary data is returned. The default is "<code id=the-websocket-interface:dom-binarytype-blob-3><a href=#dom-binarytype-blob>blob</a></code>".</p>

   </dl>

  

  <p>The <dfn id=dom-websocket><code>WebSocket(<var>url</var>,
  <var>protocols</var>)</code></dfn> constructor, when invoked, must run these steps:</p>

  <ol><li><p>Let <var>urlRecord</var> be the result of applying the <a id=the-websocket-interface:url-parser href=https://url.spec.whatwg.org/#concept-url-parser data-x-internal=url-parser>URL parser</a> to
   <var>url</var>.<li><p>If <var>urlRecord</var> is failure, then throw a <a id=the-websocket-interface:syntaxerror-2 href=https://heycam.github.io/webidl/#syntaxerror data-x-internal=syntaxerror>"<code>SyntaxError</code>"</a>
   <code id=the-websocket-interface:domexception-2><a data-x-internal=domexception href=https://heycam.github.io/webidl/#dfn-DOMException>DOMException</a></code>.<li><p>If <var>urlRecord</var>'s <a href=https://url.spec.whatwg.org/#concept-url-scheme id=the-websocket-interface:concept-url-scheme data-x-internal=concept-url-scheme>scheme</a> is not "<code>ws</code>" or "<code>wss</code>", then throw a
   <a id=the-websocket-interface:syntaxerror-3 href=https://heycam.github.io/webidl/#syntaxerror data-x-internal=syntaxerror>"<code>SyntaxError</code>"</a> <code id=the-websocket-interface:domexception-3><a data-x-internal=domexception href=https://heycam.github.io/webidl/#dfn-DOMException>DOMException</a></code>.<li><p>If <var>urlRecord</var>'s <a href=https://url.spec.whatwg.org/#concept-url-fragment id=the-websocket-interface:concept-url-fragment-2 data-x-internal=concept-url-fragment>fragment</a> is non-null,
   then throw a <a id=the-websocket-interface:syntaxerror-4 href=https://heycam.github.io/webidl/#syntaxerror data-x-internal=syntaxerror>"<code>SyntaxError</code>"</a> <code id=the-websocket-interface:domexception-4><a data-x-internal=domexception href=https://heycam.github.io/webidl/#dfn-DOMException>DOMException</a></code>.<li><p>If <var>protocols</var> is a string, set <var>protocols</var> to a sequence consisting of
   just that string.<li><p>If any of the values in <var>protocols</var> occur more than once or otherwise fail to
   match the requirements for elements that comprise the value of <code id=the-websocket-interface:http-sec-websocket-protocol-2><a href=#http-sec-websocket-protocol>Sec-WebSocket-Protocol</a></code> fields as defined by the
   WebSocket protocol specification, then throw a <a id=the-websocket-interface:syntaxerror-5 href=https://heycam.github.io/webidl/#syntaxerror data-x-internal=syntaxerror>"<code>SyntaxError</code>"</a>
   <code id=the-websocket-interface:domexception-5><a data-x-internal=domexception href=https://heycam.github.io/webidl/#dfn-DOMException>DOMException</a></code>. <a href=#refsWSP>[WSP]</a><li>
    <p>Run this step <a href=#in-parallel id=the-websocket-interface:in-parallel>in parallel</a>:</p>

    <ol><li>
      <p><a href=https://fetch.spec.whatwg.org/#concept-websocket-establish id=the-websocket-interface:concept-websocket-establish data-x-internal=concept-websocket-establish>Establish a WebSocket connection</a> given
      <var>urlRecord</var>, <var>protocols</var>, and the <a href=#entry-settings-object id=the-websocket-interface:entry-settings-object>entry settings object</a>. <a href=#refsFETCH>[FETCH]</a></p>

      <p class=note>If the <a href=https://fetch.spec.whatwg.org/#concept-websocket-establish id=the-websocket-interface:concept-websocket-establish-2 data-x-internal=concept-websocket-establish>establish a WebSocket
      connection</a> algorithm fails, it triggers the <i id=the-websocket-interface:concept-websocket-fail><a href=#concept-websocket-fail>fail the
      WebSocket connection</a></i> algorithm, which then invokes the <i id=the-websocket-interface:concept-websocket-close><a href=#concept-websocket-close>close the WebSocket connection</a></i> algorithm, which then
      establishes that <i id=the-websocket-interface:concept-websocket-closed><a href=#concept-websocket-closed>the WebSocket connection is closed</a></i>,
      which fires the <code id=the-websocket-interface:event-close><a href=#event-close>close</a></code> event <a href=#closeWebSocket>as
      described below</a>.</p>
     </ol>
   <li><p>Return a new <code id=the-websocket-interface:websocket-6><a href=#websocket>WebSocket</a></code> object whose <a href=#concept-websocket-url id=the-websocket-interface:concept-websocket-url-2>url</a> is <var>urlRecord</var>.</ol>

  <hr>

  <p>The <dfn id=dom-websocket-url><code>url</code></dfn> attribute's getter must return this
  <code id=the-websocket-interface:websocket-7><a href=#websocket>WebSocket</a></code> object's <a href=#concept-websocket-url id=the-websocket-interface:concept-websocket-url-3>url</a>, <a href=https://url.spec.whatwg.org/#concept-url-serializer id=the-websocket-interface:concept-url-serializer data-x-internal=concept-url-serializer>serialized</a>.</p>

  <p>The <dfn id=dom-websocket-readystate><code>readyState</code></dfn> attribute represents
  the state of the connection. It can have the following values:</p>

  

  

  <dl><dt><dfn id=dom-websocket-connecting><code>CONNECTING</code></dfn> (numeric value 0)<dd>The connection has not yet been established.<dt><dfn id=dom-websocket-open><code>OPEN</code></dfn> (numeric value 1)<dd><i id=the-websocket-interface:concept-websocket-established><a href=#concept-websocket-established>The WebSocket connection is established</a></i> and
   communication is possible.<dt><dfn id=dom-websocket-closing><code>CLOSING</code></dfn> (numeric value 2)<dd>The connection is going through the closing handshake, or the <code id=the-websocket-interface:dom-websocket-close-2><a href=#dom-websocket-close>close()</a></code> method has been invoked.<dt><dfn id=dom-websocket-closed><code>CLOSED</code></dfn> (numeric value 3)<dd>The connection has been closed or could not be opened.</dl>

  

  <p>When the object is created its <code id=the-websocket-interface:dom-websocket-readystate-2><a href=#dom-websocket-readystate>readyState</a></code> must be
  set to <code id=the-websocket-interface:dom-websocket-connecting-2><a href=#dom-websocket-connecting>CONNECTING</a></code> (0).</p>

  <p>The <dfn id=dom-websocket-extensions><code>extensions</code></dfn> attribute must
  initially return the empty string. After <i id=the-websocket-interface:concept-websocket-established-2><a href=#concept-websocket-established>the WebSocket
  connection is established</a></i>, its value might change, as defined below.</p>

  <p>The <dfn id=dom-websocket-protocol><code>protocol</code></dfn> attribute must initially
  return the empty string. After <i id=the-websocket-interface:concept-websocket-established-3><a href=#concept-websocket-established>the WebSocket connection
  is established</a></i>, its value might change, as defined below.</p>

  <p>The <dfn id=dom-websocket-close><code>close(<var>code</var>,
  <var>reason</var>)</code></dfn> method, when invoked, must run these steps:</p>

  <ol><li><p>If <var>code</var> is present, but is neither an integer equal to 1000 nor an integer in
   the range 3000 to 4999, inclusive, throw an <a id=the-websocket-interface:invalidaccesserror href=https://heycam.github.io/webidl/#invalidaccesserror data-x-internal=invalidaccesserror>"<code>InvalidAccessError</code>"</a>
   <code id=the-websocket-interface:domexception-6><a data-x-internal=domexception href=https://heycam.github.io/webidl/#dfn-DOMException>DOMException</a></code>.<li>
    <p>If <var>reason</var> is present, then run these substeps:</p>

    <ol><li><p>Let <var>reasonBytes</var> be the result of <a href=https://encoding.spec.whatwg.org/#utf-8-encode id=the-websocket-interface:utf-8-encode data-x-internal=utf-8-encode>encoding</a>
     <var>reason</var>.<li><p>If <var>reasonBytes</var> is longer than 123 bytes, then throw a
     <a id=the-websocket-interface:syntaxerror-6 href=https://heycam.github.io/webidl/#syntaxerror data-x-internal=syntaxerror>"<code>SyntaxError</code>"</a> <code id=the-websocket-interface:domexception-7><a data-x-internal=domexception href=https://heycam.github.io/webidl/#dfn-DOMException>DOMException</a></code>.</ol>
   <li><p>Run the first matching steps from the following list:</p>

    <dl class=switch><dt>If the <code id=the-websocket-interface:dom-websocket-readystate-3><a href=#dom-websocket-readystate>readyState</a></code> attribute is in the <code id=the-websocket-interface:dom-websocket-closing-2><a href=#dom-websocket-closing>CLOSING</a></code> (2) or <code id=the-websocket-interface:dom-websocket-closed-2><a href=#dom-websocket-closed>CLOSED</a></code> (3) state<dd>

      <p>Do nothing.</p>

      <p class=note>The connection is already closing or is already closed. If it has not already,
      a <code id=the-websocket-interface:event-close-2><a href=#event-close>close</a></code> event will eventually fire <a href=#closeWebSocket>as described below</a>.</p>

     <dt>If the WebSocket connection is not yet <i id=the-websocket-interface:concept-websocket-established-4><a href=#concept-websocket-established>established</a></i> <a href=#refsWSP>[WSP]</a><dd>

      <p><i id=the-websocket-interface:concept-websocket-fail-2><a href=#concept-websocket-fail>Fail the WebSocket connection</a></i> and set the <code id=the-websocket-interface:dom-websocket-readystate-4><a href=#dom-websocket-readystate>readyState</a></code> attribute's value to <code id=the-websocket-interface:dom-websocket-closing-3><a href=#dom-websocket-closing>CLOSING</a></code> (2). <a href=#refsWSP>[WSP]</a></p>

      <p class=note>The <i id=the-websocket-interface:concept-websocket-fail-3><a href=#concept-websocket-fail>fail the WebSocket connection</a></i>
      algorithm invokes the <i id=the-websocket-interface:concept-websocket-close-2><a href=#concept-websocket-close>close the WebSocket connection</a></i>
      algorithm, which then establishes that <i id=the-websocket-interface:concept-websocket-closed-2><a href=#concept-websocket-closed>the WebSocket
      connection is closed</a></i>, which fires the <code id=the-websocket-interface:event-close-3><a href=#event-close>close</a></code> event <a href=#closeWebSocket>as described below</a>.</p>

     <dt>If the WebSocket closing handshake has not yet been <i id=the-websocket-interface:concept-websocket-closing-handshake><a href=#concept-websocket-closing-handshake>started</a></i> <a href=#refsWSP>[WSP]</a><dd>

      <p><i id=the-websocket-interface:concept-websocket-start-closing-handshake><a href=#concept-websocket-start-closing-handshake>Start the WebSocket closing
      handshake</a></i> and set the <code id=the-websocket-interface:dom-websocket-readystate-5><a href=#dom-websocket-readystate>readyState</a></code>
      attribute's value to <code id=the-websocket-interface:dom-websocket-closing-4><a href=#dom-websocket-closing>CLOSING</a></code> (2). <a href=#refsWSP>[WSP]</a></p>

      <p>If neither <var>code</var> nor <var>reason</var> is present, the WebSocket Close message
      must not have a body.</p>

      <p class=note>The WebSocket Protocol specification erroneously states that the status code
      is required for the <i id=the-websocket-interface:concept-websocket-start-closing-handshake-2><a href=#concept-websocket-start-closing-handshake>start the WebSocket
      closing handshake</a></i> algorithm.</p>

      <p>If <var>code</var> is present, then the status code to use in the
      WebSocket Close message must be the integer given by <var>close</var>. <a href=#refsWSP>[WSP]</a></p>

      <p>If <var>reason</var> is also present, then <var>reasonBytes</var> must be provided in the
      Close message after the status code. <a href=#refsWSP>[WSP]</a></p>

      <p class=note>The <i id=the-websocket-interface:concept-websocket-start-closing-handshake-3><a href=#concept-websocket-start-closing-handshake>start the WebSocket
      closing handshake</a></i> algorithm eventually invokes the <i id=the-websocket-interface:concept-websocket-close-3><a href=#concept-websocket-close>close the WebSocket connection</a></i> algorithm, which then
      establishes that <i id=the-websocket-interface:concept-websocket-closed-3><a href=#concept-websocket-closed>the WebSocket connection is closed</a></i>,
      which fires the <code id=the-websocket-interface:event-close-4><a href=#event-close>close</a></code> event <a href=#closeWebSocket>as
      described below</a>.</p>

     <dt>Otherwise<dd>

      <p>Set the <code id=the-websocket-interface:dom-websocket-readystate-6><a href=#dom-websocket-readystate>readyState</a></code> attribute's value to <code id=the-websocket-interface:dom-websocket-closing-5><a href=#dom-websocket-closing>CLOSING</a></code> (2).</p>

      <p class=note><i id=the-websocket-interface:concept-websocket-closing-handshake-2><a href=#concept-websocket-closing-handshake>The WebSocket closing
      handshake is started</a></i>, and will eventually invoke the <i id=the-websocket-interface:concept-websocket-close-4><a href=#concept-websocket-close>close the WebSocket connection</a></i> algorithm, which will
      establish that <i id=the-websocket-interface:concept-websocket-closed-4><a href=#concept-websocket-closed>the WebSocket connection is closed</a></i>,
      and thus the <code id=the-websocket-interface:event-close-5><a href=#event-close>close</a></code> event will fire, <a href=#closeWebSocket>as described below</a>.</p>

     </dl>

   </ol>

  

  <p class=note>The <code id=the-websocket-interface:dom-websocket-close-3><a href=#dom-websocket-close>close()</a></code> method does not discard
  previously sent messages before starting the WebSocket closing handshake — even if, in
  practice, the user agent is still busy sending those messages, the handshake will only start after
  the messages are sent.</p> 

  <hr>

  <p>The <dfn id=dom-websocket-bufferedamount><code>bufferedAmount</code></dfn> attribute must
  return the number of bytes of application data (UTF-8 text and binary data) that have been queued
  using <code id=the-websocket-interface:dom-websocket-send-7><a href=#dom-websocket-send>send()</a></code> but that, as of the last time the
  <a href=#event-loop id=the-websocket-interface:event-loop>event loop</a> reached <a href=#step1>step 1</a>, had not yet been transmitted to the network. (This thus
  includes any text sent during the execution of the current task, regardless of whether the user
  agent is able to transmit text in the background <a href=#in-parallel id=the-websocket-interface:in-parallel-2>in parallel</a> with script execution.) This does not include
  framing overhead incurred by the protocol, or buffering done by the operating system or network
  hardware.</p>

  <div class=example>

   <p>In this simple example, the <code id=the-websocket-interface:dom-websocket-bufferedamount-2><a href=#dom-websocket-bufferedamount>bufferedAmount</a></code>
   attribute is used to ensure that updates are sent either at the rate of one update every 50ms, if
   the network can handle that rate, or at whatever rate the network <em>can</em> handle, if that is
   too fast.</p>

   <pre><code class='js'><c- a>var</c-> socket <c- o>=</c-> <c- k>new</c-> WebSocket<c- p>(</c-><c- t>&apos;ws://game.example.com:12010/updates&apos;</c-><c- p>);</c->
socket<c- p>.</c->onopen <c- o>=</c-> <c- a>function</c-> <c- p>()</c-> <c- p>{</c->
  setInterval<c- p>(</c-><c- a>function</c-><c- p>()</c-> <c- p>{</c->
    <c- k>if</c-> <c- p>(</c->socket<c- p>.</c->bufferedAmount <c- o>==</c-> <c- mi>0</c-><c- p>)</c->
      socket<c- p>.</c->send<c- p>(</c->getUpdateData<c- p>());</c->
  <c- p>},</c-> <c- mi>50</c-><c- p>);</c->
<c- p>};</c-></code></pre>

   <p>The <code id=the-websocket-interface:dom-websocket-bufferedamount-3><a href=#dom-websocket-bufferedamount>bufferedAmount</a></code> attribute can also be
   used to saturate the network without sending the data at a higher rate than the network can
   handle, though this requires more careful monitoring of the value of the attribute over time.</p>

  </div>

  <hr>

  

  <p>When a <code id=the-websocket-interface:websocket-8><a href=#websocket>WebSocket</a></code> object is created, its <dfn id=dom-websocket-binarytype><code>binaryType</code></dfn> IDL attribute must be set to the string
  "<code id=the-websocket-interface:dom-binarytype-blob-4><a href=#dom-binarytype-blob>blob</a></code>". On getting, it must return the last
  value it was set to. On setting, the user agent must set the IDL attribute to the new value.</p>

  <p class=note>User agents can use the
  <code id=the-websocket-interface:dom-websocket-binarytype-2><a href=#dom-websocket-binarytype>binaryType</a></code> attribute as a hint for
  how to handle incoming binary data: if the attribute is set to "<code id=the-websocket-interface:dom-binarytype-blob-5><a href=#dom-binarytype-blob>blob</a></code>", it is safe to spool it to disk, and if it is set to
  "<code id=the-websocket-interface:dom-binarytype-arraybuffer-3><a href=#dom-binarytype-arraybuffer>arraybuffer</a></code>", it is likely more efficient to
  keep the data in memory. Naturally, user agents are encouraged to use more subtle heuristics to
  decide whether to keep incoming data in memory or not, e.g. based on how big the data is or how
  common it is for a script to change the attribute at the last minute. This latter aspect is
  important in particular because it is quite possible for the attribute to be changed after the
  user agent has received the data but before the user agent has fired the event for it.</p>

  <p>The <dfn id=dom-websocket-send><code>send(<var>data</var>)</code></dfn> method transmits
  data using the connection. If the <code id=the-websocket-interface:dom-websocket-readystate-7><a href=#dom-websocket-readystate>readyState</a></code>
  attribute is <code id=the-websocket-interface:dom-websocket-connecting-3><a href=#dom-websocket-connecting>CONNECTING</a></code>, it must throw an
  <a id=the-websocket-interface:invalidstateerror href=https://heycam.github.io/webidl/#invalidstateerror data-x-internal=invalidstateerror>"<code>InvalidStateError</code>"</a> <code id=the-websocket-interface:domexception-8><a data-x-internal=domexception href=https://heycam.github.io/webidl/#dfn-DOMException>DOMException</a></code>. Otherwise, the user agent
  must run the appropriate set of steps from the following list:</p>

  <dl><dt>If the argument is a string<dd>

    <p>If <i id=the-websocket-interface:concept-websocket-established-5><a href=#concept-websocket-established>the WebSocket connection is
    established</a></i> and <i id=the-websocket-interface:concept-websocket-closing-handshake-3><a href=#concept-websocket-closing-handshake>the WebSocket closing
    handshake has not yet started</a></i>, then the user agent must <i id=the-websocket-interface:concept-websocket-send><a href=#concept-websocket-send>send a WebSocket Message</a></i> comprised of the <var>data</var> argument using
    a text frame opcode; if the data cannot be sent, e.g. because it would need to be buffered but
    the buffer is full, the user agent must <a href=#concept-websocket-close-fail id=the-websocket-interface:concept-websocket-close-fail>flag the
    WebSocket as full</a> and then <i id=the-websocket-interface:concept-websocket-close-5><a href=#concept-websocket-close>close the WebSocket
    connection</a></i>. Any invocation of this method with a string argument that does not throw an
    exception must increase the <code id=the-websocket-interface:dom-websocket-bufferedamount-4><a href=#dom-websocket-bufferedamount>bufferedAmount</a></code>
    attribute by the number of bytes needed to express the argument as UTF-8. <a href=#refsUNICODE>[UNICODE]</a>
    <a href=#refsENCODING>[ENCODING]</a> <a href=#refsWSP>[WSP]</a></p>

   <dt>If the argument is a <code id=the-websocket-interface:blob-4><a data-x-internal=blob href=https://w3c.github.io/FileAPI/#dfn-Blob>Blob</a></code> object<dd>

    <p>If <i id=the-websocket-interface:concept-websocket-established-6><a href=#concept-websocket-established>the WebSocket connection is established</a></i>, and
    <i id=the-websocket-interface:concept-websocket-closing-handshake-4><a href=#concept-websocket-closing-handshake>the WebSocket closing handshake has not yet
    started</a></i>, then the user agent must <i id=the-websocket-interface:concept-websocket-send-2><a href=#concept-websocket-send>send a WebSocket
    Message</a></i> comprised of <var>data</var> using a binary frame opcode; if the data cannot be
    sent, e.g. because it would need to be buffered but the buffer is full, the user agent must
    <a href=#concept-websocket-close-fail id=the-websocket-interface:concept-websocket-close-fail-2>flag the WebSocket as full</a> and then <i id=the-websocket-interface:concept-websocket-close-6><a href=#concept-websocket-close>close the WebSocket connection</a></i>. The data to be sent is the
    raw data represented by the <code id=the-websocket-interface:blob-5><a data-x-internal=blob href=https://w3c.github.io/FileAPI/#dfn-Blob>Blob</a></code> object.  Any invocation of this method with a
    <code id=the-websocket-interface:blob-6><a data-x-internal=blob href=https://w3c.github.io/FileAPI/#dfn-Blob>Blob</a></code> argument that does not throw an exception must increase the <code id=the-websocket-interface:dom-websocket-bufferedamount-5><a href=#dom-websocket-bufferedamount>bufferedAmount</a></code> attribute by the size of the
    <code id=the-websocket-interface:blob-7><a data-x-internal=blob href=https://w3c.github.io/FileAPI/#dfn-Blob>Blob</a></code> object's raw data, in bytes.  <a href=#refsWSP>[WSP]</a> <a href=#refsFILEAPI>[FILEAPI]</a></p>

   <dt>If the argument is an <code id=the-websocket-interface:idl-arraybuffer-4><a data-x-internal=idl-arraybuffer href=https://heycam.github.io/webidl/#idl-ArrayBuffer>ArrayBuffer</a></code> object<dd>

    <p>If <i id=the-websocket-interface:concept-websocket-established-7><a href=#concept-websocket-established>the WebSocket connection is established</a></i>, and
    <i id=the-websocket-interface:concept-websocket-closing-handshake-5><a href=#concept-websocket-closing-handshake>the WebSocket closing handshake has not yet
    started</a></i>, then the user agent must <i id=the-websocket-interface:concept-websocket-send-3><a href=#concept-websocket-send>send a WebSocket
    Message</a></i> comprised of <var>data</var> using a binary frame opcode; if the data cannot be
    sent, e.g. because it would need to be buffered but the buffer is full, the user agent must
    <a href=#concept-websocket-close-fail id=the-websocket-interface:concept-websocket-close-fail-3>flag the WebSocket as full</a> and then <i id=the-websocket-interface:concept-websocket-close-7><a href=#concept-websocket-close>close the WebSocket connection</a></i>. The data to be sent is the
    data stored in the buffer described by the <code id=the-websocket-interface:idl-arraybuffer-5><a data-x-internal=idl-arraybuffer href=https://heycam.github.io/webidl/#idl-ArrayBuffer>ArrayBuffer</a></code>
    object. Any invocation of this method with an <code id=the-websocket-interface:idl-arraybuffer-6><a data-x-internal=idl-arraybuffer href=https://heycam.github.io/webidl/#idl-ArrayBuffer>ArrayBuffer</a></code>
    argument that does not throw an exception must increase the <code id=the-websocket-interface:dom-websocket-bufferedamount-6><a href=#dom-websocket-bufferedamount>bufferedAmount</a></code> attribute by the length of the
    <code id=the-websocket-interface:idl-arraybuffer-7><a data-x-internal=idl-arraybuffer href=https://heycam.github.io/webidl/#idl-ArrayBuffer>ArrayBuffer</a></code> in bytes. <a href=#refsWSP>[WSP]</a></p>

   <dt>If the argument is an object that matches the <code id=the-websocket-interface:idl-arraybufferview-3><a data-x-internal=idl-arraybufferview href=https://heycam.github.io/webidl/#common-ArrayBufferView>ArrayBufferView</a></code> type definition<dd>

    <p>If <i id=the-websocket-interface:concept-websocket-established-8><a href=#concept-websocket-established>the WebSocket connection is established</a></i>, and
    <i id=the-websocket-interface:concept-websocket-closing-handshake-6><a href=#concept-websocket-closing-handshake>the WebSocket closing handshake has not yet
    started</a></i>, then the user agent must <i id=the-websocket-interface:concept-websocket-send-4><a href=#concept-websocket-send>send a WebSocket
    Message</a></i> comprised of <var>data</var> using a binary frame opcode; if the data cannot be
    sent, e.g. because it would need to be buffered but the buffer is full, the user agent must
    <a href=#concept-websocket-close-fail id=the-websocket-interface:concept-websocket-close-fail-4>flag the WebSocket as full</a> and then <i id=the-websocket-interface:concept-websocket-close-8><a href=#concept-websocket-close>close the WebSocket connection</a></i>. The data to be sent is the
    data stored in the section of the buffer described by the <code id=the-websocket-interface:idl-arraybuffer-8><a data-x-internal=idl-arraybuffer href=https://heycam.github.io/webidl/#idl-ArrayBuffer>ArrayBuffer</a></code> object that <var>data</var> references. Any
    invocation of this method with this kind of argument that does not throw an exception must
    increase the <code id=the-websocket-interface:dom-websocket-bufferedamount-7><a href=#dom-websocket-bufferedamount>bufferedAmount</a></code> attribute by the
    length of <var>data</var>'s buffer in bytes. <a href=#refsWSP>[WSP]</a></p>

   </dl>

  

  <hr>

  <p>The following are the <a href=#event-handlers id=the-websocket-interface:event-handlers>event handlers</a> (and their corresponding <a href=#event-handler-event-type id=the-websocket-interface:event-handler-event-type>event handler event types</a>) that must be supported,
  as <a href=#event-handler-idl-attributes id=the-websocket-interface:event-handler-idl-attributes>event handler IDL attributes</a>, by all objects implementing the
  <code id=the-websocket-interface:websocket-9><a href=#websocket>WebSocket</a></code> interface:</p>

  <table><thead><tr><th><a href=#event-handlers id=the-websocket-interface:event-handlers-2>Event handler</a> <th><a href=#event-handler-event-type id=the-websocket-interface:event-handler-event-type-2>Event handler event type</a>
   <tbody><tr><td><dfn id=handler-websocket-onopen><code>onopen</code></dfn> <td> <code id=the-websocket-interface:event-open><a href=#event-open>open</a></code>
    <tr><td><dfn id=handler-websocket-onmessage><code>onmessage</code></dfn> <td> <code id=the-websocket-interface:event-message><a href=#event-message>message</a></code>
    <tr><td><dfn id=handler-websocket-onerror><code>onerror</code></dfn> <td> <code id=the-websocket-interface:event-error><a href=#event-error>error</a></code>
    <tr><td><dfn id=handler-websocket-onclose><code>onclose</code></dfn> <td> <code id=the-websocket-interface:event-close-6><a href=#event-close>close</a></code>
  </table>


  

  <h4 id=feedback-from-the-protocol><span class=secno>9.3.3</span> Feedback from the protocol<a href=#feedback-from-the-protocol class=self-link></a></h4>

  <p>When <i id=feedback-from-the-protocol:concept-websocket-established><a href=#concept-websocket-established>the WebSocket connection is established</a></i>, the
  user agent must <a href=#queue-a-task id=feedback-from-the-protocol:queue-a-task>queue a task</a> to run these steps:</p>

  <ol><li><p>Change the <code id=feedback-from-the-protocol:dom-websocket-readystate><a href=#dom-websocket-readystate>readyState</a></code> attribute's value to
   <code id=feedback-from-the-protocol:dom-websocket-open><a href=#dom-websocket-open>OPEN</a></code> (1).<li><p>Change the <code id=feedback-from-the-protocol:dom-websocket-extensions><a href=#dom-websocket-extensions>extensions</a></code> attribute's value to
   the <i id=feedback-from-the-protocol:concept-websockets-active-extensions><a href=#concept-websockets-active-extensions>extensions in use</a></i>, if it is not the null
   value. <a href=#refsWSP>[WSP]</a><li><p>Change the <code id=feedback-from-the-protocol:dom-websocket-protocol><a href=#dom-websocket-protocol>protocol</a></code> attribute's value to the
   <i id=feedback-from-the-protocol:concept-websocket-subprotocol><a href=#concept-websocket-subprotocol>subprotocol in use</a></i>, if it is not the null value.
   <a href=#refsWSP>[WSP]</a><li><p><a href=https://dom.spec.whatwg.org/#concept-event-fire id=feedback-from-the-protocol:concept-event-fire data-x-internal=concept-event-fire>Fire an event</a> named <code id=feedback-from-the-protocol:event-open><a href=#event-open>open</a></code> at the <code id=feedback-from-the-protocol:websocket><a href=#websocket>WebSocket</a></code> object.</p>

  </ol>

  <p class=note>Since the algorithm above is <a href=#queue-a-task id=feedback-from-the-protocol:queue-a-task-2>queued as a task</a>,
  there is no race condition between <i id=feedback-from-the-protocol:concept-websocket-established-2><a href=#concept-websocket-established>the WebSocket
  connection being established</a></i> and the script setting up an event listener for the <code id=feedback-from-the-protocol:event-open-2><a href=#event-open>open</a></code> event.</p>

  <hr>

  <p>When <i id=feedback-from-the-protocol:concept-websocket-message-received><a href=#concept-websocket-message-received>a WebSocket message has been received</a></i>
  with type <var>type</var> and data <var>data</var>, the user agent must <a href=#queue-a-task id=feedback-from-the-protocol:queue-a-task-3>queue a task</a>
  to follow these steps: <a href=#refsWSP>[WSP]</a></p>

  <ol><li>

    <p>If the <code id=feedback-from-the-protocol:dom-websocket-readystate-2><a href=#dom-websocket-readystate>readyState</a></code> attribute's value is not
    <code id=feedback-from-the-protocol:dom-websocket-open-2><a href=#dom-websocket-open>OPEN</a></code> (1), then return.</p>

   <li>
    <p>Let <var>dataForEvent</var> be determined by switching on <var>type</var> and <code id=feedback-from-the-protocol:dom-websocket-binarytype><a href=#dom-websocket-binarytype>binaryType</a></code>:</p>

    <dl class=switch><dt><var>type</var> indicates that the data is Text<dd>a new <code id=feedback-from-the-protocol:idl-domstring><a data-x-internal=idl-domstring href=https://heycam.github.io/webidl/#idl-DOMString>DOMString</a></code> containing <var>data</var><dt><var>type</var> indicates that the data is Binary and <code id=feedback-from-the-protocol:dom-websocket-binarytype-2><a href=#dom-websocket-binarytype>binaryType</a></code> is "<dfn id=dom-binarytype-blob><code>blob</code></dfn>"<dd>a new <code id=feedback-from-the-protocol:blob><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=feedback-from-the-protocol:concept-relevant-realm>relevant Realm</a> of the <code id=feedback-from-the-protocol:websocket-2><a href=#websocket>WebSocket</a></code> object,
     that represents <var>data</var> as its raw data <a href=#refsFILEAPI>[FILEAPI]</a><dt><var>type</var> indicates that the data is Binary and <code id=feedback-from-the-protocol:dom-websocket-binarytype-3><a href=#dom-websocket-binarytype>binaryType</a></code> is "<dfn id=dom-binarytype-arraybuffer><code>arraybuffer</code></dfn>"<dd>a new <code id=feedback-from-the-protocol:idl-arraybuffer><a data-x-internal=idl-arraybuffer href=https://heycam.github.io/webidl/#idl-ArrayBuffer>ArrayBuffer</a></code> object, created in the <a href=#concept-relevant-realm id=feedback-from-the-protocol:concept-relevant-realm-2>relevant Realm</a> of the <code id=feedback-from-the-protocol:websocket-3><a href=#websocket>WebSocket</a></code> object,
     whose contents are <var>data</var></dl>
   <li><p><a href=https://dom.spec.whatwg.org/#concept-event-fire id=feedback-from-the-protocol:concept-event-fire-2 data-x-internal=concept-event-fire>Fire an event</a> named <code id=feedback-from-the-protocol:event-message><a href=#event-message>message</a></code> at the <code id=feedback-from-the-protocol:websocket-4><a href=#websocket>WebSocket</a></code> object, using
   <code id=feedback-from-the-protocol:messageevent><a href=#messageevent>MessageEvent</a></code>, with the <code id=feedback-from-the-protocol:dom-messageevent-origin><a href=#dom-messageevent-origin>origin</a></code>
   attribute initialized to the <a href=#ascii-serialisation-of-an-origin id=feedback-from-the-protocol:ascii-serialisation-of-an-origin>serialization</a> of
   the <code id=feedback-from-the-protocol:websocket-5><a href=#websocket>WebSocket</a></code> object's <a href=#concept-websocket-url id=feedback-from-the-protocol:concept-websocket-url>url</a>'s <a href=https://url.spec.whatwg.org/#concept-url-origin id=feedback-from-the-protocol:concept-url-origin data-x-internal=concept-url-origin>origin</a>, and the <code id=feedback-from-the-protocol:dom-messageevent-data><a href=#dom-messageevent-data>data</a></code> attribute initialized to
   <var>dataForEvent</var>.</ol>

  <p class=note>User agents are encouraged to check if they can perform the above steps
  efficiently before they run the task, picking tasks from other <a href=#task-queue id=feedback-from-the-protocol:task-queue>task
  queues</a> while they prepare the buffers if not. For example, if the <code id=feedback-from-the-protocol:dom-websocket-binarytype-4><a href=#dom-websocket-binarytype>binaryType</a></code> attribute was set to "<code id=feedback-from-the-protocol:dom-binarytype-blob><a href=#dom-binarytype-blob>blob</a></code>" when the data arrived, and the user agent spooled all
  the data to disk, but just before running the above <a href=#concept-task id=feedback-from-the-protocol:concept-task>task</a> for
  this particular message the script switched <code id=feedback-from-the-protocol:dom-websocket-binarytype-5><a href=#dom-websocket-binarytype>binaryType</a></code> to "<code id=feedback-from-the-protocol:dom-binarytype-arraybuffer><a href=#dom-binarytype-arraybuffer>arraybuffer</a></code>", the user agent would want to page the
  data back to RAM before running this <a href=#concept-task id=feedback-from-the-protocol:concept-task-2>task</a> so as to avoid
  stalling the main thread while it created the <code id=feedback-from-the-protocol:idl-arraybuffer-2><a data-x-internal=idl-arraybuffer href=https://heycam.github.io/webidl/#idl-ArrayBuffer>ArrayBuffer</a></code>
  object.</p>

  

  <div class=example>

   <p>Here is an example of how to define a handler for the <code id=feedback-from-the-protocol:event-message-2><a href=#event-message>message</a></code> event in the case of text frames:</p>

   <pre><code class='js'>mysocket<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>&apos;on&apos;</c-><c- p>)</c-> <c- p>{</c->
    turnLampOn<c- p>();</c->
  <c- p>}</c-> <c- k>else</c-> <c- k>if</c-> <c- p>(</c->event<c- p>.</c->data <c- o>==</c-> <c- t>&apos;off&apos;</c-><c- p>)</c-> <c- p>{</c->
    turnLampOff<c- p>();</c->
  <c- p>}</c->
<c- p>};</c-></code></pre>

   <p>The protocol here is a trivial one, with the server just sending "on" or "off" messages.</p>

  </div>

  <hr>

  

  <p>When <i id=feedback-from-the-protocol:concept-websocket-closing-handshake><a href=#concept-websocket-closing-handshake>the WebSocket closing handshake is
  started</a></i>, the user agent must <a href=#queue-a-task id=feedback-from-the-protocol:queue-a-task-4>queue a task</a> to change the <code id=feedback-from-the-protocol:dom-websocket-readystate-3><a href=#dom-websocket-readystate>readyState</a></code> attribute's value to <code id=feedback-from-the-protocol:dom-websocket-closing><a href=#dom-websocket-closing>CLOSING</a></code> (2). (If the <code id=feedback-from-the-protocol:dom-websocket-close><a href=#dom-websocket-close>close()</a></code> method was called, the <code id=feedback-from-the-protocol:dom-websocket-readystate-4><a href=#dom-websocket-readystate>readyState</a></code> attribute's value will already be set to <code id=feedback-from-the-protocol:dom-websocket-closing-2><a href=#dom-websocket-closing>CLOSING</a></code> (2) when this task runs.) <a href=#refsWSP>[WSP]</a></p>

  <hr>

  <p id=closeWebSocket>When <i id=feedback-from-the-protocol:concept-websocket-closed><a href=#concept-websocket-closed>the WebSocket connection is
  closed</a></i>, possibly <i>cleanly</i>, the user agent must <a href=#queue-a-task id=feedback-from-the-protocol:queue-a-task-5>queue a task</a> to run the
  following substeps:</p>

  <ol><li><p>Change the <code id=feedback-from-the-protocol:dom-websocket-readystate-5><a href=#dom-websocket-readystate>readyState</a></code> attribute's value to
   <code id=feedback-from-the-protocol:dom-websocket-closed><a href=#dom-websocket-closed>CLOSED</a></code> (3).<li><p>If the user agent was required to <i id=feedback-from-the-protocol:concept-websocket-fail><a href=#concept-websocket-fail>fail the WebSocket
   connection</a></i>, or if the <i id=feedback-from-the-protocol:concept-websocket-closed-2><a href=#concept-websocket-closed>the WebSocket connection was
   closed</a></i> after being <dfn id=concept-websocket-close-fail>flagged as full</dfn>, <a href=https://dom.spec.whatwg.org/#concept-event-fire id=feedback-from-the-protocol:concept-event-fire-3 data-x-internal=concept-event-fire>fire an event</a> named <code>error</code> at the
   <code id=feedback-from-the-protocol:websocket-6><a href=#websocket>WebSocket</a></code> object. <a href=#refsWSP>[WSP]</a><li><p><a href=https://dom.spec.whatwg.org/#concept-event-fire id=feedback-from-the-protocol:concept-event-fire-4 data-x-internal=concept-event-fire>Fire an event</a> named <code id=feedback-from-the-protocol:event-close><a href=#event-close>close</a></code> at the <code id=feedback-from-the-protocol:websocket-7><a href=#websocket>WebSocket</a></code> object, using
   <code id=feedback-from-the-protocol:closeevent><a href=#closeevent>CloseEvent</a></code>, with the <code id=feedback-from-the-protocol:dom-closeevent-wasclean><a href=#dom-closeevent-wasclean>wasClean</a></code>
   attribute initialized to true if the connection closed <i>cleanly</i> and false otherwise, the
   <code id=feedback-from-the-protocol:dom-closeevent-code><a href=#dom-closeevent-code>code</a></code> attribute initialized to <i id=feedback-from-the-protocol:concept-websocket-close-code><a href=#concept-websocket-close-code>the WebSocket connection close code</a></i>, and the <code id=feedback-from-the-protocol:dom-closeevent-reason><a href=#dom-closeevent-reason>reason</a></code> attribute initialized to the result of applying
   <a id=feedback-from-the-protocol: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> to <i id=feedback-from-the-protocol:concept-websocket-close-reason><a href=#concept-websocket-close-reason>the WebSocket
   connection close reason</a></i>. <a href=#refsWSP>[WSP]</a></ol>

  <div class=warning>

   <p>User agents must not convey any failure information to scripts in a way that would allow a
   script to distinguish the following situations:</p>

   <ul><li>A server whose host name could not be resolved.

    <li>A server to which packets could not successfully be routed.

    <li>A server that refused the connection on the specified port.

    <li>A server that failed to correctly perform a TLS handshake (e.g., the server certificate
    can't be verified).

    <li>A server that did not complete the opening handshake (e.g. because it was not a WebSocket
    server).

    <li>A WebSocket server that sent a correct opening handshake, but that specified options that
    caused the client to drop the connection (e.g. the server specified a subprotocol that the
    client did not offer).

    <li>A WebSocket server that abruptly closed the connection after successfully completing the
    opening handshake.

   </ul>

   <p>In all of these cases, the <i id=feedback-from-the-protocol:concept-websocket-close-code-2><a href=#concept-websocket-close-code>the WebSocket connection close code</a></i> would be 1006, as
   required by the WebSocket Protocol specification. <a href=#refsWSP>[WSP]</a></p>

   <p>Allowing a script to distinguish these cases would allow a script to probe the user's local
   network in preparation for an attack.</p>

   <p class=note>In particular, this means the code 1015 is not used by the user agent (unless the
   server erroneously uses it in its close frame, of course).</p>

  </div>

  <hr>

  <p>The <a href=#task-source id=feedback-from-the-protocol:task-source>task source</a> for all <a href=#concept-task id=feedback-from-the-protocol:concept-task-3>tasks</a> <a href=#queue-a-task id=feedback-from-the-protocol:queue-a-task-6>queued</a> in this section is the <dfn id=websocket-task-source>WebSocket task source</dfn>.</p>

  


  <h4 id=ping-and-pong-frames><span class=secno>9.3.4</span> Ping and Pong frames<a href=#ping-and-pong-frames class=self-link></a></h4>

  <p>The WebSocket protocol specification defines Ping and Pong frames that can be used for
  keep-alive, heart-beats, network status probing, latency instrumentation, and so forth. These are
  not currently exposed in the API.</p>

  <p>User agents may send ping and unsolicited pong frames as desired, for example in an
  attempt to maintain local network NAT mappings, to detect failed connections, or to display
  latency metrics to the user. User agents must not use pings or unsolicited pongs to aid the
  server; it is assumed that servers will solicit pongs whenever appropriate for the server's
  needs.</p>

  


  <h4 id=the-closeevent-interface><span class=secno>9.3.5</span> The <code id=the-closeevent-interface:closeevent><a href=#closeevent>CloseEvent</a></code> interface<a href=#the-closeevent-interface class=self-link></a></h4>

  <p><code id=the-closeevent-interface:websocket><a href=#websocket>WebSocket</a></code> objects use the <code id=the-closeevent-interface:closeevent-2><a href=#closeevent>CloseEvent</a></code> interface for their <code id=the-closeevent-interface:event-close><a href=#event-close>close</a></code> events:</p>

  <pre><code class='idl'>[<c- g>Constructor</c->(<c- b>DOMString</c-> <c- g>type</c->, <c- b>optional</c-> <a href='#closeeventinit' id='the-closeevent-interface:closeeventinit'><c- n>CloseEventInit</c-></a> <c- g>eventInitDict</c->), <c- g>Exposed</c->=(<c- n>Window</c->,<c- n>Worker</c->)]
<c- b>interface</c-> <dfn id='closeevent'><c- g>CloseEvent</c-></dfn> : <a href='https://dom.spec.whatwg.org/#interface-event' data-x-internal='event' id='the-closeevent-interface:event'><c- n>Event</c-></a> {
  <c- b>readonly</c-> <c- b>attribute</c-> <c- b>boolean</c-> <a href='#dom-closeevent-wasclean' id='the-closeevent-interface:dom-closeevent-wasclean'><c- g>wasClean</c-></a>;
  <c- b>readonly</c-> <c- b>attribute</c-> <c- b>unsigned</c-> <c- b>short</c-> <a href='#dom-closeevent-code' id='the-closeevent-interface:dom-closeevent-code'><c- g>code</c-></a>;
  <c- b>readonly</c-> <c- b>attribute</c-> <c- b>USVString</c-> <a href='#dom-closeevent-reason' id='the-closeevent-interface:dom-closeevent-reason'><c- g>reason</c-></a>;
};

<c- b>dictionary</c-> <dfn id='closeeventinit'><c- g>CloseEventInit</c-></dfn> : <a href='https://dom.spec.whatwg.org/#dictdef-eventinit' data-x-internal='eventinit' id='the-closeevent-interface:eventinit'><c- n>EventInit</c-></a> {
  <c- b>boolean</c-> <c- g>wasClean</c-> = <c- b>false</c->;
  <c- b>unsigned</c-> <c- b>short</c-> <c- g>code</c-> = 0;
  <c- b>USVString</c-> <c- g>reason</c-> = &quot;&quot;;
};</code></pre>

  <dl class=domintro><dt><var>event</var> . <code id=dom-closeevent-wasclean-dev><a href=#dom-closeevent-wasclean>wasClean</a></code><dd>
    <p>Returns true if the connection closed cleanly; false otherwise.</p>
   <dt><var>event</var> . <code id=dom-closeevent-code-dev><a href=#dom-closeevent-code>code</a></code><dd>
    <p>Returns the WebSocket connection close code provided by the server.</p>
   <dt><var>event</var> . <code id=dom-closeevent-reason-dev><a href=#dom-closeevent-reason>reason</a></code><dd>
    <p>Returns the WebSocket connection close reason provided by the server.</p>
   </dl>

  

  <p>The <dfn id=dom-closeevent-wasclean><code>wasClean</code></dfn> attribute must return the
  value it was initialized to. It represents whether the connection closed cleanly or not.</p>

  <p>The <dfn id=dom-closeevent-code><code>code</code></dfn> attribute must return the value
  it was initialized to. It represents the WebSocket connection close code provided by the
  server.</p>

  <p>The <dfn id=dom-closeevent-reason><code>reason</code></dfn> attribute must return the
  value it was initialized to. It represents the WebSocket connection close reason provided by the
  server.</p>



  <h4 id=garbage-collection-3><span class=secno>9.3.6</span> Garbage collection<a href=#garbage-collection-3 class=self-link></a></h4>

  <p>A <code id=garbage-collection-3:websocket><a href=#websocket>WebSocket</a></code> object whose <code id=garbage-collection-3:dom-websocket-readystate><a href=#dom-websocket-readystate>readyState</a></code>
  attribute's value was set to <code id=garbage-collection-3:dom-websocket-connecting><a href=#dom-websocket-connecting>CONNECTING</a></code> (0) as of
  the last time the <a href=#event-loop id=garbage-collection-3:event-loop>event loop</a> reached <a href=#step1>step 1</a> must not be garbage collected if there
  are any event listeners registered for <code id=garbage-collection-3:event-open><a href=#event-open>open</a></code> events, <code id=garbage-collection-3:event-message><a href=#event-message>message</a></code> events, <code id=garbage-collection-3:event-error><a href=#event-error>error</a></code> events, or
  <code id=garbage-collection-3:event-close><a href=#event-close>close</a></code> events.</p>

  <p>A <code id=garbage-collection-3:websocket-2><a href=#websocket>WebSocket</a></code> object whose <code id=garbage-collection-3:dom-websocket-readystate-2><a href=#dom-websocket-readystate>readyState</a></code>
  attribute's value was set to <code id=garbage-collection-3:dom-websocket-open><a href=#dom-websocket-open>OPEN</a></code> (1) as of the last time
  the <a href=#event-loop id=garbage-collection-3:event-loop-2>event loop</a> reached <a href=#step1>step 1</a> must not be garbage collected if there are any event
  listeners registered for <code id=garbage-collection-3:event-message-2><a href=#event-message>message</a></code> events, <code id=garbage-collection-3:event-error-2><a href=#event-error>error</a></code>, or <code id=garbage-collection-3:event-close-2><a href=#event-close>close</a></code> events.</p>

  <p>A <code id=garbage-collection-3:websocket-3><a href=#websocket>WebSocket</a></code> object whose <code id=garbage-collection-3:dom-websocket-readystate-3><a href=#dom-websocket-readystate>readyState</a></code>
  attribute's value was set to <code id=garbage-collection-3:dom-websocket-closing><a href=#dom-websocket-closing>CLOSING</a></code> (2) as of the
  last time the <a href=#event-loop id=garbage-collection-3:event-loop-3>event loop</a> reached <a href=#step1>step 1</a> must not be garbage collected if there are
  any event listeners registered for <code id=garbage-collection-3:event-error-3><a href=#event-error>error</a></code> or <code id=garbage-collection-3:event-close-3><a href=#event-close>close</a></code> events.</p>

  <p>A <code id=garbage-collection-3:websocket-4><a href=#websocket>WebSocket</a></code> object with <i id=garbage-collection-3:concept-websocket-established><a href=#concept-websocket-established>an
  established connection</a></i> that has data queued to be transmitted to the network must not be
  garbage collected. <a href=#refsWSP>[WSP]</a></p>

  <p>If a <code id=garbage-collection-3:websocket-5><a href=#websocket>WebSocket</a></code> object is garbage collected while its connection is still open, the
  user agent must <i id=garbage-collection-3:concept-websocket-start-closing-handshake><a href=#concept-websocket-start-closing-handshake>start the WebSocket closing
  handshake</a></i>, with no status code for the Close message. <a href=#refsWSP>[WSP]</a></p>

  <hr>

  <p>If a user agent is to <dfn id=make-disappear>make disappear</dfn> a <code id=garbage-collection-3:websocket-6><a href=#websocket>WebSocket</a></code> object (this happens
  when a <code id=garbage-collection-3:document><a href=#document>Document</a></code> object goes away), the user agent must follow the first appropriate
  set of steps from the following list:</p>

  <dl class=switch><dt>If the WebSocket connection is not yet <i id=garbage-collection-3:concept-websocket-established-2><a href=#concept-websocket-established>established</a></i> <a href=#refsWSP>[WSP]</a><dd>

    <p><i id=garbage-collection-3:concept-websocket-fail><a href=#concept-websocket-fail>Fail the WebSocket connection</a></i>. <a href=#refsWSP>[WSP]</a></p>

   <dt>If the WebSocket closing handshake has not yet been <i id=garbage-collection-3:concept-websocket-closing-handshake><a href=#concept-websocket-closing-handshake>started</a></i> <a href=#refsWSP>[WSP]</a><dd>

    <p><i id=garbage-collection-3:concept-websocket-start-closing-handshake-2><a href=#concept-websocket-start-closing-handshake>Start the WebSocket closing
    handshake</a></i>, with the status code to use in the WebSocket Close message being
    1001. <a href=#refsWSP>[WSP]</a></p>

   <dt>Otherwise<dd>

    <p>Do nothing.</p>

   </dl>

  


  <h3 id=web-messaging><span class=secno>9.4</span> <dfn id=crossDocumentMessages>Cross-document messaging</dfn><a href=#web-messaging class=self-link></a></h3><div class=status><input onclick=toggleStatus(this) value=⋰ type=button><p class=support><strong>Support:</strong> x-doc-messaging<span class="and_chr yes"><span>Chrome for Android</span> <span>67+</span></span><span class="chrome yes"><span>Chrome</span> <span>4+</span></span><span class="ios_saf yes"><span>iOS Safari</span> <span>3.2+</span></span><span class="and_uc yes"><span>UC Browser for Android</span> <span>11.8+</span></span><span class="firefox yes"><span>Firefox</span> <span>3+</span></span><span class="ie partial"><span>IE (limited)</span> <span>8+</span></span><span class="op_mini yes"><span>Opera Mini</span> <span>all+</span></span><span class="safari yes"><span>Safari</span> <span>4+</span></span><span class="edge yes"><span>Edge</span> <span>12+</span></span><span class="samsung yes"><span>Samsung Internet</span> <span>4+</span></span><span class="opera yes"><span>Opera</span> <span>9.5+</span></span><span class="android yes"><span>Android Browser</span> <span>2.1+</span></span><p class=caniuse>Source: <a href="https://caniuse.com/#feat=x-doc-messaging">caniuse.com</a></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 class=note>This API <a href=#fingerprint-postMessage>has some privacy implications</a> that
  might not be immediately obvious.</p>

  

  <p>The <a href=#task-source id=web-messaging:task-source>task source</a> for the <a href=#concept-task id=web-messaging:concept-task>tasks</a> in
  <a href=#web-messaging id=web-messaging:web-messaging>cross-document messaging</a> is the <dfn id=posted-message-task-source>posted message task source</dfn>.</p>

  


  <h4 id=introduction-12><span class=secno>9.4.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>&apos;iframe&apos;</c-><c- p>)[</c-><c- mi>0</c-><c- p>];</c->
o<c- p>.</c->contentWindow<c- p>.</c->postMessage<c- p>(</c-><c- t>&apos;Hello world&apos;</c-><c- p>,</c-> <c- t>&apos;https://b.example.org/&apos;</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>&apos;message&apos;</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>&apos;https://example.com&apos;</c-><c- p>)</c-> <c- p>{</c->
    <c- k>if</c-> <c- p>(</c->e<c- p>.</c->data <c- o>==</c-> <c- t>&apos;Hello world&apos;</c-><c- p>)</c-> <c- p>{</c->
      e<c- p>.</c->source<c- p>.</c->postMessage<c- p>(</c-><c- t>&apos;Hello&apos;</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.4.2</span> Security<a href=#security-postmsg class=self-link></a></h4>

  

  <h5 id=authors><span class=secno>9.4.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.4.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>Implementors 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.4.3</span> Posting messages<a href=#posting-messages class=self-link></a></h4>

  <dl class=domintro><dt><var>window</var> . <code id=dom-window-postmessage-dev><a href=#dom-window-postmessage>postMessage</a></code>(<var>message</var>, <var>targetOrigin</var> [, <var>transfer</var> ] )<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.github.io/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://heycam.github.io/webidl/#idl-ArrayBuffer>ArrayBuffer</a></code> objects.</p>

    <p>Objects listed in <var>transfer</var> are transferred, not just cloned, meaning that
    they are no longer usable on the sending side.</p>

    <p>If the origin of the target window doesn't match the given 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>". To restrict the message to same-origin targets only,
    without needing to explicitly state the origin, set the target origin to "<code>/</code>".</p>

    <p>Throws a <a id=posting-messages:datacloneerror href=https://heycam.github.io/webidl/#datacloneerror data-x-internal=datacloneerror>"<code>DataCloneError</code>"</a> <code id=posting-messages:domexception><a data-x-internal=domexception href=https://heycam.github.io/webidl/#dfn-DOMException>DOMException</a></code> if
    <var>transfer</var> array contains duplicate objects or if <var>message</var> could not be
    cloned.</p>

   </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>

  

  <p>The <dfn id=dom-window-postmessage><code>postMessage(<var>message</var>,
  <var>targetOrigin</var>, <var>transfer</var>)</code></dfn> method, when invoked on a
  <code id=posting-messages:window-3><a href=#window>Window</a></code> object must run the following steps:</p>

  <ol><li><p>Let <var>targetWindow</var> be this <code id=posting-messages:window-4><a href=#window>Window</a></code> object.</p>

   <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>.<li><p>Let <var>incumbentSettings</var> be the <a href=#incumbent-settings-object id=posting-messages:incumbent-settings-object>incumbent settings object</a>.<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>
    <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>.<li><p>If <var>parsedURL</var> is failure, then throw a <a id=posting-messages:syntaxerror href=https://heycam.github.io/webidl/#syntaxerror data-x-internal=syntaxerror>"<code>SyntaxError</code>"</a>
     <code id=posting-messages:domexception-2><a data-x-internal=domexception href=https://heycam.github.io/webidl/#dfn-DOMException>DOMException</a></code>.<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>.</ol>
   <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.<li>
    <p><a href=#queue-a-task id=posting-messages:queue-a-task>Queue a task</a> on the <a href=#posted-message-task-source id=posting-messages:posted-message-task-source>posted message task source</a> 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=#concept-origin id=posting-messages:concept-origin>origin</a> is not <a href=#same-origin id=posting-messages:same-origin>same origin</a> with
     <var>targetOrigin</var>, then return.<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>.<li><p>Let <var>source</var> be the <code id=posting-messages:windowproxy><a href=#windowproxy>WindowProxy</a></code> object's 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-5><a href=#window>Window</a></code> object).<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><p>Let <var>messageClone</var> be <var>deserializeRecord</var>.[[Deserialized]].<li><p>Let <var>newPorts</var> be a new <a id=posting-messages:frozen-array href=https://heycam.github.io/webidl/#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.<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>.</ol>
   </ol>

  




  <h3 id=channel-messaging><span class=secno>9.5</span> <dfn>Channel messaging</dfn><a href=#channel-messaging class=self-link></a></h3><div class=status><input onclick=toggleStatus(this) value=⋰ type=button><p class=support><strong>Support:</strong> channel-messaging<span class="and_chr yes"><span>Chrome for Android</span> <span>67+</span></span><span class="chrome yes"><span>Chrome</span> <span>4+</span></span><span class="ios_saf yes"><span>iOS Safari</span> <span>5.0+</span></span><span class="and_uc yes"><span>UC Browser for Android</span> <span>11.8+</span></span><span class="firefox yes"><span>Firefox</span> <span>41+</span></span><span class="ie yes"><span>IE</span> <span>10+</span></span><span class="op_mini no"><span>Opera Mini</span> <span>None</span></span><span class="safari yes"><span>Safari</span> <span>5+</span></span><span class="edge yes"><span>Edge</span> <span>12+</span></span><span class="samsung yes"><span>Samsung Internet</span> <span>4+</span></span><span class="opera yes"><span>Opera</span> <span>10.6+</span></span><span class="android yes"><span>Android Browser</span> <span>4.4+</span></span><p class=caniuse>Source: <a href="https://caniuse.com/#feat=channel-messaging">caniuse.com</a></div>

  <h4 id=introduction-13><span class=secno>9.5.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>&apos;hello&apos;</c-><c- p>,</c-> <c- t>&apos;https://example.com&apos;</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>&apos;hello&apos;</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>&apos;hello&apos;</c-><c- p>,</c-> <c- t>&apos;world&apos;</c-><c- p>]);</c-></code></pre>


  <h5 id=examples-5><span class=secno>9.5.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>&quot;contacts.js&quot;</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>&quot;compose-mail.js&quot;</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- t>&apos;search-result&apos;</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- t>&apos;search-done&apos;</c-><c- o>:</c-> handleSearchDone<c- p>();</c-> <c- k>break</c-><c- p>;</c->
      <c- t>&apos;search-error&apos;</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>&apos;message&apos;</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>&apos;search-result&apos;</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>&apos;message&apos;</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>&apos;search-done&apos;</c-><c- p>)</c->
      handleSearchDone<c- p>();</c->
  <c- p>});</c->
  port<c- p>.</c->addEventListener<c- p>(</c-><c- t>&apos;message&apos;</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>&apos;search-error&apos;</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-messageport-onmessage><a href=#handler-messageport-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-messageport-onmessage-2><a href=#handler-messageport-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.5.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>

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

  <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 e-mail 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 class=brief><li><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.<li>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.<li>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.</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></code>" by adding the given person and e-mail 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.5.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><a href=#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><a href=#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.5.2</span> Message channels<a href=#message-channels class=self-link></a></h4>

  <pre><code class='idl'>[<a href='#dom-messagechannel' id='message-channels:dom-messagechannel'><c- g>Constructor</c-></a>, <c- g>Exposed</c->=(<c- n>Window</c->,<c- n>Worker</c->)]
<c- b>interface</c-> <dfn id='messagechannel'><c- g>MessageChannel</c-></dfn> {
  <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><var>channel</var> = new <code id=dom-messagechannel-dev><a href=#dom-messagechannel>MessageChannel</a></code>()<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>

   <dt><var>channel</var> . <code id=dom-messagechannel-port1-dev><a href=#dom-messagechannel-port1>port1</a></code><dd>

    <p>Returns the first <code id=message-channels:messageport-4><a href=#messageport>MessagePort</a></code> object.</p>

   <dt><var>channel</var> . <code id=dom-messagechannel-port2-dev><a href=#dom-messagechannel-port2>port2</a></code><dd>

    <p>Returns the second <code id=message-channels:messageport-5><a href=#messageport>MessagePort</a></code> object.</p>

   </dl>

  

  <p>When the <dfn id=dom-messagechannel><code>MessageChannel()</code></dfn> constructor is
  called, it must run the following algorithm:</p>

  <ol><li><p><a href=#create-a-new-messageport-object id=message-channels:create-a-new-messageport-object>Create a new <code>MessagePort</code> object</a> whose <a href=#concept-port-owner id=message-channels:concept-port-owner>owner</a> is the <a href=#incumbent-settings-object id=message-channels:incumbent-settings-object>incumbent settings object</a>, and let
   <var>port1</var> be that object.<li><p><a href=#create-a-new-messageport-object id=message-channels:create-a-new-messageport-object-2>Create a new <code>MessagePort</code> object</a> whose <a href=#concept-port-owner id=message-channels:concept-port-owner-2>owner</a> is the <a href=#incumbent-settings-object id=message-channels:incumbent-settings-object-2>incumbent settings object</a>, and let
   <var>port2</var> be that object.<li><p><a href=#entangle id=message-channels:entangle>Entangle</a> the <var>port1</var> and <var>port2</var> objects.<li><p>Instantiate a new <code id=message-channels:messagechannel-2><a href=#messagechannel>MessageChannel</a></code> object, and let <var>channel</var> be that
   object.<li><p>Let the <code id=message-channels:dom-messagechannel-port1-2><a href=#dom-messagechannel-port1>port1</a></code> attribute of the
   <var>channel</var> object be <var>port1</var>.</p>

   <li><p>Let the <code id=message-channels:dom-messagechannel-port2-2><a href=#dom-messagechannel-port2>port2</a></code> attribute of the
   <var>channel</var> object be <var>port2</var>.</p>

   <li><p>Return <var>channel</var>.</ol>

  <p>The <dfn id=dom-messagechannel-port1><code>port1</code></dfn> and <dfn id=dom-messagechannel-port2><code>port2</code></dfn> attributes must return the values they were
  assigned when the <code id=message-channels:messagechannel-3><a href=#messagechannel>MessageChannel</a></code> object was created.</p>

  



  <h4 id=message-ports><span class=secno>9.5.3</span> Message ports<a href=#message-ports class=self-link></a></h4>

  <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'><c- g>MessagePort</c-></dfn> : <a href='https://dom.spec.whatwg.org/#interface-eventtarget' data-x-internal='eventtarget' id='message-ports:eventtarget'><c- n>EventTarget</c-></a> {
  <c- b>void</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>optional</c-> <c- b>sequence</c->&lt;<a href='https://heycam.github.io/webidl/#idl-object' data-x-internal='idl-object' id='message-ports:idl-object'><c- b>object</c-></a>&gt; <c- g>transfer</c-> = []);
  <c- b>void</c-> <a href='#dom-messageport-start' id='message-ports:dom-messageport-start'><c- g>start</c-></a>();
  <c- b>void</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-onmessage' id='message-ports:handler-messageport-onmessage'><c- g>onmessage</c-></a>;
  <c- b>attribute</c-> <a href='#eventhandler' id='message-ports:eventhandler-2'><c- n>EventHandler</c-></a> <a href='#handler-messageport-onmessageerror' id='message-ports:handler-messageport-onmessageerror'><c- g>onmessageerror</c-></a>;
};</code></pre>

  <dl class=domintro><dt><var>port</var> . <code id=dom-messageport-postmessage-dev><a href=#dom-messageport-postmessage>postMessage</a></code>(<var>message</var> [, <var>transfer</var>] )<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://heycam.github.io/webidl/#datacloneerror data-x-internal=datacloneerror>"<code>DataCloneError</code>"</a> <code id=message-ports:domexception><a data-x-internal=domexception href=https://heycam.github.io/webidl/#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>
   <dt><var>port</var> . <code id=dom-messageport-start-dev><a href=#dom-messageport-start>start</a></code>()<dd><p>Begins dispatching messages received on the port.<dt><var>port</var> . <code id=dom-messageport-close-dev><a href=#dom-messageport-close>close</a></code>()<dd><p>Disconnects the port, so that it is no longer active.</dl>

  

  <p>Each <code id=message-ports:messageport><a href=#messageport>MessagePort</a></code> object can be entangled with another (a symmetric relationship).
  Each <code id=message-ports:messageport-2><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-3><a href=#messageport>MessagePort</a></code> also has a <dfn id=has-been-shipped>has been shipped</dfn> flag, which must
  initially be false, and an <dfn id=concept-port-owner>owner</dfn>, which is a <a href=#settings-object id=message-ports:settings-object>settings
  object</a> set when the object is created, as described below.</p>

  <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-port-owner id=message-ports:concept-port-owner>owner</a> specifies a <a href=#responsible-event-loop id=message-ports:responsible-event-loop>responsible event loop</a> that is a
  <a href=#browsing-context id=message-ports:browsing-context>browsing context</a> <a href=#event-loop id=message-ports:event-loop-2>event loop</a>, 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 <a href=#responsible-document id=message-ports:responsible-document>responsible document</a> specified by
  the port's <a href=#concept-port-owner id=message-ports:concept-port-owner-2>owner</a>.</p>

  <p class=note>If the port's <a href=#concept-port-owner id=message-ports:concept-port-owner-3>owner</a> specifies a
  <a href=#responsible-document id=message-ports:responsible-document-2>responsible document</a> that is <a href=#fully-active id=message-ports:fully-active>fully active</a>, but the event listeners all
  have scripts whose <a href=#settings-object id=message-ports:settings-object-2>settings objects</a> specify <a href=#responsible-document id=message-ports:responsible-document-3>responsible documents</a> that are <em>not</em> <a href=#fully-active id=message-ports:fully-active-2>fully
  active</a>, then the messages will be lost.</p> 

  <p>Each <a href=#event-loop id=message-ports:event-loop-3>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-4><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=#concept-port-owner id=message-ports:concept-port-owner-4>owner</a>
  specifies that <a href=#event-loop id=message-ports:event-loop-4>event loop</a> as the <a href=#responsible-event-loop id=message-ports:responsible-event-loop-2>responsible 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>

  <p>When a <code id=message-ports:messageport-5><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-5>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>

  <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-6><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>

  <p>When the user agent is to <dfn id=create-a-new-messageport-object>create a new <code>MessagePort</code> object</dfn> with a
  particular <a href=#environment-settings-object id=message-ports:environment-settings-object>environment settings object</a> as its <var>owner</var>, it must instantiate
  a new <code id=message-ports:messageport-7><a href=#messageport>MessagePort</a></code> object, and let its <a href=#concept-port-owner id=message-ports:concept-port-owner-5>owner</a>
  be <var>owner</var>.</p>

  <p>When the user agent is to <dfn id=entangle>entangle</dfn> two <code id=message-ports:messageport-8><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>

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

   </ol>

  <hr>

  <p id=transferMessagePort><code id=message-ports:messageport-9><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.<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>.<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.<li><p>Set <var>dataHolder</var>.[[RemotePort]] to <var>remotePort</var>.</ol>
   <li><p>Otherwise, set <var>dataHolder</var>.[[RemotePort]] to null.</ol>

  <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.<li><p>Set <var>value</var>'s <a href=#concept-port-owner id=message-ports:concept-port-owner-6>owner</a> to <var>value</var>'s <a href=#relevant-settings-object id=message-ports:relevant-settings-object>relevant settings
   object</a>.<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><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-port-owner id=message-ports:concept-port-owner-7>owner</a> specifies a <a href=#responsible-event-loop id=message-ports:responsible-event-loop-3>responsible
   event loop</a> that is a <a href=#browsing-context id=message-ports:browsing-context-2>browsing context</a> <a href=#event-loop id=message-ports:event-loop-6>event loop</a>, associating
   the moved <a href=#concept-task id=message-ports:concept-task-5>tasks</a> with the <a href=#responsible-document id=message-ports:responsible-document-4>responsible document</a>
   specified by <var>value</var>'s <a href=#concept-port-owner id=message-ports:concept-port-owner-8>owner</a>.<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.)</ol>

  <hr>

  <p>The <dfn id=dom-messageport-postmessage><code>postMessage(<var>message</var>,
  <var>transfer</var>)</code></dfn> method, when invoked on a <code id=message-ports:messageport-10><a href=#messageport>MessagePort</a></code> object, must
  run the following steps:</p>

  <ol><li><p>Let <var>targetPort</var> be the port with which this <code id=message-ports:messageport-11><a href=#messageport>MessagePort</a></code> is
   entangled, if any; otherwise let it be null.<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> this
   <code id=message-ports:messageport-12><a href=#messageport>MessagePort</a></code>, then throw a <a id=message-ports:datacloneerror-2 href=https://heycam.github.io/webidl/#datacloneerror data-x-internal=datacloneerror>"<code>DataCloneError</code>"</a>
   <code id=message-ports:domexception-2><a data-x-internal=domexception href=https://heycam.github.io/webidl/#dfn-DOMException>DOMException</a></code>.<li><p>Let <var>doomed</var> be false.<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.<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.<li><p>If <var>targetPort</var> is null, or if <var>doomed</var> is true, then return.<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-13><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><p>Let <var>targetRealm</var> be <var>finalTargetPort</var>'s <a href=#concept-relevant-realm id=message-ports:concept-relevant-realm>relevant Realm</a>.<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 data-x-internal=concept-event-fire>fire an
      event</a> named <code id=message-ports:event-messageerror><a href=#event-messageerror>messageerror</a></code> at
      <var>finalTargetPort</var>, using <code id=message-ports:messageevent><a href=#messageevent>MessageEvent</a></code>, and then return.
     <li><p>Let <var>messageClone</var> be <var>deserializeRecord</var>.[[Deserialized]].<li><p>Let <var>newPorts</var> be a new <a id=message-ports:frozen-array href=https://heycam.github.io/webidl/#dfn-frozen-array-type data-x-internal=frozen-array>frozen array</a> consisting of all
     <code id=message-ports:messageport-14><a href=#messageport>MessagePort</a></code> objects in <var>deserializeRecord</var>.[[TransferredValues]], if any,
     maintaining their relative order.<li><p><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-message-2><a href=#event-message>message</a></code> at <var>finalTargetPort</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>.</ol>
   </ol>

  <hr>

  <p>The <dfn id=dom-messageport-start><code>start()</code></dfn> method, when invoked, must
  enable this <code id=message-ports:messageport-15><a href=#messageport>MessagePort</a></code> object's <a href=#port-message-queue id=message-ports:port-message-queue-14>port message queue</a>, if it is not
  already enabled.</p>

  <hr>

  <p>The <dfn id=dom-messageport-close><code>close()</code></dfn> method, when invoked, must
  run these steps:</p>

  <ol><li><p>Set this <code id=message-ports:messageport-16><a href=#messageport>MessagePort</a></code> object's <a href=#detached id=message-ports:detached>[[Detached]]</a> internal slot value
   to true.<li><p>If this <code id=message-ports:messageport-17><a href=#messageport>MessagePort</a></code> object is entangled, disentangle it.</ol>

  <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-18><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><a href=#event-handler-event-type id=message-ports:event-handler-event-type-2>Event handler event type</a>
   <tbody><tr><td><dfn id=handler-messageport-onmessage><code>onmessage</code></dfn> <td> <code id=message-ports:event-message-3><a href=#event-message>message</a></code>
    <tr><td><dfn id=handler-messageport-onmessageerror><code>onmessageerror</code></dfn> <td> <code id=message-ports:event-messageerror-2><a href=#event-messageerror>messageerror</a></code>
  </table>

  <p>The first time a <code id=message-ports:messageport-19><a href=#messageport>MessagePort</a></code> object's <code id=message-ports:handler-messageport-onmessage-2><a href=#handler-messageport-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>

  


  <h4 id=broadcasting-to-many-ports><span class=secno>9.5.4</span> Broadcasting to many ports<a href=#broadcasting-to-many-ports class=self-link></a></h4>

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

  <p>Broadcasting to many ports is in principle relatively simple: keep an array of
  <code id=broadcasting-to-many-ports:messageport><a href=#messageport>MessagePort</a></code> objects to send messages to, and iterate through the array to send a
  message. However, this has one rather unfortunate effect: it prevents the ports from being garbage
  collected, even if the other side has gone away. To avoid this problem, implement a simple
  protocol whereby the other side acknowledges it still exists. If it doesn't do so after a certain
  amount of time, assume it's gone, close the <code id=broadcasting-to-many-ports:messageport-2><a href=#messageport>MessagePort</a></code> object, and let it be garbage
  collected.</p>


  <h4 id=ports-and-garbage-collection><span class=secno>9.5.5</span> Ports and garbage collection<a href=#ports-and-garbage-collection class=self-link></a></h4>

  

  <p>When a <code id=ports-and-garbage-collection:messageport><a href=#messageport>MessagePort</a></code> object <var>o</var> is entangled, user agents must
  either act as if <var>o</var>'s entangled <code id=ports-and-garbage-collection:messageport-2><a href=#messageport>MessagePort</a></code> object has a strong
  reference to <var>o</var>, or as if the <a href=#concept-settings-object-global id=ports-and-garbage-collection:concept-settings-object-global>global
  object</a> specified by <var>o</var>'s <a href=#concept-port-owner id=ports-and-garbage-collection:concept-port-owner>owner</a> has a
  strong reference to <var>o</var>.</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.</p>

  </div>

  <p>Furthermore, a <code id=ports-and-garbage-collection:messageport-3><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-4><a href=#messageport>MessagePort</a></code>
  object, or while the <code id=ports-and-garbage-collection:messageport-5><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> 

  

  

  <p class=note>Authors are strongly encouraged to explicitly close <code id=ports-and-garbage-collection:messageport-6><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-7><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-8><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.6</span> <dfn>Broadcasting to other browsing contexts</dfn><a href=#broadcasting-to-other-browsing-contexts class=self-link></a></h3><div class=status><input onclick=toggleStatus(this) value=⋰ type=button><p class=support><strong>Support:</strong> broadcastchannel<span class="and_chr yes"><span>Chrome for Android</span> <span>67+</span></span><span class="chrome yes"><span>Chrome</span> <span>54+</span></span><span class="ios_saf no"><span>iOS Safari</span> <span>None</span></span><span class="and_uc yes"><span>UC Browser for Android</span> <span>11.8+</span></span><span class="firefox yes"><span>Firefox</span> <span>38+</span></span><span class="ie no"><span>IE</span> <span>None</span></span><span class="op_mini no"><span>Opera Mini</span> <span>None</span></span><span class="safari no"><span>Safari</span> <span>None</span></span><span class="edge no"><span>Edge</span> <span>None</span></span><span class="samsung yes"><span>Samsung Internet</span> <span>7.2+</span></span><span class="opera yes"><span>Opera</span> <span>41+</span></span><span class="android yes"><span>Android Browser</span> <span>67+</span></span><p class=caniuse>Source: <a href="https://caniuse.com/#feat=broadcastchannel">caniuse.com</a></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><a href=#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'>[<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- g>Exposed</c->=(<c- n>Window</c->,<c- n>Worker</c->)]
<c- b>interface</c-> <dfn id='broadcastchannel'><c- g>BroadcastChannel</c-></dfn> : <a href='https://dom.spec.whatwg.org/#interface-eventtarget' data-x-internal='eventtarget' id='broadcasting-to-other-browsing-contexts:eventtarget'><c- n>EventTarget</c-></a> {
  <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>void</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>void</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><var>broadcastChannel</var> = new <code id=dom-broadcastchannel-dev><a href=#dom-broadcastchannel>BroadcastChannel</a></code>(<var>name</var>)<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>

   <dt><var>broadcastChannel</var> . <code id=dom-broadcastchannel-name-dev><a href=#dom-broadcastchannel-name>name</a></code><dd>

    <p>Returns the channel name (as passed to the constructor).</p>

   <dt><var>broadcastChannel</var> . <code id=dom-broadcastchannel-postmessage-dev><a href=#dom-broadcastchannel-postmessage>postMessage</a></code>(<var>message</var>)<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>

   <dt><var>broadcastChannel</var> . <code id=dom-broadcastchannel-close-dev><a href=#dom-broadcastchannel-close>close</a></code>()<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>

   </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>, a
  <dfn id=broadcastchannel-settings-object><code>BroadcastChannel</code> settings object</dfn>, and a <dfn id=concept-broadcastchannel-closed>closed flag</dfn>.</p>

  <p>The <dfn id=dom-broadcastchannel><code>BroadcastChannel()</code></dfn> constructor, when
  invoked, must create and return a <code id=broadcasting-to-other-browsing-contexts:broadcastchannel-5><a href=#broadcastchannel>BroadcastChannel</a></code> object whose <a href=#channel-name id=broadcasting-to-other-browsing-contexts:channel-name>channel
  name</a> is the constructor's first argument, whose <a href=#broadcastchannel-settings-object id=broadcasting-to-other-browsing-contexts:broadcastchannel-settings-object><code>BroadcastChannel</code>
  settings object</a> is the <a href=#incumbent-settings-object id=broadcasting-to-other-browsing-contexts:incumbent-settings-object>incumbent settings object</a>, and whose <a href=#concept-broadcastchannel-closed id=broadcasting-to-other-browsing-contexts:concept-broadcastchannel-closed>closed flag</a> is false.</p>

  <p>The <dfn id=dom-broadcastchannel-name><code>name</code></dfn> attribute must return the
  <a href=#channel-name id=broadcasting-to-other-browsing-contexts:channel-name-2>channel name</a>.</p>

  <p>The <dfn id=dom-broadcastchannel-postmessage><code>postMessage(<var>message</var>)</code></dfn> method,
  when invoked on a <code id=broadcasting-to-other-browsing-contexts:broadcastchannel-6><a href=#broadcastchannel>BroadcastChannel</a></code> object, must run the following steps:</p>

  <ol><li><p>Let <var>source</var> be this <code id=broadcasting-to-other-browsing-contexts:broadcastchannel-7><a href=#broadcastchannel>BroadcastChannel</a></code>.<li><p>Let <var>sourceSettings</var> be <var>source</var>'s <a href=#broadcastchannel-settings-object id=broadcasting-to-other-browsing-contexts:broadcastchannel-settings-object-2><code>BroadcastChannel</code>
   settings object</a>.<li><p>If <var>source</var>'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://heycam.github.io/webidl/#invalidstateerror data-x-internal=invalidstateerror>"<code>InvalidStateError</code>"</a> <code id=broadcasting-to-other-browsing-contexts:domexception><a data-x-internal=domexception href=https://heycam.github.io/webidl/#dfn-DOMException>DOMException</a></code>.<li><p>Let <var>sourceChannel</var> be <var>source</var>'s <a href=#channel-name id=broadcasting-to-other-browsing-contexts:channel-name-3>channel name</a>.<li><p>Let <var>targetRealm</var> be a user-agent defined Realm.<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.<li>
    <p>Let <var>destinations</var> be a list of <code id=broadcasting-to-other-browsing-contexts:broadcastchannel-8><a href=#broadcastchannel>BroadcastChannel</a></code> objects that
    match the following criteria:</p>

    <ul><li>
      <p>Their <a href=#broadcastchannel-settings-object id=broadcasting-to-other-browsing-contexts:broadcastchannel-settings-object-3><code>BroadcastChannel</code> settings object</a> specifies either:</p>

      <ul><li><p>a <a href=#concept-settings-object-global id=broadcasting-to-other-browsing-contexts:concept-settings-object-global>global object</a> that is a
       <code id=broadcasting-to-other-browsing-contexts:window><a href=#window>Window</a></code> object and a <a href=#responsible-document id=broadcasting-to-other-browsing-contexts:responsible-document>responsible document</a> that is <a href=#fully-active id=broadcasting-to-other-browsing-contexts:fully-active>fully
       active</a>, or<li><p>a <a href=#concept-settings-object-global id=broadcasting-to-other-browsing-contexts:concept-settings-object-global-2>global object</a> that is 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 whose
       <a href=#worker id=broadcasting-to-other-browsing-contexts:worker>worker</a> is not a <a href=#suspendable-worker id=broadcasting-to-other-browsing-contexts:suspendable-worker>suspendable worker</a>.</ul>
     <li><p>Their <a href=#broadcastchannel-settings-object id=broadcasting-to-other-browsing-contexts:broadcastchannel-settings-object-4><code>BroadcastChannel</code> settings object</a>'s <a href=#concept-settings-object-origin id=broadcasting-to-other-browsing-contexts:concept-settings-object-origin>origin</a> is <a href=#same-origin id=broadcasting-to-other-browsing-contexts:same-origin>same origin</a> with
     <var>sourceSettings</var>'s <a href=#concept-settings-object-origin id=broadcasting-to-other-browsing-contexts:concept-settings-object-origin-2>origin</a>.<li><p>Their <a href=#channel-name id=broadcasting-to-other-browsing-contexts:channel-name-4>channel name</a> is a <a href=#case-sensitive id=broadcasting-to-other-browsing-contexts:case-sensitive>case-sensitive</a> match for
     <var>sourceChannel</var>.<li><p>Their <a href=#concept-broadcastchannel-closed id=broadcasting-to-other-browsing-contexts:concept-broadcastchannel-closed-3>closed flag</a> is
     false.</ul>
   <li><p>Remove <var>source</var> from <var>destinations</var>.<li><p>Sort <var>destinations</var> such that all <code id=broadcasting-to-other-browsing-contexts:broadcastchannel-9><a href=#broadcastchannel>BroadcastChannel</a></code> objects whose
   <a href=#broadcastchannel-settings-object id=broadcasting-to-other-browsing-contexts:broadcastchannel-settings-object-5><code>BroadcastChannel</code> settings
   objects</a> specify the same <a href=#responsible-event-loop id=broadcasting-to-other-browsing-contexts:responsible-event-loop>responsible event loop</a> 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 user-agent defined manner.)<li>
    <p>For each <code id=broadcasting-to-other-browsing-contexts:broadcastchannel-10><a href=#broadcastchannel>BroadcastChannel</a></code> object <var>destination</var> in
    <var>destinations</var>, <a href=#queue-a-task id=broadcasting-to-other-browsing-contexts:queue-a-task>queue a task</a> that runs the following steps:</p>

    <ol><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>.<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>sourceSettings</var>'s <a href=#concept-settings-object-origin id=broadcasting-to-other-browsing-contexts:concept-settings-object-origin-3>origin</a>, and then return.</p>
     <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>sourceSettings</var>'s <a href=#concept-settings-object-origin id=broadcasting-to-other-browsing-contexts:concept-settings-object-origin-4>origin</a>.</ol>

    <p>The <a href=#concept-task id=broadcasting-to-other-browsing-contexts:concept-task>tasks</a> must use the <a href=#dom-manipulation-task-source id=broadcasting-to-other-browsing-contexts:dom-manipulation-task-source>DOM manipulation task
    source</a>, and, for those where the <a href=#event-loop id=broadcasting-to-other-browsing-contexts:event-loop>event loop</a> specified by the target
    <code id=broadcasting-to-other-browsing-contexts:broadcastchannel-11><a href=#broadcastchannel>BroadcastChannel</a></code> object's <a href=#broadcastchannel-settings-object id=broadcasting-to-other-browsing-contexts:broadcastchannel-settings-object-6><code>BroadcastChannel</code> settings
    object</a> is a <a href=#browsing-context id=broadcasting-to-other-browsing-contexts:browsing-context-2>browsing context</a> <a href=#event-loop id=broadcasting-to-other-browsing-contexts:event-loop-2>event loop</a>, must be associated
    with the <a href=#responsible-document id=broadcasting-to-other-browsing-contexts:responsible-document-2>responsible document</a> specified by that target
    <code id=broadcasting-to-other-browsing-contexts:broadcastchannel-12><a href=#broadcastchannel>BroadcastChannel</a></code> object's <a href=#broadcastchannel-settings-object id=broadcasting-to-other-browsing-contexts:broadcastchannel-settings-object-7><code>BroadcastChannel</code> settings
    object</a>.</p>
   </ol>

  <p>While a <code id=broadcasting-to-other-browsing-contexts:broadcastchannel-13><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> events, there must be a strong
  reference from <a href=#concept-settings-object-global id=broadcasting-to-other-browsing-contexts:concept-settings-object-global-3>global object</a> specified by
  the <code id=broadcasting-to-other-browsing-contexts:broadcastchannel-14><a href=#broadcastchannel>BroadcastChannel</a></code> object's <a href=#broadcastchannel-settings-object id=broadcasting-to-other-browsing-contexts:broadcastchannel-settings-object-8><code>BroadcastChannel</code> settings
  object</a> to the <code id=broadcasting-to-other-browsing-contexts:broadcastchannel-15><a href=#broadcastchannel>BroadcastChannel</a></code> object itself.</p>

  <p>The <dfn id=dom-broadcastchannel-close><code>close()</code></dfn> method must set the
  <a href=#concept-broadcastchannel-closed id=broadcasting-to-other-browsing-contexts:concept-broadcastchannel-closed-5>closed flag</a> of the
  <code id=broadcasting-to-other-browsing-contexts:broadcastchannel-16><a href=#broadcastchannel>BroadcastChannel</a></code> object on which it was invoked to true.</p>

  <p class=note>Authors are strongly encouraged to explicitly close <code id=broadcasting-to-other-browsing-contexts:broadcastchannel-17><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-18><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-19><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><a href=#event-handler-event-type id=broadcasting-to-other-browsing-contexts:event-handler-event-type-2>Event handler event type</a>
   <tbody><tr><td><dfn id=handler-broadcastchannel-onmessage><code>onmessage</code></dfn> <td> <code id=broadcasting-to-other-browsing-contexts:event-message-3><a href=#event-message>message</a></code>
    <tr><td><dfn id=handler-broadcastchannel-onmessageerror><code>onmessageerror</code></dfn> <td> <code id=broadcasting-to-other-browsing-contexts:event-messageerror-2><a href=#event-messageerror>messageerror</a></code>
  </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>&apos;auth&apos;</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>&apos;logout&apos;</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>&apos;logout&apos;</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&apos;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>

  <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- 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>&quot;utf-8&quot;</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>&quot;result&quot;</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>&apos;worker.js&apos;</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>&apos;result&apos;</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-worker-onmessage><a href=#handler-worker-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- mi>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- mi>1</c-><c- p>;</c->
  <c- k>for</c-> <c- p>(</c-><c- a>var</c-> i <c- o>=</c-> <c- mi>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- mi>1</c-><c- p>)</c->
    <c- k>if</c-> <c- p>(</c->n <c- o>%</c-> i <c- o>==</c-> <c- mi>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>Note that such module-based workers follow different restrictions regarding cross-origin
  content, compared to classic workers. Unlike classic workers, module workers can be instantiated
  using a cross-origin script, as long as that script is exposed using the <a id=module-worker-example:cors-protocol href=https://fetch.spec.whatwg.org/#http-cors-protocol data-x-internal=cors-protocol>CORS
  protocol</a>. Additionally, the <code id=module-worker-example:dom-workerglobalscope-importscripts><a href=#dom-workerglobalscope-importscripts>importScripts()</a></code> method will automatically fail
  inside module workers; the JavaScript <code>import</code> statement is generally a
  better choice.</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>meta</c-> <c- e>charset</c-><c- o>=</c-><c- s>&quot;utf-8&quot;</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>&quot;url&quot;</c-> <c- e>id</c-><c- o>=</c-><c- s>&quot;image-url&quot;</c-> <c- e>list</c-><c- o>=</c-><c- s>&quot;image-list&quot;</c-><c- p>&gt;</c->
    <c- p>&lt;</c-><c- f>datalist</c-> <c- e>id</c-><c- o>=</c-><c- s>&quot;image-list&quot;</c-><c- p>&gt;</c->
      <c- p>&lt;</c-><c- f>option</c-> <c- e>value</c-><c- o>=</c-><c- s>&quot;https://html.spec.whatwg.org/images/drawImage.png&quot;</c-><c- p>&gt;</c->
      <c- p>&lt;</c-><c- f>option</c-> <c- e>value</c-><c- o>=</c-><c- s>&quot;https://html.spec.whatwg.org/images/robots.jpeg&quot;</c-><c- p>&gt;</c->
      <c- p>&lt;</c-><c- f>option</c-> <c- e>value</c-><c- o>=</c-><c- s>&quot;https://html.spec.whatwg.org/images/arcTo2.png&quot;</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>&quot;filter&quot;</c-><c- p>&gt;</c->
      <c- p>&lt;</c-><c- f>option</c-> <c- e>value</c-><c- o>=</c-><c- s>&quot;none&quot;</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>&quot;grayscale&quot;</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>&quot;brighten&quot;</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>canvas</c-> <c- e>id</c-><c- o>=</c-><c- s>&quot;output&quot;</c-><c- p>&gt;&lt;/</c-><c- f>canvas</c-><c- p>&gt;</c->

<c- p>&lt;</c-><c- f>script</c-> <c- e>type</c-><c- o>=</c-><c- s>&quot;module&quot;</c-><c- p>&gt;</c->
  <c- kr>const</c-> worker <c- o>=</c-> <c- k>new</c-> Worker<c- p>(</c-><c- u>&quot;worker.js&quot;</c-><c- p>,</c-> <c- p>{</c-> type<c- o>:</c-> <c- u>&quot;module&quot;</c-> <c- p>});</c->
  worker<c- p>.</c->onmessage <c- o>=</c-> receiveFromWorker<c- p>;</c->

  <c- kr>const</c-> url <c- o>=</c-> document<c- p>.</c->querySelector<c- p>(</c-><c- u>&quot;#image-url&quot;</c-><c- p>);</c->
  <c- kr>const</c-> filter <c- o>=</c-> document<c- p>.</c->querySelector<c- p>(</c-><c- u>&quot;#filter&quot;</c-><c- p>);</c->
  <c- kr>const</c-> output <c- o>=</c-> document<c- p>.</c->querySelector<c- p>(</c-><c- u>&quot;#output&quot;</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- kr>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->
      output<c- p>.</c->innerHTML <c- o>=</c-> <c- u>&quot;&quot;</c-><c- p>;</c->

      <c- kr>const</c-> canvas <c- o>=</c-> document<c- p>.</c->createElement<c- p>(</c-><c- u>&quot;canvas&quot;</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>&quot;2d&quot;</c-><c- p>);</c->
      context<c- p>.</c->drawImage<c- p>(</c->img<c- p>,</c-> <c- mi>0</c-><c- p>,</c-> <c- mi>0</c-><c- p>);</c->
      imageData <c- o>=</c-> context<c- p>.</c->getImageData<c- p>(</c-><c- mi>0</c-><c- p>,</c-> <c- mi>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->appendChild<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- mi>0</c-><c- p>,</c-> <c- mi>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- kr>import</c-> <c- o>*</c-> as filters from <c- u>&quot;./filters.js&quot;</c-><c- p>;</c->

self<c- p>.</c->onmessage <c- o>=</c-> e <c- p>=&gt;</c-> <c- p>{</c->
  <c- kr>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- kr>export</c-> <c- a>function</c-> none<c- p>()</c-> <c- p>{}</c->

<c- kr>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- mi>0</c-><c- p>;</c-> i <c- o>&lt;</c-> d<c- p>.</c->length<c- p>;</c-> i <c- o>+=</c-> <c- mi>4</c-><c- p>)</c-> <c- p>{</c->
    <c- kr>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- mi>1</c-><c- p>],</c-> d<c- p>[</c->i <c- o>+</c-> <c- mi>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- mi>1</c-><c- p>]</c-> <c- o>=</c-> d<c- p>[</c->i <c- o>+</c-> <c- mi>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- kr>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- mi>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=status><input onclick=toggleStatus(this) value=⋰ type=button><p class=support><strong>Support:</strong> sharedworkers<span class="and_chr no"><span>Chrome for Android</span> <span>None</span></span><span class="chrome yes"><span>Chrome</span> <span>4+</span></span><span class="ios_saf no"><span>iOS Safari</span> <span>None</span></span><span class="and_uc yes"><span>UC Browser for Android</span> <span>11.8+</span></span><span class="firefox yes"><span>Firefox</span> <span>29+</span></span><span class="ie no"><span>IE</span> <span>None</span></span><span class="op_mini no"><span>Opera Mini</span> <span>None</span></span><span class="safari no"><span>Safari</span> <span>None</span></span><span class="edge no"><span>Edge</span> <span>None</span></span><span class="samsung no"><span>Samsung Internet</span> <span>None</span></span><span class="opera yes"><span>Opera</span> <span>10.6+</span></span><span class="android no"><span>Android Browser</span> <span>None</span></span><p class=caniuse>Source: <a href="https://caniuse.com/#feat=sharedworkers">caniuse.com</a></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>meta</c-> <c- e>charset</c-><c- o>=</c-><c- s>&quot;utf-8&quot;</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>&quot;log&quot;</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>&apos;test.js&apos;</c-><c- p>);</c->
  <c- a>var</c-> log <c- o>=</c-> document<c- p>.</c->getElementById<c- p>(</c-><c- t>&apos;log&apos;</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>&apos;\n&apos;</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- mi>0</c-><c- p>];</c->
  port<c- p>.</c->postMessage<c- p>(</c-><c- t>&apos;Hello World!&apos;</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>meta</c-> <c- e>charset</c-><c- o>=</c-><c- s>&quot;utf-8&quot;</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>&quot;log&quot;</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>&apos;test.js&apos;</c-><c- p>);</c->
  <c- a>var</c-> log <c- o>=</c-> document<c- p>.</c->getElementById<c- p>(</c-><c- t>&apos;log&apos;</c-><c- p>);</c->
  worker<c- p>.</c->port<c- p>.</c->addEventListener<c- p>(</c-><c- t>&apos;message&apos;</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>&apos;\n&apos;</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>&apos;ping&apos;</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- mi>0</c-><c- p>];</c->
  port<c- p>.</c->postMessage<c- p>(</c-><c- t>&apos;Hello World!&apos;</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>&apos;pong&apos;</c-><c- p>);</c-> <c- c1>// not e.ports[0].postMessage!</c->
    <c- c1>// e.target.postMessage(&apos;pong&apos;); 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-browsing-context id=shared-workers-introduction:top-level-browsing-context>top-level browsing
  context</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>meta</c-> <c- e>charset</c-><c- o>=</c-><c- s>&quot;utf-8&quot;</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>&quot;log&quot;</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>&apos;test.js&apos;</c-><c- p>);</c->
  <c- a>var</c-> log <c- o>=</c-> document<c- p>.</c->getElementById<c- p>(</c-><c- t>&apos;log&apos;</c-><c- p>);</c->
  worker<c- p>.</c->port<c- p>.</c->addEventListener<c- p>(</c-><c- t>&apos;message&apos;</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>&apos;\n&apos;</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>&apos;ping&apos;</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>&quot;inner.html&quot;</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>meta</c-> <c- e>charset</c-><c- o>=</c-><c- s>&quot;utf-8&quot;</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>&apos;test.js&apos;</c-><c- p>);</c->
  <c- a>var</c-> log <c- o>=</c-> document<c- p>.</c->getElementById<c- p>(</c-><c- t>&apos;log&apos;</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>&apos;\n&apos;</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- mi>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- mi>1</c-><c- p>;</c->
  <c- a>var</c-> port <c- o>=</c-> e<c- p>.</c->ports<c- p>[</c-><c- mi>0</c-><c- p>];</c->
  port<c- p>.</c->postMessage<c- p>(</c-><c- t>&apos;Hello World! You are connection #&apos;</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>&apos;pong&apos;</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- 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>&quot;utf-8&quot;</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>&apos;viewer.html&apos;</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>&quot;openViewer()&quot;</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- 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>&quot;utf-8&quot;</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>&apos;worker.js&apos;</c-><c- p>,</c-> <c- t>&apos;core&apos;</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- mi>0</c-><c- p>,</c-> <c- mi>4</c-><c- p>)</c-> <c- o>!=</c-> <c- t>&apos;cfg &apos;</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- mi>4</c-><c- p>).</c->split<c- p>(</c-><c- t>&apos; &apos;</c-><c- p>,</c-> <c- mi>1</c-><c- p>)[</c-><c- mi>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>&apos;h1&apos;</c-><c- p>)[</c-><c- mi>0</c-><c- p>].</c->textContent <c- o>+=</c-> <c- t>&apos; &apos;</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>&apos;message&apos;</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>&apos;message&apos;</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- mi>0</c-><c- p>,</c-> <c- mi>4</c-><c- p>)</c-> <c- o>!=</c-> <c- t>&apos;map &apos;</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- mi>4</c-><c- p>).</c->split<c- p>(</c-><c- t>&apos;,&apos;</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>&apos;map&apos;</c-><c- p>);</c->
     <c- a>var</c-> context <c- o>=</c-> canvas<c- p>.</c->getContext<c- p>(</c-><c- t>&apos;2d&apos;</c-><c- p>);</c->
     <c- k>for</c-> <c- p>(</c-><c- a>var</c-> y <c- o>=</c-> <c- mi>0</c-><c- p>;</c-> y <c- o>&lt;</c-> <c- mi>3</c-><c- p>;</c-> y <c- o>+=</c-> <c- mi>1</c-><c- p>)</c-> <c- p>{</c->
       <c- k>for</c-> <c- p>(</c-><c- a>var</c-> x <c- o>=</c-> <c- mi>0</c-><c- p>;</c-> x <c- o>&lt;</c-> <c- mi>3</c-><c- p>;</c-> x <c- o>+=</c-> <c- mi>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- mi>3</c-> <c- o>+</c-> x<c- p>];</c->
         <c- k>if</c-> <c- p>(</c->tile <c- o>==</c-> <c- t>&apos;0&apos;</c-><c- p>)</c->
           context<c- p>.</c->fillStyle <c- o>=</c-> <c- t>&apos;green&apos;</c-><c- p>;</c->
         <c- k>else</c->
           context<c- p>.</c->fillStyle <c- o>=</c-> <c- t>&apos;maroon&apos;</c-><c- p>;</c->
         context<c- p>.</c->fillRect<c- p>(</c->x <c- o>*</c-> <c- mi>50</c-><c- p>,</c-> y <c- o>*</c-> <c- mi>50</c-><c- p>,</c-> <c- mi>50</c-><c- p>,</c-> <c- mi>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>&apos;message&apos;</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- mi>0</c-><c- p>,</c-> <c- mi>4</c-><c- p>)</c-> <c- o>!=</c-> <c- t>&apos;txt &apos;</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- mi>4</c-><c- p>).</c->split<c- p>(</c-><c- t>&apos; &apos;</c-><c- p>,</c-> <c- mi>1</c-><c- p>)[</c-><c- mi>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- mi>4</c-> <c- o>+</c-> name<c- p>.</c->length <c- o>+</c-> <c- mi>1</c-><c- p>);</c->
     <c- c1>// display &quot;&lt;name&gt; message&quot; in public chat</c->
     <c- a>var</c-> <c- kr>public</c-> <c- o>=</c-> document<c- p>.</c->getElementById<c- p>(</c-><c- t>&apos;public&apos;</c-><c- p>);</c->
     <c- a>var</c-> p <c- o>=</c-> document<c- p>.</c->createElement<c- p>(</c-><c- t>&apos;p&apos;</c-><c- p>);</c->
     <c- a>var</c-> n <c- o>=</c-> document<c- p>.</c->createElement<c- p>(</c-><c- t>&apos;button&apos;</c-><c- p>);</c->
     n<c- p>.</c->textContent <c- o>=</c-> <c- t>&apos;&lt;&apos;</c-> <c- o>+</c-> name <c- o>+</c-> <c- t>&apos;&gt; &apos;</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>&apos;msg &apos;</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>&apos;span&apos;</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->
     <c- kr>public</c-><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>&apos;message&apos;</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- mi>0</c-><c- p>,</c-> <c- mi>4</c-><c- p>)</c-> <c- o>!=</c-> <c- t>&apos;msg &apos;</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- mi>4</c-><c- p>).</c->split<c- p>(</c-><c- t>&apos; &apos;</c-><c- p>,</c-> <c- mi>1</c-><c- p>)[</c-><c- mi>0</c-><c- p>];</c->
     <c- a>var</c-> port <c- o>=</c-> event<c- p>.</c->ports<c- p>[</c-><c- mi>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>&apos;private&apos;</c-><c- p>);</c->
     <c- a>var</c-> li <c- o>=</c-> document<c- p>.</c->createElement<c- p>(</c-><c- t>&apos;li&apos;</c-><c- p>);</c->
     <c- a>var</c-> h3 <c- o>=</c-> document<c- p>.</c->createElement<c- p>(</c-><c- t>&apos;h3&apos;</c-><c- p>);</c->
     h3<c- p>.</c->textContent <c- o>=</c-> <c- t>&apos;Private chat with &apos;</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>&apos;div&apos;</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>&apos;p&apos;</c-><c- p>);</c->
       <c- a>var</c-> n <c- o>=</c-> document<c- p>.</c->createElement<c- p>(</c-><c- t>&apos;strong&apos;</c-><c- p>);</c->
       n<c- p>.</c->textContent <c- o>=</c-> <c- t>&apos;&lt;&apos;</c-> <c- o>+</c-> name <c- o>+</c-> <c- t>&apos;&gt; &apos;</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>&apos;span&apos;</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>&apos;form&apos;</c-><c- p>);</c->
     <c- a>var</c-> p <c- o>=</c-> document<c- p>.</c->createElement<c- p>(</c-><c- t>&apos;p&apos;</c-><c- p>);</c->
     <c- a>var</c-> input <c- o>=</c-> document<c- p>.</c->createElement<c- p>(</c-><c- t>&apos;input&apos;</c-><c- p>);</c->
     input<c- p>.</c->size <c- o>=</c-> <c- mi>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>&apos; &apos;</c-><c- p>));</c->
     <c- a>var</c-> button <c- o>=</c-> document<c- p>.</c->createElement<c- p>(</c-><c- t>&apos;button&apos;</c-><c- p>);</c->
     button<c- p>.</c->textContent <c- o>=</c-> <c- t>&apos;Post&apos;</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>&apos;me&apos;</c-><c- p>,</c-> input<c- p>.</c->value<c- p>);</c->
       input<c- p>.</c->value <c- o>=</c-> <c- t>&apos;&apos;</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>&apos;message&apos;</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>&quot;map&quot;</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>&quot;worker.port.postMessage(&apos;mov left&apos;)&quot;</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>&quot;worker.port.postMessage(&apos;mov up&apos;)&quot;</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>&quot;worker.port.postMessage(&apos;mov down&apos;)&quot;</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>&quot;worker.port.postMessage(&apos;mov right&apos;)&quot;</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>&quot;worker.port.postMessage(&apos;set 0&apos;)&quot;</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>&quot;worker.port.postMessage(&apos;set 1&apos;)&quot;</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>&quot;public&quot;</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>&quot;worker.port.postMessage(&apos;txt &apos; + message.value); message.value = &apos;&apos;; return false;&quot;</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>&quot;text&quot;</c-> <c- e>name</c-><c- o>=</c-><c- s>&quot;message&quot;</c-> <c- e>size</c-><c- o>=</c-><c- s>&quot;50&quot;</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>&quot;private&quot;</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- mi>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- mi>0</c-><c- p>,</c-> <c- mi>0</c-><c- p>,</c-> <c- mi>0</c-><c- p>,</c-> <c- mi>0</c-><c- p>,</c-> <c- mi>0</c-><c- p>,</c-> <c- mi>0</c-><c- p>,</c-> <c- mi>0</c-><c- p>],</c->
 <c- p>[</c-><c- mi>1</c-><c- p>,</c-> <c- mi>1</c-><c- p>,</c-> <c- mi>0</c-><c- p>,</c-> <c- mi>1</c-><c- p>,</c-> <c- mi>0</c-><c- p>,</c-> <c- mi>1</c-><c- p>,</c-> <c- mi>1</c-><c- p>],</c->
 <c- p>[</c-><c- mi>0</c-><c- p>,</c-> <c- mi>1</c-><c- p>,</c-> <c- mi>0</c-><c- p>,</c-> <c- mi>1</c-><c- p>,</c-> <c- mi>0</c-><c- p>,</c-> <c- mi>0</c-><c- p>,</c-> <c- mi>0</c-><c- p>],</c->
 <c- p>[</c-><c- mi>0</c-><c- p>,</c-> <c- mi>1</c-><c- p>,</c-> <c- mi>0</c-><c- p>,</c-> <c- mi>1</c-><c- p>,</c-> <c- mi>0</c-><c- p>,</c-> <c- mi>1</c-><c- p>,</c-> <c- mi>1</c-><c- p>],</c->
 <c- p>[</c-><c- mi>0</c-><c- p>,</c-> <c- mi>0</c-><c- p>,</c-> <c- mi>0</c-><c- p>,</c-> <c- mi>1</c-><c- p>,</c-> <c- mi>0</c-><c- p>,</c-> <c- mi>0</c-><c- p>,</c-> <c- mi>0</c-><c- p>],</c->
 <c- p>[</c-><c- mi>1</c-><c- p>,</c-> <c- mi>0</c-><c- p>,</c-> <c- mi>0</c-><c- p>,</c-> <c- mi>1</c-><c- p>,</c-> <c- mi>1</c-><c- p>,</c-> <c- mi>1</c-><c- p>,</c-> <c- mi>1</c-><c- p>],</c->
 <c- p>[</c-><c- mi>1</c-><c- p>,</c-> <c- mi>1</c-><c- p>,</c-> <c- mi>0</c-><c- p>,</c-> <c- mi>1</c-><c- p>,</c-> <c- mi>1</c-><c- p>,</c-> <c- mi>0</c-><c- p>,</c-> <c- mi>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- mi>0</c-><c- p>)</c-> <c- k>return</c-> wrapX<c- p>(</c->x <c- o>+</c-> map<c- p>[</c-><c- mi>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- mi>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- mi>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- mi>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- mi>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- mi>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- mi>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>&apos;&apos;</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- mi>1</c-><c- p>;</c-> y <c- o>&lt;=</c-> viewer<c- p>.</c->y<c- o>+</c-><c- mi>1</c-><c- p>;</c-> y <c- o>+=</c-> <c- mi>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- mi>1</c-><c- p>;</c-> x <c- o>&lt;=</c-> viewer<c- p>.</c->x<c- o>+</c-><c- mi>1</c-><c- p>;</c-> x <c- o>+=</c-> <c- mi>1</c-><c- p>)</c-> <c- p>{</c->
      <c- k>if</c-> <c- p>(</c->data <c- o>!=</c-> <c- t>&apos;&apos;</c-><c- p>)</c->
        data <c- o>+=</c-> <c- t>&apos;,&apos;</c-><c- p>;</c->
      data <c- o>+=</c-> map<c- p>[</c->wrap<c- p>(</c->y<c- p>,</c-> <c- mi>0</c-><c- p>,</c-> map<c- p>[</c-><c- mi>0</c-><c- p>].</c->length<c- o>-</c-><c- mi>1</c-><c- p>)][</c->wrap<c- p>(</c->x<c- p>,</c-> <c- mi>0</c-><c- p>,</c-> map<c- p>.</c->length<c- o>-</c-><c- mi>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>&apos;map &apos;</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- mi>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- mi>0</c-><c- p>],</c-> name<c- o>:</c-> name<c- p>,</c-> x<c- o>:</c-> <c- mi>0</c-><c- p>,</c-> y<c- o>:</c-> <c- mi>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- mi>0</c-><c- p>].</c->_data<c- p>;</c->
  event<c- p>.</c->ports<c- p>[</c-><c- mi>0</c-><c- p>].</c->postMessage<c- p>(</c-><c- t>&apos;cfg &apos;</c-> <c- o>+</c-> name<c- p>);</c->
  event<c- p>.</c->ports<c- p>[</c-><c- mi>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- mi>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- mi>0</c-><c- p>,</c-> <c- mi>4</c-><c- p>))</c-> <c- p>{</c->
    <c- k>case</c-> <c- t>&apos;mov &apos;</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- mi>4</c-><c- p>);</c->
      <c- a>var</c-> dx <c- o>=</c-> <c- mi>0</c-><c- p>;</c->
      <c- a>var</c-> dy <c- o>=</c-> <c- mi>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>&apos;up&apos;</c-><c- o>:</c-> dy <c- o>=</c-> <c- o>-</c-><c- mi>1</c-><c- p>;</c-> <c- k>break</c-><c- p>;</c->
        <c- k>case</c-> <c- t>&apos;down&apos;</c-><c- o>:</c-> dy <c- o>=</c-> <c- mi>1</c-><c- p>;</c-> <c- k>break</c-><c- p>;</c->
        <c- k>case</c-> <c- t>&apos;left&apos;</c-><c- o>:</c-> dx <c- o>=</c-> <c- o>-</c-><c- mi>1</c-><c- p>;</c-> <c- k>break</c-><c- p>;</c->
        <c- k>case</c-> <c- t>&apos;right&apos;</c-><c- o>:</c-> dx <c- o>=</c-> <c- mi>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>&apos;set &apos;</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- mi>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>&apos;txt &apos;</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- mi>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>&apos;txt &apos;</c-> <c- o>+</c-> name <c- o>+</c-> <c- t>&apos; &apos;</c-> <c- o>+</c-> message<c- p>);</c->
      <c- k>break</c-><c- p>;</c->
    <c- k>case</c-> <c- t>&apos;msg &apos;</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- mi>4</c-><c- p>).</c->split<c- p>(</c-><c- t>&apos; &apos;</c-><c- p>,</c-> <c- mi>1</c-><c- p>)[</c-><c- mi>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>&apos;msg &apos;</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>&apos;msg &apos;</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- 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>&quot;utf-8&quot;</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>&quot;result&quot;</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>&apos;worker.js&apos;</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>&apos;result&apos;</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- mi>10</c-><c- p>;</c->
<c- a>var</c-> items_per_worker <c- o>=</c-> <c- mi>1000000</c-><c- p>;</c->

<c- c1>// start the workers</c->
<c- a>var</c-> result <c- o>=</c-> <c- mi>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- mi>0</c-><c- p>;</c-> i <c- o>&lt;</c-> num_workers<c- p>;</c-> i <c- o>+=</c-> <c- mi>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>&apos;core.js&apos;</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- mi>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- mi>1</c-><c- o>*</c->event<c- p>.</c->data<c- p>;</c->
  pending_workers <c- o>-=</c-> <c- mi>1</c-><c- p>;</c->
  <c- k>if</c-> <c- p>(</c->pending_workers <c- o>&lt;=</c-> <c- mi>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- mi>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- mi>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- mi>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- mi>1</c-><c- p>)</c-> <c- p>{</c->
    <c- c1>// perform some complex calculation here</c->
    result <c- o>+=</c-> <c- mi>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<dd>Takes a port, on which it will send two messages, first the public key and then the private
   key.<dt>Given a plaintext and a public key, return the corresponding ciphertext<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.<dt>Given a ciphertext and a private key, return the corresponding plaintext<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.</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>&quot;genkeys&quot;</c-><c- p>)</c->
    genkeys<c- p>(</c->e<c- p>.</c->ports<c- p>[</c-><c- mi>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>&quot;encrypt&quot;</c-><c- p>)</c->
    encrypt<c- p>(</c->e<c- p>.</c->ports<c- p>[</c-><c- mi>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>&quot;decrypt&quot;</c-><c- p>)</c->
    decrypt<c- p>(</c->e<c- p>.</c->ports<c- p>[</c-><c- mi>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- mi>0</c-><c- p>]);</c->
  p<c- p>.</c->postMessage<c- p>(</c->keys<c- p>[</c-><c- mi>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- mi>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- mi>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- mi>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- mi>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- mi>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- mi>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>&apos;onmessage&apos;</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 &quot;crypto&quot; 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>&apos;encrypted-&apos;</c-> <c- o>+</c-> k <c- o>+</c-> <c- t>&apos; &apos;</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>&apos; &apos;</c-><c- p>)</c-><c- o>+</c-><c- mi>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- 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>&quot;utf-8&quot;</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- kr>const</c-> cryptoLib <c- o>=</c-> <c- k>new</c-> Worker<c- p>(</c-><c- t>&apos;libcrypto-v1.js&apos;</c-><c- p>);</c-> <c- c1>// or could use &apos;libcrypto-v2.js&apos;</c->
   <c- a>function</c-> startConversation<c- p>(</c->source<c- p>,</c-> message<c- p>)</c-> <c- p>{</c->
     <c- kr>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- mi>0</c-><c- p>;</c->
     startConversation<c- p>(</c->cryptoLib<c- p>,</c-> <c- u>&quot;genkeys&quot;</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- mi>0</c-><c- p>)</c->
         document<c- p>.</c->getElementById<c- p>(</c-><c- t>&apos;public&apos;</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- mi>1</c-><c- p>)</c->
         document<c- p>.</c->getElementById<c- p>(</c-><c- t>&apos;private&apos;</c-><c- p>).</c->value <c- o>=</c-> e<c- p>.</c->data<c- p>;</c->
       state <c- o>+=</c-> <c- mi>1</c-><c- p>;</c->
     <c- p>};</c->
   <c- p>}</c->
   <c- a>function</c-> enc<c- p>()</c-> <c- p>{</c->
     <c- kr>const</c-> port <c- o>=</c-> startConversation<c- p>(</c->cryptoLib<c- p>,</c-> <c- u>&quot;encrypt&quot;</c-><c- p>);</c->
     port<c- p>.</c->postMessage<c- p>(</c->document<c- p>.</c->getElementById<c- p>(</c-><c- t>&apos;public&apos;</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>&apos;input&apos;</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>&apos;input&apos;</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- kr>const</c-> port <c- o>=</c-> startConversation<c- p>(</c->cryptoLib<c- p>,</c-> <c- u>&quot;decrypt&quot;</c-><c- p>);</c->
     port<c- p>.</c->postMessage<c- p>(</c->document<c- p>.</c->getElementById<c- p>(</c-><c- t>&apos;private&apos;</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>&apos;input&apos;</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>&apos;input&apos;</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>&quot;getKeys()&quot;</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>&quot;public&quot;</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>&quot;private&quot;</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>&quot;input&quot;</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>&quot;enc()&quot;</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>&quot;dec()&quot;</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>&quot;genkeys&quot;</c-><c- p>)</c->
    genkeys<c- p>(</c->e<c- p>.</c->ports<c- p>[</c-><c- mi>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>&quot;encrypt&quot;</c-><c- p>)</c->
    encrypt<c- p>(</c->e<c- p>.</c->ports<c- p>[</c-><c- mi>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>&quot;decrypt&quot;</c-><c- p>)</c->
    decrypt<c- p>(</c->e<c- p>.</c->ports<c- p>[</c-><c- mi>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>&apos;libcrypto-v2-generator.js&apos;</c-><c- p>);</c->
  generator<c- p>.</c->postMessage<c- p>(</c-><c- t>&apos;&apos;</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>&apos;libcrypto-v2-encryptor.js&apos;</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>&apos;libcrypto-v2-decryptor.js&apos;</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>&apos;onmessage&apos;</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- mi>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- mi>0</c-><c- p>].</c->postMessage<c- p>(</c->k<c- p>[</c-><c- mi>0</c-><c- p>]);</c->
  e<c- p>.</c->ports<c- p>[</c-><c- mi>0</c-><c- p>].</c->postMessage<c- p>(</c->k<c- p>[</c-><c- mi>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- mi>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>&apos;encrypted-&apos;</c-> <c- o>+</c-> k <c- o>+</c-> <c- t>&apos; &apos;</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- mi>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>&apos; &apos;</c-><c- p>)</c-><c- o>+</c-><c- mi>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>&apos;helper.js&apos;</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>&apos;helper.mjs&apos;</c-><c- p>,</c-> <c- p>{</c-> type<c- o>:</c-> <c- u>&quot;module&quot;</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-worker-onmessage><a href=#handler-worker-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://heycam.github.io/webidl/#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>&apos;find-edges&apos;</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-dedicatedworkerglobalscope-onmessage><a href=#handler-dedicatedworkerglobalscope-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" data-export=""><span class=secno>10.1.3.3</span> Shared workers<a href=#shared-workers class=self-link></a></h5>

  <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>&apos;service.js&apos;</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>&apos;some message&apos;</c-><c- p>);</c->
worker<c- p>.</c->port<c- p>.</c->postMessage<c- p>({</c-> foo<c- o>:</c-> <c- t>&apos;structured&apos;</c-><c- p>,</c-> bar<c- o>:</c-> <c- p>[</c-><c- t>&apos;data&apos;</c-><c- p>,</c-> <c- t>&apos;also&apos;</c-><c- p>,</c-> <c- t>&apos;possible&apos;</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>&apos;ready!&apos;</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>There are 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.</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>

  <pre><code class='idl'>[<c- g>Exposed</c->=<c- n>Worker</c->]
<c- b>interface</c-> <dfn id='workerglobalscope'><c- g>WorkerGlobalScope</c-></dfn> : <a href='https://dom.spec.whatwg.org/#interface-eventtarget' data-x-internal='eventtarget' id='the-workerglobalscope-common-interface: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>void</c-> <a href='#dom-workerglobalscope-importscripts' id='the-workerglobalscope-common-interface:dom-workerglobalscope-importscripts'><c- g>importScripts</c-></a>(<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 accomodate
  <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="the-worker's-workers" data-export="">worker set</dfn> (a <a id=the-workerglobalscope-common-interface:set-3 href=https://infra.spec.whatwg.org/#ordered-set data-x-internal=set>set</a> of
  <code id=the-workerglobalscope-common-interface:workerglobalscope-6><a href=#workerglobalscope>WorkerGlobalScope</a></code> objects). It is initially empty and populated when the worker
  creates or obtains further workers.</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-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-8><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-9><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-10><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-11><a href=#workerglobalscope>WorkerGlobalScope</a></code> object has an associated <dfn data-dfn-for=WorkerGlobalScope id=concept-workerglobalscope-https-state data-export="">HTTPS state</dfn>
  (an <a id=the-workerglobalscope-common-interface:https-state-value href=https://fetch.spec.whatwg.org/#concept-https-state-value data-x-internal=https-state-value>HTTPS state value</a>). It is initially "<code>none</code>".</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-referrer-policy data-export="">referrer
  policy</dfn> (a <a id=the-workerglobalscope-common-interface:referrer-policy href=https://w3c.github.io/webappsec-referrer-policy/#referrer-policy data-x-internal=referrer-policy>referrer policy</a>). It is initially the empty string.</p>

  <p>A <code id=the-workerglobalscope-common-interface:workerglobalscope-13><a href=#workerglobalscope>WorkerGlobalScope</a></code> object has an associated <dfn data-dfn-for=WorkerGlobalScope id=concept-workerglobalscope-csp-list data-export="">CSP list</dfn>, which
  is a <a href=https://w3c.github.io/webappsec-csp/#csp-list id=the-workerglobalscope-common-interface:concept-csp-list data-x-internal=concept-csp-list>CSP list</a> containing all of the <a id=the-workerglobalscope-common-interface:content-security-policy href=https://w3c.github.io/webappsec-csp/#content-security-policy-object data-x-internal=content-security-policy>Content Security
  Policy</a> objects active for the worker. It is initially an empty list.</p>

  <p>A <code id=the-workerglobalscope-common-interface:workerglobalscope-14><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>

  

  <dl class=domintro><dt><var>workerGlobal</var> . <code id=dom-workerglobalscope-self-dev><a href=#dom-workerglobalscope-self>self</a></code><dd>Returns <var>workerGlobal</var>.<dt><var>workerGlobal</var> . <code id=dom-workerglobalscope-location-dev><a href=#dom-workerglobalscope-location>location</a></code><dd>Returns <var>workerGlobal</var>'s <code id=the-workerglobalscope-common-interface:workerlocation-2><a href=#workerlocation>WorkerLocation</a></code> object.<dt><var>workerGlobal</var> . <code id=dom-worker-navigator-dev><a href=#dom-worker-navigator>navigator</a></code><dd>Returns <var>workerGlobal</var>'s <code id=the-workerglobalscope-common-interface:workernavigator-2><a href=#workernavigator>WorkerNavigator</a></code> object.<dt><var>workerGlobal</var> . <code id=dom-workerglobalscope-importscripts-dev><a href=#dom-workerglobalscope-importscripts>importScripts</a></code>(<var>urls</var>...)<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).</dl>

  

  <p>The <dfn id=dom-workerglobalscope-self><code>self</code></dfn> attribute must return the
  <code id=the-workerglobalscope-common-interface:workerglobalscope-15><a href=#workerglobalscope>WorkerGlobalScope</a></code> object itself.</p>

  <p>The <dfn id=dom-workerglobalscope-location><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-16><a href=#workerglobalscope>WorkerGlobalScope</a></code> object.</p>

  <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-17><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-18><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><a href=#event-handler-event-type id=the-workerglobalscope-common-interface:event-handler-event-type-2>Event handler event type</a>
   <tbody><tr><td><dfn id=handler-workerglobalscope-onerror><code>onerror</code></dfn> <td> <code id=the-workerglobalscope-common-interface:event-error><a href=#event-error>error</a></code>
    <tr><td><dfn id=handler-workerglobalscope-onlanguagechange><code>onlanguagechange</code></dfn> <td> <code id=the-workerglobalscope-common-interface:event-languagechange><a href=#event-languagechange>languagechange</a></code> 
    <tr><td><dfn id=handler-workerglobalscope-onoffline><code>onoffline</code></dfn> <td> <code id=the-workerglobalscope-common-interface:event-offline><a href=#event-offline>offline</a></code> 
    <tr><td><dfn id=handler-workerglobalscope-ononline><code>ononline</code></dfn> <td> <code id=the-workerglobalscope-common-interface:event-online><a href=#event-online>online</a></code> 
    <tr><td><dfn id=handler-workerglobalscope-onrejectionhandled><code>onrejectionhandled</code></dfn> <td> <code id=the-workerglobalscope-common-interface:event-rejectionhandled><a href=#event-rejectionhandled>rejectionhandled</a></code>
    <tr><td><dfn id=handler-workerglobalscope-onunhandledrejection><code>onunhandledrejection</code></dfn> <td> <code id=the-workerglobalscope-common-interface:event-unhandledrejection><a href=#event-unhandledrejection>unhandledrejection</a></code>
  </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>

  <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'><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>void</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>optional</c-> <c- b>sequence</c->&lt;<a href='https://heycam.github.io/webidl/#idl-object' data-x-internal='idl-object' id='dedicated-workers-and-the-dedicatedworkerglobalscope-interface:idl-object'><c- b>object</c-></a>&gt; <c- g>transfer</c-> = []);

  <c- b>void</c-> <a href='#dom-dedicatedworkerglobalscope-close' id='dedicated-workers-and-the-dedicatedworkerglobalscope-interface:dom-dedicatedworkerglobalscope-close'><c- g>close</c-></a>();

  <c- b>attribute</c-> <a href='#eventhandler' id='dedicated-workers-and-the-dedicatedworkerglobalscope-interface:eventhandler'><c- n>EventHandler</c-></a> <a href='#handler-dedicatedworkerglobalscope-onmessage' id='dedicated-workers-and-the-dedicatedworkerglobalscope-interface:handler-dedicatedworkerglobalscope-onmessage'><c- g>onmessage</c-></a>;
  <c- b>attribute</c-> <a href='#eventhandler' id='dedicated-workers-and-the-dedicatedworkerglobalscope-interface:eventhandler-2'><c- n>EventHandler</c-></a> <a href='#handler-dedicatedworkerglobalscope-onmessageerror' id='dedicated-workers-and-the-dedicatedworkerglobalscope-interface:handler-dedicatedworkerglobalscope-onmessageerror'><c- g>onmessageerror</c-></a>;
};</code></pre>

  <p><code id=dedicated-workers-and-the-dedicatedworkerglobalscope-interface:dedicatedworkerglobalscope><a href=#dedicatedworkerglobalscope>DedicatedWorkerGlobalScope</a></code> objects act as if they had an implicit
  <code id=dedicated-workers-and-the-dedicatedworkerglobalscope-interface:messageport><a href=#messageport>MessagePort</a></code> associated with them. 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-2><a href=#dedicatedworkerglobalscope>DedicatedWorkerGlobalScope</a></code> object.</p>

  <p>All messages received by that port must immediately be retargeted at the
  <code id=dedicated-workers-and-the-dedicatedworkerglobalscope-interface:dedicatedworkerglobalscope-3><a href=#dedicatedworkerglobalscope>DedicatedWorkerGlobalScope</a></code> object.</p>

  <dl class=domintro><dt><var>dedicatedWorkerGlobal</var> . <code id=dom-dedicatedworkerglobalscope-name-dev><a href=#dom-dedicatedworkerglobalscope-name>name</a></code><dd>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.<dt><var>dedicatedWorkerGlobal</var> . <code id=dom-dedicatedworkerglobalscope-postmessage-dev><a href=#dom-dedicatedworkerglobalscope-postmessage>postMessage</a></code>(<var>message</var> [,
   <var>transfer</var> ])<dd>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.<dt><var>dedicatedWorkerGlobal</var> . <code id=dom-dedicatedworkerglobalscope-close-dev><a href=#dom-dedicatedworkerglobalscope-close>close</a></code>()<dd>Aborts <var>dedicatedWorkerGlobal</var>.</dl>

  

  <p>The <dfn id=dom-dedicatedworkerglobalscope-name><code>name</code></dfn> attribute must
  return the <code id=dedicated-workers-and-the-dedicatedworkerglobalscope-interface:dedicatedworkerglobalscope-4><a href=#dedicatedworkerglobalscope>DedicatedWorkerGlobalScope</a></code> object'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>

  <p>The <dfn id=dom-dedicatedworkerglobalscope-postmessage><code>postMessage()</code></dfn>
  method on <code id=dedicated-workers-and-the-dedicatedworkerglobalscope-interface:dedicatedworkerglobalscope-5><a href=#dedicatedworkerglobalscope>DedicatedWorkerGlobalScope</a></code> objects must act as if, when invoked, it
  immediately invoked <a href=#dom-messageport-postmessage id=dedicated-workers-and-the-dedicatedworkerglobalscope-interface:dom-messageport-postmessage>the method of the same name</a>
  on the port, with the same arguments, and returned the same return value.</p>

  <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=#event-loop id=dedicated-workers-and-the-dedicatedworkerglobalscope-interface:event-loop>event loop</a>'s <a href=#task-queue id=dedicated-workers-and-the-dedicatedworkerglobalscope-interface:task-queue>task
   queues</a>.</p>

   <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.)</ol>

  <p>The <dfn id=dom-dedicatedworkerglobalscope-close><code>close()</code></dfn> method, when
  invoked, must <a href=#close-a-worker id=dedicated-workers-and-the-dedicatedworkerglobalscope-interface:close-a-worker>close a worker</a> with this <code id=dedicated-workers-and-the-dedicatedworkerglobalscope-interface:dedicatedworkerglobalscope-6><a href=#dedicatedworkerglobalscope>DedicatedWorkerGlobalScope</a></code>
  object.</p>

  <hr>

  

  <p>The following are the <a href=#event-handlers id=dedicated-workers-and-the-dedicatedworkerglobalscope-interface:event-handlers>event handlers</a> (and their corresponding <a href=#event-handler-event-type id=dedicated-workers-and-the-dedicatedworkerglobalscope-interface:event-handler-event-type>event handler event types</a>) that must be supported,
  as <a href=#event-handler-idl-attributes id=dedicated-workers-and-the-dedicatedworkerglobalscope-interface:event-handler-idl-attributes>event handler IDL attributes</a>, by objects implementing the
  <code id=dedicated-workers-and-the-dedicatedworkerglobalscope-interface:dedicatedworkerglobalscope-7><a href=#dedicatedworkerglobalscope>DedicatedWorkerGlobalScope</a></code> interface:</p>

  <table><thead><tr><th><a href=#event-handlers id=dedicated-workers-and-the-dedicatedworkerglobalscope-interface:event-handlers-2>Event handler</a> <th><a href=#event-handler-event-type id=dedicated-workers-and-the-dedicatedworkerglobalscope-interface:event-handler-event-type-2>Event handler event type</a>
   <tbody><tr><td><dfn id=handler-dedicatedworkerglobalscope-onmessage><code>onmessage</code></dfn> <td> <code id=dedicated-workers-and-the-dedicatedworkerglobalscope-interface:event-message><a href=#event-message>message</a></code>
    <tr><td><dfn id=handler-dedicatedworkerglobalscope-onmessageerror><code>onmessageerror</code></dfn> <td> <code id=dedicated-workers-and-the-dedicatedworkerglobalscope-interface:event-messageerror><a href=#event-messageerror>messageerror</a></code>
  </table>

  <p>For the purposes of the <a href=#application-cache id=dedicated-workers-and-the-dedicatedworkerglobalscope-interface:application-cache>application cache</a> networking model, a dedicated worker is
  an extension of the <a href=#cache-host id=dedicated-workers-and-the-dedicatedworkerglobalscope-interface:cache-host>cache host</a> from which it was created.</p>



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

  <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'><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>void</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 an associated <dfn data-dfn-for=SharedWorkerGlobalScope id=concept-sharedworkerglobalscope-constructor-origin>constructor origin</dfn>, and <dfn data-dfn-for=SharedWorkerGlobalScope id=concept-sharedworkerglobalscope-constructor-url>constructor url</dfn>. 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><var>sharedWorkerGlobal</var> . <code id=dom-sharedworkerglobalscope-name-dev><a href=#dom-sharedworkerglobalscope-name>name</a></code><dd>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.<dt><var>sharedWorkerGlobal</var> . <code id=dom-sharedworkerglobalscope-close-dev><a href=#dom-sharedworkerglobalscope-close>close</a></code>()<dd>Aborts <var>sharedWorkerGlobal</var>.</dl>

  

  <p>The <dfn id=dom-sharedworkerglobalscope-name><code>name</code></dfn> attribute must
  return the <code id=shared-workers-and-the-sharedworkerglobalscope-interface:sharedworkerglobalscope-5><a href=#sharedworkerglobalscope>SharedWorkerGlobalScope</a></code> object'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>

  <p>The <dfn id=dom-sharedworkerglobalscope-close><code>close()</code></dfn> method, when
  invoked, must <a href=#close-a-worker id=shared-workers-and-the-sharedworkerglobalscope-interface:close-a-worker>close a worker</a> with this <code id=shared-workers-and-the-sharedworkerglobalscope-interface:sharedworkerglobalscope-6><a href=#sharedworkerglobalscope>SharedWorkerGlobalScope</a></code>
  object.</p>

  <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-7><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><a href=#event-handler-event-type id=shared-workers-and-the-sharedworkerglobalscope-interface:event-handler-event-type-2>Event handler event type</a>
   <tbody><tr><td><dfn id=handler-sharedworkerglobalscope-onconnect><code>onconnect</code></dfn> <td> <code id=shared-workers-and-the-sharedworkerglobalscope-interface:event-workerglobalscope-connect-2><a href=#event-workerglobalscope-connect>connect</a></code>
  </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>Each <code id=worker-event-loop:workerglobalscope><a href=#workerglobalscope>WorkerGlobalScope</a></code> object has a distinct <a href=#event-loop id=worker-event-loop:event-loop>event loop</a>, separate
  from those used by <a href=#unit-of-related-similar-origin-browsing-contexts id=worker-event-loop:unit-of-related-similar-origin-browsing-contexts>units of related
  similar-origin browsing contexts</a>. This <a href=#event-loop id=worker-event-loop:event-loop-2>event loop</a> has no associated
  <a href=#browsing-context id=worker-event-loop:browsing-context>browsing context</a>, and its <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=#event-loop id=worker-event-loop:event-loop-3>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-2><a href=#workerglobalscope>WorkerGlobalScope</a></code> object also has a <dfn data-dfn-for=WorkerGlobalScope id=dom-workerglobalscope-closing data-dfn-type=dfn 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>

  <p>Once the <code id=worker-event-loop:workerglobalscope-3><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-4>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>



  

  <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 <a href=#browsing-context id="the-worker's-lifetime:browsing-context">browsing
  contexts</a> 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>

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

  <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> specifies a <a href=#concept-settings-object-global id="the-worker's-lifetime:concept-settings-object-global-2">global
  object</a> that 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
  worker), then the relevant owner is that global object. Otherwise, <var>o</var> specifies a <a href=#concept-settings-object-global id="the-worker's-lifetime:concept-settings-object-global-3">global object</a> that is a <code id="the-worker's-lifetime:window"><a href=#window>Window</a></code> object,
  and the relevant owner is the <a href=#responsible-document id="the-worker's-lifetime:responsible-document">responsible document</a> specified by <var>o</var>.</p>

  <hr>

  <p>A worker is said to be a <dfn id=permissible-worker>permissible worker</dfn> if its <code id="the-worker's-lifetime:workerglobalscope-3"><a href=#workerglobalscope>WorkerGlobalScope</a></code>'s
  <a href=#concept-WorkerGlobalScope-owner-set id="the-worker's-lifetime:concept-WorkerGlobalScope-owner-set">owner set</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> or:</p>

  <ul class=brief><li>its <a href=#concept-WorkerGlobalScope-owner-set id="the-worker's-lifetime:concept-WorkerGlobalScope-owner-set-2">owner set</a> has been <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> for no more
   than a short user-agent-defined timeout value,<li>its <code id="the-worker's-lifetime:workerglobalscope-4"><a href=#workerglobalscope>WorkerGlobalScope</a></code> object is a <code id="the-worker's-lifetime:sharedworkerglobalscope"><a href=#sharedworkerglobalscope>SharedWorkerGlobalScope</a></code> object
   (i.e., the worker is a shared worker), and<li>the user agent has a <a href=#browsing-context id="the-worker's-lifetime:browsing-context-2">browsing context</a> whose <code id="the-worker's-lifetime:document"><a href=#document>Document</a></code> object is not
   <a href=#completely-loaded id="the-worker's-lifetime:completely-loaded">completely loaded</a>.</ul>

  <p class=note>The second part of this definition allows a shared worker to survive for a short
  time while a page is loading, in case that page is going to contact the shared worker again. This
  can be used by user agents as a way to 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>A worker is said to be an <dfn id=active-needed-worker>active needed worker</dfn> if any its <a href=#concept-WorkerGlobalScope-owner-set id="the-worker's-lifetime:concept-WorkerGlobalScope-owner-set-3">owners</a> are either <code id="the-worker's-lifetime:document-2"><a href=#document>Document</a></code> objects that are <a href=#fully-active id="the-worker's-lifetime:fully-active">fully active</a> or
  <a href=#active-needed-worker id="the-worker's-lifetime:active-needed-worker">active needed workers</a>.</p>

  <p>A worker is said to be a <dfn id=protected-worker>protected worker</dfn> if it is an <a href=#active-needed-worker id="the-worker's-lifetime:active-needed-worker-2">active needed
  worker</a> and either it has outstanding timers, database transactions, or network connections,
  or its list of <a href="#the-worker's-ports" id="the-worker's-lifetime:the-worker's-ports">the worker's ports</a> is not empty, or its <code id="the-worker's-lifetime:workerglobalscope-5"><a href=#workerglobalscope>WorkerGlobalScope</a></code>
  is actually a <code id="the-worker's-lifetime:sharedworkerglobalscope-2"><a href=#sharedworkerglobalscope>SharedWorkerGlobalScope</a></code> object (i.e. the worker is a shared
  worker).</p>

  <p>A worker is said to be a <dfn id=suspendable-worker>suspendable worker</dfn> if it is not an <a href=#active-needed-worker id="the-worker's-lifetime:active-needed-worker-3">active needed
  worker</a> but it is a <a href=#permissible-worker id="the-worker's-lifetime:permissible-worker">permissible worker</a>.</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>

  <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 id=worker-processing-model-top>

    <p>Create a separate parallel execution environment (i.e. a separate thread or process or
    equivalent construct), and run the rest of these steps in that context.</p>

    <p>For the purposes of timing APIs, this is the <dfn id=official-moment-of-creation data-export="">official moment of
    creation</dfn> of the worker.</p>

   <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.<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>.<li><p>Let <var>parent worker global scope</var> be null.</p>

   <li><p>If <var>owner</var> is a <code id=worker-processing-model:workerglobalscope><a href=#workerglobalscope>WorkerGlobalScope</a></code> object (i.e., we are creating a
   nested worker), then set <var>parent worker global scope</var> to <var>owner</var>.<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 JavaScript
    realm</a> with 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.</ul>
   <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 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><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> and <var>outside settings</var>, and let <var>inside settings</var> be the
   result.<li><p>Set <var>worker global scope</var>'s <a href=#concept-workerglobalscope-name id=worker-processing-model:concept-workerglobalscope-name>name</a> to the value of <var>options</var>'s
   <code>name</code> member.<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>.<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>.</ol>
   <li><p>Let <var>destination</var> be "<code>sharedworker</code>" if <var>is
   shared</var> is true, and "<code>worker</code>" otherwise.<li>
    <p>Obtain <var>script</var> by switching on the value of <var>options</var>'s <code>type</code> member:</p>

    <dl class=switch><dt>"<code>classic</code>"<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>, and <var>inside settings</var>.<dt>"<code>module</code>"<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>, and <var>inside settings</var>.</dl>

    <p>In both cases, to <a href=#fetching-scripts-perform-fetch id=worker-processing-model:fetching-scripts-perform-fetch>perform the fetch</a>
    given <var>request</var>, perform the following steps if the <var id=worker-processing-model:fetching-scripts-is-top-level><a href=#fetching-scripts-is-top-level>is top-level</a></var> flag is set:</p>

    <ol><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><p><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>, and asynchronously wait
     to run the remaining steps as part of fetch's <a id=worker-processing-model:process-response href=https://fetch.spec.whatwg.org/#process-response data-x-internal=process-response>process response</a> for the <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>.<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>.<li><p>Set <var>worker global scope</var>'s <a href=#concept-workerglobalscope-https-state id=worker-processing-model:concept-workerglobalscope-https-state>HTTPS state</a> to <var>response</var>'s
     <a href=https://fetch.spec.whatwg.org/#concept-response-https-state id=worker-processing-model:concept-response-https-state data-x-internal=concept-response-https-state>HTTPS state</a>.<li><p>Set <var>worker global scope</var>'s <a href=#concept-workerglobalscope-referrer-policy id=worker-processing-model:concept-workerglobalscope-referrer-policy>referrer policy</a> to the result of
     <a href=https://w3c.github.io/webappsec-referrer-policy/#parse-referrer-policy-from-header id=worker-processing-model:parse-referrer-policy-header data-x-internal=parse-referrer-policy-header>parsing the `<code>Referrer-Policy</code>`
     header</a> of <var>response</var>.<li><p>Execute the <a id="worker-processing-model:initialize-a-global-object's-csp-list" href=https://w3c.github.io/webappsec-csp/#initialize-global-object-csp data-x-internal="initialize-a-global-object's-csp-list">Initialize a <code>global object</code>'s CSP list</a>
     algorithm on <var>worker global scope</var> and <var>response</var>. <a href=#refsCSP>[CSP]</a><li><p>Asynchronously complete the <a href=#fetching-scripts-perform-fetch id=worker-processing-model:fetching-scripts-perform-fetch-2>perform the
     fetch</a> steps with <var>response</var>.</ol>

    <p>If the algorithm asynchronously completes with null, then:</p>
    <ol><li><p><a href=#queue-a-task id=worker-processing-model:queue-a-task>Queue a task</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>.<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>.<li><p>Return.</ol>

    <p>Otherwise, continue the rest of these steps after the algorithm's asynchronous completion,
    with <var>script</var> being the asynchronous completion value.</p>
   <li><p>Associate <var>worker</var> with <var>worker global scope</var>.<li><p><a href=#create-a-new-messageport-object id=worker-processing-model:create-a-new-messageport-object>Create a new <code>MessagePort</code> object</a> whose <a href=#concept-port-owner id=worker-processing-model:concept-port-owner>owner</a> is <var>inside settings</var>. Let <var>inside
   port</var> be this new object.<li><p>Associate <var>inside port</var> with <var>worker global scope</var>.<li><p><a href=#entangle id=worker-processing-model:entangle>Entangle</a> <var>outside port</var> and <var>inside port</var>.<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>.<li><p>If <var>parent worker global scope</var> is not null, then <a href=https://infra.spec.whatwg.org/#set-append id=worker-processing-model:set-append-2 data-x-internal=set-append>append</a> <var>worker global scope</var> to <var>parent worker global scope</var>'s
   <a href="#the-worker's-workers" id="worker-processing-model:the-worker's-workers">worker set</a>.<li><p>Set <var>worker global scope</var>'s <a href=#concept-workerglobalscope-type id=worker-processing-model:concept-workerglobalscope-type>type</a> to the value of the <code>type</code> member of <var>options</var>.<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>

    <p><strong>Closing orphan workers</strong>: Start monitoring the worker such that no sooner than
    it stops being a <a href=#protected-worker id=worker-processing-model:protected-worker>protected worker</a>, and no later than it stops being a
    <a href=#permissible-worker id=worker-processing-model:permissible-worker>permissible worker</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>

    <p><strong>Suspending workers</strong>: Start monitoring the worker, 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 the worker is a <a href=#suspendable-worker id=worker-processing-model:suspendable-worker>suspendable worker</a>, the user agent suspends
    execution of script in that worker 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 the worker stops
    being a <a href=#suspendable-worker id=worker-processing-model:suspendable-worker-2>suspendable worker</a>.</p>

   <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>.<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><p>Enable <var>outside port</var>'s <a href=#port-message-queue id=worker-processing-model:port-message-queue>port message queue</a>.<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.<li><p>If <var>is shared</var> is true, then <a href=#queue-a-task id=worker-processing-model:queue-a-task-2>queue a task</a>, using the <a href=#dom-manipulation-task-source id=worker-processing-model:dom-manipulation-task-source>DOM
   manipulation task source</a>, 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://heycam.github.io/webidl/#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>.<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>.<li>

    <p><strong>Event loop</strong>: 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>

    <p>Empty the <var>worker global scope</var>'s <a href=#list-of-active-timers id=worker-processing-model:list-of-active-timers>list of active timers</a>.</p>

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

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

   </ol>

  <hr>

  <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-2><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.<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-3><a href=#workerglobalscope>WorkerGlobalScope</a></code> object's <a href=#event-loop id=worker-processing-model:event-loop-3>event loop</a>'s <a href=#task-queue id=worker-processing-model:task-queue>task
   queues</a>, discard them without processing them.<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.<li><p>If the worker's <code id=worker-processing-model:workerglobalscope-4><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.</ol>

  <p>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
  an <a href=#active-needed-worker id=worker-processing-model:active-needed-worker>active needed worker</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>

  <hr>

  <p>The <a href=#task-source id=worker-processing-model:task-source>task source</a> for the tasks mentioned above is the <a href=#dom-manipulation-task-source id=worker-processing-model:dom-manipulation-task-source-2>DOM manipulation task
  source</a>.</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>

  <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 must
   <a href=#report-the-error id=runtime-script-errors-2:report-the-error>report the error</a> for that <a href=#concept-script id=runtime-script-errors-2:concept-script>script</a>, with the position (line number and column number) where the
  error occurred, using the <code id=runtime-script-errors-2:workerglobalscope><a href=#workerglobalscope>WorkerGlobalScope</a></code> object as the target.</p>

  <p>For shared workers, if the error is still <i id=runtime-script-errors-2:concept-error-nothandled><a href=#concept-error-nothandled>not handled</a></i>
  afterwards, the error may be reported to a developer console.</p>

  <p>For dedicated workers, if the error is still <i id=runtime-script-errors-2:concept-error-nothandled-2><a href=#concept-error-nothandled>not
  handled</a></i> afterwards, the user agent must <a href=#queue-a-task id=runtime-script-errors-2:queue-a-task>queue a
  task</a> to run these steps:</p>

  

  <ol><li><p>Let <var>notHandled</var> be the result of <a href=https://dom.spec.whatwg.org/#concept-event-fire id=runtime-script-errors-2:concept-event-fire data-x-internal=concept-event-fire>firing an
   event</a> named <code id=runtime-script-errors-2:event-error><a href=#event-error>error</a></code> at the <code id=runtime-script-errors-2:worker><a href=#worker>Worker</a></code> object
   associated with the worker, using <code id=runtime-script-errors-2:errorevent><a href=#errorevent>ErrorEvent</a></code>, with the <code id=runtime-script-errors-2: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=runtime-script-errors-2:dom-errorevent-message><a href=#dom-errorevent-message>message</a></code>, <code id=runtime-script-errors-2:dom-errorevent-filename><a href=#dom-errorevent-filename>filename</a></code>, <code id=runtime-script-errors-2:dom-errorevent-lineno><a href=#dom-errorevent-lineno>lineno</a></code>, and <code id=runtime-script-errors-2:dom-errorevent-colno><a href=#dom-errorevent-colno>colno</a></code> attributes initialized appropriately, and the <code id=runtime-script-errors-2:dom-errorevent-error><a href=#dom-errorevent-error>error</a></code> attribute initialized to null.<li><p>If <var>notHandled</var> is true, then the user agent must act as if the uncaught runtime
   script error had occurred in the global scope that the <code id=runtime-script-errors-2:worker-2><a href=#worker>Worker</a></code> object is in, thus
   repeating the entire runtime script error reporting process one level up.</ol>

  <p>If the implicit port connecting the worker to its <code id=runtime-script-errors-2: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-2:worker-4><a href=#worker>Worker</a></code> object had no <code id=runtime-script-errors-2:event-error-2><a href=#event-error>error</a></code> event handler and as
  if that worker's <code id=runtime-script-errors-2: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-2:document><a href=#document>Document</a></code>, even if some of the
  workers along this chain have been terminated and garbage collected.</p>

  <p>The <a href=#task-source id=runtime-script-errors-2:task-source>task source</a> for the task mentioned above is the <a href=#dom-manipulation-task-source id=runtime-script-errors-2:dom-manipulation-task-source>DOM manipulation
  task source</a>.</p>


  <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'><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><a href=#event-handler-event-type id=the-abstractworker-mixin:event-handler-event-type-2>Event handler event type</a>
   <tbody><tr><td><dfn id=handler-abstractworker-onerror><code>onerror</code></dfn> <td> <code id=the-abstractworker-mixin:event-error><a href=#event-error>error</a></code>
  </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>

  <p>When the user agent is required 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.github.io/ecma262/#sec-execution-contexts data-x-internal=javascript-execution-context>JavaScript execution context</a> <var>execution context</var> and
  <a href=#environment-settings-object id=script-settings-for-workers:environment-settings-object>environment settings object</a> <var>outside settings</var>, it must run the following
  steps:</p>

  <ol><li><p>Let <var>inherited responsible browsing context</var> be <var>outside settings</var>'s
   <a href=#responsible-browsing-context id=script-settings-for-workers:responsible-browsing-context>responsible browsing context</a>.<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>.<li><p>Let <var>worker event loop</var> be a newly created <a href=#event-loop id=script-settings-for-workers:event-loop>event
   loop</a>.<li><p>Let <var>realm</var> be the value of <var>execution context</var>'s Realm
   component.<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>.<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><dd>

      <p>Return <var>execution context</var>.

     <dt>The <a href=#concept-settings-object-module-map id=script-settings-for-workers:concept-settings-object-module-map>module map</a><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>

     <dt>The <a href=#responsible-browsing-context id=script-settings-for-workers:responsible-browsing-context-2>responsible browsing context</a><dd>

      <p>Return <var>inherited responsible browsing context</var>.</p>

     <dt>The <a href=#responsible-event-loop id=script-settings-for-workers:responsible-event-loop>responsible event loop</a><dd>

      <p>Return <var>worker event loop</var>.</p>

     <dt>The <a href=#responsible-document id=script-settings-for-workers:responsible-document>responsible document</a><dd>

      <p>Not applicable (the <a href=#responsible-event-loop id=script-settings-for-workers:responsible-event-loop-2>responsible event loop</a> is not a <a href=#browsing-context id=script-settings-for-workers:browsing-context>browsing context</a>
      <a href=#event-loop id=script-settings-for-workers:event-loop-2>event loop</a>).</p>

     <dt>The <a href=#api-url-character-encoding id=script-settings-for-workers:api-url-character-encoding>API URL character encoding</a><dd>

      <p>Return <a id=script-settings-for-workers:utf-8 href=https://encoding.spec.whatwg.org/#utf-8 data-x-internal=utf-8>UTF-8</a>.</p>

     <dt>The <a href=#api-base-url id=script-settings-for-workers:api-base-url>API base URL</a><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>

     <dt>The <a href=#concept-settings-object-origin id=script-settings-for-workers:concept-settings-object-origin-2>origin</a><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>

     <dt>The <a href=#https-state id=script-settings-for-workers:https-state>HTTPS state</a><dd>

      <p>Return <var>worker global scope</var>'s <a href=#concept-workerglobalscope-https-state id=script-settings-for-workers:concept-workerglobalscope-https-state>HTTPS state</a>.</p>

     <dt>The <a href=#concept-settings-object-referrer-policy id=script-settings-for-workers:concept-settings-object-referrer-policy>referrer policy</a><dd>

      <p>Return <var>worker global scope</var>'s <a href=#concept-workerglobalscope-referrer-policy id=script-settings-for-workers:concept-workerglobalscope-referrer-policy>referrer policy</a>.</p>

     </dl>

   <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, <var>settings object</var>'s <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>, <var>settings object</var>'s <a href=#concept-environment-target-browsing-context id=script-settings-for-workers:concept-environment-target-browsing-context>target browsing context</a> to null, and
   <var>settings object</var>'s <a href=#concept-environment-active-service-worker id=script-settings-for-workers:concept-environment-active-service-worker>active
   service worker</a> to null.<li><p>Set <var>realm</var>'s [[HostDefined]] field to <var>settings object</var>.<li><p>Return <var>settings object</var>.</ol>
  


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

  <pre><code class='idl'>[<a href='#dom-worker' id='dedicated-workers-and-the-worker-interface:dom-worker'><c- g>Constructor</c-></a>(<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- g>Exposed</c->=(<c- n>Window</c->,<c- n>Worker</c->)]
<c- b>interface</c-> <dfn id='worker'><c- g>Worker</c-></dfn> : <a href='https://dom.spec.whatwg.org/#interface-eventtarget' data-x-internal='eventtarget' id='dedicated-workers-and-the-worker-interface:eventtarget'><c- n>EventTarget</c-></a> {
  <c- b>void</c-> <a href='#dom-worker-terminate' id='dedicated-workers-and-the-worker-interface:dom-worker-terminate'><c- g>terminate</c-></a>();

  <c- b>void</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>optional</c-> <c- b>sequence</c->&lt;<a href='https://heycam.github.io/webidl/#idl-object' data-x-internal='idl-object' id='dedicated-workers-and-the-worker-interface:idl-object'><c- b>object</c-></a>&gt; <c- g>transfer</c-> = []);
  <c- b>attribute</c-> <a href='#eventhandler' id='dedicated-workers-and-the-worker-interface:eventhandler'><c- n>EventHandler</c-></a> <a href='#handler-worker-onmessage' id='dedicated-workers-and-the-worker-interface:handler-worker-onmessage'><c- g>onmessage</c-></a>;
  <c- b>attribute</c-> <a href='#eventhandler' id='dedicated-workers-and-the-worker-interface:eventhandler-2'><c- n>EventHandler</c-></a> <a href='#handler-worker-onmessageerror' id='dedicated-workers-and-the-worker-interface:handler-worker-onmessageerror'><c- g>onmessageerror</c-></a>;
};

<c- b>dictionary</c-> <dfn id='workeroptions'><c- g>WorkerOptions</c-></dfn> {
  <a href='#workertype' id='dedicated-workers-and-the-worker-interface:workertype'><c- n>WorkerType</c-></a> <c- g>type</c-> = &quot;classic&quot;;
  <a href='https://fetch.spec.whatwg.org/#requestcredentials' data-x-internal='requestcredentials' id='dedicated-workers-and-the-worker-interface:requestcredentials'><c- n>RequestCredentials</c-></a> <c- g>credentials</c-> = &quot;omit&quot;; // credentials is only used if type is &quot;module&quot;
  <c- b>DOMString</c-> <c- g>name</c-> = &quot;&quot;;
};

<c- b>enum</c-> <dfn id='workertype'><c- g>WorkerType</c-></dfn> { <c- s>&quot;classic&quot;</c->, <c- s>&quot;module&quot;</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>;</code></pre>

  <dl class=domintro><dt><var>worker</var> = new <code id=dom-worker-dev><a href=#dom-worker>Worker</a></code>(<var>scriptURL</var> [, <var>options</var> ])<dd>Returns a new <code id=dedicated-workers-and-the-worker-interface:worker-2><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. <var>options</var> 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 via the <code>name</code> option, primarily for debugging purposes. It can also ensure this new
   global environment supports JavaScript modules (specify <code>type: "module"</code>),
   and if that is specified, can also be used to specify how <var>scriptURL</var> is fetched through
   the <code>credentials</code> option.

   <dt><var>worker</var> . <code id=dom-worker-terminate-dev><a href=#dom-worker-terminate>terminate</a></code>()<dd>Aborts <var>worker</var>'s associated global environment.<dt><var>worker</var> . <code id=dom-worker-postmessage-dev><a href=#dom-worker-postmessage>postMessage</a></code>(<var>message</var> [, <var>transfer</var> ])
   <dd>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.</dl>

  

  <p>The <dfn id=dom-worker-terminate><code>terminate()</code></dfn> method, when invoked,
  must cause the <a href=#terminate-a-worker id=dedicated-workers-and-the-worker-interface:terminate-a-worker>terminate a worker</a> algorithm to be run on the worker with which the
  object is associated.</p>

  <p><code id=dedicated-workers-and-the-worker-interface:worker-3><a href=#worker>Worker</a></code> objects act as if they had an implicit <code id=dedicated-workers-and-the-worker-interface:messageport><a href=#messageport>MessagePort</a></code> associated
  with them. 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-4><a href=#worker>Worker</a></code> object.</p>

  <p>All messages received by that port must immediately be retargeted at the <code id=dedicated-workers-and-the-worker-interface:worker-5><a href=#worker>Worker</a></code>
  object.</p>

  <p>The <dfn id=dom-worker-postmessage><code>postMessage()</code></dfn> method on
  <code id=dedicated-workers-and-the-worker-interface:worker-6><a href=#worker>Worker</a></code> objects must act as if, when invoked, it immediately invoked <a href=#dom-messageport-postmessage id=dedicated-workers-and-the-worker-interface:dom-messageport-postmessage>the method of the same name</a> on the port, with the same
  arguments, and returned the same return value.</p>

  

  <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>&apos;activate&apos;</c-><c- p>,</c-> device<c- o>:</c-> <c- mi>1938</c-><c- p>,</c-> parameters<c- o>:</c-> <c- p>[</c-><c- mi>23</c-><c- p>,</c-> <c- mi>102</c-><c- p>]});</c-></code></pre>

  </div>

  <p>The following are the <a href=#event-handlers id=dedicated-workers-and-the-worker-interface:event-handlers>event handlers</a> (and their corresponding <a href=#event-handler-event-type id=dedicated-workers-and-the-worker-interface:event-handler-event-type>event handler event types</a>) that must be supported,
  as <a href=#event-handler-idl-attributes id=dedicated-workers-and-the-worker-interface:event-handler-idl-attributes>event handler IDL attributes</a>, by objects implementing the <code id=dedicated-workers-and-the-worker-interface:worker-7><a href=#worker>Worker</a></code>
  interface:</p>

  <table><thead><tr><th><a href=#event-handlers id=dedicated-workers-and-the-worker-interface:event-handlers-2>Event handler</a> <th><a href=#event-handler-event-type id=dedicated-workers-and-the-worker-interface:event-handler-event-type-2>Event handler event type</a>
   <tbody><tr><td><dfn id=handler-worker-onmessage><code>onmessage</code></dfn> <td> <code id=dedicated-workers-and-the-worker-interface:event-message><a href=#event-message>message</a></code>
    <tr><td><dfn id=handler-worker-onmessageerror><code>onmessageerror</code></dfn> <td> <code id=dedicated-workers-and-the-worker-interface:event-messageerror><a href=#event-messageerror>messageerror</a></code>
  </table>

  

  <hr>

  <p>When the <dfn id=dom-worker><code>Worker(<var>scriptURL</var>,
  <var>options</var>)</code></dfn> constructor is invoked, the user agent must run the following
  steps:</p>

  <ol><li><p>The user agent may throw a <a id=dedicated-workers-and-the-worker-interface:securityerror href=https://heycam.github.io/webidl/#securityerror data-x-internal=securityerror>"<code>SecurityError</code>"</a>
   <code id=dedicated-workers-and-the-worker-interface:domexception><a data-x-internal=domexception href=https://heycam.github.io/webidl/#dfn-DOMException>DOMException</a></code> if the request violates a policy decision (e.g. if the user agent is
   configured to not allow the page to start dedicated workers).<li><p>Let <var>outside settings</var> be the <a href=#current-settings-object id=dedicated-workers-and-the-worker-interface:current-settings-object>current settings object</a>.</p>

   <li><p><a href=#parse-a-url id=dedicated-workers-and-the-worker-interface:parse-a-url>Parse</a> the <var>scriptURL</var> argument relative to
   <var>outside settings</var>.<li><p>If this fails, throw a <a id=dedicated-workers-and-the-worker-interface:syntaxerror href=https://heycam.github.io/webidl/#syntaxerror data-x-internal=syntaxerror>"<code>SyntaxError</code>"</a> <code id=dedicated-workers-and-the-worker-interface:domexception-2><a data-x-internal=domexception href=https://heycam.github.io/webidl/#dfn-DOMException>DOMException</a></code>.<li>
    <p>Let <var>worker URL</var> be the <a href=#resulting-url-record id=dedicated-workers-and-the-worker-interface:resulting-url-record>resulting URL record</a>.</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://tools.ietf.org/html/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><p>Let <var>worker</var> be a new <code id=dedicated-workers-and-the-worker-interface:worker-8><a href=#worker>Worker</a></code> object.<li><p><a href=#create-a-new-messageport-object id=dedicated-workers-and-the-worker-interface:create-a-new-messageport-object>Create a new <code>MessagePort</code> object</a> whose <a href=#concept-port-owner id=dedicated-workers-and-the-worker-interface:concept-port-owner>owner</a> is <var>outside settings</var>. Let this be the
   <var>outside port</var>.<li><p>Associate the <var>outside port</var> with <var>worker</var>.<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>worker URL</var>, <var>outside
     settings</var>, <var>outside port</var>, and <var>options</var>.</ol>
   <li><p>Return <var>worker</var>.</ol>

  


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

  <pre><code class='idl'>[<a href='#dom-sharedworker' id='shared-workers-and-the-sharedworker-interface:dom-sharedworker'><c- g>Constructor</c-></a>(<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- g>Exposed</c->=(<c- n>Window</c->,<c- n>Worker</c->)]
<c- b>interface</c-> <dfn id='sharedworker'><c- g>SharedWorker</c-></dfn> : <a href='https://dom.spec.whatwg.org/#interface-eventtarget' data-x-internal='eventtarget' id='shared-workers-and-the-sharedworker-interface:eventtarget'><c- n>EventTarget</c-></a> {
  <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><var>sharedWorker</var> = new <code id=dom-sharedworker-dev><a href=#dom-sharedworker>SharedWorker</a></code>(<var>scriptURL</var> [, <var>name</var> ])<dd>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.<dt><var>sharedWorker</var> = new <code id=shared-workers-and-the-sharedworker-interface:dom-sharedworker-2><a href=#dom-sharedworker>SharedWorker</a></code>(<var>scriptURL</var> [, <var>options</var> ])<dd>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. <var>options</var> 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 via the <code>name</code> option. It can also ensure this new global environment supports JavaScript
   modules (specify <code>type: "module"</code>), and if that is specified, can also be
   used to specify how <var>scriptURL</var> is fetched through the <code>credentials</code> option.<dt><var>sharedWorker</var> . <code id=dom-sharedworker-port-dev><a href=#dom-sharedworker-port>port</a></code><dd>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.</dl>

  

  <p>The <dfn id=dom-sharedworker-port><code>port</code></dfn> attribute must return the value
  it was assigned by the object's constructor. It represents the <code id=shared-workers-and-the-sharedworker-interface:messageport-3><a href=#messageport>MessagePort</a></code> for
  communicating with the shared worker.</p>

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

  <p>When the <dfn id=dom-sharedworker><code>SharedWorker(<var>scriptURL</var>,
  <var>options</var>)</code></dfn> constructor is invoked:</p>

  <ol><li><p>Optionally, throw a <a id=shared-workers-and-the-sharedworker-interface:securityerror href=https://heycam.github.io/webidl/#securityerror data-x-internal=securityerror>"<code>SecurityError</code>"</a> <code id=shared-workers-and-the-sharedworker-interface:domexception><a data-x-internal=domexception href=https://heycam.github.io/webidl/#dfn-DOMException>DOMException</a></code>
   if the request violates a policy decision (e.g. if the user agent is configured to not allow the
   page to start shared workers).<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://heycam.github.io/webidl/#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>name</code> member is set to the value of <var>options</var> and whose other members
   are set to their default values.<li><p>Let <var>outside settings</var> be the <a href=#current-settings-object id=shared-workers-and-the-sharedworker-interface:current-settings-object>current settings object</a>.<li><p><a href=#parse-a-url id=shared-workers-and-the-sharedworker-interface:parse-a-url>Parse</a> <var>scriptURL</var> relative to <var>outside
   settings</var>.<li><p>If this fails, throw a <a id=shared-workers-and-the-sharedworker-interface:syntaxerror href=https://heycam.github.io/webidl/#syntaxerror data-x-internal=syntaxerror>"<code>SyntaxError</code>"</a> <code id=shared-workers-and-the-sharedworker-interface:domexception-2><a data-x-internal=domexception href=https://heycam.github.io/webidl/#dfn-DOMException>DOMException</a></code>.<li>
    <p>Otherwise, let <var>urlRecord</var> be the <a href=#resulting-url-record id=shared-workers-and-the-sharedworker-interface:resulting-url-record>resulting URL record</a>.</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://tools.ietf.org/html/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><p>Let <var>worker</var> be a new <code id=shared-workers-and-the-sharedworker-interface:sharedworker-4><a href=#sharedworker>SharedWorker</a></code> object.<li><p><a href=#create-a-new-messageport-object id=shared-workers-and-the-sharedworker-interface:create-a-new-messageport-object>Create a new <code>MessagePort</code> object</a> whose <a href=#concept-port-owner id=shared-workers-and-the-sharedworker-interface:concept-port-owner>owner</a> is <var>outside settings</var>. Let this be the
   <var>outside port</var>.<li><p>Assign <var>outside port</var> to the <code id=shared-workers-and-the-sharedworker-interface:dom-sharedworker-port-2><a href=#dom-sharedworker-port>port</a></code>
   attribute of <var>worker</var>.<li><p>Let <var>callerIsSecureContext</var> be the result of executing <a id=shared-workers-and-the-sharedworker-interface:is-environment-settings-object-a-secure-context href=https://w3c.github.io/webappsec-secure-contexts/#settings-object data-x-internal=is-environment-settings-object-a-secure-context>Is environment
   settings object a secure context?</a> on <var>outside settings</var>.<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>worker global scope</var> be null.<li>
      <p>If there exists a <code id=shared-workers-and-the-sharedworker-interface:sharedworkerglobalscope><a href=#sharedworkerglobalscope>SharedWorkerGlobalScope</a></code> object whose <a href=#dom-workerglobalscope-closing id=shared-workers-and-the-sharedworker-interface:dom-workerglobalscope-closing>closing</a> flag is false, <a href=#concept-sharedworkerglobalscope-constructor-origin id=shared-workers-and-the-sharedworker-interface:concept-sharedworkerglobalscope-constructor-origin>constructor origin</a> is
      <a href=#same-origin id=shared-workers-and-the-sharedworker-interface:same-origin-2>same origin</a> with <var>outside settings</var>'s <a href=#concept-settings-object-origin id=shared-workers-and-the-sharedworker-interface:concept-settings-object-origin>origin</a>, <a href=#concept-sharedworkerglobalscope-constructor-url id=shared-workers-and-the-sharedworker-interface:concept-sharedworkerglobalscope-constructor-url>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 <a href=#concept-workerglobalscope-name id=shared-workers-and-the-sharedworker-interface:concept-workerglobalscope-name-3>name</a> equals the value of <var>options</var>'s
      <code>name</code> member, then set <var>worker global scope</var> to that
      <code id=shared-workers-and-the-sharedworker-interface:sharedworkerglobalscope-2><a href=#sharedworkerglobalscope>SharedWorkerGlobalScope</a></code> object.</p>

      <p class=note><code id=shared-workers-and-the-sharedworker-interface:data-protocol-2><a data-x-internal=data-protocol href=https://tools.ietf.org/html/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-2>constructor origin</a> and
      <a href=#concept-sharedworkerglobalscope-constructor-url id=shared-workers-and-the-sharedworker-interface:concept-sharedworkerglobalscope-constructor-url-2>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://tools.ietf.org/html/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-3><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-3>same origin</a> restriction.</p>
     <li>
      <p>If <var>worker global scope</var> is not null, but the user agent has been
      configured to disallow communication between the worker represented by the <var>worker global
      scope</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>outside settings</var>, then set <var>worker global
      scope</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-browsing-context id=shared-workers-and-the-sharedworker-interface:top-level-browsing-context>top-level browsing context</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>
      <p>If <var>worker global scope</var> is not null, then run these subsubsteps:</p>

      <ol><li><p>Let <var>settings object</var> be the <a href=#relevant-settings-object id=shared-workers-and-the-sharedworker-interface:relevant-settings-object>relevant settings object</a> for
       <var>worker global scope</var>.<li><p>Let <var>workerIsSecureContext</var> be the result of executing <a id=shared-workers-and-the-sharedworker-interface:is-environment-settings-object-a-secure-context-2 href=https://w3c.github.io/webappsec-secure-contexts/#settings-object data-x-internal=is-environment-settings-object-a-secure-context>Is environment
       settings object a secure context?</a> on <var>settings object</var>.<li><p>If <var>workerIsSecureContext</var> is not <var>callerIsSecureContext</var>, then
       <a href=#queue-a-task id=shared-workers-and-the-sharedworker-interface:queue-a-task>queue a task</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><a href=#event-error>error</a></code> at <var>worker</var> and abort these subsubsteps.
       <a href=#refsSECURE-CONTEXTS>[SECURE-CONTEXTS]</a><li><p>Associate <var>worker</var> with <var>worker global scope</var>.<li><p><a href=#create-a-new-messageport-object id=shared-workers-and-the-sharedworker-interface:create-a-new-messageport-object-2>Create a new <code>MessagePort</code> object</a> whose <a href=#concept-port-owner id=shared-workers-and-the-sharedworker-interface:concept-port-owner-2>owner</a> is <var>settings object</var>. Let this be
       the <var>inside port</var>.<li><p><a href=#entangle id=shared-workers-and-the-sharedworker-interface:entangle>Entangle</a> <var>outside port</var> and <var>inside port</var>.<li><p><a href=#queue-a-task id=shared-workers-and-the-sharedworker-interface:queue-a-task-2>Queue a task</a>, using the <a href=#dom-manipulation-task-source id=shared-workers-and-the-sharedworker-interface:dom-manipulation-task-source>DOM manipulation task source</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-workerglobalscope-connect><a href=#event-workerglobalscope-connect>connect</a></code> at <var>worker global scope</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://heycam.github.io/webidl/#dfn-frozen-array-type data-x-internal=frozen-array>frozen
       array</a> containing only <var>inside port</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>inside
       port</var>.<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>outside settings</var> to <var>worker global scope</var>'s <a href=#concept-WorkerGlobalScope-owner-set id=shared-workers-and-the-sharedworker-interface:concept-WorkerGlobalScope-owner-set>owner
       set</a>.<li><p>If <var>outside settings</var>'s <a href=#concept-settings-object-global id=shared-workers-and-the-sharedworker-interface:concept-settings-object-global>global
       object</a> is a <code id=shared-workers-and-the-sharedworker-interface:workerglobalscope><a href=#workerglobalscope>WorkerGlobalScope</a></code> object, then <a href=https://infra.spec.whatwg.org/#set-append id=shared-workers-and-the-sharedworker-interface:set-append-2 data-x-internal=set-append>append</a> <var>worker global scope</var> to <var>outside settings</var>'s <a href=#concept-settings-object-global id=shared-workers-and-the-sharedworker-interface:concept-settings-object-global-2>global object</a>'s <a href="#the-worker's-workers" id="shared-workers-and-the-sharedworker-interface:the-worker's-workers">worker
       set</a>.</ol>
     <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>outside settings</var>, <var>outside port</var>, and
     <var>options</var>.</ol>
   <li><p>Return <var>worker</var>.</ol>

  


  <h4 id=navigator.hardwareconcurrency><span class=secno>10.2.7</span> Concurrent hardware capabilities<a href=#navigator.hardwareconcurrency class=self-link></a></h4><div class=status><input onclick=toggleStatus(this) value=⋰ type=button><p class=support><strong>Support:</strong> hardwareconcurrency<span class="and_chr yes"><span>Chrome for Android</span> <span>67+</span></span><span class="chrome yes"><span>Chrome</span> <span>37+</span></span><span class="ios_saf yes"><span>iOS Safari</span> <span>10.3+</span></span><span class="and_uc yes"><span>UC Browser for Android</span> <span>11.8+</span></span><span class="firefox yes"><span>Firefox</span> <span>48+</span></span><span class="ie no"><span>IE</span> <span>None</span></span><span class="op_mini no"><span>Opera Mini</span> <span>None</span></span><span class="safari yes"><span>Safari</span> <span>10.1+</span></span><span class="edge yes"><span>Edge</span> <span>15+</span></span><span class="samsung yes"><span>Samsung Internet</span> <span>4+</span></span><span class="opera yes"><span>Opera</span> <span>24+</span></span><span class="android yes"><span>Android Browser</span> <span>67+</span></span><p class=caniuse>Source: <a href="https://caniuse.com/#feat=hardwareconcurrency">caniuse.com</a></div>

  <pre><code class='idl'><c- b>interface</c-> <c- b>mixin</c-> <dfn id='navigatorconcurrenthardware'><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><var>self</var> . <code id=navigator.hardwareconcurrency:dom-navigator><a href=#dom-navigator>navigator</a></code> . <code id=dom-navigator-hardwareconcurrency-dev><a href=#dom-navigator-hardwareconcurrency>hardwareConcurrency</a></code><dd><p>Returns the number of logical processors potentially available to the user agent.</dl>

  

  <p>The <dfn id=dom-navigator-hardwareconcurrency><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.
  <a href=#fingerprinting-vector id=navigator.hardwareconcurrency:fingerprinting-vector class=fingerprint title="There is a potential fingerprinting vector here."><img alt="(This is a fingerprinting vector.)" src=/images/fingerprint.png width=46 height=64></a></p>

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

  <p>When a script invokes the <dfn id=dom-workerglobalscope-importscripts><code>importScripts(<var>urls</var>)</code></dfn> method on
  a <code id=importing-scripts-and-libraries:workerglobalscope><a href=#workerglobalscope>WorkerGlobalScope</a></code> object, the user agent must <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 this <code id=importing-scripts-and-libraries:workerglobalscope-2><a href=#workerglobalscope>WorkerGlobalScope</a></code> object and <var>urls</var>.</p>

  <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-3><a href=#workerglobalscope>WorkerGlobalScope</a></code> object <var>worker global scope</var> and a <code>sequence&lt;DOMString></code> <var>urls</var>, run these steps. The algorithm may
  optionally be customized by supplying custom <a href=#fetching-scripts-perform-fetch id=importing-scripts-and-libraries:fetching-scripts-perform-fetch>perform
  the fetch</a> hooks, which if provided will be used when invoking <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>.</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.github.io/ecma262/#sec-native-error-types-used-in-this-standard-typeerror>TypeError</a></code> exception.<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>.<li><p>If <var>urls</var> is empty, return.<li><p><a href=#parse-a-url id=importing-scripts-and-libraries:parse-a-url>Parse</a> each value in <var>urls</var> relative to
   <var>settings object</var>. If any fail, throw a <a id=importing-scripts-and-libraries:syntaxerror href=https://heycam.github.io/webidl/#syntaxerror data-x-internal=syntaxerror>"<code>SyntaxError</code>"</a>
   <code id=importing-scripts-and-libraries:domexception><a data-x-internal=domexception href=https://heycam.github.io/webidl/#dfn-DOMException>DOMException</a></code>.<li>
    <p>For each <var>url</var> in the <a href=#resulting-url-record id=importing-scripts-and-libraries:resulting-url-record>resulting URL
    records</a>, run these substeps:</p>

    <ol><li><p><a href=#fetch-a-classic-worker-imported-script id=importing-scripts-and-libraries:fetch-a-classic-worker-imported-script-2>Fetch a classic worker-imported script</a> given <var>url</var> and
     <var>settings object</var>, passing along any custom <a href=#fetching-scripts-perform-fetch id=importing-scripts-and-libraries:fetching-scripts-perform-fetch-2>perform the fetch</a> steps provided. If this
     succeeds, let <var>script</var> be the result. Otherwise, rethrow the exception.<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
      the rethrow errors argument 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>

     </ol>

   </ol>

  <p class=note><cite>Service Workers</cite> is an example of a specification that runs this
  algorithm with its own options for the <a href=#fetching-scripts-perform-fetch id=importing-scripts-and-libraries:fetching-scripts-perform-fetch-3>perform the
  fetch</a> hook. <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>

  

  <p>The <dfn id=dom-worker-navigator><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>

  

  <pre><code class='idl'>[<c- g>Exposed</c->=<c- n>Worker</c->]
<c- b>interface</c-> <dfn id='workernavigator'><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>

  <pre><code class='idl'>[<c- g>Exposed</c->=<c- n>Worker</c->]
<c- b>interface</c-> <dfn id='workerlocation'><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>The <dfn id=dom-workerlocation-href><code>href</code></dfn> attribute's getter must
  return the associated <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>

  <p>The <dfn id=dom-workerlocation-origin><code>origin</code></dfn> attribute's getter must
  return the <a href=#ascii-serialisation-of-an-origin id=worker-locations:ascii-serialisation-of-an-origin>serialization</a> of the associated <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>

  <p>The <dfn id=dom-workerlocation-protocol><code>protocol</code></dfn> attribute's getter
  must return the associated <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>

  <p>The <dfn id=dom-workerlocation-host><code>host</code></dfn> attribute's getter must run
  these steps:</p>

  <ol><li><p>Let <var>url</var> be the associated <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>.<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.<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>.<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>.</ol>

  <p>The <dfn id=dom-workerlocation-hostname><code>hostname</code></dfn> attribute's getter
  must run these steps:</p>

  <ol><li><p>Let <var>host</var> be the associated <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>.<li><p>If <var>host</var> is null, return the empty string.<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>.</ol>

  <p>The <dfn id=dom-workerlocation-port><code>port</code></dfn> attribute's getter must run
  these steps:</p>

  <ol><li><p>Let <var>port</var> be the associated <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>.<li><p>If <var>port</var> is null, return the empty string.<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>.</ol>

  <p>The <dfn id=dom-workerlocation-pathname><code>pathname</code></dfn> attribute's getter
  must run these steps:</p>

  <ol><li><p>Let <var>url</var> be the associated <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>.<li><p>If <var>url</var>'s <a id=worker-locations:cannot-be-a-base-url-flag href=https://url.spec.whatwg.org/#url-cannot-be-a-base-url-flag data-x-internal=cannot-be-a-base-url-flag>cannot-be-a-base-URL flag</a> is set, return the first string
   in <var>url</var>'s <a href=https://url.spec.whatwg.org/#concept-url-path id=worker-locations:concept-url-path data-x-internal=concept-url-path>path</a>.<li><p>Return "<code>/</code>", followed by the strings in <var>url</var>'s <a href=https://url.spec.whatwg.org/#concept-url-path id=worker-locations:concept-url-path-2 data-x-internal=concept-url-path>path</a> (including empty strings), separated from each other by
   "<code>/</code>".</ol>

  <p>The <dfn id=dom-workerlocation-search><code>search</code></dfn> attribute's getter must
  run these steps:</p>

  <ol><li><p>Let <var>query</var> be the associated <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>.<li><p>If <var>query</var> is either null or the empty string, return the empty string.<li><p>Return "<code>?</code>", followed by <var>query</var>.</ol>

  <p>The <dfn id=dom-workerlocation-hash><code>hash</code></dfn> attribute's getter must run
  these steps:</p>

  <ol><li><p>Let <var>fragment</var> be the associated <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>.<li><p>If <var>fragment</var> is either null or the empty string, return the empty string.<li><p>Return "<code>#</code>", followed by <var>fragment</var>.</ol>

  




  <h2 id=webstorage><span class=secno>11</span> Web storage<a href=#webstorage class=self-link></a></h2>

  <h3 id=introduction-15><span class=secno>11.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 really noticing.</p>

  <p>To address this, this specification introduces the <code id=introduction-15:dom-sessionstorage><a href=#dom-sessionstorage>sessionStorage</a></code> IDL attribute. 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>&quot;checkbox&quot;</c-> <c- e>onchange</c-><c- o>=</c-><c- s>&quot;sessionStorage.insurance = checked ? &apos;true&apos; : &apos;&apos;&quot;</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> IDL attribute 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>&quot;count&quot;</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- mi>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- mi>1</c-><c- p>;</c->
  document<c- p>.</c->getElementById<c- p>(</c-><c- t>&apos;count&apos;</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>




  <h3 id=storage><span class=secno>11.2</span> The API<a href=#storage class=self-link></a></h3><div class=status><input onclick=toggleStatus(this) value=⋰ type=button><p class=support><strong>Support:</strong> namevalue-storage<span class="and_chr yes"><span>Chrome for Android</span> <span>67+</span></span><span class="chrome yes"><span>Chrome</span> <span>4+</span></span><span class="ios_saf yes"><span>iOS Safari</span> <span>3.2+</span></span><span class="and_uc yes"><span>UC Browser for Android</span> <span>11.8+</span></span><span class="firefox yes"><span>Firefox</span> <span>3.5+</span></span><span class="ie yes"><span>IE</span> <span>8+</span></span><span class="op_mini no"><span>Opera Mini</span> <span>None</span></span><span class="safari yes"><span>Safari</span> <span>4+</span></span><span class="edge yes"><span>Edge</span> <span>12+</span></span><span class="samsung yes"><span>Samsung Internet</span> <span>4+</span></span><span class="opera yes"><span>Opera</span> <span>10.5+</span></span><span class="android yes"><span>Android Browser</span> <span>2.1+</span></span><p class=caniuse>Source: <a href="https://caniuse.com/#feat=namevalue-storage">caniuse.com</a></div>

  <h4 id=the-storage-interface><span class=secno>11.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'><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>void</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>void</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>void</c-> <a href='#dom-storage-clear' id='the-storage-interface:dom-storage-clear'><c- g>clear</c-></a>();
};</code></pre>

  

  <p>Each <code id=the-storage-interface:storage-2-2><a href=#storage-2>Storage</a></code> object provides access to a list of key/value pairs, which are
  sometimes called items. Keys are strings. Any string (including the empty string) is a valid key.
  Values are similarly strings.</p>

  <p>Each <code id=the-storage-interface:storage-2-3><a href=#storage-2>Storage</a></code> object is associated with a list of key/value pairs when it is
  created, as defined in the sections on the <code id=the-storage-interface:dom-sessionstorage><a href=#dom-sessionstorage>sessionStorage</a></code>
  and <code id=the-storage-interface:dom-localstorage><a href=#dom-localstorage>localStorage</a></code> attributes. Multiple separate objects
  implementing the <code id=the-storage-interface:storage-2-4><a href=#storage-2>Storage</a></code> interface can all be associated with the same list of
  key/value pairs simultaneously.</p>

  <dl class=domintro><dt><var>storage</var> . <code id=dom-storage-length-dev><a href=#dom-storage-length>length</a></code><dd>
    <p>Returns the number of key/value pairs currently present in the list associated with the
    object.</p>
   <dd>

   <dt><var>storage</var> . <code id=dom-storage-key-dev><a href=#dom-storage-key>key</a></code> ( <var>n</var> )<dd>
    <p>Returns the name of the <var>n</var>th key in the list, or null if <var>n</var> is greater
    than or equal to the number of key/value pairs in the object.</p>
   <dd>

   <dt><var>value</var> = <var>storage</var> . <code id=dom-storage-getitem-dev><a href=#dom-storage-getitem>getItem</a></code> ( <var>key</var> )<dt><var>value</var> = <var>storage</var>[<var>key</var>]<dd>
    <p>Returns the current value associated with the given <var>key</var>, or null if the given
    <var>key</var> does not exist in the list associated with the object.</p>
   <dd>

   <dt><var>storage</var> . <code id=dom-storage-setitem-dev><a href=#dom-storage-setitem>setItem</a></code> ( <var>key</var>, <var>value</var> )<dt><var>storage</var>[<var>key</var>] = <var>value</var><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 <a id=the-storage-interface:quotaexceedederror href=https://heycam.github.io/webidl/#quotaexceedederror data-x-internal=quotaexceedederror>"<code>QuotaExceededError</code>"</a> <code id=the-storage-interface:domexception><a data-x-internal=domexception href=https://heycam.github.io/webidl/#dfn-DOMException>DOMException</a></code> exception
    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>

   <dt><var>storage</var> . <code id=dom-storage-removeitem-dev><a href=#dom-storage-removeitem>removeItem</a></code> ( <var>key</var> )<dt><code id=the-storage-interface:delete><a data-x-internal=delete href=https://tc39.github.io/ecma262/#sec-delete-operator>delete</a></code> <var>storage</var>[<var>key</var>]<dd>
    <p>Removes the key/value pair with the given <var>key</var> from the list associated with the
    object, if a key/value pair with the given <var>key</var> exists.</p>
   <dt><var>storage</var> . <code id=dom-storage-clear-dev><a href=#dom-storage-clear>clear</a></code>()<dd>
    <p>Empties the list associated with the object of all key/value pairs, if there are any.</p>
   </dl>

  

  <p>The <dfn id=dom-storage-length><code>length</code></dfn> attribute must return the number
  of key/value pairs currently present in the list associated with the object.</p>

  <p>The <dfn id=dom-storage-key><code>key(<var>n</var>)</code></dfn> method must
  return the name of the <var>n</var>th key in the list. The order of keys is user-agent
  defined, but must be consistent within an object so long as the number of keys doesn't change.
  (Thus, <a href=#dom-storage-setitem id=the-storage-interface:dom-storage-setitem-2>adding</a> or <a href=#dom-storage-removeitem id=the-storage-interface:dom-storage-removeitem-2>removing</a> a key may change the order of the keys, but merely
  changing the value of an existing key must not.)  If <var>n</var> is
   greater than or equal to the number of key/value pairs
  in the object, then this method must return null.</p>

  <p>The <a id=the-storage-interface:supported-property-names href=https://heycam.github.io/webidl/#dfn-supported-property-names data-x-internal=supported-property-names>supported property names</a> on a <code id=the-storage-interface:storage-2-5><a href=#storage-2>Storage</a></code> object are the keys of each
  key/value pair currently present in the list associated with the object, in the order that the
  keys were last added to the storage area.</p>

  <p>The <dfn id=dom-storage-getitem><code>getItem(<var>key</var>)</code></dfn> method
  must return the current value associated with the given <var>key</var>. If the given <var>key</var> does not exist in the list associated with the object then this method must
  return null. </p>

  <p>The <dfn id=dom-storage-setitem><code>setItem(<var>key</var>, <var>value</var>)</code></dfn> method must first check if a key/value pair with the given <var>key</var> already exists in the list associated with the object.</p>

  <p>If it does not, then a new key/value pair must be added to the list, with the given <var>key</var> and with its value set to <var>value</var>.</p>

  <p>If the given <var>key</var> <em>does</em> exist in the list, and its value is not
  equal to <var>value</var>, then it must have its value updated to <var>value</var>. If its previous value <em>is</em> equal to <var>value</var>, then
  the method must do nothing.</p>

  <p>If it couldn't set the new value, the method must throw a
  <a id=the-storage-interface:quotaexceedederror-2 href=https://heycam.github.io/webidl/#quotaexceedederror data-x-internal=quotaexceedederror>"<code>QuotaExceededError</code>"</a> <code id=the-storage-interface:domexception-2><a data-x-internal=domexception href=https://heycam.github.io/webidl/#dfn-DOMException>DOMException</a></code> exception.</p>

  <p>The <dfn id=dom-storage-removeitem><code>removeItem(<var>key</var>)</code></dfn>
  method must cause the key/value pair with the given <var>key</var> to be removed from the
  list associated with the object, if it exists. If no item with that key exists, the method must do
  nothing.</p>

  <p>The <code id=the-storage-interface:dom-storage-setitem-3><a href=#dom-storage-setitem>setItem()</a></code> and <code id=the-storage-interface:dom-storage-removeitem-3><a href=#dom-storage-removeitem>removeItem()</a></code> methods must be atomic with respect to failure.
  In the case of failure, the method does nothing. That is, changes to the data storage area must
  either be successful, or the data storage area must not be changed at all.</p>

  <p>The <dfn id=dom-storage-clear><code>clear()</code></dfn> method must atomically cause the
  list associated with the object to be emptied of all key/value pairs, if there are any. If there
  are none, then the method must do nothing.</p>

  

  <p class=note>When the <code id=the-storage-interface:dom-storage-setitem-4><a href=#dom-storage-setitem>setItem()</a></code>, <code id=the-storage-interface:dom-storage-removeitem-4><a href=#dom-storage-removeitem>removeItem()</a></code>, and <code id=the-storage-interface:dom-storage-clear-2><a href=#dom-storage-clear>clear()</a></code> methods are invoked, events are fired on the
  <a href=#concept-relevant-global id=the-storage-interface:concept-relevant-global>relevant global objects</a> of other
  <code id=the-storage-interface:document><a href=#document>Document</a></code> objects that can access the newly stored or removed data, as defined in the
  sections on the <code id=the-storage-interface:dom-sessionstorage-2><a href=#dom-sessionstorage>sessionStorage</a></code> and <code id=the-storage-interface:dom-localstorage-2><a href=#dom-localstorage>localStorage</a></code> attributes.</p> 

  <p class=note>This specification does not require that the above methods wait until the data has
  been physically written to disk. Only consistency in what different scripts accessing the same
  underlying list of key/value pairs see is required.</p>


  <h4 id=the-sessionstorage-attribute><span class=secno>11.2.2</span> The <code id=the-sessionstorage-attribute:dom-sessionstorage><a href=#dom-sessionstorage>sessionStorage</a></code> attribute<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'><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>

  <p>The <dfn id=dom-sessionstorage><code>sessionStorage</code></dfn> attribute represents the
  set of storage areas specific to the current <a href=#top-level-browsing-context id=the-sessionstorage-attribute:top-level-browsing-context>top-level browsing context</a>.</p>

  <dl class=domintro><dt><var>window</var> . <code id=dom-sessionstorage-dev><a href=#dom-sessionstorage>sessionStorage</a></code><dd>
     <p>Returns the <code id=the-sessionstorage-attribute:storage-2-2><a href=#storage-2>Storage</a></code> object associated with that origin's session storage
     area.</p>
   </dl>

  <p>Each <a href=#top-level-browsing-context id=the-sessionstorage-attribute:top-level-browsing-context-2>top-level browsing context</a> has a unique set of session storage areas, one for
  each <a href=#concept-origin id=the-sessionstorage-attribute:concept-origin>origin</a>.</p>

  <p>User agents should not expire data from a browsing context's session storage areas, but may do
  so when the user requests that such data be deleted, or when the UA detects that it has limited
  storage space, or for security reasons. User agents should always avoid deleting data while a
  script that could access that data is running. When a top-level browsing context is destroyed (and
  therefore permanently inaccessible to the user) the data stored in its session storage areas can
  be discarded with it, as the API described in this specification provides no way for that data to
  ever be subsequently retrieved.</p>

  

  <p class=note>The lifetime of a browsing context can be unrelated to the lifetime of the actual
  user agent process itself, as the user agent can support resuming sessions after a restart.</p>

  <p>When a new <code id=the-sessionstorage-attribute:document><a href=#document>Document</a></code> is created in a <a href=#browsing-context id=the-sessionstorage-attribute:browsing-context>browsing context</a> which has a
  <a href=#top-level-browsing-context id=the-sessionstorage-attribute:top-level-browsing-context-3>top-level browsing context</a>, the user agent must check to see if that <a href=#top-level-browsing-context id=the-sessionstorage-attribute:top-level-browsing-context-4>top-level
  browsing context</a> has a session storage area for that document's <a href=#concept-origin id=the-sessionstorage-attribute:concept-origin-2>origin</a>. If it
  does, then that is the <code id=the-sessionstorage-attribute:document-2><a href=#document>Document</a></code>'s assigned session storage area. If it does not, a
  new storage area for that document's <a href=#concept-origin id=the-sessionstorage-attribute:concept-origin-3>origin</a> must be created, and then <em>that</em>
  is the <code id=the-sessionstorage-attribute:document-3><a href=#document>Document</a></code>'s assigned session storage area. A <code id=the-sessionstorage-attribute:document-4><a href=#document>Document</a></code>'s assigned
  storage area does not change during the lifetime of a <code id=the-sessionstorage-attribute:document-5><a href=#document>Document</a></code>.</p>

  <p class=note>In the case of an <code id=the-sessionstorage-attribute:the-iframe-element><a href=#the-iframe-element>iframe</a></code> being moved to another
  <code id=the-sessionstorage-attribute:document-6><a href=#document>Document</a></code>, the nested browsing context is destroyed and a new one created.</p>

  <p>The <code id=the-sessionstorage-attribute:dom-sessionstorage-3><a href=#dom-sessionstorage>sessionStorage</a></code> attribute must return a
  <code id=the-sessionstorage-attribute:storage-2-3><a href=#storage-2>Storage</a></code> object associated with the <code id=the-sessionstorage-attribute:document-7><a href=#document>Document</a></code>'s assigned session storage
  area. Each <code id=the-sessionstorage-attribute:document-8><a href=#document>Document</a></code> object must have a separate object for its <a href=#concept-relevant-global id=the-sessionstorage-attribute:concept-relevant-global>relevant global
  object</a>'s <code id=the-sessionstorage-attribute:dom-sessionstorage-4><a href=#dom-sessionstorage>sessionStorage</a></code> attribute.</p>

  <p>While <a href=#creating-a-new-browsing-context id=the-sessionstorage-attribute:creating-a-new-browsing-context>creating a new browsing context</a>, the session storage area <a href=#copy-session-storage>is sometimes copied</a> over.</p>

  

  <p id=sessionStorageEvent>When the <code id=the-sessionstorage-attribute:dom-storage-setitem><a href=#dom-storage-setitem>setItem()</a></code>, <code id=the-sessionstorage-attribute:dom-storage-removeitem><a href=#dom-storage-removeitem>removeItem()</a></code>, and <code id=the-sessionstorage-attribute:dom-storage-clear><a href=#dom-storage-clear>clear()</a></code> methods are called on a <code id=the-sessionstorage-attribute:storage-2-4><a href=#storage-2>Storage</a></code> object <var>x</var> that is associated with a session storage area, if the methods did not throw an
  exception or "do nothing" as defined above, then for every <code id=the-sessionstorage-attribute:document-9><a href=#document>Document</a></code> object whose
  <a href=#concept-relevant-global id=the-sessionstorage-attribute:concept-relevant-global-2>relevant global object</a>'s <code id=the-sessionstorage-attribute:dom-sessionstorage-5><a href=#dom-sessionstorage>sessionStorage</a></code>
  attribute's <code id=the-sessionstorage-attribute:storage-2-5><a href=#storage-2>Storage</a></code> object is associated with the same storage area, other than
  <var>x</var>,  <a href=#send-a-storage-notification id=the-sessionstorage-attribute:send-a-storage-notification>send a storage notification</a>.</p>


  <h4 id=the-localstorage-attribute><span class=secno>11.2.3</span> The <code id=the-localstorage-attribute:dom-localstorage><a href=#dom-localstorage>localStorage</a></code> attribute<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'><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>

  <p>The <dfn id=dom-localstorage><code>localStorage</code></dfn> object provides a
  <code id=the-localstorage-attribute:storage-2-2><a href=#storage-2>Storage</a></code> object for an <a href=#concept-origin id=the-localstorage-attribute:concept-origin>origin</a>.
  <a href=#fingerprinting-vector id=the-localstorage-attribute:fingerprinting-vector class=fingerprint title="There is a potential fingerprinting vector here."><img alt="(This is a fingerprinting vector.)" src=/images/fingerprint.png width=46 height=64></a>
  </p>

  <dl class=domintro><dt><var>window</var> . <code id=dom-localstorage-dev><a href=#dom-localstorage>localStorage</a></code><dd>
     <p>Returns the <code id=the-localstorage-attribute:storage-2-3><a href=#storage-2>Storage</a></code> object associated with that origin's local storage
     area.</p>
     <p>Throws a <a id=the-localstorage-attribute:securityerror href=https://heycam.github.io/webidl/#securityerror data-x-internal=securityerror>"<code>SecurityError</code>"</a> <code id=the-localstorage-attribute:domexception><a data-x-internal=domexception href=https://heycam.github.io/webidl/#dfn-DOMException>DOMException</a></code> if the
     <code id=the-localstorage-attribute:document><a href=#document>Document</a></code>'s <a href=#concept-origin id=the-localstorage-attribute:concept-origin-2>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>
   </dl>

  

  <p>User agents must have a set of local storage areas, one for each <a href=#concept-origin id=the-localstorage-attribute:concept-origin-3>origin</a>.</p>

  <p>User agents should expire data from the local storage areas only for security reasons or when
  requested to do so by the user. User agents should always avoid deleting data while a script that
  could access that data is running.</p>

  <p>When the <code id=the-localstorage-attribute:dom-localstorage-3><a href=#dom-localstorage>localStorage</a></code> attribute is accessed, the user
  agent must run the following steps, which are known as the
  <dfn id=storage-object-initialisation-steps><code>Storage</code> object
  initialization steps</dfn>:</p> 

  <ol><li><p>If the request violates a policy decision (e.g. if the user agent is configured to not
   allow the page to persist data), the user agent may throw a
   <a id=the-localstorage-attribute:securityerror-2 href=https://heycam.github.io/webidl/#securityerror data-x-internal=securityerror>"<code>SecurityError</code>"</a> <code id=the-localstorage-attribute:domexception-2><a data-x-internal=domexception href=https://heycam.github.io/webidl/#dfn-DOMException>DOMException</a></code> instead of returning a
   <code id=the-localstorage-attribute:storage-2-4><a href=#storage-2>Storage</a></code> object<li><p>If the <code id=the-localstorage-attribute:document-2><a href=#document>Document</a></code>'s <a href=#concept-origin id=the-localstorage-attribute:concept-origin-4>origin</a> is an <a href=#concept-origin-opaque id=the-localstorage-attribute:concept-origin-opaque-2>opaque origin</a>, then throw a
   <a id=the-localstorage-attribute:securityerror-3 href=https://heycam.github.io/webidl/#securityerror data-x-internal=securityerror>"<code>SecurityError</code>"</a> <code id=the-localstorage-attribute:domexception-3><a data-x-internal=domexception href=https://heycam.github.io/webidl/#dfn-DOMException>DOMException</a></code>.<li><p>Check to see if the user agent has allocated a local storage area for the
   <a href=#concept-origin id=the-localstorage-attribute:concept-origin-5>origin</a> of the <a href=#concept-document-window id=the-localstorage-attribute:concept-document-window>associated
   <code>Document</code></a> of the <code id=the-localstorage-attribute:window-2><a href=#window>Window</a></code> object on which the attribute was
   accessed. If it has not, create a new storage area for that <a href=#concept-origin id=the-localstorage-attribute:concept-origin-6>origin</a>.<li><p>Return the <code id=the-localstorage-attribute:storage-2-5><a href=#storage-2>Storage</a></code> object associated with that origin's local storage area.
   Each <code id=the-localstorage-attribute:document-3><a href=#document>Document</a></code> object must have a separate object for its <a href=#concept-relevant-global id=the-localstorage-attribute:concept-relevant-global>relevant global
   object</a>'s <code id=the-localstorage-attribute:dom-localstorage-4><a href=#dom-localstorage>localStorage</a></code> attribute.</p>

  </ol>

  

  <p id=localStorageEvent>When the <code id=the-localstorage-attribute:dom-storage-setitem><a href=#dom-storage-setitem>setItem()</a></code>, <code id=the-localstorage-attribute:dom-storage-removeitem><a href=#dom-storage-removeitem>removeItem()</a></code>, and <code id=the-localstorage-attribute:dom-storage-clear><a href=#dom-storage-clear>clear()</a></code> methods are called on a <code id=the-localstorage-attribute:storage-2-6><a href=#storage-2>Storage</a></code> object <var>x</var> that is associated with a local storage area, if the methods did not throw an
  exception or "do nothing" as defined above, then for every <code id=the-localstorage-attribute:document-4><a href=#document>Document</a></code> object whose
  <a href=#concept-relevant-global id=the-localstorage-attribute:concept-relevant-global-2>relevant global object</a>'s <code id=the-localstorage-attribute:dom-localstorage-5><a href=#dom-localstorage>localStorage</a></code>
  attribute's <code id=the-localstorage-attribute:storage-2-7><a href=#storage-2>Storage</a></code> object is associated with the same storage area, other than
  <var>x</var>,  <a href=#send-a-storage-notification id=the-localstorage-attribute:send-a-storage-notification>send a storage notification</a>.

  <p class=warning>The <code id=the-localstorage-attribute:dom-localstorage-6><a href=#dom-localstorage>localStorage</a></code> attribute provides
  access to shared state. This specification does not define the interaction with other browsing
  contexts 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>


  <h4 id=the-storage-event><span class=secno>11.2.4</span> The <code id=the-storage-event:event-storage><a href=#event-storage>storage</a></code> event<a href=#the-storage-event class=self-link></a></h4>

  <p><a href=#send-a-storage-notification id=send-a-storage-notification-dev>The <code>storage</code> event is fired on a <code>Document</code> object's
  <span>relevant global object</span> when a storage area changes</a>, as described in the
  previous two sections (<a href=#sessionStorageEvent>for session storage</a>, <a href=#localStorageEvent>for local storage</a>).</p>

  

  <p>When a user agent is to <dfn id=send-a-storage-notification>send a storage notification</dfn> for a <code id=the-storage-event:document><a href=#document>Document</a></code>, the
  user agent must <a href=#queue-a-task id=the-storage-event:queue-a-task>queue a task</a> to <a href=https://dom.spec.whatwg.org/#concept-event-fire id=the-storage-event:concept-event-fire data-x-internal=concept-event-fire>fire an
  event</a> named <code id=the-storage-event:storage-2><a href=#storage-2>storage</a></code> at the <code id=the-storage-event:document-2><a href=#document>Document</a></code> object's <a href=#concept-relevant-global id=the-storage-event:concept-relevant-global>relevant
  global object</a>, using <code id=the-storage-event:storageevent><a href=#storageevent>StorageEvent</a></code>.</p>

  <p class=note>Such a <code id=the-storage-event:document-3><a href=#document>Document</a></code> object is not necessarily <a href=#fully-active id=the-storage-event:fully-active>fully active</a>,
  but events fired on such objects are ignored by the <a href=#event-loop id=the-storage-event:event-loop>event loop</a> until the
  <code id=the-storage-event:document-4><a href=#document>Document</a></code> becomes <a href=#fully-active id=the-storage-event:fully-active-2>fully active</a> again.</p>

  <p>The <a href=#task-source id=the-storage-event:task-source>task source</a> for these tasks is the <a href=#dom-manipulation-task-source id=the-storage-event:dom-manipulation-task-source>DOM manipulation task
  source</a>.</p>

  <p>If the event is being fired due to an invocation of the <code id=the-storage-event:dom-storage-setitem><a href=#dom-storage-setitem>setItem()</a></code> or <code id=the-storage-event:dom-storage-removeitem><a href=#dom-storage-removeitem>removeItem()</a></code> methods, the event must have its <code id=the-storage-event:dom-storageevent-key><a href=#dom-storageevent-key>key</a></code> attribute initialized to the name of the key in question,
  its <code id=the-storage-event:dom-storageevent-oldvalue><a href=#dom-storageevent-oldvalue>oldValue</a></code> attribute initialized to the old
  value of the key in question, or null if the key is newly added, and its <code id=the-storage-event:dom-storageevent-newvalue><a href=#dom-storageevent-newvalue>newValue</a></code> attribute initialized to the new value of the
  key in question, or null if the key was removed.</p>

  <p>Otherwise, if the event is being fired due to an invocation of the <code id=the-storage-event:dom-storage-clear><a href=#dom-storage-clear>clear()</a></code> method, the event must have its <code id=the-storage-event:dom-storageevent-key-2><a href=#dom-storageevent-key>key</a></code>, <code id=the-storage-event:dom-storageevent-oldvalue-2><a href=#dom-storageevent-oldvalue>oldValue</a></code>,
  and <code id=the-storage-event:dom-storageevent-newvalue-2><a href=#dom-storageevent-newvalue>newValue</a></code> attributes initialized to null.</p>

  <p>In addition, the event must have its <code id=the-storage-event:dom-storageevent-url><a href=#dom-storageevent-url>url</a></code> attribute
  initialized to the <a href=https://dom.spec.whatwg.org/#concept-document-url id="the-storage-event:the-document's-address" data-x-internal="the-document's-address">URL</a> of the document whose
  <code id=the-storage-event:storage-2-2><a href=#storage-2>Storage</a></code> object was affected; and its <code id=the-storage-event:dom-storageevent-storagearea><a href=#dom-storageevent-storagearea>storageArea</a></code> attribute initialized to the
  <code id=the-storage-event:storage-2-3><a href=#storage-2>Storage</a></code> object from the <a href=#concept-relevant-global id=the-storage-event:concept-relevant-global-2>relevant global object</a> of the target
  <code id=the-storage-event:document-5><a href=#document>Document</a></code> that represents the same kind of <code id=the-storage-event:storage-2-4><a href=#storage-2>Storage</a></code> area as was affected
  (i.e. session or local).</p>

  


  <h5 id=the-storageevent-interface><span class=secno>11.2.4.1</span> The <code id=the-storageevent-interface:storageevent><a href=#storageevent>StorageEvent</a></code> interface<a href=#the-storageevent-interface class=self-link></a></h5>

  <pre><code class='idl'>[<c- g>Exposed</c->=<c- n>Window</c->,
 <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>interface</c-> <dfn id='storageevent'><c- g>StorageEvent</c-></dfn> : <a href='https://dom.spec.whatwg.org/#interface-event' data-x-internal='event' id='the-storageevent-interface:event'><c- n>Event</c-></a> {
  <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>dictionary</c-> <dfn id='storageeventinit'><c- g>StorageEventInit</c-></dfn> : <a href='https://dom.spec.whatwg.org/#dictdef-eventinit' data-x-internal='eventinit' id='the-storageevent-interface: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-> = &quot;&quot;;
  <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><var>event</var> . <code id=dom-storageevent-key-dev><a href=#dom-storageevent-key>key</a></code><dd>
     <p>Returns the key of the storage item being changed.</p>
   <dt><var>event</var> . <code id=dom-storageevent-oldvalue-dev><a href=#dom-storageevent-oldvalue>oldValue</a></code><dd>
     <p>Returns the old value of the key of the storage item whose value is being changed.</p>
   <dt><var>event</var> . <code id=dom-storageevent-newvalue-dev><a href=#dom-storageevent-newvalue>newValue</a></code><dd>
     <p>Returns the new value of the key of the storage item whose value is being changed.</p>
   <dt><var>event</var> . <code id=dom-storageevent-url-dev><a href=#dom-storageevent-url>url</a></code><dd>
     <p>Returns the <a id=the-storageevent-interface:url href=https://url.spec.whatwg.org/#concept-url data-x-internal=url>URL</a> of the document whose storage item changed.</p>
   <dt><var>event</var> . <code id=dom-storageevent-storagearea-dev><a href=#dom-storageevent-storagearea>storageArea</a></code><dd>
     <p>Returns the <code id=the-storageevent-interface:storage-2-3><a href=#storage-2>Storage</a></code> object that was affected.</p>
   </dl>

  

  <p>The <dfn id=dom-storageevent-key><code>key</code></dfn>, <dfn id=dom-storageevent-oldvalue><code>oldValue</code></dfn>, <dfn id=dom-storageevent-newvalue><code>newValue</code></dfn>, <dfn id=dom-storageevent-url><code>url</code></dfn>, and <dfn id=dom-storageevent-storagearea><code>storageArea</code></dfn> attributes must return the values
  they were initialized to.</p>

  


  <h3 id=disk-space-2><span class=secno>11.3</span> Disk space<a href=#disk-space-2 class=self-link></a></h3>

  <p>User agents should limit the total amount of space allowed for storage areas, because hostile
  authors could otherwise use this feature to exhaust the user's available disk space.</p>

  <p>User agents should guard against sites storing data under their origin's other affiliated
  sites, e.g. storing up to the limit in a1.example.com, a2.example.com, a3.example.com, etc,
  circumventing the main example.com storage limit.</p>

  <p>User agents may prompt the user when quotas are reached, allowing the user to grant a site more
  space. This enables sites to store many user-created documents on the user's computer, for
  instance.</p>

  <p>User agents should allow users to see how much space each domain is using.</p>

  

  <p>A mostly arbitrary limit of five megabytes per <a href=#concept-origin id=disk-space-2:concept-origin>origin</a> is suggested. Implementation
  feedback is welcome and will be used to update this suggestion in the future.</p>

  <p>For predictability, quotas should be based on the uncompressed size of data stored.</p>
  


  <h3 id=privacy><span class=secno>11.4</span> Privacy<a href=#privacy class=self-link></a></h3>

  <h4 id=user-tracking><span class=secno>11.4.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<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=#active-document id=user-tracking:active-document>active document</a> of the <a href=#top-level-browsing-context id=user-tracking:top-level-browsing-context>top-level browsing
    context</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>

   <dt>Expiring stored data<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=#browsing-context id=user-tracking:browsing-context>browsing contexts</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>

    

   <dt>Treating persistent storage as cookies<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>

   <dt>Site-specific safelisting of access to local storage areas<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>

   <dt>Origin-tracking of stored data<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>

   <dt>Shared blocklists<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>

   </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>11.4.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 e-mails, 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>11.5</span> Security<a href=#security-storage class=self-link></a></h3>

  <h4 id=dns-spoofing-attacks><span class=secno>11.5.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>11.5.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>11.5.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>12</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>12.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>

  

  <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>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>A <a href=#syntax-doctype id=writing:syntax-doctype>DOCTYPE</a>.

   <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>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>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>.</ol>

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

  <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>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>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>Optionally, a <a href=#doctype-legacy-string id=the-doctype:doctype-legacy-string>DOCTYPE legacy string</a>.<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>A U+003E GREATER-THAN SIGN character (>).</ol>

  <p class=note>In other words, <code>&lt;!DOCTYPE html></code>, case-insensitively.</p>

  <hr>

  <p>For the purposes of HTML generators that cannot output HTML markup with the short DOCTYPE
  "<code>&lt;!DOCTYPE html></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>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>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>A U+0022 QUOTATION MARK or U+0027 APOSTROPHE character (the <i>quote mark</i>).<li>The literal string "<code id=the-doctype:about:legacy-compat><a href=#about:legacy-compat>about:legacy-compat</a></code>".<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>).</ol>

  <p class=note>In other words, <code>&lt;!DOCTYPE html SYSTEM "about:legacy-compat"></code> or
  <code>&lt;!DOCTYPE html SYSTEM 'about:legacy-compat'></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>12.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><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-param-element><a href=#the-param-element>param</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><dt><dfn id=the-template-element-2>The <code>template</code> element</dfn><dd><code id=elements-2:the-template-element><a href=#the-template-element>template</a></code><dt><dfn id=raw-text-elements>Raw text elements</dfn><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><dt><dfn id=escapable-raw-text-elements>escapable raw text elements</dfn><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><dt><dfn id=foreign-elements>Foreign elements</dfn><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>.<dt><dfn id=normal-elements>Normal elements</dfn><dd>All other allowed <a href=#html-elements id=elements-2:html-elements>HTML elements</a> are normal elements.</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>&quot;https://www.example.com/cdr/metadata&quot;</c-> <c- e>name</c-><c- o>=</c-><c- s>&quot;MIT&quot;</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 the
   SVG specification 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>12.1.2.1</span> Start tags<a href=#start-tags class=self-link></a></h5>

  <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>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>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>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>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>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 (/). This character has no effect on <a href=#void-elements id=start-tags:void-elements-2>void elements</a>, but on <a href=#foreign-elements id=start-tags:foreign-elements-2>foreign
   elements</a> it marks the start tag as self-closing.<li>Finally, start tags must be closed by a U+003E GREATER-THAN SIGN character (>).</ol>


  <h5 id=end-tags><span class=secno>12.1.2.2</span> End tags<a href=#end-tags class=self-link></a></h5>

  <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>The second character of an end tag must be a U+002F SOLIDUS character (/).<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>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>Finally, end tags must be closed by a U+003E GREATER-THAN SIGN character (>).</ol>


  <h5 id=attributes-2><span class=secno>12.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 (>), 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<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>

   <dt id=unquoted>Unquoted attribute value syntax<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 (>), 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>

   <dt>Single-quoted attribute value syntax<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>&apos;checkbox&apos;</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>

   <dt>Double-quoted attribute value syntax<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>&quot;be evil&quot;</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>

   </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> Namespace <th> Attribute name
   <tbody><tr><td> <code>actuate</code> <td> <a id=attributes-2:xlink-namespace href=https://infra.spec.whatwg.org/#xlink-namespace data-x-internal=xlink-namespace>XLink namespace</a> <td> <code>xlink:actuate</code>
    <tr><td> <code>arcrole</code> <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> <code>xlink:arcrole</code>
    <tr><td> <code>href</code> <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> <code>xlink:href</code>
    <tr><td> <code>role</code> <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> <code>xlink:role</code>
    <tr><td> <code>show</code> <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> <code>xlink:show</code>
    <tr><td> <code>title</code> <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> <code>xlink:title</code>
    <tr><td> <code>type</code> <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> <code>xlink:type</code>
    <tr><td> <code>lang</code> <td> <a id=attributes-2:xml-namespace href=https://infra.spec.whatwg.org/#xml-namespace data-x-internal=xml-namespace>XML namespace</a> <td> <code>xml:lang</code>
    <tr><td> <code>space</code> <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> <code>xml:space</code>
    <tr><td> <code>xmlns</code> <td> <a id=attributes-2:xmlns-namespace href=https://infra.spec.whatwg.org/#xmlns-namespace data-x-internal=xmlns-namespace>XMLNS namespace</a> <td> <code>xmlns</code>
    <tr><td> <code>xlink</code> <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> <code>xmlns:xlink</code>
  </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. the SVG and MathML specifications); this section only describes the
  syntax rules if the attributes are serialized using the HTML syntax.</p>


  <h5 id=optional-tags><span class=secno>12.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></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></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-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-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-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><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:

   <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.<small><c- p>&lt;/</c-><c- f>p</c-><c- p>&gt;</c-></small></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, 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, or
  if it is immediately followed by an <code id=optional-tags:the-optgroup-element-4><a href=#the-optgroup-element>optgroup</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&apos;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&apos;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&apos;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>&quot;en&quot;</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>&quot;demo&quot;</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>12.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>12.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
  (>), or U+002F SOLIDUS (/).</p>


  <h4 id=text-2><span class=secno>12.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>12.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>12.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>

  <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<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 (;).<dt>Decimal numeric character reference<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 (;).<dt>Hexadecimal numeric character reference<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 (;).</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>

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


  <h4 id=cdata-sections><span class=secno>12.1.5</span> CDATA sections<a href=#cdata-sections class=self-link></a></h4>

  <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>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>]]></code>".<li>The string "<code>]]></code>".</ol>

  <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://www.w3.org/Math/draft-spec/chapter3.html#presm.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>12.1.6</span> Comments<a href=#comments class=self-link></a></h4>

  <p><dfn id=syntax-comments>Comments</dfn> must have the following format:</p>

  <ol><li>The string "<code>&lt;!--</code>".<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>></code>", nor start with the string
   "<code>-></code>", nor contain the strings "<code>&lt;!--</code>", "<code>--></code>", or "<code>--!></code>", nor end with the string "<code>&lt;!-</code>".<li>The string "<code>--></code>".</ol>

  <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 > and
  &lt;!--></code>.</p>




  

  <h3 id=parsing><span class=secno>12.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>

   <p>Authors interested in using SGML tools in their authoring pipeline are encouraged to use XML
   tools and the XML serialization of HTML.</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 class=no-backref>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>12.2.1</span> Overview of the parsing model<a href=#overview-of-the-parsing-model class=self-link></a></h4>

  <p class=overview><img 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>&apos;&lt;p&gt;&apos;</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>12.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>Description
    <tbody><tr><td><dfn id=parse-error-abrupt-closing-of-empty-comment>abrupt-closing-of-empty-comment</dfn>
     <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 (>) <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;!--></code> or <code>&lt;!---></code>). The
     parser behaves as if the comment is closed correctly.</p>

    <tr><td><dfn id=parse-error-abrupt-doctype-public-identifier>abrupt-doctype-public-identifier</dfn>
     <td><p>This error occurs if the parser encounters a U+003E (>) <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></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>

    <tr><td><dfn id=parse-error-abrupt-doctype-system-identifier>abrupt-doctype-system-identifier</dfn>
     <td><p>This error occurs if the parser encounters a U+003E (>) <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></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>

    <tr><td><dfn id=parse-error-absence-of-digits-in-numeric-character-reference>absence-of-digits-in-numeric-character-reference</dfn>
     <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>

    <tr><td><dfn id=parse-error-cdata-in-html-content>cdata-in-html-content</dfn>
     <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>

    <tr><td><dfn id=parse-error-character-reference-outside-unicode-range>character-reference-outside-unicode-range</dfn>
     <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>

    <tr><td><dfn id=parse-error-control-character-in-input-stream>control-character-in-input-stream</dfn>
     <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>

    <tr><td><dfn id=parse-error-control-character-reference>control-character-reference</dfn>
     <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>, a U+000D CARRIAGE RETURN, or U+0000 NULL. 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>

    <tr><td><dfn id=parse-error-end-tag-with-attributes>end-tag-with-attributes</dfn>
     <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>attributes</a>. Attributes in end tags are
     completely ignored and do not make their way into the DOM.</p>

    <tr><td><dfn id=parse-error-duplicate-attribute>duplicate-attribute</dfn>
     <td><p>This error occurs if the parser encounters an <a href=#syntax-attributes id=parse-errors:syntax-attributes-2>attribute</a> in a tag that already has an attribute with the
     same name. The parser ignores all such duplicate occurrences of the attribute.

    <tr><td><dfn id=parse-error-end-tag-with-trailing-solidus>end-tag-with-trailing-solidus</dfn>
     <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 (>)
     code point (e.g., <code>&lt;/div/></code>). Such a tag is treated as a regular end
     tag.</p>

    <tr><td><dfn id=parse-error-eof-before-tag-name>eof-before-tag-name</dfn>
     <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>

    <tr><td><dfn id=parse-error-eof-in-cdata>eof-in-cdata</dfn>
     <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>

    <tr><td><dfn id=parse-error-eof-in-comment>eof-in-comment</dfn>
     <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>

    <tr><td><dfn id=parse-error-eof-in-doctype>eof-in-doctype</dfn>
     <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>

    <tr><td><dfn id=parse-error-eof-in-script-html-comment-like-text>eof-in-script-html-comment-like-text</dfn>
     <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>&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>

    <tr><td><dfn id=parse-error-eof-in-tag>eof-in-tag</dfn>
     <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 completely ignored.</p>

    <tr><td><dfn id=parse-error-incorrectly-closed-comment>incorrectly-closed-comment</dfn>
     <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>--!></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>--></code>" code point sequence.</p>

    <tr><td><dfn id=parse-error-incorrectly-opened-comment>incorrectly-opened-comment</dfn>
     <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 immidiately 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 (>) 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></code>) in HTML.</p>

    <tr><td><dfn id=parse-error-invalid-character-sequence-after-doctype-name>invalid-character-sequence-after-doctype-name</dfn>
     <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,
     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>

    <tr><td><dfn id=parse-error-invalid-first-character-of-tag-name>invalid-first-character-of-tag-name</dfn>
     <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 (>) 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 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></span><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></ul></ul></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>

    <tr><td><dfn id=parse-error-missing-attribute-value>missing-attribute-value</dfn>
     <td><p>This error occurs if the parser encounters a U+003E (>) <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=></code>). The parser treats the attribute as having an empty value.</p>

    <tr><td><dfn id=parse-error-missing-doctype-name>missing-doctype-name</dfn>
     <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></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>

    <tr><td><dfn id=parse-error-missing-doctype-public-identifier>missing-doctype-public-identifier</dfn>
     <td><p>This error occurs if the parser encounters a U+003E (>) <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 ></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>

    <tr><td><dfn id=parse-error-missing-doctype-system-identifier>missing-doctype-system-identifier</dfn>
     <td><p>This error occurs if the parser encounters a U+003E (>) <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 ></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>

    <tr><td><dfn id=parse-error-missing-end-tag-name>missing-end-tag-name</dfn>
     <td><p>This error occurs if the parser encounters a U+003E (>) <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;/></code>. The parser completely ignores whole "<code>&lt;/></code>"
     code point sequence.</p>

    <tr><td><dfn id=parse-error-missing-quote-before-doctype-public-identifier>missing-quote-before-doctype-public-identifier</dfn>
     <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"></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>

    <tr><td><dfn id=parse-error-missing-quote-before-doctype-system-identifier>missing-quote-before-doctype-system-identifier</dfn>
     <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"></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>

    <tr><td><dfn id=parse-error-missing-semicolon-after-character-reference>missing-semicolon-after-character-reference</dfn>
     <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>. Usually the
      parser behaves as if character reference is terminated by the U+003B (;) code point; however,
      there are some ambiguous cases in which the parser includes subsequent code points in the
      character reference.</p>

      <p class=example>For example, <code>&amp;not;in</code> will be parsed as "<code>¬in</code>" whereas <code>&amp;notin</code> will be parsed as "<code>∉</code>".</p>

    <tr><td><dfn id=parse-error-missing-whitespace-after-doctype-public-keyword>missing-whitespace-after-doctype-public-keyword</dfn>
     <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>

    <tr><td><dfn id=parse-error-missing-whitespace-after-doctype-system-keyword>missing-whitespace-after-doctype-system-keyword</dfn>
     <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>

    <tr><td><dfn id=parse-error-missing-whitespace-before-doctype-name>missing-whitespace-before-doctype-name</dfn>
     <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>

    <tr><td><dfn id=parse-error-missing-whitespace-between-attributes>missing-whitespace-between-attributes</dfn>
     <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"></code>). In this case the
     parser behaves as if ASCII whitespace is present.</p>

    <tr><td><dfn id=parse-error-missing-whitespace-between-doctype-public-and-system-identifiers>missing-whitespace-between-doctype-public-and-system-identifiers</dfn>
     <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>

    <tr><td><dfn id=parse-error-nested-comment>nested-comment</dfn>
     <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 -->
     --></code>). Such a comment will be closed by the first occuring "<code>--></code>"
     <a id=parse-errors:code-point-17 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>

    <tr><td><dfn id=parse-error-noncharacter-character-reference>noncharacter-character-reference</dfn>
     <td><p>This error occurs if the parser encounters a numeric <a href=#syntax-charref id=parse-errors:syntax-charref-5>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>

    <tr><td><dfn id=parse-error-noncharacter-in-input-stream>noncharacter-in-input-stream</dfn>
     <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-18 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>

    <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>
      <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-19 href=https://infra.spec.whatwg.org/#code-point data-x-internal=code-point>code
      point</a> right before the closing U+003E (>) 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 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 class=t1><code id=parse-errors:the-span-element-2><a href=#the-span-element>span</a></code></ul></ul></ul></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>

    <tr><td><dfn id=parse-error-null-character-reference>null-character-reference</dfn>
     <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 U+0000 NULL <a id=parse-errors:code-point-20 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>

    <tr><td><dfn id=parse-error-surrogate-character-reference>surrogate-character-reference</dfn>
     <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 <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>

    <tr><td><dfn id=parse-error-surrogate-in-input-stream>surrogate-in-input-stream</dfn>
     <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-21 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>

    <tr><td><dfn id=parse-error-unexpected-character-after-doctype-system-identifier>unexpected-character-after-doctype-system-identifier</dfn>
     <td><p>This error occurs if the parser encounters any <a href=https://infra.spec.whatwg.org/#code-point id=parse-errors:code-point-22 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 (>) after the <a href=#syntax-doctype id=parse-errors:syntax-doctype-15>DOCTYPE</a> system identifier. The parser ignores these code
     points.</p>

    <tr><td><dfn id=parse-error-unexpected-character-in-attribute-name>unexpected-character-in-attribute-name</dfn>
     <td>
      <p>This error occurs if the parser encounters a U+0022 ("), U+0027 ('), or U+003C (&lt;)
      <a id=parse-errors:code-point-23 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 (>) 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->&apos;<c- e>bar</c->&apos;<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>

    <tr><td><dfn id=parse-error-unexpected-character-in-unquoted-attribute-value>unexpected-character-in-unquoted-attribute-value</dfn>
     <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-24 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&apos;ar&apos;</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>

    <tr><td><dfn id=parse-error-unexpected-equals-sign-before-attribute-name>unexpected-equals-sign-before-attribute-name</dfn>
     <td>
      <p>This error occurs if the parser encounters a U+003D (=) <a id=parse-errors:code-point-25 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>&quot;bar&quot;</c-> =&quot;<c- e>baz</c->&quot;<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>

    <tr><td><dfn id=parse-error-unexpected-null-character>unexpected-null-character</dfn>
     <td><p>This error occurs if the parser encounters a U+0000 NULL <a id=parse-errors:code-point-26 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
     completely ignored or, for security reasons, replaced with a U+FFFD REPLACEMENT CHARACTER.</p>

    <tr><td><dfn id=parse-error-unexpected-question-mark-instead-of-tag-name>unexpected-question-mark-instead-of-tag-name</dfn>
     <td>
      <p>This error occurs if the parser encounters a U+003F (?) <a id=parse-errors:code-point-27 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 (>) 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=&quot;text/css&quot; href=&quot;style.css&quot;?&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 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 class=t1><code id=parse-errors:the-body-element-3><a href=#the-body-element>body</a></code></ul></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"?></code>) or an XML declaration
      (e.g., <code>&lt;?xml version="1.0" encoding="UTF-8"?></code>) being used in
      HTML.</p>

    <tr><td><dfn id=parse-error-unexpected-solidus-in-tag>unexpected-solidus-in-tag</dfn>
     <td><p>This error occurs if the parser encounters a U+002F (/) <a id=parse-errors:code-point-28 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 (>) code point in a tag (e.g., <code>&lt;div /
     id="foo"></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>

    <tr><td><dfn id=parse-error-unknown-named-character-reference>unknown-named-character-reference</dfn>
     <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-8>character reference</a>.</p>

  </table>

  


  

  <h4 id=the-input-byte-stream><span class=secno>12.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 the XML specification. 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>

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

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

  <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 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-2>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>

    <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><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-3>confidence</a> <i>certain</i>.<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>. The <var>end condition</var> is that 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 either aborts unsuccessfully or returns a character encoding. 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-4>confidence</a> <i>tentative</i>.</p>

   <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> that is itself in a <a href=#nested-browsing-context id=determining-the-character-encoding:nested-browsing-context>nested browsing context</a>, run these
    substeps:</p>

    <ol><li><p>Let <var>new document</var> be the <code id=determining-the-character-encoding:document-2><a href=#document>Document</a></code> with which the
     <a href=#html-parser id=determining-the-character-encoding:html-parser-2>HTML parser</a> is associated.<li><p>Let <var>parent document</var> be the <code id=determining-the-character-encoding:document-3><a href=#document>Document</a></code> <a href=#browsing-context-nested-through id=determining-the-character-encoding:browsing-context-nested-through>through which <var>new document</var> is
     nested</a> (the <a href=#active-document id=determining-the-character-encoding:active-document>active document</a> of the <a href=#parent-browsing-context id=determining-the-character-encoding:parent-browsing-context>parent browsing context</a> of
     <var>new document</var>).<li><p>If <var>parent document</var>'s <a href=#concept-origin id=determining-the-character-encoding:concept-origin>origin</a> is <a href=#same-origin id=determining-the-character-encoding:same-origin>same origin</a> with
     <var>new document</var>'s <a href=#concept-origin id=determining-the-character-encoding:concept-origin-2>origin</a>, and <var>parent document</var>'s <a href=https://dom.spec.whatwg.org/#concept-document-encoding id="determining-the-character-encoding:document's-character-encoding" data-x-internal="document's-character-encoding">character encoding</a> is an <a href=#ascii-compatible-encoding id=determining-the-character-encoding:ascii-compatible-encoding>ASCII-compatible
     encoding</a>, then return <var>parent document</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>, with the <a href=#concept-encoding-confidence id=determining-the-character-encoding:concept-encoding-confidence-5>confidence</a> <i>tentative</i>.</ol>

   <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-6>confidence</a> <i>tentative</i>.<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-7>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>

    <p>Otherwise, return an implementation-defined or user-specified default character encoding,
    with the <a href=#concept-encoding-confidence id=determining-the-character-encoding:concept-encoding-confidence-8>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>Suggested default encoding
     <tbody><tr><td>ar
       <td>Arabic
       <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> 

      

      

      

      
      
      <tr><td>ba
       <td>Bashkir
       <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> 

      
      
      <tr><td>be
       <td>Belarusian
       <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> 

      

      <tr><td>bg
       <td>Bulgarian
       <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> 

      

      

      

      

      

      

      <tr><td>cs
       <td>Czech
       <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> 

      

      

      

      
      
      
      <tr><td>el
       <td>Greek
       <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> 

      

      

      <tr><td>et
       <td>Estonian
       <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> 

      

      <tr><td>fa
       <td>Persian
       <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> 

      

      

      

      

      

      

      

      

      

      

      <tr><td>he
       <td>Hebrew
       <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> 

      

      <tr><td>hr
       <td>Croatian
       <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> 

      <tr><td>hu
       <td>Hungarian
       <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> 

      

      

      

      

      

      

      <tr><td>ja
       <td>Japanese
       <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> 

      
      
      <tr><td>kk
       <td>Kazakh
       <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> 

      

      

      <tr><td>ko
       <td>Korean
       <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> 

      <tr><td>ku
       <td>Kurdish
       <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> 

      
      
      <tr><td>ky
       <td>Kyrgyz
       <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> 

      

      <tr><td>lt
       <td>Lithuanian
       <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> 

      <tr><td>lv
       <td>Latvian
       <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> 

      
      
      <tr><td>mk
       <td>Macedonian
       <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> 

      

      

      

      

      

      

      

      

      

      

      

      <tr><td>pl
       <td>Polish
       <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> 

      

      

      

      

      

      

      

      

      

      

      <tr><td>ru
       <td>Russian
       <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> 

      

      
      
      <tr><td>sah
       <td>Yakut
       <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> 

      

      

      

      <tr><td>sk
       <td>Slovak
       <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> 

      <tr><td>sl
       <td>Slovenian
       <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> 

      

      

      

      

      

      

      

      

      <tr><td>sr
       <td>Serbian
       <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> 

      

      

      

      

      

      

      
      
      <tr><td>tg
       <td>Tajik
       <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> 

      <tr><td>th
       <td>Thai
       <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> 

      

      

      <tr><td>tr
       <td>Turkish
       <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> 

      
      
      <tr><td>tt
       <td>Tatar
       <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> 

      

      

      <tr><td>uk
       <td>Ukrainian
       <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> 

      

      

      

      <tr><td>vi
       <td>Vietnamese
       <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> 

      

      

      

      

      

      <tr><td>zh-CN
       <td>Chinese (People's Republic of China)
       <td><a id=determining-the-character-encoding:gb18030 href=https://encoding.spec.whatwg.org/#gb18030 data-x-internal=gb18030>gb18030</a> 

      

      

      

      

      

      <tr><td>zh-TW
       <td>Chinese (Taiwan)
       <td><a id=determining-the-character-encoding:big5 href=https://encoding.spec.whatwg.org/#big5 data-x-internal=big5>Big5</a> 

      

      <tr><td colspan=2>All other locales
       <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>

    </table>

    <p class=tablenote><small>The contents of this table are derived from the intersection of
    Windows, Chrome, and Firefox defaults.</small></p>

   </ol>

  <p>The <a id="determining-the-character-encoding:document's-character-encoding-3" 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>

  <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 <var>end condition</var>, then it must run the
  following steps. These steps either abort unsuccessfully or return a character encoding. 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 unsuccessfully.</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>

    <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>`)<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 '-->' 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>

     <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)<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).<li><p>Let <var>attribute list</var> be an empty list of strings.<li><p>Let <var>got pragma</var> be false.<li><p>Let <var>need pragma</var> be null.<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).<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.<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><p>Add the attribute's name to <var>attribute list</var>.</p>

       <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>"<dd><p>If the attribute's value is "<code>content-type</code>", then set <var>got pragma</var> to true.<dt>If the attribute's name is "<code>content</code>"<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.<dt>If the attribute's name is "<code>charset</code>"<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.</dl>

       <li><p>Return to the step labeled <i>attributes</i>.<li><p><i>Processing</i>: If <var>need pragma</var> is null, then jump to the step
       below labeled <i>next byte</i>.<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>.<li><p>If <var>charset</var> is failure, then jump to the step below labeled <i>next
       byte</i>.<li><p>If <var>charset</var> is a <a href=#utf-16-encoding id=determining-the-character-encoding:utf-16-encoding>UTF-16 encoding</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>.

       <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>.<li><p>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-3>prescan a byte stream to determine its encoding</a> algorithm,
       returning the encoding given by <var>charset</var>.</ol>

     <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)<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 (>) byte.<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>.</ol>

     <dt>A sequence of bytes starting with: 0x3C 0x21 (`<code>&lt;!</code>`)<dt>A sequence of bytes starting with: 0x3C 0x2F (`<code>&lt;/</code>`)<dt>A sequence of bytes starting with: 0x3C 0x3F (`<code>&lt;?</code>`)<dd>

      <p>Advance the <var>position</var> pointer so that it points at the first 0x3E byte (>) that
      comes after the 0x3C byte that was found.</p>

     <dt>Any other byte<dd>

      <p>Do nothing with that byte.</p>

     </dl>

   <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>.</ol>

  <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.<li><p>If the byte at <var>position</var> is 0x3E (>), 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.<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.<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<dd>Advance <var>position</var> to the next byte and jump to the step below labeled
     <i>value</i>.<dt>If it is 0x09 (HT), 0x0A (LF), 0x0C (FF), 0x0D (CR), or 0x20 (SP)<dd>Jump to the step below labeled <i>spaces</i>.<dt>If it is 0x2F (/) or 0x3E (>)<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.<dt>If it is in the range 0x41 (A) to 0x5A (Z)<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.)<dt>Anything else<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.)</dl>

   <li><p>Advance <var>position</var> to the next byte and return to the previous
   step.<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.<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.<li><p>Advance <var>position</var> past the 0x3D (=) byte.<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.<li><p>Process the byte at <var>position</var> as follows:</p>

    <dl class=switch><dt>If it is 0x22 (") or 0x27 (')<dd>

      <ol><li>Let <var>b</var> be the value of the byte at <var>position</var>.<li><i>Quote loop</i>: Advance <var>position</var> to the next byte.<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>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>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>Return to the step above labeled <i>quote loop</i>.</ol>

     <dt>If it is 0x3E (>)<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.<dt>If it is in the range 0x41 (A) to 0x5A (Z)<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.<dt>Anything else<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.</dl>

   <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 (>)<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>.<dt>If it is in the range 0x41 (A) to 0x5A (Z)<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>).<dt>Anything else<dd>Append a code point with the same value as the byte at <var>position</var> to
     <var>attribute value</var>.</dl>

   <li><p>Advance <var>position</var> to the next byte and return to the previous
   step.</ol>

  <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>12.2.3.3</span> Character encodings<a href=#character-encodings class=self-link></a></h5>

  <p>User agents must support the encodings defined in the WHATWG Encoding standard, 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=gb18030><a href=https://encoding.spec.whatwg.org/#gb18030>gb18030</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>, 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>12.2.3.4</span> Changing the encoding while parsing<a href=#changing-the-encoding-while-parsing class=self-link></a></h5>

  <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 <a href=#utf-16-encoding id=changing-the-encoding-while-parsing:utf-16-encoding>UTF-16
   encoding</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.<li><p>If the new encoding is a <a href=#utf-16-encoding id=changing-the-encoding-while-parsing:utf-16-encoding-2>UTF-16 encoding</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>.<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>.<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.<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.<li><p>Otherwise, <a href=#navigate id=changing-the-encoding-while-parsing:navigate>navigate</a> to the document again, with
   <a href=#replacement-enabled id=changing-the-encoding-while-parsing:replacement-enabled>replacement enabled</a>, and using the same <a href=#source-browsing-context id=changing-the-encoding-while-parsing:source-browsing-context>source browsing context</a>, 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.</ol>

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

  <p>U+000D CARRIAGE RETURN (CR) characters and U+000A LINE FEED (LF) characters are treated
  specially. Any LF character that immediately follows a CR character must be ignored, and all CR
  characters must then be converted to LF characters. Thus, newlines in HTML DOMs are represented by
  LF characters, and there are never any CR characters in the input to the <a href=#tokenization id=preprocessing-the-input-stream:tokenization>tokenization</a>
  stage.</p>

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

  <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>12.2.4</span> Parse state<a href=#parse-state class=self-link></a></h4>

  <h5 id=the-insertion-mode><span class=secno>12.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-inselect id=the-insertion-mode:parsing-main-inselect>in select</a>", "<a href=#parsing-main-inselectintable id=the-insertion-mode:parsing-main-inselectintable>in select in table</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>

  <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>", "<a href=#parsing-main-intable id=the-insertion-mode:parsing-main-intable-2>in
  table</a>", and "<a href=#parsing-main-inselect id=the-insertion-mode:parsing-main-inselect-2>in select</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>

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

  <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.<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>.<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 originally 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.<li>

    <p>If <var>node</var> is a <code id=the-insertion-mode:the-select-element><a href=#the-select-element>select</a></code> element, run these substeps:</p>

    <ol><li><p>If <var>last</var> is true, jump to the step below labeled
     <i>done</i>.<li><p>Let <var>ancestor</var> be <var>node</var>.<li><p><i>Loop</i>: If <var>ancestor</var> is the first node in the <a href=#stack-of-open-elements id=the-insertion-mode:stack-of-open-elements-2>stack of
     open elements</a>, jump to the step below labeled <i>done</i>.<li><p>Let <var>ancestor</var> be the node before <var>ancestor</var> in the
     <a href=#stack-of-open-elements id=the-insertion-mode:stack-of-open-elements-3>stack of open elements</a>.<li><p>If <var>ancestor</var> is a <code id=the-insertion-mode:the-template-element-2><a href=#the-template-element>template</a></code> node, jump to the step below
     labeled <i>done</i>.<li><p>If <var>ancestor</var> is a <code id=the-insertion-mode:the-table-element><a href=#the-table-element>table</a></code> node, switch the <a href=#insertion-mode id=the-insertion-mode:insertion-mode-5>insertion
     mode</a> to "<a href=#parsing-main-inselectintable id=the-insertion-mode:parsing-main-inselectintable-2>in select in table</a>"
     and return.<li><p>Jump back to the step labeled <i>loop</i>.<li><p><i>Done</i>: Switch the <a href=#insertion-mode id=the-insertion-mode:insertion-mode-6>insertion mode</a> to "<a href=#parsing-main-inselect id=the-insertion-mode:parsing-main-inselect-3>in select</a>" and return.</ol>

   <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-7>insertion mode</a> to "<a href=#parsing-main-intd id=the-insertion-mode:parsing-main-intd-2>in
   cell</a>" and return.<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-8>insertion
   mode</a> to "<a href=#parsing-main-intr id=the-insertion-mode:parsing-main-intr-2>in row</a>" and return.<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-9>insertion mode</a> to "<a href=#parsing-main-intbody id=the-insertion-mode:parsing-main-intbody-2>in table body</a>" and return.<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-10>insertion mode</a> to "<a href=#parsing-main-incaption id=the-insertion-mode:parsing-main-incaption-2>in caption</a>" and
   return.<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-11>insertion mode</a> to "<a href=#parsing-main-incolgroup id=the-insertion-mode:parsing-main-incolgroup-2>in column
   group</a>" and return.<li><p>If <var>node</var> is a <code id=the-insertion-mode:the-table-element-2><a href=#the-table-element>table</a></code> element, then switch the
   <a href=#insertion-mode id=the-insertion-mode:insertion-mode-12>insertion mode</a> to "<a href=#parsing-main-intable id=the-insertion-mode:parsing-main-intable-3>in table</a>" and
   return.<li><p>If <var>node</var> is a <code id=the-insertion-mode:the-template-element-3><a href=#the-template-element>template</a></code> element, then switch the
   <a href=#insertion-mode id=the-insertion-mode:insertion-mode-13>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.<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-14>insertion mode</a> to "<a href=#parsing-main-inhead id=the-insertion-mode:parsing-main-inhead-3>in
   head</a>" and return.<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-15>insertion mode</a> to "<a href=#parsing-main-inbody id=the-insertion-mode:parsing-main-inbody-3>in body</a>" and
   return.<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-16>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>)<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-17>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>)<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-18>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.</ol>

   <li><p>If <var>last</var> is true, then switch the <a href=#insertion-mode id=the-insertion-mode:insertion-mode-19>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>)<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-4>stack of open elements</a>.<li><p>Return to the step labeled <i>loop</i>.</ol>


  <h5 id=the-stack-of-open-elements><span class=secno>12.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>

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

  <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 by 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>

  <p>Elements in the <a href=#stack-of-open-elements id=the-stack-of-open-elements:stack-of-open-elements-4>stack of open elements</a> fall into the following categories:</p>

  <dl><dt><dfn id=special>Special</dfn><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:the-param-element><a href=#the-param-element>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-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://www.w3.org/Math/draft-spec/chapter3.html#presm.mi data-x-internal=mathml-mi>MathML <code>mi</code></a>, <a id=the-stack-of-open-elements:mathml-mo href=https://www.w3.org/Math/draft-spec/chapter3.html#presm.mo data-x-internal=mathml-mo>MathML <code>mo</code></a>,
    <a id=the-stack-of-open-elements:mathml-mn href=https://www.w3.org/Math/draft-spec/chapter3.html#presm.mn data-x-internal=mathml-mn>MathML <code>mn</code></a>, <a id=the-stack-of-open-elements:mathml-ms href=https://www.w3.org/Math/draft-spec/chapter3.html#presm.ms data-x-internal=mathml-ms>MathML <code>ms</code></a>, <a id=the-stack-of-open-elements:mathml-mtext href=https://www.w3.org/Math/draft-spec/chapter3.html#presm.mtext data-x-internal=mathml-mtext>MathML
    <code>mtext</code></a>, and <a id=the-stack-of-open-elements:mathml-annotation-xml href=https://www.w3.org/Math/draft-spec/chapter5.html#mixing.elements.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>
   <dt><dfn id=formatting>Formatting</dfn><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>.<dt><dfn id=ordinary>Ordinary</dfn><dd><p>All other elements found while parsing an HTML document.</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-5>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>

  <p>The <a href=#stack-of-open-elements id=the-stack-of-open-elements:stack-of-open-elements-6>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-2>current node</a> (the bottommost
   node of the stack).<li><p>If <var>node</var> is the target node, terminate in a match state.<li><p>Otherwise, if <var>node</var> is one of the element types in <var>list</var>, terminate in a failure state.<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-7>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.)</ol>

  <p>The <a href=#stack-of-open-elements id=the-stack-of-open-elements:stack-of-open-elements-8>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><code id=the-stack-of-open-elements:the-caption-element-2><a href=#the-caption-element>caption</a></code><li><code id=the-stack-of-open-elements:the-html-element-6><a href=#the-html-element>html</a></code><li><code id=the-stack-of-open-elements:the-table-element-2><a href=#the-table-element>table</a></code><li><code id=the-stack-of-open-elements:the-td-element-2><a href=#the-td-element>td</a></code><li><code id=the-stack-of-open-elements:the-th-element-2><a href=#the-th-element>th</a></code><li><code id=the-stack-of-open-elements:the-marquee-element-2><a href=#the-marquee-element>marquee</a></code><li><code id=the-stack-of-open-elements:the-object-element-2><a href=#the-object-element>object</a></code><li><code id=the-stack-of-open-elements:the-template-element-2><a href=#the-template-element>template</a></code><li><a id=the-stack-of-open-elements:mathml-mi-2 href=https://www.w3.org/Math/draft-spec/chapter3.html#presm.mi data-x-internal=mathml-mi>MathML <code>mi</code></a><li><a id=the-stack-of-open-elements:mathml-mo-2 href=https://www.w3.org/Math/draft-spec/chapter3.html#presm.mo data-x-internal=mathml-mo>MathML <code>mo</code></a><li><a id=the-stack-of-open-elements:mathml-mn-2 href=https://www.w3.org/Math/draft-spec/chapter3.html#presm.mn data-x-internal=mathml-mn>MathML <code>mn</code></a><li><a id=the-stack-of-open-elements:mathml-ms-2 href=https://www.w3.org/Math/draft-spec/chapter3.html#presm.ms data-x-internal=mathml-ms>MathML <code>ms</code></a><li><a id=the-stack-of-open-elements:mathml-mtext-2 href=https://www.w3.org/Math/draft-spec/chapter3.html#presm.mtext data-x-internal=mathml-mtext>MathML <code>mtext</code></a><li><a id=the-stack-of-open-elements:mathml-annotation-xml-2 href=https://www.w3.org/Math/draft-spec/chapter5.html#mixing.elements.annotation.xml data-x-internal=mathml-annotation-xml>MathML <code>annotation-xml</code></a><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><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><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></ul>

  <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-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><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><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></ul>

  <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-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><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></ul>

  <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-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><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><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></ul>

  <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-select-scope>have a particular element in select 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-5>has that element in the specific scope</a> consisting of all element types
  <em>except</em> the following:</p>

  <ul class=brief><li><code id=the-stack-of-open-elements:the-optgroup-element><a href=#the-optgroup-element>optgroup</a></code> in the <a id=the-stack-of-open-elements:html-namespace-2-7 href=https://infra.spec.whatwg.org/#html-namespace data-x-internal=html-namespace-2>HTML namespace</a><li><code id=the-stack-of-open-elements:the-option-element-2><a href=#the-option-element>option</a></code> in the <a id=the-stack-of-open-elements:html-namespace-2-8 href=https://infra.spec.whatwg.org/#html-namespace data-x-internal=html-namespace-2>HTML namespace</a></ul>

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

  <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.<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>.</ol>

  <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.<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.<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>.<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>.<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>.<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>.<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>.<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>.<li><p>Replace the entry for <var>entry</var> in the list with an entry for <var>new element</var>.<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>.</ol>

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

  <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>.<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>.<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>.<li><p>Go to step 1.</ol>


  <h5 id=the-element-pointers><span class=secno>12.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>12.2.4.5</span> Other parsing state flags<a href=#other-parsing-state-flags class=self-link></a></h5>

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

  <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 originally
  created for 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>12.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>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>

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

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

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

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

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

  <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) 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>

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

  <p>The tokenizer state machine consists of the states defined in the following subsections.</p>


  


  <h5 id=data-state><span class=secno>12.2.5.1</span> <dfn>Data state</dfn><a href=#data-state class=self-link></a></h5>

  <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;)<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>.<dt>U+003C LESS-THAN SIGN (&lt;)<dd>Switch to the <a href=#tag-open-state id=data-state:tag-open-state>tag open state</a>.<dt>U+0000 NULL<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.<dt>EOF<dd>Emit an end-of-file token.<dt>Anything else<dd>Emit the <a href=#current-input-character id=data-state:current-input-character-2>current input character</a> as a character token.</dl>


  <h5 id=rcdata-state><span class=secno>12.2.5.2</span> <dfn>RCDATA state</dfn><a href=#rcdata-state class=self-link></a></h5>

  <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;)<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>.<dt>U+003C LESS-THAN SIGN (&lt;)<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>.<dt>U+0000 NULL<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.<dt>EOF<dd>Emit an end-of-file token.<dt>Anything else<dd>Emit the <a href=#current-input-character id=rcdata-state:current-input-character>current input character</a> as a character token.</dl>


  <h5 id=rawtext-state><span class=secno>12.2.5.3</span> <dfn>RAWTEXT state</dfn><a href=#rawtext-state class=self-link></a></h5>

  <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;)<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>.<dt>U+0000 NULL<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.<dt>EOF<dd>Emit an end-of-file token.<dt>Anything else<dd>Emit the <a href=#current-input-character id=rawtext-state:current-input-character>current input character</a> as a character token.</dl>


  <h5 id=script-data-state><span class=secno>12.2.5.4</span> <dfn>Script data state</dfn><a href=#script-data-state class=self-link></a></h5>

  <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;)<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>.<dt>U+0000 NULL<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.<dt>EOF<dd>Emit an end-of-file token.<dt>Anything else<dd>Emit the <a href=#current-input-character id=script-data-state:current-input-character>current input character</a> as a character token.</dl>


  <h5 id=plaintext-state><span class=secno>12.2.5.5</span> <dfn>PLAINTEXT state</dfn><a href=#plaintext-state class=self-link></a></h5>

  <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<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.<dt>EOF<dd>Emit an end-of-file token.<dt>Anything else<dd>Emit the <a href=#current-input-character id=plaintext-state:current-input-character>current input character</a> as a character token.</dl>


  <h5 id=tag-open-state><span class=secno>12.2.5.6</span> <dfn>Tag open state</dfn><a href=#tag-open-state class=self-link></a></h5>

  <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 (!)<dd>Switch to the <a href=#markup-declaration-open-state id=tag-open-state:markup-declaration-open-state>markup declaration open state</a>.<dt>U+002F SOLIDUS (/)<dd>Switch to the <a href=#end-tag-open-state id=tag-open-state:end-tag-open-state>end tag open state</a>.<dt><a id=tag-open-state:ascii-letters href=https://infra.spec.whatwg.org/#ascii-alpha data-x-internal=ascii-letters>ASCII alpha</a><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>.

   <dt>U+003F QUESTION MARK (?)<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>.<dt>EOF<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.<dt>Anything else<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>.</dl>

  <h5 id=end-tag-open-state><span class=secno>12.2.5.7</span> <dfn>End tag open state</dfn><a href=#end-tag-open-state class=self-link></a></h5>

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

   <dt>U+003E GREATER-THAN SIGN (>)<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>.<dt>EOF<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.

   <dt>Anything else<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>.</dl>


  <h5 id=tag-name-state><span class=secno>12.2.5.8</span> <dfn>Tag name state</dfn><a href=#tag-name-state class=self-link></a></h5>

  <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>U+000A LINE FEED (LF)<dt>U+000C FORM FEED (FF)<dt>U+0020 SPACE<dd>Switch to the <a href=#before-attribute-name-state id=tag-name-state:before-attribute-name-state>before attribute name state</a>.<dt>U+002F SOLIDUS (/)<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>.<dt>U+003E GREATER-THAN SIGN (>)<dd>Switch to the <a href=#data-state id=tag-name-state:data-state>data state</a>. Emit the current tag token.<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><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.<dt>U+0000 NULL<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.<dt>EOF<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.<dt>Anything else<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.</dl>


  <h5 id=rcdata-less-than-sign-state><span class=secno>12.2.5.9</span> <dfn>RCDATA less-than sign state</dfn><a href=#rcdata-less-than-sign-state class=self-link></a></h5>
  

  <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 (/)<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>.<dt>Anything else<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>.</dl>


  <h5 id=rcdata-end-tag-open-state><span class=secno>12.2.5.10</span> <dfn>RCDATA end tag open state</dfn><a href=#rcdata-end-tag-open-state class=self-link></a></h5>
  

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

   <dt>Anything else<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>.</dl>


  <h5 id=rcdata-end-tag-name-state><span class=secno>12.2.5.11</span> <dfn>RCDATA end tag name state</dfn><a href=#rcdata-end-tag-name-state class=self-link></a></h5>
  

  <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>U+000A LINE FEED (LF)<dt>U+000C FORM FEED (FF)<dt>U+0020 SPACE<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.<dt>U+002F SOLIDUS (/)<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.<dt>U+003E GREATER-THAN SIGN (>)<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.<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><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>.<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><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>.<dt>Anything else<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>.</dl>


  <h5 id=rawtext-less-than-sign-state><span class=secno>12.2.5.12</span> <dfn>RAWTEXT less-than sign state</dfn><a href=#rawtext-less-than-sign-state class=self-link></a></h5>
  

  <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 (/)<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>.<dt>Anything else<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>.</dl>


  <h5 id=rawtext-end-tag-open-state><span class=secno>12.2.5.13</span> <dfn>RAWTEXT end tag open state</dfn><a href=#rawtext-end-tag-open-state class=self-link></a></h5>
  

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

   <dt>Anything else<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>.</dl>


  <h5 id=rawtext-end-tag-name-state><span class=secno>12.2.5.14</span> <dfn>RAWTEXT end tag name state</dfn><a href=#rawtext-end-tag-name-state class=self-link></a></h5>
  

  <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>U+000A LINE FEED (LF)<dt>U+000C FORM FEED (FF)<dt>U+0020 SPACE<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.<dt>U+002F SOLIDUS (/)<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.<dt>U+003E GREATER-THAN SIGN (>)<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.<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><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>.<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><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>.<dt>Anything else<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>.</dl>


  <h5 id=script-data-less-than-sign-state><span class=secno>12.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>

  <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 (/)<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>.<dt>U+0021 EXCLAMATION MARK (!)<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.<dt>Anything else<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>.</dl>


  <h5 id=script-data-end-tag-open-state><span class=secno>12.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>
  

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

   <dt>Anything else<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>.</dl>


  <h5 id=script-data-end-tag-name-state><span class=secno>12.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>
  

  <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>U+000A LINE FEED (LF)<dt>U+000C FORM FEED (FF)<dt>U+0020 SPACE<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.<dt>U+002F SOLIDUS (/)<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.<dt>U+003E GREATER-THAN SIGN (>)<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.<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><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>.<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><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>.<dt>Anything else<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>.</dl>


  <h5 id=script-data-escape-start-state><span class=secno>12.2.5.18</span> <dfn>Script data escape start state</dfn><a href=#script-data-escape-start-state class=self-link></a></h5>

  <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 (-)<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.<dt>Anything else<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>.</dl>


  <h5 id=script-data-escape-start-dash-state><span class=secno>12.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>

  <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 (-)<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.<dt>Anything else<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>.</dl>


  <h5 id=script-data-escaped-state><span class=secno>12.2.5.20</span> <dfn>Script data escaped state</dfn><a href=#script-data-escaped-state class=self-link></a></h5>

  <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 (-)<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.<dt>U+003C LESS-THAN SIGN (&lt;)<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>.<dt>U+0000 NULL<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.<dt>EOF<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.<dt>Anything else<dd>Emit the <a href=#current-input-character id=script-data-escaped-state:current-input-character>current input character</a> as a character token.</dl>


  <h5 id=script-data-escaped-dash-state><span class=secno>12.2.5.21</span> <dfn>Script data escaped dash state</dfn><a href=#script-data-escaped-dash-state class=self-link></a></h5>

  <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 (-)<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.<dt>U+003C LESS-THAN SIGN (&lt;)<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>.<dt>U+0000 NULL<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.<dt>EOF<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.<dt>Anything else<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.</dl>


  <h5 id=script-data-escaped-dash-dash-state><span class=secno>12.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>

  <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 (-)<dd>Emit a U+002D HYPHEN-MINUS character token.<dt>U+003C LESS-THAN SIGN (&lt;)<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>.<dt>U+003E GREATER-THAN SIGN (>)<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.<dt>U+0000 NULL<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.<dt>EOF<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.<dt>Anything else<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.</dl>


  <h5 id=script-data-escaped-less-than-sign-state><span class=secno>12.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>

  <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 (/)<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>.<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><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>.<dt>Anything else<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>.</dl>


  <h5 id=script-data-escaped-end-tag-open-state><span class=secno>12.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>

  <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><dd>Create a new end tag token. <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>. (Don't emit the token yet; further details will be filled in before it is
   emitted.)<dt>Anything else<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>.</dl>


  <h5 id=script-data-escaped-end-tag-name-state><span class=secno>12.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>

  <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>U+000A LINE FEED (LF)<dt>U+000C FORM FEED (FF)<dt>U+0020 SPACE<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.<dt>U+002F SOLIDUS (/)<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.<dt>U+003E GREATER-THAN SIGN (>)<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.<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><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>.<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><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>.<dt>Anything else<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>.</dl>


  <h5 id=script-data-double-escape-start-state><span class=secno>12.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>

  <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>U+000A LINE FEED (LF)<dt>U+000C FORM FEED (FF)<dt>U+0020 SPACE<dt>U+002F SOLIDUS (/)<dt>U+003E GREATER-THAN SIGN (>)<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.<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><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.<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><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.<dt>Anything else<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>.</dl>


  <h5 id=script-data-double-escaped-state><span class=secno>12.2.5.27</span> <dfn>Script data double escaped state</dfn><a href=#script-data-double-escaped-state class=self-link></a></h5>

  <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 (-)<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.<dt>U+003C LESS-THAN SIGN (&lt;)<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.<dt>U+0000 NULL<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.<dt>EOF<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.<dt>Anything else<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.</dl>


  <h5 id=script-data-double-escaped-dash-state><span class=secno>12.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>

  <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 (-)<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.<dt>U+003C LESS-THAN SIGN (&lt;)<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.<dt>U+0000 NULL<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.<dt>EOF<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.<dt>Anything else<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.</dl>


  <h5 id=script-data-double-escaped-dash-dash-state><span class=secno>12.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>

  <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 (-)<dd>Emit a U+002D HYPHEN-MINUS character token.<dt>U+003C LESS-THAN SIGN (&lt;)<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.<dt>U+003E GREATER-THAN SIGN (>)<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.<dt>U+0000 NULL<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.<dt>EOF<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.<dt>Anything else<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.</dl>


  <h5 id=script-data-double-escaped-less-than-sign-state><span class=secno>12.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>

  <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 (/)<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.<dt>Anything else<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>.</dl>


  <h5 id=script-data-double-escape-end-state><span class=secno>12.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>

  <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>U+000A LINE FEED (LF)<dt>U+000C FORM FEED (FF)<dt>U+0020 SPACE<dt>U+002F SOLIDUS (/)<dt>U+003E GREATER-THAN SIGN (>)<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.<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><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.<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><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.<dt>Anything else<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>.</dl>


  <h5 id=before-attribute-name-state><span class=secno>12.2.5.32</span> <dfn>Before attribute name state</dfn><a href=#before-attribute-name-state class=self-link></a></h5>

  <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>U+000A LINE FEED (LF)<dt>U+000C FORM FEED (FF)<dt>U+0020 SPACE<dd>Ignore the character.<dt>U+002F SOLIDUS (/)<dt>U+003E GREATER-THAN SIGN (>)<dt>EOF<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>.<dt>U+003D EQUALS SIGN (=)<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>.<dt>Anything else<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>.</dl>


  <h5 id=attribute-name-state><span class=secno>12.2.5.33</span> <dfn>Attribute name state</dfn><a href=#attribute-name-state class=self-link></a></h5>

  <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>U+000A LINE FEED (LF)<dt>U+000C FORM FEED (FF)<dt>U+0020 SPACE<dt>U+002F SOLIDUS (/)<dt>U+003E GREATER-THAN SIGN (>)<dt>EOF<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>.<dt>U+003D EQUALS SIGN (=)<dd>Switch to the <a href=#before-attribute-value-state id=attribute-name-state:before-attribute-value-state>before attribute value state</a>.<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><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.<dt>U+0000 NULL<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.<dt>U+0022 QUOTATION MARK (")<dt>U+0027 APOSTROPHE (')<dt>U+003C LESS-THAN SIGN (&lt;)<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.<dt>Anything else<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.</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>

  <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>12.2.5.34</span> <dfn>After attribute name state</dfn><a href=#after-attribute-name-state class=self-link></a></h5>

  <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>U+000A LINE FEED (LF)<dt>U+000C FORM FEED (FF)<dt>U+0020 SPACE<dd>Ignore the character.<dt>U+002F SOLIDUS (/)<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>.<dt>U+003D EQUALS SIGN (=)<dd>Switch to the <a href=#before-attribute-value-state id=after-attribute-name-state:before-attribute-value-state>before attribute value state</a>.<dt>U+003E GREATER-THAN SIGN (>)<dd>Switch to the <a href=#data-state id=after-attribute-name-state:data-state>data state</a>. Emit the current tag token.<dt>EOF<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.<dt>Anything else<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>.</dl>


  <h5 id=before-attribute-value-state><span class=secno>12.2.5.35</span> <dfn>Before attribute value state</dfn><a href=#before-attribute-value-state class=self-link></a></h5>

  <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>U+000A LINE FEED (LF)<dt>U+000C FORM FEED (FF)<dt>U+0020 SPACE<dd>Ignore the character.<dt>U+0022 QUOTATION MARK (")<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>.<dt>U+0027 APOSTROPHE (')<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>.<dt>U+003E GREATER-THAN SIGN (>)<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.<dt>Anything else<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>.</dl>


  <h5 id=attribute-value-(double-quoted)-state><span class=secno>12.2.5.36</span> <dfn>Attribute value (double-quoted) state</dfn><a href=#attribute-value-(double-quoted)-state class=self-link></a></h5>

  <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 (")<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>.<dt>U+0026 AMPERSAND (&amp;)<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>.<dt>U+0000 NULL<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.<dt>EOF<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.<dt>Anything else<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.</dl>


  <h5 id=attribute-value-(single-quoted)-state><span class=secno>12.2.5.37</span> <dfn>Attribute value (single-quoted) state</dfn><a href=#attribute-value-(single-quoted)-state class=self-link></a></h5>

  <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 (')<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>.<dt>U+0026 AMPERSAND (&amp;)<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>.<dt>U+0000 NULL<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.<dt>EOF<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.<dt>Anything else<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.</dl>


  <h5 id=attribute-value-(unquoted)-state><span class=secno>12.2.5.38</span> <dfn>Attribute value (unquoted) state</dfn><a href=#attribute-value-(unquoted)-state class=self-link></a></h5>

  <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>U+000A LINE FEED (LF)<dt>U+000C FORM FEED (FF)<dt>U+0020 SPACE<dd>Switch to the <a href=#before-attribute-name-state id=attribute-value-(unquoted)-state:before-attribute-name-state>before attribute name state</a>.<dt>U+0026 AMPERSAND (&amp;)<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>.<dt>U+003E GREATER-THAN SIGN (>)<dd>Switch to the <a href=#data-state id=attribute-value-(unquoted)-state:data-state>data state</a>. Emit the current tag token.<dt>U+0000 NULL<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.<dt>U+0022 QUOTATION MARK (")<dt>U+0027 APOSTROPHE (')<dt>U+003C LESS-THAN SIGN (&lt;)<dt>U+003D EQUALS SIGN (=)<dt>U+0060 GRAVE ACCENT (`)<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.<dt>EOF<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.<dt>Anything else<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.</dl>


  <h5 id=after-attribute-value-(quoted)-state><span class=secno>12.2.5.39</span> <dfn>After attribute value (quoted) state</dfn><a href=#after-attribute-value-(quoted)-state class=self-link></a></h5>

  <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>U+000A LINE FEED (LF)<dt>U+000C FORM FEED (FF)<dt>U+0020 SPACE<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>.<dt>U+002F SOLIDUS (/)<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>.<dt>U+003E GREATER-THAN SIGN (>)<dd>Switch to the <a href=#data-state id=after-attribute-value-(quoted)-state:data-state>data state</a>. Emit the current tag token.<dt>EOF<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.<dt>Anything else<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>.
   </dl>


  <h5 id=self-closing-start-tag-state><span class=secno>12.2.5.40</span> <dfn>Self-closing start tag state</dfn><a href=#self-closing-start-tag-state class=self-link></a></h5>

  <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 (>)<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.<dt>EOF<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.<dt>Anything else<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>.</dl>


  <h5 id=bogus-comment-state><span class=secno>12.2.5.41</span> <dfn>Bogus comment state</dfn><a href=#bogus-comment-state class=self-link></a></h5>

  <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 (>)<dd>Switch to the <a href=#data-state id=bogus-comment-state:data-state>data state</a>. Emit the comment token.<dt>EOF<dd>Emit the comment. Emit an end-of-file token.<dt>U+0000 NULL<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.<dt>Anything else<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.</dl>


  <h5 id=markup-declaration-open-state><span class=secno>12.2.5.42</span> <dfn>Markup declaration open state</dfn><a href=#markup-declaration-open-state class=self-link></a></h5>

  <p>If the next few characters are:<p>

  <dl class=switch><dt>Two U+002D HYPHEN-MINUS characters (-)<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>.<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"<dd>Consume those characters and switch to the <a href=#doctype-state id=markup-declaration-open-state:doctype-state>DOCTYPE state</a>.<dt><a href=#case-sensitive id=markup-declaration-open-state:case-sensitive>Case-sensitive</a> match for the string "[CDATA[" (the five uppercase letters
   "CDATA" with a U+005B LEFT SQUARE BRACKET character before and after)<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>.<dt>Anything else<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).</dl>


  <h5 id=comment-start-state><span class=secno>12.2.5.43</span> <dfn>Comment start state</dfn><a href=#comment-start-state class=self-link></a></h5>

  <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 (-)<dd>Switch to the <a href=#comment-start-dash-state id=comment-start-state:comment-start-dash-state>comment start dash state</a>.<dt>U+003E GREATER-THAN SIGN (>)<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 comment token.<dt>Anything else<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>.</dl>


  <h5 id=comment-start-dash-state><span class=secno>12.2.5.44</span> <dfn>Comment start dash state</dfn><a href=#comment-start-dash-state class=self-link></a></h5>

  <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 (-)<dd>Switch to the <a href=#comment-end-state id=comment-start-dash-state:comment-end-state>comment end state</a><dt>U+003E GREATER-THAN SIGN (>)<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 comment token.<dt>EOF<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 comment token. Emit an end-of-file token.<dt>Anything else<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>.</dl>


  <h5 id=comment-state><span class=secno>12.2.5.45</span> <dfn id=comment>Comment state</dfn><a href=#comment-state class=self-link></a></h5>

  <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;)<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>.<dt>U+002D HYPHEN-MINUS (-)<dd>Switch to the <a href=#comment-end-dash-state id=comment-state:comment-end-dash-state>comment end dash state</a>.<dt>U+0000 NULL<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.<dt>EOF<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 comment token. Emit an end-of-file token.<dt>Anything else<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.</dl>


  <h5 id=comment-less-than-sign-state><span class=secno>12.2.5.46</span> <dfn>Comment less-than sign state</dfn><a href=#comment-less-than-sign-state class=self-link></a></h5>

  <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 (!)<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>.<dt>U+003C LESS-THAN SIGN (&lt;)<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.<dt>Anything else<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>.</dl>


  <h5 id=comment-less-than-sign-bang-state><span class=secno>12.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>

  <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 (-)<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>.<dt>Anything else<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>.</dl>


  <h5 id=comment-less-than-sign-bang-dash-state><span class=secno>12.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>

  <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 (-)<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>.<dt>Anything else<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>.</dl>


  <h5 id=comment-less-than-sign-bang-dash-dash-state><span class=secno>12.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>

  <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 (>)<dt>EOF<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>.<dt>Anything else<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>.</dl>


  <h5 id=comment-end-dash-state><span class=secno>12.2.5.50</span> <dfn>Comment end dash state</dfn><a href=#comment-end-dash-state class=self-link></a></h5>

  <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 (-)<dd>Switch to the <a href=#comment-end-state id=comment-end-dash-state:comment-end-state>comment end state</a><dt>EOF<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 comment token. Emit an end-of-file token.<dt>Anything else<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>.</dl>


  <h5 id=comment-end-state><span class=secno>12.2.5.51</span> <dfn>Comment end state</dfn><a href=#comment-end-state class=self-link></a></h5>

  <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 (>)<dd>Switch to the <a href=#data-state id=comment-end-state:data-state>data state</a>. Emit the comment token.<dt>U+0021 EXCLAMATION MARK (!)<dd>Switch to the <a href=#comment-end-bang-state id=comment-end-state:comment-end-bang-state>comment end bang state</a>.<dt>U+002D HYPHEN-MINUS (-)<dd>Append a U+002D HYPHEN-MINUS character (-) to the comment token's data.<dt>EOF<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 comment token. Emit an end-of-file token.<dt>Anything else<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>.</dl>


  <h5 id=comment-end-bang-state><span class=secno>12.2.5.52</span> <dfn>Comment end bang state</dfn><a href=#comment-end-bang-state class=self-link></a></h5>

  <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 (-)<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>.<dt>U+003E GREATER-THAN SIGN (>)<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 comment token.<dt>EOF<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 comment token. Emit an end-of-file token.<dt>Anything else<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>.</dl>


  <h5 id=doctype-state><span class=secno>12.2.5.53</span> <dfn>DOCTYPE state</dfn><a href=#doctype-state class=self-link></a></h5>

  <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>U+000A LINE FEED (LF)<dt>U+000C FORM FEED (FF)<dt>U+0020 SPACE<dd>Switch to the <a href=#before-doctype-name-state id=doctype-state:before-doctype-name-state>before DOCTYPE name state</a>.<dt>U+003E GREATER-THAN SIGN (>)<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>.<dt>EOF<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 token. Emit an end-of-file token.<dt>Anything else<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>.
   </dl>


  <h5 id=before-doctype-name-state><span class=secno>12.2.5.54</span> <dfn>Before DOCTYPE name state</dfn><a href=#before-doctype-name-state class=self-link></a></h5>

  <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>U+000A LINE FEED (LF)<dt>U+000C FORM FEED (FF)<dt>U+0020 SPACE<dd>Ignore the character.<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><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>.<dt>U+0000 NULL<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>.<dt>U+003E GREATER-THAN SIGN (>)<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 token.<dt>EOF<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 token. Emit an end-of-file token.<dt>Anything else<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>.</dl>


  <h5 id=doctype-name-state><span class=secno>12.2.5.55</span> <dfn>DOCTYPE name state</dfn><a href=#doctype-name-state class=self-link></a></h5>

  <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>U+000A LINE FEED (LF)<dt>U+000C FORM FEED (FF)<dt>U+0020 SPACE<dd>Switch to the <a href=#after-doctype-name-state id=doctype-name-state:after-doctype-name-state>after DOCTYPE name state</a>.<dt>U+003E GREATER-THAN SIGN (>)<dd>Switch to the <a href=#data-state id=doctype-name-state:data-state>data state</a>. Emit the current DOCTYPE token.<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><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.<dt>U+0000 NULL<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.<dt>EOF<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 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 that DOCTYPE token. Emit an end-of-file token.<dt>Anything else<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.</dl>


  <h5 id=after-doctype-name-state><span class=secno>12.2.5.56</span> <dfn>After DOCTYPE name state</dfn><a href=#after-doctype-name-state class=self-link></a></h5>

  <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>U+000A LINE FEED (LF)<dt>U+000C FORM FEED (FF)<dt>U+0020 SPACE<dd>Ignore the character.<dt>U+003E GREATER-THAN SIGN (>)<dd>Switch to the <a href=#data-state id=after-doctype-name-state:data-state>data state</a>. Emit the current DOCTYPE token.<dt>EOF<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 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 that DOCTYPE token. Emit an end-of-file token.<dt>Anything else<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 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>

   </dl>


  <h5 id=after-doctype-public-keyword-state><span class=secno>12.2.5.57</span> <dfn>After DOCTYPE public keyword state</dfn><a href=#after-doctype-public-keyword-state class=self-link></a></h5>

  <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>U+000A LINE FEED (LF)<dt>U+000C FORM FEED (FF)<dt>U+0020 SPACE<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>.<dt>U+0022 QUOTATION MARK (")<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 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>.<dt>U+0027 APOSTROPHE (')<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 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>.<dt>U+003E GREATER-THAN SIGN (>)<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 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 that DOCTYPE token.<dt>EOF<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 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 that DOCTYPE token. Emit an end-of-file token.<dt>Anything else<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 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>.</dl>


  <h5 id=before-doctype-public-identifier-state><span class=secno>12.2.5.58</span> <dfn>Before DOCTYPE public identifier state</dfn><a href=#before-doctype-public-identifier-state class=self-link></a></h5>

  <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>U+000A LINE FEED (LF)<dt>U+000C FORM FEED (FF)<dt>U+0020 SPACE<dd>Ignore the character.<dt>U+0022 QUOTATION MARK (")<dd>Set the 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>.<dt>U+0027 APOSTROPHE (')<dd>Set the 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>.<dt>U+003E GREATER-THAN SIGN (>)<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 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 that DOCTYPE token.<dt>EOF<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 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 that DOCTYPE token. Emit an end-of-file token.<dt>Anything else<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 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>.</dl>


  <h5 id=doctype-public-identifier-(double-quoted)-state><span class=secno>12.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>

  <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 (")<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>.<dt>U+0000 NULL<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.<dt>U+003E GREATER-THAN SIGN (>)<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 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 that DOCTYPE token.<dt>EOF<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 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 that DOCTYPE token. Emit an end-of-file token.<dt>Anything else<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.</dl>


  <h5 id=doctype-public-identifier-(single-quoted)-state><span class=secno>12.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>

  <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 (')<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>.<dt>U+0000 NULL<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.<dt>U+003E GREATER-THAN SIGN (>)<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 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 that DOCTYPE token.<dt>EOF<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 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 that DOCTYPE token. Emit an end-of-file token.<dt>Anything else<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.</dl>


  <h5 id=after-doctype-public-identifier-state><span class=secno>12.2.5.61</span> <dfn>After DOCTYPE public identifier state</dfn><a href=#after-doctype-public-identifier-state class=self-link></a></h5>

  <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>U+000A LINE FEED (LF)<dt>U+000C FORM FEED (FF)<dt>U+0020 SPACE<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>.<dt>U+003E GREATER-THAN SIGN (>)<dd>Switch to the <a href=#data-state id=after-doctype-public-identifier-state:data-state>data state</a>. Emit the current DOCTYPE token.<dt>U+0022 QUOTATION MARK (")<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 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>.<dt>U+0027 APOSTROPHE (')<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 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>.<dt>EOF<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 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 that DOCTYPE token. Emit an end-of-file token.<dt>Anything else<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 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>.</dl>


  <h5 id=between-doctype-public-and-system-identifiers-state><span class=secno>12.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>

  <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>U+000A LINE FEED (LF)<dt>U+000C FORM FEED (FF)<dt>U+0020 SPACE<dd>Ignore the character.<dt>U+003E GREATER-THAN SIGN (>)<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.<dt>U+0022 QUOTATION MARK (")<dd>Set the 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>.<dt>U+0027 APOSTROPHE (')<dd>Set the 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>.<dt>EOF<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 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 that DOCTYPE token. Emit an end-of-file token.<dt>Anything else<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 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>.</dl>


  <h5 id=after-doctype-system-keyword-state><span class=secno>12.2.5.63</span> <dfn>After DOCTYPE system keyword state</dfn><a href=#after-doctype-system-keyword-state class=self-link></a></h5>

  <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>U+000A LINE FEED (LF)<dt>U+000C FORM FEED (FF)<dt>U+0020 SPACE<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>.<dt>U+0022 QUOTATION MARK (")<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 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>.<dt>U+0027 APOSTROPHE (')<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 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>.<dt>U+003E GREATER-THAN SIGN (>)<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 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 that DOCTYPE token.<dt>EOF<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 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 that DOCTYPE token. Emit an end-of-file token.<dt>Anything else<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 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>.</dl>


  <h5 id=before-doctype-system-identifier-state><span class=secno>12.2.5.64</span> <dfn>Before DOCTYPE system identifier state</dfn><a href=#before-doctype-system-identifier-state class=self-link></a></h5>

  <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>U+000A LINE FEED (LF)<dt>U+000C FORM FEED (FF)<dt>U+0020 SPACE<dd>Ignore the character.<dt>U+0022 QUOTATION MARK (")<dd>Set the 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>.<dt>U+0027 APOSTROPHE (')<dd>Set the 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>.<dt>U+003E GREATER-THAN SIGN (>)<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 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 that DOCTYPE token.<dt>EOF<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 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 that DOCTYPE token. Emit an end-of-file token.<dt>Anything else<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 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>.</dl>


  <h5 id=doctype-system-identifier-(double-quoted)-state><span class=secno>12.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>

  <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 (")<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>.<dt>U+0000 NULL<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.<dt>U+003E GREATER-THAN SIGN (>)<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 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 that DOCTYPE token.<dt>EOF<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 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 that DOCTYPE token. Emit an end-of-file token.<dt>Anything else<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.</dl>


  <h5 id=doctype-system-identifier-(single-quoted)-state><span class=secno>12.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>

  <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 (')<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>.<dt>U+0000 NULL<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.<dt>U+003E GREATER-THAN SIGN (>)<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 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 that DOCTYPE token.<dt>EOF<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 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 that DOCTYPE token. Emit an end-of-file token.<dt>Anything else<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.</dl>


  <h5 id=after-doctype-system-identifier-state><span class=secno>12.2.5.67</span> <dfn>After DOCTYPE system identifier state</dfn><a href=#after-doctype-system-identifier-state class=self-link></a></h5>

  <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>U+000A LINE FEED (LF)<dt>U+000C FORM FEED (FF)<dt>U+0020 SPACE<dd>Ignore the character.<dt>U+003E GREATER-THAN SIGN (>)<dd>Switch to the <a href=#data-state id=after-doctype-system-identifier-state:data-state>data state</a>. Emit the current DOCTYPE token.<dt>EOF<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 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 that DOCTYPE token. Emit an end-of-file token.<dt>Anything else<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 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>.)</dl>


  <h5 id=bogus-doctype-state><span class=secno>12.2.5.68</span> <dfn>Bogus DOCTYPE state</dfn><a href=#bogus-doctype-state class=self-link></a></h5>

  <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 (>)<dd>Switch to the <a href=#data-state id=bogus-doctype-state:data-state>data state</a>. Emit the DOCTYPE token.<dt>U+0000 NULL<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.<dt>EOF<dd>Emit the DOCTYPE token. Emit an end-of-file token.<dt>Anything else<dd>Ignore the character.</dl>


  <h5 id=cdata-section-state><span class=secno>12.2.5.69</span> <dfn>CDATA section state</dfn><a href=#cdata-section-state class=self-link></a></h5>

  <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 (])<dd>Switch to the <a href=#cdata-section-bracket-state id=cdata-section-state:cdata-section-bracket-state>CDATA section bracket state</a>.<dt>EOF<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.<dt>Anything else<dd>Emit the <a href=#current-input-character id=cdata-section-state:current-input-character>current input character</a> as a character token.</dl>

  <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>12.2.5.70</span> <dfn>CDATA section bracket state</dfn><a href=#cdata-section-bracket-state class=self-link></a></h5>

  <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 (])<dd>Switch to the <a href=#cdata-section-end-state id=cdata-section-bracket-state:cdata-section-end-state>CDATA section end state</a>.<dt>Anything else<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>.</dl>


  <h5 id=cdata-section-end-state><span class=secno>12.2.5.71</span> <dfn>CDATA section end state</dfn><a href=#cdata-section-end-state class=self-link></a></h5>

  <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 (])<dd>Emit a U+005D RIGHT SQUARE BRACKET character token.<dt>U+003E GREATER-THAN SIGN character<dd>Switch to the <a href=#data-state id=cdata-section-end-state:data-state>data state</a>.<dt>Anything else<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>.</dl>



  <h5 id=character-reference-state><span class=secno>12.2.5.72</span> <dfn>Character reference state</dfn><a href=#character-reference-state class=self-link></a></h5>

  <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><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>.<dt>U+0023 NUMBER SIGN (#)<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>.<dt>Anything else<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>.</dl>


  <h5 id=named-character-reference-state><span class=secno>12.2.5.73</span> <dfn>Named character reference state</dfn><a href=#named-character-reference-state class=self-link></a></h5>

  <p>Consume the maximum number of characters possible, with the consumed characters matching 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 (in
  a <a href=#case-sensitive id=named-character-reference-state:case-sensitive>case-sensitive</a> manner). 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<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>.<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>.<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>.</ol>
   <dt>Otherwise<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>.</dl>

  <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>12.2.5.74</span> <dfn>Ambiguous ampersand state</dfn><a href=#ambiguous-ampersand-state class=self-link></a></h5>

  <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><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.<dt>U+003B SEMICOLON (;)<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>.

    <dt>Anything else<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>.</dl>

  <h5 id=numeric-character-reference-state><span class=secno>12.2.5.75</span> <dfn>Numeric character reference state</dfn><a href=#numeric-character-reference-state class=self-link></a></h5>

  <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>U+0058 LATIN CAPITAL LETTER X<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>.<dt>Anything else<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>.</dl>


  <h5 id=hexadecimal-character-reference-start-state><span class=secno>12.2.5.76</span> <dfn>Hexadecimal character reference start state</dfn><a href=#hexadecimal-character-reference-start-state class=self-link></a></h5>

  <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><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>.<dt>Anything else<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>.</dl>


  <h5 id=decimal-character-reference-start-state><span class=secno>12.2.5.77</span> <dfn>Decimal character reference start state</dfn><a href=#decimal-character-reference-start-state class=self-link></a></h5>

  <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><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>.<dt>Anything else<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>.</dl>


  <h5 id=hexadecimal-character-reference-state><span class=secno>12.2.5.78</span> <dfn>Hexadecimal character reference state</dfn><a href=#hexadecimal-character-reference-state class=self-link></a></h5>

  <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><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>.<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><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>.<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><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>.<dt>U+003B SEMICOLON<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>.<dt>Anything else<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>.</dl>


  <h5 id=decimal-character-reference-state><span class=secno>12.2.5.79</span> <dfn>Decimal character reference state</dfn><a href=#decimal-character-reference-state class=self-link></a></h5>

  <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><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>.<dt>U+003B SEMICOLON<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>.<dt>Anything else<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>.</dl>


  <h5 id=numeric-character-reference-end-state><span class=secno>12.2.5.80</span> <dfn>Numeric character reference end state</dfn><a href=#numeric-character-reference-end-state class=self-link></a></h5>

  <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.<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.<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.<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>.<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 colspan=2>Code point
      <tbody><tr><td>0x80 <td>0x20AC <td>EURO SIGN (€)
      
      <tr><td>0x82 <td>0x201A <td>SINGLE LOW-9 QUOTATION MARK (‚)
      <tr><td>0x83 <td>0x0192 <td>LATIN SMALL LETTER F WITH HOOK (ƒ)
      <tr><td>0x84 <td>0x201E <td>DOUBLE LOW-9 QUOTATION MARK („)
      <tr><td>0x85 <td>0x2026 <td>HORIZONTAL ELLIPSIS (…)
      <tr><td>0x86 <td>0x2020 <td>DAGGER (†)
      <tr><td>0x87 <td>0x2021 <td>DOUBLE DAGGER (‡)
      <tr><td>0x88 <td>0x02C6 <td>MODIFIER LETTER CIRCUMFLEX ACCENT (ˆ)
      <tr><td>0x89 <td>0x2030 <td>PER MILLE SIGN (‰)
      <tr><td>0x8A <td>0x0160 <td>LATIN CAPITAL LETTER S WITH CARON (Š)
      <tr><td>0x8B <td>0x2039 <td>SINGLE LEFT-POINTING ANGLE QUOTATION MARK (‹)
      <tr><td>0x8C <td>0x0152 <td>LATIN CAPITAL LIGATURE OE (Œ)
      
      <tr><td>0x8E <td>0x017D <td>LATIN CAPITAL LETTER Z WITH CARON (Ž)
      
      
      <tr><td>0x91 <td>0x2018 <td>LEFT SINGLE QUOTATION MARK (‘)
      <tr><td>0x92 <td>0x2019 <td>RIGHT SINGLE QUOTATION MARK (’)
      <tr><td>0x93 <td>0x201C <td>LEFT DOUBLE QUOTATION MARK (“)
      <tr><td>0x94 <td>0x201D <td>RIGHT DOUBLE QUOTATION MARK (”)
      <tr><td>0x95 <td>0x2022 <td>BULLET (•)
      <tr><td>0x96 <td>0x2013 <td>EN DASH (–)
      <tr><td>0x97 <td>0x2014 <td>EM DASH (—)
      <tr><td>0x98 <td>0x02DC <td>SMALL TILDE (˜)
      <tr><td>0x99 <td>0x2122 <td>TRADE MARK SIGN (™)
      <tr><td>0x9A <td>0x0161 <td>LATIN SMALL LETTER S WITH CARON (š)
      <tr><td>0x9B <td>0x203A <td>SINGLE RIGHT-POINTING ANGLE QUOTATION MARK (›)
      <tr><td>0x9C <td>0x0153 <td>LATIN SMALL LIGATURE OE (œ)
      
      <tr><td>0x9E <td>0x017E <td>LATIN SMALL LETTER Z WITH CARON (ž)
      <tr><td>0x9F <td>0x0178 <td>LATIN CAPITAL LETTER Y WITH DIAERESIS (Ÿ)
    </table></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>

  


  

  

  <h4 id=tree-construction><span class=secno>12.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>

  <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>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>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>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>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://www.w3.org/Math/draft-spec/chapter5.html#mixing.elements.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>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>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>If the token is an end-of-file token<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.<dt>Otherwise<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>.</dl>

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

  <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://www.w3.org/Math/draft-spec/chapter3.html#presm.mi data-x-internal=mathml-mi>MathML <code>mi</code></a> element<li>A <a id=tree-construction:mathml-mo href=https://www.w3.org/Math/draft-spec/chapter3.html#presm.mo data-x-internal=mathml-mo>MathML <code>mo</code></a> element<li>A <a id=tree-construction:mathml-mn href=https://www.w3.org/Math/draft-spec/chapter3.html#presm.mn data-x-internal=mathml-mn>MathML <code>mn</code></a> element<li>A <a id=tree-construction:mathml-ms href=https://www.w3.org/Math/draft-spec/chapter3.html#presm.ms data-x-internal=mathml-ms>MathML <code>ms</code></a> element<li>A <a id=tree-construction:mathml-mtext href=https://www.w3.org/Math/draft-spec/chapter3.html#presm.mtext data-x-internal=mathml-mtext>MathML <code>mtext</code></a> element</ul>

  <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://www.w3.org/Math/draft-spec/chapter5.html#mixing.elements.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>A <a id=tree-construction:mathml-annotation-xml-3 href=https://www.w3.org/Math/draft-spec/chapter5.html#mixing.elements.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>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>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>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</ul>

  <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 avoid arbitrary limits, it is recognized that <a href=#hardwareLimitations>practical concerns</a> will likely force user agents to impose nesting
  depth constraints.</p>


  <h5 id=creating-and-inserting-nodes><span class=secno>12.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>

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

    <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<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><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><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 substeps.<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 substeps.
       (<a href=#fragment-case id=creating-and-inserting-nodes:fragment-case>fragment case</a>)</p>

       

       <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 substeps.<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>.<li><p>Let <var>adjusted insertion location</var> be inside <var>previous
       element</var>, after its last child (if any).</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>

     <dt>Otherwise<dd>

      <p>Let <var>adjusted insertion location</var> be inside <var>target</var>,
      after its last child (if any).</p>

     </dl>

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

    <p>Return the <var>adjusted insertion location</var>.</p>

   </ol>

  <hr>

  <p>When the steps below require the UA to <dfn id=create-an-element-for-the-token>create an
  element for a token</dfn> in a particular <var>given namespace</var> and with a
  particular <var>intended parent</var>, the UA must run the following steps:</p>

  <ol><li><p>Let <var>document</var> be <var>intended parent</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>.<li><p>Let <var>local name</var> be the tag name of the token.<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 the
   given token, if such an attribute exists, or null otherwise.<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>document</var>, <var>given
   namespace</var>, <var>local name</var>, and <var>is</var>.<li><p>If <var>definition</var> is non-null and the parser was not originally created for the
   <a href=#html-fragment-parsing-algorithm id=creating-and-inserting-nodes:html-fragment-parsing-algorithm>HTML fragment parsing algorithm</a>, then let <var>will execute script</var> be true.
   Otherwise, let it be false.<li>
    <p>If <var>will execute script</var> is true, then:</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>.<li><p>If the <a id=creating-and-inserting-nodes:javascript-execution-context-stack href=https://tc39.github.io/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>.<li><p>Push a new <a href=#element-queue id=creating-and-inserting-nodes:element-queue>element queue</a> onto the <a href=#custom-element-reactions-stack id=creating-and-inserting-nodes:custom-element-reactions-stack>custom element reactions
     stack</a>.</ol>
   <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>given
    namespace</var>, null, and <var>is</var>. If <var>will execute script</var> is true, set the
    <var>synchronous custom elements flag</var>; otherwise, leave it unset.</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>will execute script</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>
    <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>
    <p>If <var>will execute script</var> is true, then:</p>

    <ol><li><p>Let <var>queue</var> be the result of popping the <a href=#current-element-queue id=creating-and-inserting-nodes:current-element-queue>current element queue</a>
     from the <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.)<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>.<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>.</ol>
   <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>.<li><p>If <var>element</var> is a <a href=#category-reset id=creating-and-inserting-nodes:category-reset>resettable element</a>, 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.)<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>, 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>intended parent</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>.<li><p>Return <var>element</var>.</ol>

  <hr>

  

  <p>When the steps below require the user agent to <dfn id=insert-a-foreign-element>insert a foreign element</dfn> for a token
  in a given namespace, the user agent must 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=creating-and-inserting-nodes:appropriate-place-for-inserting-a-node>appropriate place for
   inserting a node</a>.<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> in the given namespace, with the intended
   parent being the element in which the <var>adjusted insertion location</var> finds
   itself.<li>
    <p>If it is possible to insert <var>element</var> at the <var>adjusted insertion location</var>,
    then:</p>

    <ol><li><p>Push a new <a href=#element-queue id=creating-and-inserting-nodes:element-queue-3>element queue</a> onto the <a href=#custom-element-reactions-stack id=creating-and-inserting-nodes:custom-element-reactions-stack-3>custom element reactions
     stack</a>.<li><p>Insert <var>element</var> at the <var>adjusted insertion location</var>.<li><p>Pop the <a href=#element-queue id=creating-and-inserting-nodes:element-queue-4>element queue</a> from the <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.</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>
   <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>.<li><p>Return <var>element</var>.</ol>

  <p>When the steps below require the user agent to <dfn id=insert-an-html-element>insert an HTML element</dfn> for a token,
  the user agent must <a href=#insert-a-foreign-element id=creating-and-inserting-nodes:insert-a-foreign-element>insert a foreign element</a> for the token, in 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>.</p>

  <hr>

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

  <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> Attribute name on element
   <tbody><tr><td> <code>attributename</code> <td> <code>attributeName</code>
    <tr><td> <code>attributetype</code> <td> <code>attributeType</code>
    <tr><td> <code>basefrequency</code> <td> <code>baseFrequency</code>
    <tr><td> <code>baseprofile</code> <td> <code>baseProfile</code>
    <tr><td> <code>calcmode</code> <td> <code>calcMode</code>
    <tr><td> <code>clippathunits</code> <td> <code>clipPathUnits</code>
    <tr><td> <code>diffuseconstant</code> <td> <code>diffuseConstant</code>
    <tr><td> <code>edgemode</code> <td> <code>edgeMode</code>
    <tr><td> <code>filterunits</code> <td> <code>filterUnits</code>
    <tr><td> <code>glyphref</code> <td> <code>glyphRef</code>
    <tr><td> <code>gradienttransform</code> <td> <code>gradientTransform</code>
    <tr><td> <code>gradientunits</code> <td> <code>gradientUnits</code>
    <tr><td> <code>kernelmatrix</code> <td> <code>kernelMatrix</code>
    <tr><td> <code>kernelunitlength</code> <td> <code>kernelUnitLength</code>
    <tr><td> <code>keypoints</code> <td> <code>keyPoints</code>
    <tr><td> <code>keysplines</code> <td> <code>keySplines</code>
    <tr><td> <code>keytimes</code> <td> <code>keyTimes</code>
    <tr><td> <code>lengthadjust</code> <td> <code>lengthAdjust</code>
    <tr><td> <code>limitingconeangle</code> <td> <code>limitingConeAngle</code>
    <tr><td> <code>markerheight</code> <td> <code>markerHeight</code>
    <tr><td> <code>markerunits</code> <td> <code>markerUnits</code>
    <tr><td> <code>markerwidth</code> <td> <code>markerWidth</code>
    <tr><td> <code>maskcontentunits</code> <td> <code>maskContentUnits</code>
    <tr><td> <code>maskunits</code> <td> <code>maskUnits</code>
    <tr><td> <code>numoctaves</code> <td> <code>numOctaves</code>
    <tr><td> <code>pathlength</code> <td> <code>pathLength</code>
    <tr><td> <code>patterncontentunits</code> <td> <code>patternContentUnits</code>
    <tr><td> <code>patterntransform</code> <td> <code>patternTransform</code>
    <tr><td> <code>patternunits</code> <td> <code>patternUnits</code>
    <tr><td> <code>pointsatx</code> <td> <code>pointsAtX</code>
    <tr><td> <code>pointsaty</code> <td> <code>pointsAtY</code>
    <tr><td> <code>pointsatz</code> <td> <code>pointsAtZ</code>
    <tr><td> <code>preservealpha</code> <td> <code>preserveAlpha</code>
    <tr><td> <code>preserveaspectratio</code> <td> <code>preserveAspectRatio</code>
    <tr><td> <code>primitiveunits</code> <td> <code>primitiveUnits</code>
    <tr><td> <code>refx</code> <td> <code>refX</code>
    <tr><td> <code>refy</code> <td> <code>refY</code>
    <tr><td> <code>repeatcount</code> <td> <code>repeatCount</code>
    <tr><td> <code>repeatdur</code> <td> <code>repeatDur</code>
    <tr><td> <code>requiredextensions</code> <td> <code>requiredExtensions</code>
    <tr><td> <code>requiredfeatures</code> <td> <code>requiredFeatures</code>
    <tr><td> <code>specularconstant</code> <td> <code>specularConstant</code>
    <tr><td> <code>specularexponent</code> <td> <code>specularExponent</code>
    <tr><td> <code>spreadmethod</code> <td> <code>spreadMethod</code>
    <tr><td> <code>startoffset</code> <td> <code>startOffset</code>
    <tr><td> <code>stddeviation</code> <td> <code>stdDeviation</code>
    <tr><td> <code>stitchtiles</code> <td> <code>stitchTiles</code>
    <tr><td> <code>surfacescale</code> <td> <code>surfaceScale</code>
    <tr><td> <code>systemlanguage</code> <td> <code>systemLanguage</code>
    <tr><td> <code>tablevalues</code> <td> <code>tableValues</code>
    <tr><td> <code>targetx</code> <td> <code>targetX</code>
    <tr><td> <code>targety</code> <td> <code>targetY</code>
    <tr><td> <code>textlength</code> <td> <code>textLength</code>
    <tr><td> <code>viewbox</code> <td> <code>viewBox</code>
    <tr><td> <code>viewtarget</code> <td> <code>viewTarget</code>
    <tr><td> <code>xchannelselector</code> <td> <code>xChannelSelector</code>
    <tr><td> <code>ychannelselector</code> <td> <code>yChannelSelector</code>
    <tr><td> <code>zoomandpan</code> <td> <code>zoomAndPan</code>
  </table>

  <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=#attr-xml-lang id=creating-and-inserting-nodes:attr-xml-lang><code>lang</code> attributes in the <span>XML
  namespace</span></a>.)</p>

  <table><thead><tr><th> Attribute name <th> Prefix <th> Local name <th> Namespace
   <tbody><tr><td> <code>xlink:actuate</code> <td> <code>xlink</code> <td> <code>actuate</code> <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>
    <tr><td> <code>xlink:arcrole</code> <td> <code>xlink</code> <td> <code>arcrole</code> <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>
    <tr><td> <code>xlink:href</code> <td> <code>xlink</code> <td> <code>href</code> <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>
    <tr><td> <code>xlink:role</code> <td> <code>xlink</code> <td> <code>role</code> <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>
    <tr><td> <code>xlink:show</code> <td> <code>xlink</code> <td> <code>show</code> <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>
    <tr><td> <code>xlink:title</code> <td> <code>xlink</code> <td> <code>title</code> <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>
    <tr><td> <code>xlink:type</code> <td> <code>xlink</code> <td> <code>type</code> <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>
    <tr><td> <code>xml:lang</code> <td> <code>xml</code> <td> <code>lang</code> <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>
    <tr><td> <code>xml:space</code> <td> <code>xml</code> <td> <code>space</code> <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>
    <tr><td> <code>xmlns</code> <td> (none) <td> <code>xmlns</code> <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>
    <tr><td> <code>xmlns:xlink</code> <td> <code>xmlns</code> <td> <code>xlink</code> <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>
  </table>

  <hr>

  <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.<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-2>appropriate
   place for inserting a node</a>.<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 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>

    <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 data.</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 data 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>

   </ol>

  <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>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
    <tbody><tr><td><pre><code class='html'>A<c- p>&lt;</c-><c- f>script</c-><c- p>&gt;</c->
<c- a>var</c-> script <c- o>=</c-> document<c- p>.</c->getElementsByTagName<c- p>(</c-><c- t>&apos;script&apos;</c-><c- p>)[</c-><c- mi>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>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".
     <tr><td><pre><code class='html'>A<c- p>&lt;</c-><c- f>script</c-><c- p>&gt;</c->
<c- a>var</c-> text <c- o>=</c-> document<c- p>.</c->createTextNode<c- p>(</c-><c- t>&apos;B&apos;</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>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).
     <tr><td><pre><code class='html'>A<c- p>&lt;</c-><c- f>script</c-><c- p>&gt;</c->
<c- a>var</c-> text <c- o>=</c-> document<c- p>.</c->getElementsByTagName<c- p>(</c-><c- t>&apos;script&apos;</c-><c- p>)[</c-><c- mi>0</c-><c- p>].</c->firstChild<c- p>;</c->
text<c- p>.</c->data <c- o>=</c-> <c- t>&apos;B&apos;</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>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".
     <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>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>.)
     <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-> B<c- p>&lt;/</c-><c- f>tr</c-><c- p>&gt;</c-> C<c- p>&lt;/</c-><c- f>table</c-><c- p>&gt;</c-></code></pre>
      <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 B 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>.)
     <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-> B<c- p>&lt;/</c-><c- f>tr</c-><c- p>&gt;</c-> <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>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 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.)
   </table>

  </div>

  <hr>

  <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 explicitly 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.<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-3>appropriate place for inserting a node</a>.<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><p>Insert the newly created node at the <var>adjusted insertion
   location</var>.</ol>

  <hr>

  <p id=mutation-during-parsing>DOM mutation events must not fire for changes caused by the UA
  parsing the document. This includes the parsing of any content inserted using <code id=creating-and-inserting-nodes:dom-document-write-2><a href=#dom-document-write>document.write()</a></code> and <code id=creating-and-inserting-nodes:dom-document-writeln><a href=#dom-document-writeln>document.writeln()</a></code> calls. <a href=#refsUIEVENTS>[UIEVENTS]</a></p>

  <p>However, <a id=creating-and-inserting-nodes:mutation-observers href=https://dom.spec.whatwg.org/#mutation-observers data-x-internal=mutation-observers>mutation observers</a> <em>do</em> fire, as required by the WHATWG DOM
  Standard.</p>



  <h5 id=parsing-elements-that-contain-only-text><span class=secno>12.2.6.2</span> Parsing elements that contain only text<a href=#parsing-elements-that-contain-only-text class=self-link></a></h5>

  <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.<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>.<li><p>Let the <a href=#original-insertion-mode id=parsing-elements-that-contain-only-text:original-insertion-mode>original insertion mode</a> be the current <a href=#insertion-mode id=parsing-elements-that-contain-only-text:insertion-mode>insertion
   mode</a>.</p>

   <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>".</ol>


  <h5 id=closing-elements-that-have-implied-end-tags><span class=secno>12.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>

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

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



  <h5 id=parsing-main-inhtml><span class=secno>12.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>12.2.6.4.1</span> The "<dfn>initial</dfn>" insertion mode<a href=#the-initial-insertion-mode class=self-link></a></h6>

  <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<dd>
    <p>Ignore the token.</p>
   <dt>A comment token<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><a href=#document>Document</a></code> object.</p>
   <dt>A DOCTYPE token<dd>

    <p>If the DOCTYPE token's name is not a <a href=#case-sensitive id=the-initial-insertion-mode:case-sensitive>case-sensitive</a> match for the string "<code>html</code>", or the token's public identifier is not missing, or the token's system
    identifier is neither missing nor a <a href=#case-sensitive id=the-initial-insertion-mode:case-sensitive-2>case-sensitive</a> match for the string
    "<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-2><a href=#document>Document</a></code> node, with the <code>name</code> attribute set to the name given in the DOCTYPE token, or the empty string
    if the name was missing; the <code>publicId</code> attribute set to the public
    identifier given in the DOCTYPE token, or the empty string if the public identifier was missing;
    the <code>systemId</code> attribute set to the system identifier given in the DOCTYPE
    token, or the empty string if the system identifier was missing; and the other attributes
    specific to <code id=the-initial-insertion-mode:documenttype-2><a data-x-internal=documenttype href=https://dom.spec.whatwg.org/#interface-documenttype>DocumentType</a></code> objects set to null and empty lists as appropriate.
    Associate the <code id=the-initial-insertion-mode:documenttype-3><a data-x-internal=documenttype href=https://dom.spec.whatwg.org/#interface-documenttype>DocumentType</a></code> node with the <code id=the-initial-insertion-mode:document-3><a href=#document>Document</a></code> object so that it is
    returned as the value of the <code>doctype</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 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> The name is set to anything other than "<code>html</code>" (compared <a href=#case-sensitive id=the-initial-insertion-mode:case-sensitive-3>case-sensitively</a>). <li> The public identifier is set to: "<code>-//W3O//DTD W3 HTML Strict 3.0//EN//</code>" <li> The public identifier is set to: "<code>-/W3C/DTD HTML 4.0 Transitional/EN</code>" <li> The public identifier is set to: "<code>HTML</code>" <li> The system identifier is set to: "<code>http://www.ibm.com/data/dtd/v11/ibmxhtml1-transitional.dtd</code>" <li> The public identifier starts with: "<code>+//Silmaril//dtd html Pro v0r11 19970101//</code>" <li> The public identifier starts with: "<code>-//AS//DTD HTML 3.0 asWedit + extensions//</code>" <li> The public identifier starts with: "<code>-//AdvaSoft Ltd//DTD HTML 3.0 asWedit + extensions//</code>" <li> The public identifier starts with: "<code>-//IETF//DTD HTML 2.0 Level 1//</code>" <li> The public identifier starts with: "<code>-//IETF//DTD HTML 2.0 Level 2//</code>" <li> The public identifier starts with: "<code>-//IETF//DTD HTML 2.0 Strict Level 1//</code>" <li> The public identifier starts with: "<code>-//IETF//DTD HTML 2.0 Strict Level 2//</code>" <li> The public identifier starts with: "<code>-//IETF//DTD HTML 2.0 Strict//</code>" <li> The public identifier starts with: "<code>-//IETF//DTD HTML 2.0//</code>" <li> The public identifier starts with: "<code>-//IETF//DTD HTML 2.1E//</code>" <li> The public identifier starts with: "<code>-//IETF//DTD HTML 3.0//</code>" <li> The public identifier starts with: "<code>-//IETF//DTD HTML 3.2 Final//</code>" <li> The public identifier starts with: "<code>-//IETF//DTD HTML 3.2//</code>" <li> The public identifier starts with: "<code>-//IETF//DTD HTML 3//</code>" <li> The public identifier starts with: "<code>-//IETF//DTD HTML Level 0//</code>" <li> The public identifier starts with: "<code>-//IETF//DTD HTML Level 1//</code>" <li> The public identifier starts with: "<code>-//IETF//DTD HTML Level 2//</code>" <li> The public identifier starts with: "<code>-//IETF//DTD HTML Level 3//</code>" <li> The public identifier starts with: "<code>-//IETF//DTD HTML Strict Level 0//</code>" <li> The public identifier starts with: "<code>-//IETF//DTD HTML Strict Level 1//</code>" <li> The public identifier starts with: "<code>-//IETF//DTD HTML Strict Level 2//</code>" <li> The public identifier starts with: "<code>-//IETF//DTD HTML Strict Level 3//</code>" <li> The public identifier starts with: "<code>-//IETF//DTD HTML Strict//</code>" <li> The public identifier starts with: "<code>-//IETF//DTD HTML//</code>" <li> The public identifier starts with: "<code>-//Metrius//DTD Metrius Presentational//</code>" <li> The public identifier starts with: "<code>-//Microsoft//DTD Internet Explorer 2.0 HTML Strict//</code>" <li> The public identifier starts with: "<code>-//Microsoft//DTD Internet Explorer 2.0 HTML//</code>" <li> The public identifier starts with: "<code>-//Microsoft//DTD Internet Explorer 2.0 Tables//</code>" <li> The public identifier starts with: "<code>-//Microsoft//DTD Internet Explorer 3.0 HTML Strict//</code>" <li> The public identifier starts with: "<code>-//Microsoft//DTD Internet Explorer 3.0 HTML//</code>" <li> The public identifier starts with: "<code>-//Microsoft//DTD Internet Explorer 3.0 Tables//</code>" <li> The public identifier starts with: "<code>-//Netscape Comm. Corp.//DTD HTML//</code>" <li> The public identifier starts with: "<code>-//Netscape Comm. Corp.//DTD Strict HTML//</code>" <li> The public identifier starts with: "<code>-//O'Reilly and Associates//DTD HTML 2.0//</code>" <li> The public identifier starts with: "<code>-//O'Reilly and Associates//DTD HTML Extended 1.0//</code>" <li> The public identifier starts with: "<code>-//O'Reilly and Associates//DTD HTML Extended Relaxed 1.0//</code>" <li> The public identifier starts with: "<code>-//SQ//DTD HTML 2.0 HoTMetaL + extensions//</code>" <li> The public identifier starts with: "<code>-//SoftQuad Software//DTD HoTMetaL PRO 6.0::19990601::extensions to HTML 4.0//</code>" <li> The public identifier starts with: "<code>-//SoftQuad//DTD HoTMetaL PRO 4.0::19971010::extensions to HTML 4.0//</code>" <li> The public identifier starts with: "<code>-//Spyglass//DTD HTML 2.0 Extended//</code>" <li> The public identifier starts with: "<code>-//Sun Microsystems Corp.//DTD HotJava HTML//</code>" <li> The public identifier starts with: "<code>-//Sun Microsystems Corp.//DTD HotJava Strict HTML//</code>" <li> The public identifier starts with: "<code>-//W3C//DTD HTML 3 1995-03-24//</code>" <li> The public identifier starts with: "<code>-//W3C//DTD HTML 3.2 Draft//</code>" <li> The public identifier starts with: "<code>-//W3C//DTD HTML 3.2 Final//</code>" <li> The public identifier starts with: "<code>-//W3C//DTD HTML 3.2//</code>" <li> The public identifier starts with: "<code>-//W3C//DTD HTML 3.2S Draft//</code>" <li> The public identifier starts with: "<code>-//W3C//DTD HTML 4.0 Frameset//</code>" <li> The public identifier starts with: "<code>-//W3C//DTD HTML 4.0 Transitional//</code>" <li> The public identifier starts with: "<code>-//W3C//DTD HTML Experimental 19960712//</code>" <li> The public identifier starts with: "<code>-//W3C//DTD HTML Experimental 970421//</code>" <li> The public identifier starts with: "<code>-//W3C//DTD W3 HTML//</code>" <li> The public identifier starts with: "<code>-//W3O//DTD W3 HTML 3.0//</code>" <li> The public identifier starts with: "<code>-//WebTechs//DTD Mozilla HTML 2.0//</code>" <li> The public identifier starts with: "<code>-//WebTechs//DTD Mozilla HTML//</code>" <li> The system identifier is missing and the public identifier starts with: "<code>-//W3C//DTD HTML 4.01 Frameset//</code>" <li> The system identifier is missing and the public identifier starts with: "<code>-//W3C//DTD HTML 4.01 Transitional//</code>" </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 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> The public identifier starts with: "<code>-//W3C//DTD XHTML 1.0 Transitional//</code>" <li> The system identifier is not missing and the public identifier starts with: "<code>-//W3C//DTD HTML 4.01 Frameset//</code>" <li> The system identifier is not missing and the public identifier starts with: "<code>-//W3C//DTD HTML 4.01 Transitional//</code>" </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>

   <dt>Anything else<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>; 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>

   </dl>


  <h6 id=the-before-html-insertion-mode><span class=secno>12.2.6.4.2</span> The "<dfn>before html</dfn>" insertion mode<a href=#the-before-html-insertion-mode class=self-link></a></h6>

  <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<dd>
    <p><a href=#parse-errors id=the-before-html-insertion-mode:parse-errors>Parse error</a>. Ignore the token.</p>
   <dt>A comment token<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>
   <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<dd>
    <p>Ignore the token.</p>
   <dt>A start tag whose tag name is "html"<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 id=parser-appcache>If the <code id=the-before-html-insertion-mode:document-4><a href=#document>Document</a></code> is being loaded as part of <a href=#navigate id=the-before-html-insertion-mode:navigate>navigation</a> of a <a href=#browsing-context id=the-before-html-insertion-mode:browsing-context>browsing context</a>, run these steps:</p>

    <ol><li><p>If the result of running <a href=https://w3c.github.io/ServiceWorker/#scope-match-algorithm id=the-before-html-insertion-mode:scope-match-algorithm data-x-internal=scope-match-algorithm>match service worker
     registration</a> for the document's <a href=https://dom.spec.whatwg.org/#concept-document-url id="the-before-html-insertion-mode:the-document's-address" data-x-internal="the-document's-address">URL</a> is
     non-null, run the <a href=#concept-appcache-init id=the-before-html-insertion-mode:concept-appcache-init>application cache selection
     algorithm</a> passing the <code id=the-before-html-insertion-mode:document-5><a href=#document>Document</a></code> object with no manifest.<li>

      <p>Otherwise, run these substeps:</p>

      <ol><li><p>If the newly created element has a <code id=the-before-html-insertion-mode:attr-html-manifest><a href=#attr-html-manifest>manifest</a></code>
       attribute whose value is not the empty string, then <a href=#parse-a-url id=the-before-html-insertion-mode:parse-a-url>parse</a> the value of that attribute, relative to the newly created element's
       <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>, and if that is successful, run the <a href=#concept-appcache-init id=the-before-html-insertion-mode:concept-appcache-init-2>application cache selection algorithm</a> passing the
       <code id=the-before-html-insertion-mode:document-6><a href=#document>Document</a></code> object with the result of applying the <a href=https://url.spec.whatwg.org/#concept-url-serializer id=the-before-html-insertion-mode:concept-url-serializer data-x-internal=concept-url-serializer>URL serializer</a> algorithm to the <a href=#resulting-url-record id=the-before-html-insertion-mode:resulting-url-record>resulting URL
       record</a> with the <i>exclude fragment flag</i> set.<li><p>Otherwise, run the <a href=#concept-appcache-init id=the-before-html-insertion-mode:concept-appcache-init-3>application cache selection
       algorithm</a> passing the <code id=the-before-html-insertion-mode:document-7><a href=#document>Document</a></code> object with no manifest.</ol>

     </ol>

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

   <dt>An end tag whose tag name is one of: "head", "body", "html", "br"<dd>
    <p>Act as described in the "anything else" entry below.</p>
   <dt>Any other end tag<dd>
    <p><a href=#parse-errors id=the-before-html-insertion-mode:parse-errors-2>Parse error</a>. Ignore the token.</p>
   <dt>Anything else<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-2 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-8><a href=#document>Document</a></code> object. Append
    it to the <code id=the-before-html-insertion-mode:document-9><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>If the <code id=the-before-html-insertion-mode:document-10><a href=#document>Document</a></code> is being loaded as part of <a href=#navigate id=the-before-html-insertion-mode:navigate-2>navigation</a> of a <a href=#browsing-context id=the-before-html-insertion-mode:browsing-context-2>browsing context</a>, then: run the <a href=#concept-appcache-init id=the-before-html-insertion-mode:concept-appcache-init-4>application cache selection algorithm</a> with no manifest,
    passing it the <code id=the-before-html-insertion-mode:document-11><a href=#document>Document</a></code> object.</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>

   </dl>

  <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-12><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>12.2.6.4.3</span> The "<dfn>before head</dfn>" insertion mode<a href=#the-before-head-insertion-mode class=self-link></a></h6>

  <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<dd>
    <p>Ignore the token.</p> 
   <dt>A comment token<dd>
    <p><a href=#insert-a-comment id=the-before-head-insertion-mode:insert-a-comment>Insert a comment</a>.</p>
   <dt>A DOCTYPE token<dd>
    <p><a href=#parse-errors id=the-before-head-insertion-mode:parse-errors>Parse error</a>. Ignore the token.</p>
   <dt>A start tag whose tag name is "html"<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>
   <dt>A start tag whose tag name is "head"<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>

   <dt>An end tag whose tag name is one of: "head", "body", "html", "br"<dd>

    <p>Act as described in the "anything else" entry below.</p>

   <dt>Any other end tag<dd>

    <p><a href=#parse-errors id=the-before-head-insertion-mode:parse-errors-2>Parse error</a>. Ignore the token.</p>

   <dt>Anything else<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>

   </dl>


  <h6 id=parsing-main-inhead><span class=secno>12.2.6.4.4</span> The "<dfn>in head</dfn>" insertion mode<a href=#parsing-main-inhead class=self-link></a></h6>

  <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<dd>
    <p><a href=#insert-a-character id=parsing-main-inhead:insert-a-character>Insert the character</a>.</p>
   <dt>A comment token<dd>
    <p><a href=#insert-a-comment id=parsing-main-inhead:insert-a-comment>Insert a comment</a>.</p>
   <dt>A DOCTYPE token<dd>
    <p><a href=#parse-errors id=parsing-main-inhead:parse-errors>Parse error</a>. Ignore the token.</p>
   <dt>A start tag whose tag name is "html"<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>
   <dt>A start tag whose tag name is one of: "base", "basefont",
   "bgsound", "link"<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>

   <dt>A start tag whose tag name is "meta"<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 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>

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

   <dt>A start tag whose tag name is "title"<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>
   <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>A start tag whose tag name is one of: "noframes", "style"<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>
   <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<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>

   <dt id=scriptTag>A start tag whose tag name is "script"<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>.<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.<li>

      <p>Mark the element as being <a href=#parser-inserted id=parsing-main-inhead:parser-inserted>"parser-inserted"</a> and unset the element's
      <a href=#non-blocking id=parsing-main-inhead:non-blocking>"non-blocking"</a> flag.</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><p>If the parser was originally created for the <a href=#html-fragment-parsing-algorithm id=parsing-main-inhead:html-fragment-parsing-algorithm>HTML fragment parsing
     algorithm</a>, then mark the <code id=parsing-main-inhead:the-script-element><a href=#the-script-element>script</a></code> element as <a href=#already-started id=parsing-main-inhead:already-started>"already started"</a>.
     (<a href=#fragment-case id=parsing-main-inhead:fragment-case>fragment case</a>)<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 mark the
     <code id=parsing-main-inhead:the-script-element-2><a href=#the-script-element>script</a></code> element as <a href=#already-started id=parsing-main-inhead:already-started-2>"already started"</a>. (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.)<li><p>Insert the newly created element at the <var>adjusted insertion
     location</var>.<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>.<li><p>Switch the tokenizer to the <a href=#script-data-state id=parsing-main-inhead:script-data-state>script data state</a>.<li><p>Let the <a href=#original-insertion-mode id=parsing-main-inhead:original-insertion-mode>original insertion mode</a> be the current <a href=#insertion-mode id=parsing-main-inhead:insertion-mode-4>insertion
     mode</a>.</p>

     <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>".</ol>

   <dt>An end tag whose tag name is "head"<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>

   <dt>An end tag whose tag name is one of: "body", "html", "br"<dd>
    <p>Act as described in the "anything else" entry below.</p>
   <dt>A start tag whose tag name is "template"<dd>

    <p><a href=#insert-an-html-element id=parsing-main-inhead:insert-an-html-element-4>Insert an HTML element</a> for the token.</p>

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

    <p>Set the <a href=#frameset-ok-flag id=parsing-main-inhead:frameset-ok-flag>frameset-ok flag</a> to "not ok".</p>

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

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

   <dt>An end tag whose tag name is "template"<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-5>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>.<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>.<li><p>Pop elements from the <a href=#stack-of-open-elements id=parsing-main-inhead:stack-of-open-elements-6>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.<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><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><p><a href=#reset-the-insertion-mode-appropriately id=parsing-main-inhead:reset-the-insertion-mode-appropriately>Reset the insertion mode appropriately</a>.</ol>

   <dt>A start tag whose tag name is "head"<dt>Any other end tag<dd>
    <p><a href=#parse-errors id=parsing-main-inhead:parse-errors-4>Parse error</a>. Ignore the token.</p>
   <dt>Anything else<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-7>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>

   </dl>


  <h6 id=parsing-main-inheadnoscript><span class=secno>12.2.6.4.5</span> The "<dfn>in head noscript</dfn>" insertion mode<a href=#parsing-main-inheadnoscript class=self-link></a></h6>

  <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<dd>
    <p><a href=#parse-errors id=parsing-main-inheadnoscript:parse-errors>Parse error</a>. Ignore the token.</p>
   <dt>A start tag whose tag name is "html"<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>

   <dt>An end tag whose tag name is "noscript"<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>

   <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>A comment token<dt>A start tag whose tag name is one of: "basefont", "bgsound", "link", "meta", "noframes",
   "style"<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>

   <dt>An end tag whose tag name is "br"<dd>
    <p>Act as described in the "anything else" entry below.</p>
   <dt>A start tag whose tag name is one of: "head", "noscript"<dt>Any other end tag<dd>
    <p><a href=#parse-errors id=parsing-main-inheadnoscript:parse-errors-2>Parse error</a>. Ignore the token.</p>
   <dt>Anything else<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>

   </dl>


  <h6 id=the-after-head-insertion-mode><span class=secno>12.2.6.4.6</span> The "<dfn>after head</dfn>" insertion mode<a href=#the-after-head-insertion-mode class=self-link></a></h6>

  <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<dd>
    <p><a href=#insert-a-character id=the-after-head-insertion-mode:insert-a-character>Insert the character</a>.</p>
   <dt>A comment token<dd>
    <p><a href=#insert-a-comment id=the-after-head-insertion-mode:insert-a-comment>Insert a comment</a>.</p>
   <dt>A DOCTYPE token<dd>
    <p><a href=#parse-errors id=the-after-head-insertion-mode:parse-errors>Parse error</a>. Ignore the token.</p>
   <dt>A start tag whose tag name is "html"<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>

   <dt>A start tag whose tag name is "body"<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>

   <dt>A start tag whose tag name is "frameset"<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>

   <dt>A start tag whose tag name is one of: "base", "basefont", "bgsound", "link", "meta",
   "noframes", "script", "style", "template", "title"<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>

   <dt>An end tag whose tag name is "template"<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>
   <dt>An end tag whose tag name is one of: "body", "html", "br"<dd>
    <p>Act as described in the "anything else" entry below.</p>
   <dt>A start tag whose tag name is "head"<dt>Any other end tag<dd>
    <p><a href=#parse-errors id=the-after-head-insertion-mode:parse-errors-3>Parse error</a>. Ignore the token.</p>
   <dt>Anything else<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>

   </dl>


  <h6 id=parsing-main-inbody><span class=secno>12.2.6.4.7</span> The "<dfn>in body</dfn>" insertion mode<a href=#parsing-main-inbody class=self-link></a></h6>

  <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<dd>

    <p><a href=#parse-errors id=parsing-main-inbody:parse-errors>Parse error</a>. Ignore the token.</p>

    

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

   <dt>Any other character token<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>

   <dt>A comment token<dd>
    <p><a href=#insert-a-comment id=parsing-main-inbody:insert-a-comment>Insert a comment</a>.</p>
   <dt>A DOCTYPE token<dd>
    <p><a href=#parse-errors id=parsing-main-inbody:parse-errors-2>Parse error</a>. Ignore the token.</p>
   <dt>A start tag whose tag name is "html"<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>

   <dt>A start tag whose tag name is one of: "base", "basefont", "bgsound", "link", "meta",
   "noframes", "script", "style", "template", "title"<dt>An end tag whose tag name is "template"<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>
   <dt>A start tag whose tag name is "body"<dd>

    <p><a href=#parse-errors id=parsing-main-inbody:parse-errors-4>Parse error</a>.</p>

    <p>If the second element on the <a href=#stack-of-open-elements id=parsing-main-inbody:stack-of-open-elements-3>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, if the <a href=#stack-of-open-elements id=parsing-main-inbody:stack-of-open-elements-4>stack of open elements</a> has only one node on it, 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>)</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>

   <dt>A start tag whose tag name is "frameset"<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>)</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.<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><p><a href=#insert-an-html-element id=parsing-main-inbody:insert-an-html-element>Insert an HTML element</a> for the token.<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>

    </ol>

   <dt>An end-of-file token<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>.<li><p><a href=#stop-parsing id=parsing-main-inbody:stop-parsing>Stop parsing</a>.</ol>

   <dt>An end tag whose tag name is "body"<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>

   <dt>An end tag whose tag name is "html"<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>

   <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", "section", "summary", "ul"<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>

   <dt>A start tag whose tag name is one of: "h1", "h2", "h3", "h4",
   "h5", "h6"<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>

   <dt>A start tag whose tag name is one of: "pre", "listing"<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>

   <dt>A start tag whose tag name is "form"<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-3><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>

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

    <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-4><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>

   <dt>A start tag whose tag name is "li"<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".<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).<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.<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>.<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.<li><p>Jump to the step labeled <i>done</i> below.</ol>

     <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.<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>.<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>.<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.</ol>

   <dt>A start tag whose tag name is one of: "dd", "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".<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).<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.<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>.<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.<li><p>Jump to the step labeled <i>done</i> below.</ol>

     <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.<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>.<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.<li><p>Jump to the step labeled <i>done</i> below.</ol>

     <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.<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>.<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>.<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.</ol>

   <dt>A start tag whose tag name is "plaintext"<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, that will be the
    last token ever seen other than character tokens (and the end-of-file token), because there is
    no way to switch out of the <a href=#plaintext-state id=parsing-main-inbody:plaintext-state-2>PLAINTEXT state</a>.</p>

   <dt>A start tag whose tag name is "button"<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>.<li><p><a href=#generate-implied-end-tags id=parsing-main-inbody:generate-implied-end-tags-4>Generate implied end tags</a>.<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.</ol>

     <li><p><a href=#reconstruct-the-active-formatting-elements id=parsing-main-inbody:reconstruct-the-active-formatting-elements-3>Reconstruct the active formatting elements</a>, if any.<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.<li><p>Set the <a href=#frameset-ok-flag id=parsing-main-inbody:frameset-ok-flag-7>frameset-ok flag</a> to "not ok".</ol>

   <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", "section", "summary",
   "ul"<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>.<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>.<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.</ol>

   <dt>An end tag whose tag name is "form"<dd>

    <p>If 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-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.<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.<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.<li><p><a href=#generate-implied-end-tags id=parsing-main-inbody:generate-implied-end-tags-6>Generate implied end tags</a>.<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>.<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>.</ol>

    <p>If there <em>is</em> a <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-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.<li><p><a href=#generate-implied-end-tags id=parsing-main-inbody:generate-implied-end-tags-7>Generate implied end tags</a>.<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>.<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.</ol>

   <dt>An end tag whose tag name is "p"<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>

   <dt>An end tag whose tag name is "li"<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.<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>.<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.</ol>

   <dt>An end tag whose tag name is one of: "dd", "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.<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>.<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.</ol>

   <dt>An end tag whose tag name is one of: "h1", "h2", "h3", "h4", "h5", "h6"<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>.<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>.<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.</ol>

   <dt>An end tag whose tag name is "sarcasm"<dd>
    <p>Take a deep breath, then act as described in the "any other end
    tag" entry below.</p>
   <dt>A start tag whose tag name is "a"<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 href="a">a&lt;table>&lt;a href="b">b&lt;/table>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></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-4>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>

   <dt>A start tag whose tag name is one of: "b", "big", "code", "em",
   "font", "i", "s", "small", "strike", "strong", "tt", "u"<dd>

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

   <dt>A start tag whose tag name is "nobr"<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>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-7>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>

   <dt>An end tag whose tag name is one of: "a",
   "b", "big", "code", "em", "font", "i", "nobr", "s", "small",
   "strike", "strong", "tt", "u"<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>

   <dt>A start tag whose tag name is one of: "applet", "marquee", "object"<dd>

    <p><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-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>

   <dt>An end tag token whose tag name is one of: "applet", "marquee", "object"<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>.<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>.<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.<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>.</ol>

   <dt>A start tag whose tag name is "table"<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>

   <dt>An end tag whose tag name is "br"<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>

   <dt>A start tag whose tag name is one of: "area", "br", "embed",
   "img", "keygen", "wbr"<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-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>
    

   <dt>A start tag whose tag name is "input"<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-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-54>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>

   <dt>A start tag whose tag name is one of: "param", "source", "track"<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-55>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>

   <dt>A start tag whose tag name is "hr"<dd>

    <p>If the <a href=#stack-of-open-elements id=parsing-main-inbody:stack-of-open-elements-56>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><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-57>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>

   <dt>A start tag whose tag name is "image"<dd>
    
    <p><a href=#parse-errors id=parsing-main-inbody:parse-errors-35>Parse error</a>. Change the token's tag name to "img" and reprocess it. (Don't
    ask.)</p>
   <dt>A start tag whose tag name is "textarea"<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.<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.)<li><p>Switch the tokenizer to the <a href=#rcdata-state id=parsing-main-inbody:rcdata-state>RCDATA state</a>.<li><p>Let the <a href=#original-insertion-mode id=parsing-main-inbody:original-insertion-mode>original insertion mode</a> be the current <a href=#insertion-mode id=parsing-main-inbody:insertion-mode-8>insertion
     mode</a>.</p>

     <li><p>Set the <a href=#frameset-ok-flag id=parsing-main-inbody:frameset-ok-flag-13>frameset-ok flag</a> to "not ok".<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>".</ol>

   <dt>A start tag whose tag name is "xmp"<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-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-11>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>

   <dt>A start tag whose tag name is "iframe"<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>

   <dt>A start tag whose tag name is "noembed"<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<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>

   <dt>A start tag whose tag name is "select"<dd>

    <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><a href=#insert-an-html-element id=parsing-main-inbody:insert-an-html-element-21>Insert an HTML element</a> for the token.</p>

    <p>Set the <a href=#frameset-ok-flag id=parsing-main-inbody:frameset-ok-flag-16>frameset-ok flag</a> to "not ok".</p>

    <p>If the <a href=#insertion-mode id=parsing-main-inbody:insertion-mode-10>insertion mode</a> is one of "<a href=#parsing-main-intable id=parsing-main-inbody:parsing-main-intable-2>in
    table</a>", "<a href=#parsing-main-incaption id=parsing-main-inbody:parsing-main-incaption>in caption</a>", "<a href=#parsing-main-intbody id=parsing-main-inbody:parsing-main-intbody>in table body</a>", "<a href=#parsing-main-intr id=parsing-main-inbody:parsing-main-intr>in row</a>", or "<a href=#parsing-main-intd id=parsing-main-inbody:parsing-main-intd>in cell</a>", then switch the
    <a href=#insertion-mode id=parsing-main-inbody:insertion-mode-11>insertion mode</a> to "<a href=#parsing-main-inselectintable id=parsing-main-inbody:parsing-main-inselectintable>in select in
    table</a>". Otherwise, switch the <a href=#insertion-mode id=parsing-main-inbody:insertion-mode-12>insertion mode</a> to "<a href=#parsing-main-inselect id=parsing-main-inbody:parsing-main-inselect>in select</a>".</p>

   <dt>A start tag whose tag name is one of: "optgroup", "option"<dd>

    <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-59>stack of open elements</a>.</p>

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

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

   <dt>A start tag whose tag name is one of: "rb", "rtc"<dd>

    <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-11>has a
    <code>ruby</code> element in scope</a>, then <a href=#generate-implied-end-tags id=parsing-main-inbody:generate-implied-end-tags-12>generate implied end tags</a>. If the
    <a href=#current-node id=parsing-main-inbody:current-node-22>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-36>parse error</a>.</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>

   <dt>A start tag whose tag name is one of: "rp", "rt"<dd>

    <p>If the <a href=#stack-of-open-elements id=parsing-main-inbody:stack-of-open-elements-61>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>ruby</code> element in scope</a>, then <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:rtc-4><a href=#rtc>rtc</a></code> elements. If the <a href=#current-node id=parsing-main-inbody:current-node-23>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-37>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>

   <dt>A start tag whose tag name is "math"<dd>

    <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=#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, in the <a id=parsing-main-inbody:mathml-namespace href=https://infra.spec.whatwg.org/#mathml-namespace data-x-internal=mathml-namespace>MathML
    namespace</a>.</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-24>current node</a> off the
    <a href=#stack-of-open-elements id=parsing-main-inbody:stack-of-open-elements-62>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>

   <dt>A start tag whose tag name is "svg"<dd>

    <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=#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, in the <a id=parsing-main-inbody:svg-namespace href=https://infra.spec.whatwg.org/#svg-namespace data-x-internal=svg-namespace>SVG namespace</a>.</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-25>current node</a> off the
    <a href=#stack-of-open-elements id=parsing-main-inbody:stack-of-open-elements-63>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>

   <dt>A start  tag whose tag name is one of: "caption", "col", "colgroup", "frame",
   "head", "tbody", "td", "tfoot", "th", "thead", "tr"<dd>

    <p><a href=#parse-errors id=parsing-main-inbody:parse-errors-38>Parse error</a>. Ignore the token.</p>

    

   <dt>Any other start tag<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=#insert-an-html-element id=parsing-main-inbody:insert-an-html-element-25>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.</p>

   <dt>Any other end tag<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-26>current node</a> (the bottommost
     node of the stack).<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-14>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.<li><p>If <var>node</var> is not the <a href=#current-node id=parsing-main-inbody:current-node-27>current node</a>, then this is a
       <a href=#parse-errors id=parsing-main-inbody:parse-errors-39>parse error</a>.<li><p>Pop all the nodes from the <a href=#current-node id=parsing-main-inbody:current-node-28>current node</a> up to <var>node</var>,
       including <var>node</var>, then stop these steps.</ol>

     <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-40>parse error</a>; ignore the token, and return.<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-64>stack of open
     elements</a>.<li><p>Return to the step labeled <i>loop</i>.</ol>

   </dl>

  <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-15>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.<li><p>If the <a href=#current-node id=parsing-main-inbody:current-node-29>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-41>parse error</a>.<li><p>Pop elements from the <a href=#stack-of-open-elements id=parsing-main-inbody:stack-of-open-elements-65>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.</ol>

  
  <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.<li><p>If the <a href=#current-node id=parsing-main-inbody:current-node-30>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-31>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-32>current node</a> off the
   <a href=#stack-of-open-elements id=parsing-main-inbody:stack-of-open-elements-66>stack of open elements</a>, and return.<li><p>Let <var>outer loop counter</var> be zero.<li><p><i>Outer loop</i>: If <var>outer loop counter</var> is greater than or equal to
   eight, then return.<li><p>Increment <var>outer loop counter</var> by one.<li>

    <p>Let <var>formatting element</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>has the tag name <var>subject</var>.</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><p>If <var>formatting element</var> is not in the <a href=#stack-of-open-elements id=parsing-main-inbody:stack-of-open-elements-67>stack of open
   elements</a>, then this is a <a href=#parse-errors id=parsing-main-inbody:parse-errors-42>parse error</a>; remove the element from the list, and
   return.<li><p>If <var>formatting element</var> is in the <a href=#stack-of-open-elements id=parsing-main-inbody:stack-of-open-elements-68>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-13>in scope</a>, then this is a
   <a href=#parse-errors id=parsing-main-inbody:parse-errors-43>parse error</a>; return.<li><p>If <var>formatting element</var> is not the <a href=#current-node id=parsing-main-inbody:current-node-33>current node</a>, this is a
   <a href=#parse-errors id=parsing-main-inbody:parse-errors-44>parse error</a>. (But do not return.)<li><p>Let <var>furthest block</var> be the topmost node in the <a href=#stack-of-open-elements id=parsing-main-inbody:stack-of-open-elements-69>stack of open
   elements</a> that is lower in the stack than <var>formatting element</var>, and is an
   element in the <a href=#special id=parsing-main-inbody:special-4>special</a> category. There might not be one.<li><p>If there is no <var>furthest block</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-70>stack of open elements</a>, from the <a href=#current-node id=parsing-main-inbody:current-node-34>current
   node</a> up to and including <var>formatting element</var>, then remove <var>formatting element</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.<li><p>Let <var>common ancestor</var> be the element immediately above <var>formatting element</var> in the <a href=#stack-of-open-elements id=parsing-main-inbody:stack-of-open-elements-71>stack of open elements</a>.<li><p>Let a bookmark note the position of <var>formatting element</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.<li>

    <p>Let <var>node</var> and <var>last node</var> be <var>furthest
    block</var>. Follow these steps:</p>

    <ol><li><p>Let <var>inner loop counter</var> be zero.<li><p><i>Inner loop</i>: Increment <var>inner loop counter</var> by one.<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-72>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-73>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-74>stack of open elements</a> before <var>node</var>
     was removed.<li><p>If <var>node</var> is <var>formatting element</var>, then go to the
     next step in the overall algorithm.<li><p>If <var>inner loop counter</var> is greater than three 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>.<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-75>stack of open
     elements</a> and then go back to the step labeled <i>inner loop</i>.<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>common
     ancestor</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-76>stack of open elements</a> with an entry for
     the new element, and let <var>node</var> be the new element.<li><p>If <var>last node</var> is <var>furthest block</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>.<li><p>Insert <var>last node</var> into <var>node</var>, first removing it
     from its previous parent node if any.<li><p>Let <var>last node</var> be <var>node</var>.<li><p>Return to the step labeled <i>inner loop</i>.</ol>

   <li><p>Insert whatever <var>last node</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>common
   ancestor</var> as the <i>override target</i>.<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>formatting
   element</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>furthest
   block</var> as the intended parent.<li><p>Take all of the child nodes of <var>furthest block</var> and append them to the
   element created in the last step.<li><p>Append that new element to <var>furthest block</var>.<li><p>Remove <var>formatting element</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.<li><p>Remove <var>formatting element</var> from the <a href=#stack-of-open-elements id=parsing-main-inbody:stack-of-open-elements-77>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-78>stack of open elements</a>
   immediately below the position of <var>furthest block</var> in that stack.<li><p>Jump back to the step labeled <i>outer loop</i>.</ol>

  <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>12.2.6.4.8</span> The "<dfn>text</dfn>" insertion mode<a href=#parsing-main-incdata class=self-link></a></h6>

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

   <dt>An end-of-file token<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, mark the
    <code id=parsing-main-incdata:the-script-element-2><a href=#the-script-element>script</a></code> element as <a href=#already-started id=parsing-main-incdata:already-started>"already started"</a>.</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>

   <dt id=scriptEndTag>An end tag whose tag name is "script"<dd>

    <p>If the <a id=parsing-main-incdata:javascript-execution-context-stack href=https://tc39.github.io/ecma262/#execution-context-stack data-x-internal=javascript-execution-context-stack>JavaScript execution context stack</a> is empty, <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-3><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><a href=#prepare-a-script id=parsing-main-incdata:prepare-a-script>Prepare</a> the <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 there is a <a href=#pending-parsing-blocking-script id=parsing-main-incdata:pending-parsing-blocking-script>pending parsing-blocking
    script</a>, 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:<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>

     <dt>Otherwise:<dd>

      <p>Run these steps:</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-2>pending parsing-blocking
       script</a>. There is no longer a <a href=#pending-parsing-blocking-script id=parsing-main-incdata:pending-parsing-blocking-script-3>pending parsing-blocking script</a>.<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>.<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>
       flag is not set: <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> flag is set.<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 <a href=#browsing-context id=parsing-main-incdata:browsing-context>browsing context</a> gets closed, 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-3><a href=#document>Document</a></code>.</p>

       <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.<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>.<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).<li><p><a href=#execute-the-script-block id=parsing-main-incdata:execute-the-script-block>Execute</a> <var>the
       script</var>.<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><p>Let the <a href=#insertion-point id=parsing-main-incdata:insertion-point-6>insertion point</a> be undefined again.<li><p>If there is once again a <a href=#pending-parsing-blocking-script id=parsing-main-incdata:pending-parsing-blocking-script-4>pending parsing-blocking script</a>, then repeat
       these steps from step 1.</ol>

     </dl>

   <dt>Any other end tag<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>

   </dl>


  <h6 id=parsing-main-intable><span class=secno>12.2.6.4.9</span> The "<dfn>in table</dfn>" insertion mode<a href=#parsing-main-intable class=self-link></a></h6>

  <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-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<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>Let the <a href=#original-insertion-mode id=parsing-main-intable:original-insertion-mode>original insertion mode</a> be 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>

   <dt>A comment token<dd>
    <p><a href=#insert-a-comment id=parsing-main-intable:insert-a-comment>Insert a comment</a>.</p>
   <dt>A DOCTYPE token<dd>
    <p><a href=#parse-errors id=parsing-main-intable:parse-errors>Parse error</a>. Ignore the token.</p>
   <dt>A start tag whose tag name is "caption"<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>

   <dt>A start tag whose tag name is "colgroup"<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>

   <dt>A start tag whose tag name is "col"<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>

   <dt>A start tag whose tag name is one of: "tbody", "tfoot", "thead"<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>

   <dt>A start tag whose tag name is one of: "td", "th", "tr"<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>

   <dt>A start tag whose tag name is "table"<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>

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

    <p><a href=#reset-the-insertion-mode-appropriately id=parsing-main-intable:reset-the-insertion-mode-appropriately>Reset the insertion mode appropriately</a>.</p>
    

    <p>Reprocess the token.</p>

   <dt>An end tag whose tag name is "table"<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>

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

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

   <dt>An end tag whose tag name is one of: "body", "caption", "col", "colgroup", "html", "tbody",
   "td", "tfoot", "th", "thead", "tr"<dd>
    <p><a href=#parse-errors id=parsing-main-intable:parse-errors-4>Parse error</a>. Ignore the token.</p>
   <dt>A start tag whose tag name is one of: "style", "script", "template"<dt>An end tag whose tag name is "template"<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>

   <dt>A start tag whose tag name is "input"<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>

    <p><a href=#parse-errors id=parsing-main-intable:parse-errors-5>Parse error</a>.</p>

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

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

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

   <dt>A start tag whose tag name is "form"<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><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>

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

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

   <dt>An end-of-file token<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>

   <dt>Anything else<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>

   </dl>

  <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-2><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>

  <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>12.2.6.4.10</span> The "<dfn>in table text</dfn>" insertion mode<a href=#parsing-main-intabletext class=self-link></a></h6>

  <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<dd>

    <p><a href=#parse-errors id=parsing-main-intabletext:parse-errors>Parse error</a>. Ignore the token.</p>

   <dt>Any other character token<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>

   <dt>Anything else<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>

   </dl>


  <h6 id=parsing-main-incaption><span class=secno>12.2.6.4.11</span> The "<dfn>in caption</dfn>" insertion mode<a href=#parsing-main-incaption class=self-link></a></h6>

  <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"<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>

    <p><a href=#generate-implied-end-tags id=parsing-main-incaption:generate-implied-end-tags>Generate implied end tags</a>.</p>

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

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

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

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

   <dt>A start tag whose tag name is one of: "caption", "col", "colgroup", "tbody", "td", "tfoot",
   "th", "thead", "tr"<dt>An end tag whose tag name is "table"<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>

    
    <p><a href=#generate-implied-end-tags id=parsing-main-incaption:generate-implied-end-tags-2>Generate implied end tags</a>.</p>

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

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

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

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

    <p>Reprocess the token.</p>

   <dt>An end tag whose tag name is one of: "body", "col", "colgroup", "html", "tbody", "td",
   "tfoot", "th", "thead", "tr"<dd>
    <p><a href=#parse-errors id=parsing-main-incaption:parse-errors-5>Parse error</a>. Ignore the token.</p>
   <dt>Anything else<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>

   </dl>


  <h6 id=parsing-main-incolgroup><span class=secno>12.2.6.4.12</span> The "<dfn>in column group</dfn>" insertion mode<a href=#parsing-main-incolgroup class=self-link></a></h6>

  <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<dd>
    <p><a href=#insert-a-character id=parsing-main-incolgroup:insert-a-character>Insert the character</a>.</p>
   <dt>A comment token<dd>
    <p><a href=#insert-a-comment id=parsing-main-incolgroup:insert-a-comment>Insert a comment</a>.</p>
   <dt>A DOCTYPE token<dd>
    <p><a href=#parse-errors id=parsing-main-incolgroup:parse-errors>Parse error</a>. Ignore the token.</p>
   <dt>A start tag whose tag name is "html"<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>

   <dt>A start tag whose tag name is "col"<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>

   <dt>An end tag whose tag name is "colgroup"<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>

   <dt>An end tag whose tag name is "col"<dd>
    <p><a href=#parse-errors id=parsing-main-incolgroup:parse-errors-3>Parse error</a>. Ignore the token.</p>
   <dt>A start tag whose tag name is "template"<dt>An end tag whose tag name is "template"<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>

   <dt>An end-of-file token<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>

   <dt>Anything else<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>

   </dl>


  <h6 id=parsing-main-intbody><span class=secno>12.2.6.4.13</span> The "<dfn>in table body</dfn>" insertion mode<a href=#parsing-main-intbody class=self-link></a></h6>

  <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"<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>

   <dt>A start tag whose tag name is one of: "th", "td"<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>

   <dt>An end tag whose tag name is one of: "tbody", "tfoot",
   "thead"<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>

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

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

   <dt>A start tag whose tag name is one of: "caption", "col",
   "colgroup", "tbody", "tfoot", "thead"<dt>An end tag whose tag name is "table"<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>

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

    

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

    

    <p>Reprocess the token.</p>

   <dt>An end tag whose tag name is one of: "body", "caption", "col", "colgroup", "html", "td",
   "th", "tr"<dd>
    <p><a href=#parse-errors id=parsing-main-intbody:parse-errors-4>Parse error</a>. Ignore the token.</p>
   <dt>Anything else<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>
   </dl>

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

  <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>12.2.6.4.14</span> The "<dfn>in row</dfn>" insertion mode<a href=#parsing-main-intr class=self-link></a></h6>

  <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"<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>

   <dt>An end tag whose tag name is "tr"<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>

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

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

   <dt>A start tag whose tag name is one of: "caption", "col", "colgroup", "tbody", "tfoot",
   "thead", "tr"<dt>An end tag whose tag name is "table"<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>

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

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

    <p>Reprocess the token.</p>

   <dt>An end tag whose tag name is one of: "tbody", "tfoot", "thead"<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>

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

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

    <p>Reprocess the token.</p>

   <dt>An end tag whose tag name is one of: "body", "caption", "col", "colgroup", "html", "td",
   "th"<dd>
    <p><a href=#parse-errors id=parsing-main-intr:parse-errors-4>Parse error</a>. Ignore the token.</p>
   <dt>Anything else<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>

   </dl>

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

  <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>12.2.6.4.15</span> The "<dfn>in cell</dfn>" insertion mode<a href=#parsing-main-intd class=self-link></a></h6>

  <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"<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>

    <p><a href=#generate-implied-end-tags id=parsing-main-intd:generate-implied-end-tags>Generate implied end tags</a>.</p>

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

    <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> stack 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>

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

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

   <dt>A start tag whose tag name is one of: "caption", "col",
   "colgroup", "tbody", "td", "tfoot", "th", "thead", "tr"<dd>

    <p>If the <a href=#stack-of-open-elements id=parsing-main-intd:stack-of-open-elements-3>stack of open elements</a> does <em>not</em> <a href=#has-an-element-in-table-scope id=parsing-main-intd:has-an-element-in-table-scope-2>have a <code>td</code> or <code>th</code> element in table scope</a>, then this
    is a <a href=#parse-errors id=parsing-main-intd:parse-errors-3>parse error</a>; ignore the token. (<a href=#fragment-case id=parsing-main-intd:fragment-case>fragment case</a>)</p>

    <p>Otherwise, <a href=#close-the-cell id=parsing-main-intd:close-the-cell>close the cell</a> (see below) and reprocess the token.</p>

   <dt>An end tag whose tag name is one of: "body", "caption",
   "col", "colgroup", "html"<dd>
    <p><a href=#parse-errors id=parsing-main-intd:parse-errors-4>Parse error</a>. Ignore the token.</p>
   <dt>An end tag whose tag name is one of: "table", "tbody",
   "tfoot", "thead", "tr"<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-5>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>

   <dt>Anything else<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>

   </dl>

  <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>.<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-6>parse error</a>.<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> stack 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.<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>.<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>".</ol>

  <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-inselect><span class=secno>12.2.6.4.16</span> The "<dfn>in select</dfn>" insertion mode<a href=#parsing-main-inselect class=self-link></a></h6>

  <p>When the user agent is to apply the rules for the "<a href=#parsing-main-inselect id=parsing-main-inselect:parsing-main-inselect>in
  select</a>" <a href=#insertion-mode id=parsing-main-inselect: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<dd>
    <p><a href=#parse-errors id=parsing-main-inselect:parse-errors>Parse error</a>. Ignore the token.</p>
   <dt>Any other character token<dd>

    <p><a href=#insert-a-character id=parsing-main-inselect:insert-a-character>Insert the token's character</a>.</p>

   <dt>A comment token<dd>
    <p><a href=#insert-a-comment id=parsing-main-inselect:insert-a-comment>Insert a comment</a>.</p>
   <dt>A DOCTYPE token<dd>
    <p><a href=#parse-errors id=parsing-main-inselect:parse-errors-2>Parse error</a>. Ignore the token.</p>
   <dt>A start tag whose tag name is "html"<dd>

    <p>Process the token <a href=#using-the-rules-for id=parsing-main-inselect:using-the-rules-for>using the rules for</a> the "<a href=#parsing-main-inbody id=parsing-main-inselect:parsing-main-inbody>in body</a>" <a href=#insertion-mode id=parsing-main-inselect:insertion-mode-2>insertion mode</a>.</p>

   <dt>A start tag whose tag name is "option"<dd>

    
    <p>If the <a href=#current-node id=parsing-main-inselect:current-node>current node</a> is an <code id=parsing-main-inselect:the-option-element><a href=#the-option-element>option</a></code> element, pop that node from the
    <a href=#stack-of-open-elements id=parsing-main-inselect:stack-of-open-elements>stack of open elements</a>.</p>
    

    <p><a href=#insert-an-html-element id=parsing-main-inselect:insert-an-html-element>Insert an HTML element</a> for the token.</p>

   <dt>A start tag whose tag name is "optgroup"<dd>

    
    <p>If the <a href=#current-node id=parsing-main-inselect:current-node-2>current node</a> is an <code id=parsing-main-inselect:the-option-element-2><a href=#the-option-element>option</a></code> element, pop that node from the
    <a href=#stack-of-open-elements id=parsing-main-inselect:stack-of-open-elements-2>stack of open elements</a>.</p>
    

    
    <p>If the <a href=#current-node id=parsing-main-inselect:current-node-3>current node</a> is an <code id=parsing-main-inselect:the-optgroup-element><a href=#the-optgroup-element>optgroup</a></code> element, pop that node from the
    <a href=#stack-of-open-elements id=parsing-main-inselect:stack-of-open-elements-3>stack of open elements</a>.</p>
    

    <p><a href=#insert-an-html-element id=parsing-main-inselect:insert-an-html-element-2>Insert an HTML element</a> for the token.</p>

   <dt>An end tag whose tag name is "optgroup"<dd>

    
    <p>First, if the <a href=#current-node id=parsing-main-inselect:current-node-4>current node</a> is an <code id=parsing-main-inselect:the-option-element-3><a href=#the-option-element>option</a></code> element, and the node
    immediately before it in the <a href=#stack-of-open-elements id=parsing-main-inselect:stack-of-open-elements-4>stack of open elements</a> is an <code id=parsing-main-inselect:the-optgroup-element-2><a href=#the-optgroup-element>optgroup</a></code>
    element, then pop the <a href=#current-node id=parsing-main-inselect:current-node-5>current node</a> from the <a href=#stack-of-open-elements id=parsing-main-inselect:stack-of-open-elements-5>stack of open
    elements</a>.</p>
    

    <p>If the <a href=#current-node id=parsing-main-inselect:current-node-6>current node</a> is an <code id=parsing-main-inselect:the-optgroup-element-3><a href=#the-optgroup-element>optgroup</a></code> element, then pop that node from
    the <a href=#stack-of-open-elements id=parsing-main-inselect:stack-of-open-elements-6>stack of open elements</a>. Otherwise, this is a <a href=#parse-errors id=parsing-main-inselect:parse-errors-3>parse error</a>; ignore
    the token.</p>

   <dt>An end tag whose tag name is "option"<dd>

    <p>If the <a href=#current-node id=parsing-main-inselect:current-node-7>current node</a> is an <code id=parsing-main-inselect:the-option-element-4><a href=#the-option-element>option</a></code> element, then pop that node from
    the <a href=#stack-of-open-elements id=parsing-main-inselect:stack-of-open-elements-7>stack of open elements</a>. Otherwise, this is a <a href=#parse-errors id=parsing-main-inselect:parse-errors-4>parse error</a>; ignore
    the token.</p>

   <dt>An end tag whose tag name is "select"<dd>

    <p>If the <a href=#stack-of-open-elements id=parsing-main-inselect:stack-of-open-elements-8>stack of open elements</a> does not <a href=#has-an-element-in-select-scope id=parsing-main-inselect:has-an-element-in-select-scope>have a <code>select</code> element in select scope</a>, this is a <a href=#parse-errors id=parsing-main-inselect:parse-errors-5>parse
    error</a>; ignore the token. (<a href=#fragment-case id=parsing-main-inselect:fragment-case>fragment case</a>)</p>

    <p>Otherwise:</p>

    <p>Pop elements from the <a href=#stack-of-open-elements id=parsing-main-inselect:stack-of-open-elements-9>stack of open elements</a> until a <code id=parsing-main-inselect:the-select-element><a href=#the-select-element>select</a></code> element
    has been popped from the stack.</p>

    <p><a href=#reset-the-insertion-mode-appropriately id=parsing-main-inselect:reset-the-insertion-mode-appropriately>Reset the insertion mode appropriately</a>.</p>

   <dt>A start tag whose tag name is "select"<dd>

    <p><a href=#parse-errors id=parsing-main-inselect:parse-errors-6>Parse error</a>.</p>

    
    <p>If the <a href=#stack-of-open-elements id=parsing-main-inselect:stack-of-open-elements-10>stack of open elements</a> does not <a href=#has-an-element-in-select-scope id=parsing-main-inselect:has-an-element-in-select-scope-2>have a <code>select</code> element in select scope</a>, ignore the token.
    (<a href=#fragment-case id=parsing-main-inselect:fragment-case-2>fragment case</a>)</p>

    <p>Otherwise:</p>

    <p>Pop elements from the <a href=#stack-of-open-elements id=parsing-main-inselect:stack-of-open-elements-11>stack of open elements</a> until a <code id=parsing-main-inselect:the-select-element-2><a href=#the-select-element>select</a></code> element
    has been popped from the stack.</p>

    <p><a href=#reset-the-insertion-mode-appropriately id=parsing-main-inselect:reset-the-insertion-mode-appropriately-2>Reset the insertion mode appropriately</a>.</p>
    

    <p class=note>It just gets treated like an end tag.</p>

   <dt>A start tag whose tag name is one of: "input", "keygen", "textarea"<dd>

    <p><a href=#parse-errors id=parsing-main-inselect:parse-errors-7>Parse error</a>.</p>

    
    <p>If the <a href=#stack-of-open-elements id=parsing-main-inselect:stack-of-open-elements-12>stack of open elements</a> does not <a href=#has-an-element-in-select-scope id=parsing-main-inselect:has-an-element-in-select-scope-3>have a <code>select</code> element in select scope</a>, ignore the token.
    (<a href=#fragment-case id=parsing-main-inselect:fragment-case-3>fragment case</a>)</p>

    <p>Otherwise:</p>

    <p>Pop elements from the <a href=#stack-of-open-elements id=parsing-main-inselect:stack-of-open-elements-13>stack of open elements</a> until a <code id=parsing-main-inselect:the-select-element-3><a href=#the-select-element>select</a></code> element
    has been popped from the stack.</p>

    <p><a href=#reset-the-insertion-mode-appropriately id=parsing-main-inselect:reset-the-insertion-mode-appropriately-3>Reset the insertion mode appropriately</a>.</p>
    

    <p>Reprocess the token.</p>

   <dt>A start tag whose tag name is one of: "script", "template"<dt>An end tag whose tag name is "template"<dd>

    <p>Process the token <a href=#using-the-rules-for id=parsing-main-inselect:using-the-rules-for-2>using the rules for</a> the "<a href=#parsing-main-inhead id=parsing-main-inselect:parsing-main-inhead>in head</a>" <a href=#insertion-mode id=parsing-main-inselect:insertion-mode-3>insertion mode</a>.</p>

   <dt>An end-of-file token<dd>

    <p>Process the token <a href=#using-the-rules-for id=parsing-main-inselect:using-the-rules-for-3>using the rules for</a> the "<a href=#parsing-main-inbody id=parsing-main-inselect:parsing-main-inbody-2>in body</a>" <a href=#insertion-mode id=parsing-main-inselect:insertion-mode-4>insertion mode</a>.</p>

   <dt>Anything else<dd>
    <p><a href=#parse-errors id=parsing-main-inselect:parse-errors-8>Parse error</a>. Ignore the token.</p>
   </dl>


  <h6 id=parsing-main-inselectintable><span class=secno>12.2.6.4.17</span> The "<dfn>in select in table</dfn>" insertion mode<a href=#parsing-main-inselectintable class=self-link></a></h6>

  <p>When the user agent is to apply the rules for the "<a href=#parsing-main-inselectintable id=parsing-main-inselectintable:parsing-main-inselectintable>in select in table</a>" <a href=#insertion-mode id=parsing-main-inselectintable: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: "caption", "table", "tbody", "tfoot", "thead", "tr",
   "td", "th"<dd>

    <p><a href=#parse-errors id=parsing-main-inselectintable:parse-errors>Parse error</a>.</p>

    
    <p>Pop elements from the <a href=#stack-of-open-elements id=parsing-main-inselectintable:stack-of-open-elements>stack of open elements</a> until a <code id=parsing-main-inselectintable:the-select-element><a href=#the-select-element>select</a></code> element
    has been popped from the stack.</p>

    <p><a href=#reset-the-insertion-mode-appropriately id=parsing-main-inselectintable:reset-the-insertion-mode-appropriately>Reset the insertion mode appropriately</a>.</p>
    

    <p>Reprocess the token.</p>

   <dt>An end tag whose tag name is one of: "caption", "table", "tbody", "tfoot", "thead", "tr",
   "td", "th"<dd>

    <p><a href=#parse-errors id=parsing-main-inselectintable:parse-errors-2>Parse error</a>.</p>

    <p>If the <a href=#stack-of-open-elements id=parsing-main-inselectintable:stack-of-open-elements-2>stack of open elements</a> does not <a href=#has-an-element-in-table-scope id=parsing-main-inselectintable:has-an-element-in-table-scope>have an element in table scope</a> that is an <a href=#html-elements id=parsing-main-inselectintable:html-elements>HTML
    element</a> with the same tag name as that of the token, then ignore the token.</p>

    <p>Otherwise:</p>

    
    <p>Pop elements from the <a href=#stack-of-open-elements id=parsing-main-inselectintable:stack-of-open-elements-3>stack of open elements</a> until a <code id=parsing-main-inselectintable:the-select-element-2><a href=#the-select-element>select</a></code> element
    has been popped from the stack.</p>

    <p><a href=#reset-the-insertion-mode-appropriately id=parsing-main-inselectintable:reset-the-insertion-mode-appropriately-2>Reset the insertion mode appropriately</a>.</p>
    

    <p>Reprocess the token.</p>

   <dt>Anything else<dd>

    <p>Process the token <a href=#using-the-rules-for id=parsing-main-inselectintable:using-the-rules-for>using the rules for</a> the "<a href=#parsing-main-inselect id=parsing-main-inselectintable:parsing-main-inselect>in select</a>" <a href=#insertion-mode id=parsing-main-inselectintable:insertion-mode-2>insertion mode</a>.</p>

   </dl>



  <h6 id=parsing-main-intemplate><span class=secno>12.2.6.4.18</span> The "<dfn>in template</dfn>" insertion mode<a href=#parsing-main-intemplate class=self-link></a></h6>

  <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>A comment token<dt>A DOCTYPE token<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>

   <dt>A start tag whose tag name is one of: "base", "basefont", "bgsound", "link", "meta", "noframes", "script", "style", "template", "title"<dt>An end tag whose tag name is "template"<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>

   <dt>A start tag whose tag name is one of: "caption", "colgroup", "tbody", "tfoot", "thead"<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>

   <dt>A start tag whose tag name is "col"<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>

   <dt>A start tag whose tag name is "tr"<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>

   <dt>A start tag whose tag name is one of: "td", "th"<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>

   <dt>Any other start tag<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>

   <dt>Any other end tag<dd>
    <p><a href=#parse-errors id=parsing-main-intemplate:parse-errors>Parse error</a>. Ignore the token.</p>
   <dt>An end-of-file token<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>

   </dl>


  <h6 id=parsing-main-afterbody><span class=secno>12.2.6.4.19</span> The "<dfn>after body</dfn>" insertion mode<a href=#parsing-main-afterbody class=self-link></a></h6>

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

   <dt>A comment token<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>

   <dt>A DOCTYPE token<dd>
    <p><a href=#parse-errors id=parsing-main-afterbody:parse-errors>Parse error</a>. Ignore the token.</p>
   <dt>A start tag whose tag name is "html"<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>

   <dt>An end tag whose tag name is "html"<dd>

    <p>If the parser was originally 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>

   <dt>An end-of-file token<dd>
    <p><a href=#stop-parsing id=parsing-main-afterbody:stop-parsing>Stop parsing</a>.</p>
   <dt>Anything else<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>

   </dl>


  <h6 id=parsing-main-inframeset><span class=secno>12.2.6.4.20</span> The "<dfn>in frameset</dfn>" insertion mode<a href=#parsing-main-inframeset class=self-link></a></h6>

  <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<dd>
    <p><a href=#insert-a-character id=parsing-main-inframeset:insert-a-character>Insert the character</a>.</p>
   <dt>A comment token<dd>
    <p><a href=#insert-a-comment id=parsing-main-inframeset:insert-a-comment>Insert a comment</a>.</p>
   <dt>A DOCTYPE token<dd>
    <p><a href=#parse-errors id=parsing-main-inframeset:parse-errors>Parse error</a>. Ignore the token.</p>
   <dt>A start tag whose tag name is "html"<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>

   <dt>A start tag whose tag name is "frameset"<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>
   <dt>An end tag whose tag name is "frameset"<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 <em>not</em> originally 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>

   <dt>A start tag whose tag name is "frame"<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>

   <dt>A start tag whose tag name is "noframes"<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>

   <dt>An end-of-file token<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>

   <dt>Anything else<dd>
    <p><a href=#parse-errors id=parsing-main-inframeset:parse-errors-4>Parse error</a>. Ignore the token.</p>
   </dl>


  <h6 id=parsing-main-afterframeset><span class=secno>12.2.6.4.21</span> The "<dfn>after frameset</dfn>" insertion mode<a href=#parsing-main-afterframeset class=self-link></a></h6>

  <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<dd>
    <p><a href=#insert-a-character id=parsing-main-afterframeset:insert-a-character>Insert the character</a>.</p>
   <dt>A comment token<dd>
    <p><a href=#insert-a-comment id=parsing-main-afterframeset:insert-a-comment>Insert a comment</a>.</p>
   <dt>A DOCTYPE token<dd>
    <p><a href=#parse-errors id=parsing-main-afterframeset:parse-errors>Parse error</a>. Ignore the token.</p>
   <dt>A start tag whose tag name is "html"<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>

   <dt>An end tag whose tag name is "html"<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>

   <dt>A start tag whose tag name is "noframes"<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>

   <dt>An end-of-file token<dd>
    <p><a href=#stop-parsing id=parsing-main-afterframeset:stop-parsing>Stop parsing</a>.</p>
   <dt>Anything else<dd>
    <p><a href=#parse-errors id=parsing-main-afterframeset:parse-errors-2>Parse error</a>. Ignore the token.</p>
   </dl>


  <h6 id=the-after-after-body-insertion-mode><span class=secno>12.2.6.4.22</span> The "<dfn>after after body</dfn>" insertion mode<a href=#the-after-after-body-insertion-mode class=self-link></a></h6>

  <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<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>
   <dt>A DOCTYPE token<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>A start tag whose tag name is "html"<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>

   <dt>An end-of-file token<dd>
    <p><a href=#stop-parsing id=the-after-after-body-insertion-mode:stop-parsing>Stop parsing</a>.</p>
   <dt>Anything else<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>

   </dl>


  <h6 id=the-after-after-frameset-insertion-mode><span class=secno>12.2.6.4.23</span> The "<dfn>after after frameset</dfn>" insertion mode<a href=#the-after-after-frameset-insertion-mode class=self-link></a></h6>

  <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<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>
   <dt>A DOCTYPE token<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>A start tag whose tag name is "html"<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>

   <dt>An end-of-file token<dd>
    <p><a href=#stop-parsing id=the-after-after-frameset-insertion-mode:stop-parsing>Stop parsing</a>.</p>
   <dt>A start tag whose tag name is "noframes"<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>

   <dt>Anything else<dd>
    <p><a href=#parse-errors id=the-after-after-frameset-insertion-mode:parse-errors>Parse error</a>. Ignore the token.</p>
   </dl>



  <h5 id=parsing-main-inforeign><span class=secno>12.2.6.5</span> The rules for parsing tokens <dfn>in foreign content</dfn><a href=#parsing-main-inforeign class=self-link></a></h5>

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

   <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<dd>

    <p><a href=#insert-a-character id=parsing-main-inforeign:insert-a-character-2>Insert the token's character</a>.</p>

   <dt>Any other character token<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>

   <dt>A comment token<dd>

    <p><a href=#insert-a-comment id=parsing-main-inforeign:insert-a-comment>Insert a comment</a>.</p>

   <dt>A DOCTYPE token<dd>
    <p><a href=#parse-errors id=parsing-main-inforeign:parse-errors-2>Parse error</a>. Ignore the token.</p>
   <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>A start tag whose tag name is "font", if the token has any attributes named "color", "face",
   or "size"<dd>

    <p><a href=#parse-errors id=parsing-main-inforeign:parse-errors-3>Parse error</a>.</p>

    

    <p>If the parser was originally created for the <a href=#html-fragment-parsing-algorithm id=parsing-main-inforeign:html-fragment-parsing-algorithm>HTML fragment parsing algorithm</a>,
    then act as described in the "any other start tag" entry below. (<a href=#fragment-case id=parsing-main-inforeign:fragment-case>fragment case</a>)</p>

    <p>Otherwise:</p>

    <p>Pop an element from the <a href=#stack-of-open-elements id=parsing-main-inforeign:stack-of-open-elements>stack of open elements</a>, and then keep popping more
    elements from the <a href=#stack-of-open-elements id=parsing-main-inforeign:stack-of-open-elements-2>stack of open elements</a> until the <a href=#current-node id=parsing-main-inforeign:current-node>current node</a> is 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>.</p>

    <p>Then, reprocess the token.</p>

   <dt>Any other start tag<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> Element name
     <tbody><tr><td> <code>altglyph</code> <td> <code>altGlyph</code>
      <tr><td> <code>altglyphdef</code> <td> <code>altGlyphDef</code>
      <tr><td> <code>altglyphitem</code> <td> <code>altGlyphItem</code>
      <tr><td> <code>animatecolor</code> <td> <code>animateColor</code>
      <tr><td> <code>animatemotion</code> <td> <code>animateMotion</code>
      <tr><td> <code>animatetransform</code> <td> <code>animateTransform</code>
      <tr><td> <code>clippath</code> <td> <code>clipPath</code>
      <tr><td> <code>feblend</code> <td> <code>feBlend</code>
      <tr><td> <code>fecolormatrix</code> <td> <code>feColorMatrix</code>
      <tr><td> <code>fecomponenttransfer</code> <td> <code>feComponentTransfer</code>
      <tr><td> <code>fecomposite</code> <td> <code>feComposite</code>
      <tr><td> <code>feconvolvematrix</code> <td> <code>feConvolveMatrix</code>
      <tr><td> <code>fediffuselighting</code> <td> <code>feDiffuseLighting</code>
      <tr><td> <code>fedisplacementmap</code> <td> <code>feDisplacementMap</code>
      <tr><td> <code>fedistantlight</code> <td> <code>feDistantLight</code>
      <tr><td> <code>fedropshadow</code> <td> <code>feDropShadow</code>
      <tr><td> <code>feflood</code> <td> <code>feFlood</code>
      <tr><td> <code>fefunca</code> <td> <code>feFuncA</code>
      <tr><td> <code>fefuncb</code> <td> <code>feFuncB</code>
      <tr><td> <code>fefuncg</code> <td> <code>feFuncG</code>
      <tr><td> <code>fefuncr</code> <td> <code>feFuncR</code>
      <tr><td> <code>fegaussianblur</code> <td> <code>feGaussianBlur</code>
      <tr><td> <code>feimage</code> <td> <code>feImage</code>
      <tr><td> <code>femerge</code> <td> <code>feMerge</code>
      <tr><td> <code>femergenode</code> <td> <code>feMergeNode</code>
      <tr><td> <code>femorphology</code> <td> <code>feMorphology</code>
      <tr><td> <code>feoffset</code> <td> <code>feOffset</code>
      <tr><td> <code>fepointlight</code> <td> <code>fePointLight</code>
      <tr><td> <code>fespecularlighting</code> <td> <code>feSpecularLighting</code>
      <tr><td> <code>fespotlight</code> <td> <code>feSpotLight</code>
      <tr><td> <code>fetile</code> <td> <code>feTile</code>
      <tr><td> <code>feturbulence</code> <td> <code>feTurbulence</code>
      <tr><td> <code>foreignobject</code> <td> <code>foreignObject</code>
      <tr><td> <code>glyphref</code> <td> <code>glyphRef</code>
      <tr><td> <code>lineargradient</code> <td> <code>linearGradient</code>
      <tr><td> <code>radialgradient</code> <td> <code>radialGradient</code>
      
      <tr><td> <code>textpath</code> <td> <code>textPath</code>
    </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, in the same namespace as the
    <a href=#adjusted-current-node id=parsing-main-inforeign:adjusted-current-node-4>adjusted current node</a>.</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><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>

     <dt>Otherwise<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-3>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>

     </dl>

   <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<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-4>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><a href=https://www.w3.org/TR/SVGMobile12/script.html#ScriptContentProcessing>Process the
    SVG <code>script</code> element</a> according to the SVG rules, if the user agent
    supports SVG. <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>

   <dt>Any other end tag<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).<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>.<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-5>stack of
     open elements</a>, then return. (<a href=#fragment-case id=parsing-main-inforeign:fragment-case-2>fragment case</a>)<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-6>stack of open
     elements</a> until <var>node</var> has been popped from the stack, and then return.<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-7>stack of open
     elements</a>.<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>.<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>insertion mode</a> in HTML content.</ol>

   </dl>

  


  

  <h4 id=the-end><span class=secno>12.2.7</span> The end<a href=#the-end class=self-link></a></h4>

  <p>Once the user agent <dfn id=stop-parsing>stops parsing</dfn> the document, the user agent
  must run the following steps:<div class=status><input onclick=toggleStatus(this) value=⋰ type=button><p class=support><strong>Support:</strong> domcontentloaded<span class="and_chr yes"><span>Chrome for Android</span> <span>67+</span></span><span class="chrome yes"><span>Chrome</span> <span>4+</span></span><span class="ios_saf yes"><span>iOS Safari</span> <span>3.2+</span></span><span class="and_uc yes"><span>UC Browser for Android</span> <span>11.8+</span></span><span class="firefox yes"><span>Firefox</span> <span>2+</span></span><span class="ie yes"><span>IE</span> <span>9+</span></span><span class="op_mini yes"><span>Opera Mini</span> <span>all+</span></span><span class="safari yes"><span>Safari</span> <span>3.1+</span></span><span class="edge yes"><span>Edge</span> <span>12+</span></span><span class="samsung yes"><span>Samsung Internet</span> <span>4+</span></span><span class="opera yes"><span>Opera</span> <span>9+</span></span><span class="android yes"><span>Android Browser</span> <span>2.1+</span></span><p class=caniuse>Source: <a href="https://caniuse.com/#feat=domcontentloaded">caniuse.com</a></div>

  <ol><li><p>Set the <a href=#current-document-readiness id=the-end:current-document-readiness>current document readiness</a> to "<code>interactive</code>"
    and the <a href=#insertion-point id=the-end:insertion-point>insertion point</a> to
   undefined.<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>.<li><p>If 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, run these substeps:</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> flag set <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>.<li><p><a href=#execute-the-script-block id=the-end:execute-the-script-block>Execute</a> 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>.<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).<li><p>If 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-5>list of scripts that will execute when the document has finished
     parsing</a> is still not empty, repeat these substeps again from substep 1.</p>

    </ol>

   <li>
    <p><a href=#queue-a-task id=the-end:queue-a-task>Queue a task</a> to run the following substeps:</p>

    <ol><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-2><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.<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-3><a href=#document>Document</a></code> object's <a href=#relevant-settings-object id=the-end:relevant-settings-object>relevant settings object</a>.</ol>
   <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.<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-4><a href=#document>Document</a></code>.<li>

    <p><a href=#queue-a-task id=the-end:queue-a-task-2>Queue a task</a> to run the following substeps:</p>

    <ol><li><p>Set the <a href=#current-document-readiness id=the-end:current-document-readiness-2>current document readiness</a> to "<code>complete</code>".<li><p><i>Load event</i>: If the <code id=the-end:document-5><a href=#document>Document</a></code> has a <a href=#concept-document-bc id=the-end:concept-document-bc>browsing context</a>, then <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
     the <code id=the-end:document-6><a href=#document>Document</a></code> object's <a href=#concept-relevant-global id=the-end:concept-relevant-global>relevant global object</a>, with <var>legacy target
     override flag</var> set.</ol>

   <li>

    <p>If the <code id=the-end:document-7><a href=#document>Document</a></code> has a <a href=#concept-document-bc id=the-end:concept-document-bc-2>browsing
    context</a>, then <a href=#queue-a-task id=the-end:queue-a-task-3>queue a task</a> to run the following substeps:</p>

    <ol><li><p>If the <code id=the-end:document-8><a href=#document>Document</a></code>'s <a href=#page-showing id=the-end:page-showing>page showing</a> flag is true, then return
     (i.e. don't fire the event below).<li><p>Set the <code id=the-end:document-9><a href=#document>Document</a></code>'s <a href=#page-showing id=the-end:page-showing-2>page showing</a> flag to true.<li><p><a href=https://dom.spec.whatwg.org/#concept-event-fire id=the-end:concept-event-fire-3 data-x-internal=concept-event-fire>Fire an event</a> named <code id=the-end:event-pageshow><a href=#event-pageshow>pageshow</a></code> at the <code id=the-end:document-10><a href=#document>Document</a></code> object's <a href=#concept-relevant-global id=the-end:concept-relevant-global-2>relevant
     global object</a>, using <code id=the-end:pagetransitionevent><a href=#pagetransitionevent>PageTransitionEvent</a></code>, with the <code id=the-end:dom-pagetransitionevent-persisted><a href=#dom-pagetransitionevent-persisted>persisted</a></code> attribute initialized to false, and
     <var>legacy target override flag</var> set.</ol>

   <li><p>If the <code id=the-end:document-11><a href=#document>Document</a></code> has any <a href=#pending-application-cache-download-process-tasks id=the-end:pending-application-cache-download-process-tasks>pending application cache download process
   tasks</a>, then <a href=#queue-a-task id=the-end:queue-a-task-4>queue</a> each such <a href=#concept-task id=the-end:concept-task>task</a> in the order they were added to the list of <a href=#pending-application-cache-download-process-tasks id=the-end:pending-application-cache-download-process-tasks-2>pending
   application cache download process tasks</a>, and then empty the list of <a href=#pending-application-cache-download-process-tasks id=the-end:pending-application-cache-download-process-tasks-3>pending
   application cache download process tasks</a>. The <a href=#task-source id=the-end:task-source>task source</a> for these <a href=#concept-task id=the-end:concept-task-2>tasks</a> is the <a href=#networking-task-source id=the-end:networking-task-source>networking task source</a>.<li><p>If the <code id=the-end:document-12><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>.<li><p>The <code id=the-end:document-13><a href=#document>Document</a></code> is now <dfn id=ready-for-post-load-tasks>ready for post-load tasks</dfn>.<li><p><a href=#queue-a-task id=the-end:queue-a-task-5>Queue a task</a> to mark the <code id=the-end:document-14><a href=#document>Document</a></code> as <dfn id=completely-loaded>completely
   loaded</dfn>.</ol>

  <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.<li><p>Set the <a href=#current-document-readiness id=the-end:current-document-readiness-3>current document readiness</a> to "<code>interactive</code>".<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>.<li><p>Set the <a href=#current-document-readiness id=the-end:current-document-readiness-4>current document readiness</a> to "<code>complete</code>".</ol>

  <p>Except where otherwise specified, the <a href=#task-source id=the-end:task-source-2>task source</a> for the <a href=#concept-task id=the-end:concept-task-3>tasks</a> mentioned in this section is the <a href=#dom-manipulation-task-source id=the-end:dom-manipulation-task-source>DOM manipulation task
  source</a>.</p>

  


  

  <h4 id=coercing-an-html-dom-into-an-infoset><span class=secno>12.2.8</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>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>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.</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::></code> start tag
  will be closed by a <code>&lt;/a::></code> end tag, and never by a <code>&lt;/aU00003AU00003A></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>12.2.9</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>12.2.9.1</span> Misnested tags: &lt;b>&lt;i>&lt;/b>&lt;/i><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 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 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 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></ul></ul></ul></ul></ul></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>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>formatting
  element</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 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 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 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></ul></ul><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></ul><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></ul></ul></ul></ul>


  <h5 id=misnested-tags:-b-p-/b-/p><span class=secno>12.2.9.2</span> Misnested tags: &lt;b>&lt;p>&lt;/b>&lt;/p><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 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 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></ul></ul></ul></ul></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>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>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>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>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 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></ul><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></ul></ul></ul></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 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></ul><li class=t1><code id=misnested-tags:-b-p-/b-/p:the-p-element-7><a href=#the-p-element>p</a></code></ul></ul></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></ul></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 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></ul><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></ul></ul></ul></ul></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 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></ul><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></ul><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></ul></ul></ul></ul>


  <h5 id=unexpected-markup-in-tables><span class=secno>12.2.9.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 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></ul></ul></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 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 class=t1><code id=unexpected-markup-in-tables:the-table-element-3><a href=#the-table-element>table</a></code></ul></ul></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 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 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></ul></ul></ul></ul></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 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 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></ul></ul></ul></ul></ul></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 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 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></ul></ul></ul></ul></ul></ul></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 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 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></ul><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></ul></ul></ul></ul></ul></ul></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 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 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></ul><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></ul></ul></ul></ul><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></ul></ul></ul></ul>


  <h5 id=scripts-that-modify-the-page-as-it-is-being-parsed><span class=secno>12.2.9.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>&apos;a&apos;</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 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 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></ul></ul></ul></ul></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 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></ul></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 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></ul></ul></ul></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>12.2.9.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>12.2.9.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 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 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></ul></ul></ul></ul></ul></ul></ul><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></ul></ul></ul></ul></ul></ul><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></ul></ul></ul></ul></ul></ul></ul></ul></ul><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></ul></ul></ul></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>12.3</span> Serializing HTML fragments<a href=#serialising-html-fragments class=self-link></a></h3>

  <p>The following steps form the <dfn data-export="" id=html-fragment-serialisation-algorithm>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>, 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>Let <var>s</var> be a string, and initialize it to the empty string.<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).<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:

    <ol><li><p>Let <var>current node</var> be the child node being processed.<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>Element</code><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<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>Element.setAttribute()</code>, the local name will be
          lowercase.</p>

         <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><dd><p>The attribute's serialized name is the string "<code>xml:</code>" followed
         by the attribute's local name.<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><dd><p>The attribute's serialized name is the string "<code>xmlns</code>".<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><dd><p>The attribute's serialized name is the string "<code>xmlns:</code>"
         followed by the attribute's local name.<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><dd><p>The attribute's serialized name is the string "<code>xlink:</code>"
         followed by the attribute's local name.<dt>If the attribute is in some other namespace<dd><p>The attribute's serialized name is the attribute's qualified name.</dl>

        <p>While the exact order of attributes is UA-defined, 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 (>).</p>

        <p>If <var>current node</var> is an <code id=serialising-html-fragments:the-area-element><a href=#the-area-element>area</a></code>, <code id=serialising-html-fragments:the-base-element><a href=#the-base-element>base</a></code>,
        <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:the-br-element><a href=#the-br-element>br</a></code>, <code id=serialising-html-fragments:the-col-element><a href=#the-col-element>col</a></code>,
        <code id=serialising-html-fragments:the-embed-element><a href=#the-embed-element>embed</a></code>, <code id=serialising-html-fragments:frame><a href=#frame>frame</a></code>, <code id=serialising-html-fragments:the-hr-element><a href=#the-hr-element>hr</a></code>, <code id=serialising-html-fragments:the-img-element><a href=#the-img-element>img</a></code>,
        <code id=serialising-html-fragments:the-input-element><a href=#the-input-element>input</a></code>, <code id=serialising-html-fragments:keygen><a href=#keygen>keygen</a></code>, <code id=serialising-html-fragments:the-link-element><a href=#the-link-element>link</a></code>, <code id=serialising-html-fragments:the-meta-element><a href=#the-meta-element>meta</a></code>,
        <code id=serialising-html-fragments:the-param-element><a href=#the-param-element>param</a></code>, <code id=serialising-html-fragments:the-source-element><a href=#the-source-element>source</a></code>, <code id=serialising-html-fragments:the-track-element><a href=#the-track-element>track</a></code> or <code id=serialising-html-fragments:the-wbr-element><a href=#the-wbr-element>wbr</a></code> element,
        then continue 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>HTML fragment serialization algorithm</a> on the
        <var>current node</var> element (thus recursing into this algorithm for that
        element), 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
        (>).</p>

       <dt>If <var>current node</var> is a <code>Text</code> node<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 <code>data</code> IDL attribute literally.</p>

        <p>Otherwise, append the value of <var>current node</var>'s <code>data</code> IDL attribute, <a href=#escapingString id=serialising-html-fragments:escapingString-3>escaped as described
        below</a>.</p>

       <dt>If <var>current node</var> is a <code>Comment</code><dd>

        <p>Append the literal string "<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 <code>data</code> IDL attribute, followed by the
        literal string "<code>--></code>" (U+002D HYPHEN-MINUS, U+002D HYPHEN-MINUS,
        U+003E GREATER-THAN SIGN).</p>

       <dt>If <var>current node</var> is a <code>ProcessingInstruction</code><dd>

        <p>Append the literal string "<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 <code>data</code> IDL
        attribute, followed by a single U+003E GREATER-THAN SIGN character (>).</p>

       <dt>If <var>current node</var> is a <code>DocumentType</code><dd>

        <p>Append the literal string "<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 <code>name</code> IDL
        attribute, followed by the literal string "<code>></code>" (U+003E GREATER-THAN SIGN).</p>

       </dl>

     </ol>

   <li><p>The result of the algorithm is the string <var>s</var>.</ol>

  <p 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 class=example>

   <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 the literal string "<code>--></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><a data-x-internal=text href=https://dom.spec.whatwg.org/#interface-text>Text</a></code> node with the text string "<code>&lt;/script></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-innerhtml><a data-x-internal=dom-innerhtml href=https://w3c.github.io/DOM-Parsing/#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>&lt;script>attack&lt;/script></code>" as a font family name, <code id=serialising-html-fragments:dom-innerhtml-2><a data-x-internal=dom-innerhtml href=https://w3c.github.io/DOM-Parsing/#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 class=example>

   <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>&quot;outer&quot;</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>&quot;inner&quot;</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 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-2><a href=#the-input-element>input</a></code></ul></ul></ul></ul></ul></ul>

   <p>The <code id=serialising-html-fragments:the-input-element-3><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"></code> start tag will be ignored, and so the <code id=serialising-html-fragments:the-input-element-4><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>&quot;outer&quot;</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>&quot;inner&quot;</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 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-5><a href=#the-input-element>input</a></code></ul></ul></ul></ul></ul>

  </div>

  <div class=example>

   <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 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 class=t1><code id=serialising-html-fragments:the-table-element><a href=#the-table-element>table</a></code></ul></ul></ul></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></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 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 class=t1><code id=serialising-html-fragments:the-a-element-8><a href=#the-a-element>a</a></code><li class=t1><code id=serialising-html-fragments:the-table-element-3><a href=#the-table-element>table</a></code></ul></ul></ul>

  </div>

  <p>For historical reasons, this algorithm does not round-trip an initial U+000A LINE FEED (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 LINE FEED (LF) character.</p>
  

  <div class=example>
   <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 class=example>
   <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- kr>class</c-> <c- kr>extends</c-> HTMLParagraphElement <c- p>{};</c->
customElements<c- p>.</c->define<c- p>(</c-><c- u>&quot;super-p&quot;</c-><c- p>,</c-> SuperP<c- p>,</c-> <c- p>{</c-> <c- kr>extends</c-><c- o>:</c-> <c- u>&quot;p&quot;</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>&quot;container&quot;</c-><c- p>&gt;&lt;</c-><c- f>p</c-> <c- e>is</c-><c- o>=</c-><c- s>&quot;super-p&quot;</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=&quot;super-p&quot;&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=&quot;super-p&quot;&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>&quot;&quot;</c-><c- p>;</c->
<c- kr>const</c-> p <c- o>=</c-> document<c- p>.</c->createElement<c- p>(</c-><c- u>&quot;p&quot;</c-><c- p>,</c-> <c- p>{</c-> is<c- o>:</c-> <c- u>&quot;super-p&quot;</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>&quot;is&quot;</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=&quot;super-p&quot;&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=&quot;super-p&quot;&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>

  <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>".<li><p>Replace any occurrences of the U+00A0 NO-BREAK SPACE character by the string "<code>&amp;nbsp;</code>".<li><p>If the algorithm was invoked in the <i>attribute mode</i>, replace any occurrences of the
   "<code>"</code>" character by the string "<code>&amp;quot;</code>".<li><p>If the algorithm was <em>not</em> invoked in the <i>attribute mode</i>, replace any
   occurrences of the "<code>&lt;</code>" character by the string "<code>&amp;lt;</code>", and any occurrences of the "<code>></code>" character by
   the string "<code>&amp;gt;</code>".</ol>


  <h3 id=parsing-html-fragments><span class=secno>12.4</span> Parsing HTML fragments<a href=#parsing-html-fragments class=self-link></a></h3>

  <p>The following steps form the <dfn id=html-fragment-parsing-algorithm>HTML fragment parsing algorithm</dfn>. The algorithm
  takes as input an <code id=parsing-html-fragments:element><a data-x-internal=element href=https://dom.spec.whatwg.org/#interface-element>Element</a></code> node, referred to as the <dfn id=concept-frag-parse-context><var>context</var></dfn> element, which gives the context for
  the parser, as well as <var>input</var>, a string to parse, and returns a list of zero or
  more nodes.</p>

  <p class=note>Parts marked <dfn id=fragment-case>fragment case</dfn> in algorithms in the parser 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>Create a new <code id=parsing-html-fragments:document><a href=#document>Document</a></code> node, and mark it as being an <a href=https://dom.spec.whatwg.org/#html-document id=parsing-html-fragments:html-documents data-x-internal=html-documents>HTML document</a>.</p>

   <li>

    <p>If the
    <a id=parsing-html-fragments:node-document href=https://dom.spec.whatwg.org/#concept-node-document data-x-internal=node-document>node document</a> of the <var id=parsing-html-fragments:concept-frag-parse-context><a href=#concept-frag-parse-context>context</a></var> element 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 let the <code id=parsing-html-fragments:document-2><a href=#document>Document</a></code> be in <a id=parsing-html-fragments:quirks-mode-2 href=https://dom.spec.whatwg.org/#concept-document-quirks data-x-internal=quirks-mode>quirks mode</a>.
    Otherwise, the
    <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> of the <var id=parsing-html-fragments:concept-frag-parse-context-2><a href=#concept-frag-parse-context>context</a></var> element 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 let the <code id=parsing-html-fragments:document-3><a href=#document>Document</a></code> be in <a id=parsing-html-fragments:limited-quirks-mode-2 href=https://dom.spec.whatwg.org/#concept-document-limited-quirks data-x-internal=limited-quirks-mode>limited-quirks
    mode</a>. Otherwise, leave the <code id=parsing-html-fragments:document-4><a href=#document>Document</a></code> in <a id=parsing-html-fragments: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>

    <p>Create a new <a href=#html-parser id=parsing-html-fragments:html-parser>HTML parser</a>, and associate it with the just created
    <code id=parsing-html-fragments:document-5><a href=#document>Document</a></code> node.</p>

   <li>

    <p>Set the state of the <a href=#html-parser id=parsing-html-fragments:html-parser-2>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><code id=parsing-html-fragments:the-textarea-element><a href=#the-textarea-element>textarea</a></code><dd>Switch the tokenizer to the <a href=#rcdata-state id=parsing-html-fragments:rcdata-state>RCDATA state</a>.<dt><code id=parsing-html-fragments:the-style-element><a href=#the-style-element>style</a></code><dt><code id=parsing-html-fragments:xmp><a href=#xmp>xmp</a></code><dt><code id=parsing-html-fragments:the-iframe-element><a href=#the-iframe-element>iframe</a></code><dt><code id=parsing-html-fragments:noembed><a href=#noembed>noembed</a></code><dt><code id=parsing-html-fragments:noframes><a href=#noframes>noframes</a></code><dd>Switch the tokenizer to the <a href=#rawtext-state id=parsing-html-fragments:rawtext-state>RAWTEXT state</a>.<dt><code id=parsing-html-fragments:the-script-element><a href=#the-script-element>script</a></code><dd>Switch the tokenizer to the <a href=#script-data-state id=parsing-html-fragments:script-data-state>script data state</a>.<dt><code id=parsing-html-fragments:the-noscript-element><a href=#the-noscript-element>noscript</a></code><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>.<dt><code id=parsing-html-fragments:plaintext><a href=#plaintext>plaintext</a></code><dd>Switch the tokenizer to the <a href=#plaintext-state id=parsing-html-fragments:plaintext-state>PLAINTEXT state</a>.<dt>Any other element<dd>Leave the tokenizer in the <a href=#data-state id=parsing-html-fragments:data-state-2>data state</a>.</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>

    <p>Let <var>root</var> be a new <code id=parsing-html-fragments:the-html-element><a href=#the-html-element>html</a></code> element with no attributes.</p>

   <li>

    <p>Append the element <var>root</var> to the <code id=parsing-html-fragments:document-6><a href=#document>Document</a></code> node created
    above.</p>

   <li>

    <p>Set up the parser'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>

    <p>If the <var id=parsing-html-fragments:concept-frag-parse-context-4><a href=#concept-frag-parse-context>context</a></var> element is a
    <code id=parsing-html-fragments:the-template-element><a href=#the-template-element>template</a></code> element, 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>

    <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 the <var id=parsing-html-fragments:concept-frag-parse-context-7><a href=#concept-frag-parse-context>context</a></var> node, 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>

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

    <p>Set the parser's <a href=#form-element-pointer id=parsing-html-fragments:form-element-pointer><code>form</code> element pointer</a> to the nearest node to the
    <var id=parsing-html-fragments:concept-frag-parse-context-9><a href=#concept-frag-parse-context>context</a></var> element 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>

    <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-3>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>

    <p>Start the parser and let it run until it has consumed all the characters just inserted into
    the input stream.</p>

   <li>

    <p>Return the child
    nodes of <var>root</var>, 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>

   </ol>

  



  <h3 id=named-character-references><span class=secno>12.5</span> <dfn>Named character references</dfn><a href=#named-character-references class=self-link></a></h3>

  <p>This table lists the character reference names that are supported by HTML, and the code points
  to which they refer. It is referenced by the previous sections.</p>

  <div id=named-character-references-table>
   <table><thead><tr><th> Name <th> Character(s) <th> Glyph <tbody><tr id=entity-Aacute><td> <code>Aacute;</code> <td> U+000C1 <td> <span class=glyph>Á</span> <tr id=entity-Aacute-legacy class=impl><td> <code>Aacute</code> <td> U+000C1 <td> <span>Á</span> <tr id=entity-aacute><td> <code>aacute;</code> <td> U+000E1 <td> <span class=glyph>á</span> <tr id=entity-aacute-legacy class=impl><td> <code>aacute</code> <td> U+000E1 <td> <span>á</span> <tr id=entity-Abreve><td> <code>Abreve;</code> <td> U+00102 <td> <span class=glyph>Ă</span> <tr id=entity-abreve><td> <code>abreve;</code> <td> U+00103 <td> <span class=glyph>ă</span> <tr id=entity-ac><td> <code>ac;</code> <td> U+0223E <td> <span class=glyph>∾</span> <tr id=entity-acd><td> <code>acd;</code> <td> U+0223F <td> <span class=glyph>∿</span> <tr id=entity-acE><td> <code>acE;</code> <td> U+0223E U+00333 <td> <span class="glyph compound">∾̳</span> <tr id=entity-Acirc><td> <code>Acirc;</code> <td> U+000C2 <td> <span class=glyph>Â</span> <tr id=entity-Acirc-legacy class=impl><td> <code>Acirc</code> <td> U+000C2 <td> <span>Â</span> <tr id=entity-acirc><td> <code>acirc;</code> <td> U+000E2 <td> <span class=glyph>â</span> <tr id=entity-acirc-legacy class=impl><td> <code>acirc</code> <td> U+000E2 <td> <span>â</span> <tr id=entity-acute><td> <code>acute;</code> <td> U+000B4 <td> <span class=glyph>´</span> <tr id=entity-acute-legacy class=impl><td> <code>acute</code> <td> U+000B4 <td> <span>´</span> <tr id=entity-Acy><td> <code>Acy;</code> <td> U+00410 <td> <span class=glyph>А</span> <tr id=entity-acy><td> <code>acy;</code> <td> U+00430 <td> <span class=glyph>а</span> <tr id=entity-AElig><td> <code>AElig;</code> <td> U+000C6 <td> <span class=glyph>Æ</span> <tr id=entity-AElig-legacy class=impl><td> <code>AElig</code> <td> U+000C6 <td> <span>Æ</span> <tr id=entity-aelig><td> <code>aelig;</code> <td> U+000E6 <td> <span class=glyph>æ</span> <tr id=entity-aelig-legacy class=impl><td> <code>aelig</code> <td> U+000E6 <td> <span>æ</span> <tr id=entity-af><td> <code>af;</code> <td> U+02061 <td> <span class=glyph>⁡</span> <tr id=entity-Afr><td> <code>Afr;</code> <td> U+1D504 <td> <span class=glyph>𝔄</span> <tr id=entity-afr><td> <code>afr;</code> <td> U+1D51E <td> <span class=glyph>𝔞</span> <tr id=entity-Agrave><td> <code>Agrave;</code> <td> U+000C0 <td> <span class=glyph>À</span> <tr id=entity-Agrave-legacy class=impl><td> <code>Agrave</code> <td> U+000C0 <td> <span>À</span> <tr id=entity-agrave><td> <code>agrave;</code> <td> U+000E0 <td> <span class=glyph>à</span> <tr id=entity-agrave-legacy class=impl><td> <code>agrave</code> <td> U+000E0 <td> <span>à</span> <tr id=entity-alefsym><td> <code>alefsym;</code> <td> U+02135 <td> <span class=glyph>ℵ</span> <tr id=entity-aleph><td> <code>aleph;</code> <td> U+02135 <td> <span class=glyph>ℵ</span> <tr id=entity-Alpha><td> <code>Alpha;</code> <td> U+00391 <td> <span class=glyph>Α</span> <tr id=entity-alpha><td> <code>alpha;</code> <td> U+003B1 <td> <span class=glyph>α</span> <tr id=entity-Amacr><td> <code>Amacr;</code> <td> U+00100 <td> <span class=glyph>Ā</span> <tr id=entity-amacr><td> <code>amacr;</code> <td> U+00101 <td> <span class=glyph>ā</span> <tr id=entity-amalg><td> <code>amalg;</code> <td> U+02A3F <td> <span class=glyph>⨿</span> <tr id=entity-AMP><td> <code>AMP;</code> <td> U+00026 <td> <span class=glyph>&amp;</span> <tr id=entity-AMP-legacy class=impl><td> <code>AMP</code> <td> U+00026 <td> <span>&amp;</span> <tr id=entity-amp><td> <code>amp;</code> <td> U+00026 <td> <span class=glyph>&amp;</span> <tr id=entity-amp-legacy class=impl><td> <code>amp</code> <td> U+00026 <td> <span>&amp;</span> <tr id=entity-And><td> <code>And;</code> <td> U+02A53 <td> <span class=glyph>⩓</span> <tr id=entity-and><td> <code>and;</code> <td> U+02227 <td> <span class=glyph>∧</span> <tr id=entity-andand><td> <code>andand;</code> <td> U+02A55 <td> <span class=glyph>⩕</span> <tr id=entity-andd><td> <code>andd;</code> <td> U+02A5C <td> <span class=glyph>⩜</span> <tr id=entity-andslope><td> <code>andslope;</code> <td> U+02A58 <td> <span class=glyph>⩘</span> <tr id=entity-andv><td> <code>andv;</code> <td> U+02A5A <td> <span class=glyph>⩚</span> <tr id=entity-ang><td> <code>ang;</code> <td> U+02220 <td> <span class=glyph>∠</span> <tr id=entity-ange><td> <code>ange;</code> <td> U+029A4 <td> <span class=glyph>⦤</span> <tr id=entity-angle><td> <code>angle;</code> <td> U+02220 <td> <span class=glyph>∠</span> <tr id=entity-angmsd><td> <code>angmsd;</code> <td> U+02221 <td> <span class=glyph>∡</span> <tr id=entity-angmsdaa><td> <code>angmsdaa;</code> <td> U+029A8 <td> <span class=glyph>⦨</span> <tr id=entity-angmsdab><td> <code>angmsdab;</code> <td> U+029A9 <td> <span class=glyph>⦩</span> <tr id=entity-angmsdac><td> <code>angmsdac;</code> <td> U+029AA <td> <span class=glyph>⦪</span> <tr id=entity-angmsdad><td> <code>angmsdad;</code> <td> U+029AB <td> <span class=glyph>⦫</span> <tr id=entity-angmsdae><td> <code>angmsdae;</code> <td> U+029AC <td> <span class=glyph>⦬</span> <tr id=entity-angmsdaf><td> <code>angmsdaf;</code> <td> U+029AD <td> <span class=glyph>⦭</span> <tr id=entity-angmsdag><td> <code>angmsdag;</code> <td> U+029AE <td> <span class=glyph>⦮</span> <tr id=entity-angmsdah><td> <code>angmsdah;</code> <td> U+029AF <td> <span class=glyph>⦯</span> <tr id=entity-angrt><td> <code>angrt;</code> <td> U+0221F <td> <span class=glyph>∟</span> <tr id=entity-angrtvb><td> <code>angrtvb;</code> <td> U+022BE <td> <span class=glyph>⊾</span> <tr id=entity-angrtvbd><td> <code>angrtvbd;</code> <td> U+0299D <td> <span class=glyph>⦝</span> <tr id=entity-angsph><td> <code>angsph;</code> <td> U+02222 <td> <span class=glyph>∢</span> <tr id=entity-angst><td> <code>angst;</code> <td> U+000C5 <td> <span class=glyph>Å</span> <tr id=entity-angzarr><td> <code>angzarr;</code> <td> U+0237C <td> <span class=glyph>⍼</span> <tr id=entity-Aogon><td> <code>Aogon;</code> <td> U+00104 <td> <span class=glyph>Ą</span> <tr id=entity-aogon><td> <code>aogon;</code> <td> U+00105 <td> <span class=glyph>ą</span> <tr id=entity-Aopf><td> <code>Aopf;</code> <td> U+1D538 <td> <span class=glyph>𝔸</span> <tr id=entity-aopf><td> <code>aopf;</code> <td> U+1D552 <td> <span class=glyph>𝕒</span> <tr id=entity-ap><td> <code>ap;</code> <td> U+02248 <td> <span class=glyph>≈</span> <tr id=entity-apacir><td> <code>apacir;</code> <td> U+02A6F <td> <span class=glyph>⩯</span> <tr id=entity-apE><td> <code>apE;</code> <td> U+02A70 <td> <span class=glyph>⩰</span> <tr id=entity-ape><td> <code>ape;</code> <td> U+0224A <td> <span class=glyph>≊</span> <tr id=entity-apid><td> <code>apid;</code> <td> U+0224B <td> <span class=glyph>≋</span> <tr id=entity-apos><td> <code>apos;</code> <td> U+00027 <td> <span class=glyph>'</span> <tr id=entity-ApplyFunction><td> <code>ApplyFunction;</code> <td> U+02061 <td> <span class=glyph>⁡</span> <tr id=entity-approx><td> <code>approx;</code> <td> U+02248 <td> <span class=glyph>≈</span> <tr id=entity-approxeq><td> <code>approxeq;</code> <td> U+0224A <td> <span class=glyph>≊</span> <tr id=entity-Aring><td> <code>Aring;</code> <td> U+000C5 <td> <span class=glyph>Å</span> <tr id=entity-Aring-legacy class=impl><td> <code>Aring</code> <td> U+000C5 <td> <span>Å</span> <tr id=entity-aring><td> <code>aring;</code> <td> U+000E5 <td> <span class=glyph>å</span> <tr id=entity-aring-legacy class=impl><td> <code>aring</code> <td> U+000E5 <td> <span>å</span> <tr id=entity-Ascr><td> <code>Ascr;</code> <td> U+1D49C <td> <span class=glyph>𝒜</span> <tr id=entity-ascr><td> <code>ascr;</code> <td> U+1D4B6 <td> <span class=glyph>𝒶</span> <tr id=entity-Assign><td> <code>Assign;</code> <td> U+02254 <td> <span class=glyph>≔</span> <tr id=entity-ast><td> <code>ast;</code> <td> U+0002A <td> <span class=glyph>*</span> <tr id=entity-asymp><td> <code>asymp;</code> <td> U+02248 <td> <span class=glyph>≈</span> <tr id=entity-asympeq><td> <code>asympeq;</code> <td> U+0224D <td> <span class=glyph>≍</span> <tr id=entity-Atilde><td> <code>Atilde;</code> <td> U+000C3 <td> <span class=glyph>Ã</span> <tr id=entity-Atilde-legacy class=impl><td> <code>Atilde</code> <td> U+000C3 <td> <span>Ã</span> <tr id=entity-atilde><td> <code>atilde;</code> <td> U+000E3 <td> <span class=glyph>ã</span> <tr id=entity-atilde-legacy class=impl><td> <code>atilde</code> <td> U+000E3 <td> <span>ã</span> <tr id=entity-Auml><td> <code>Auml;</code> <td> U+000C4 <td> <span class=glyph>Ä</span> <tr id=entity-Auml-legacy class=impl><td> <code>Auml</code> <td> U+000C4 <td> <span>Ä</span> <tr id=entity-auml><td> <code>auml;</code> <td> U+000E4 <td> <span class=glyph>ä</span> <tr id=entity-auml-legacy class=impl><td> <code>auml</code> <td> U+000E4 <td> <span>ä</span> <tr id=entity-awconint><td> <code>awconint;</code> <td> U+02233 <td> <span class=glyph>∳</span> <tr id=entity-awint><td> <code>awint;</code> <td> U+02A11 <td> <span class=glyph>⨑</span> <tr id=entity-backcong><td> <code>backcong;</code> <td> U+0224C <td> <span class=glyph>≌</span> <tr id=entity-backepsilon><td> <code>backepsilon;</code> <td> U+003F6 <td> <span class=glyph>϶</span> <tr id=entity-backprime><td> <code>backprime;</code> <td> U+02035 <td> <span class=glyph>‵</span> <tr id=entity-backsim><td> <code>backsim;</code> <td> U+0223D <td> <span class=glyph>∽</span> <tr id=entity-backsimeq><td> <code>backsimeq;</code> <td> U+022CD <td> <span class=glyph>⋍</span> <tr id=entity-Backslash><td> <code>Backslash;</code> <td> U+02216 <td> <span class=glyph>∖</span> <tr id=entity-Barv><td> <code>Barv;</code> <td> U+02AE7 <td> <span class=glyph>⫧</span> <tr id=entity-barvee><td> <code>barvee;</code> <td> U+022BD <td> <span class=glyph>⊽</span> <tr id=entity-Barwed><td> <code>Barwed;</code> <td> U+02306 <td> <span class=glyph>⌆</span> <tr id=entity-barwed><td> <code>barwed;</code> <td> U+02305 <td> <span class=glyph>⌅</span> <tr id=entity-barwedge><td> <code>barwedge;</code> <td> U+02305 <td> <span class=glyph>⌅</span> <tr id=entity-bbrk><td> <code>bbrk;</code> <td> U+023B5 <td> <span class=glyph>⎵</span> <tr id=entity-bbrktbrk><td> <code>bbrktbrk;</code> <td> U+023B6 <td> <span class=glyph>⎶</span> <tr id=entity-bcong><td> <code>bcong;</code> <td> U+0224C <td> <span class=glyph>≌</span> <tr id=entity-Bcy><td> <code>Bcy;</code> <td> U+00411 <td> <span class=glyph>Б</span> <tr id=entity-bcy><td> <code>bcy;</code> <td> U+00431 <td> <span class=glyph>б</span> <tr id=entity-bdquo><td> <code>bdquo;</code> <td> U+0201E <td> <span class=glyph>„</span> <tr id=entity-becaus><td> <code>becaus;</code> <td> U+02235 <td> <span class=glyph>∵</span> <tr id=entity-Because><td> <code>Because;</code> <td> U+02235 <td> <span class=glyph>∵</span> <tr id=entity-because><td> <code>because;</code> <td> U+02235 <td> <span class=glyph>∵</span> <tr id=entity-bemptyv><td> <code>bemptyv;</code> <td> U+029B0 <td> <span class=glyph>⦰</span> <tr id=entity-bepsi><td> <code>bepsi;</code> <td> U+003F6 <td> <span class=glyph>϶</span> <tr id=entity-bernou><td> <code>bernou;</code> <td> U+0212C <td> <span class=glyph>ℬ</span> <tr id=entity-Bernoullis><td> <code>Bernoullis;</code> <td> U+0212C <td> <span class=glyph>ℬ</span> <tr id=entity-Beta><td> <code>Beta;</code> <td> U+00392 <td> <span class=glyph>Β</span> <tr id=entity-beta><td> <code>beta;</code> <td> U+003B2 <td> <span class=glyph>β</span> <tr id=entity-beth><td> <code>beth;</code> <td> U+02136 <td> <span class=glyph>ℶ</span> <tr id=entity-between><td> <code>between;</code> <td> U+0226C <td> <span class=glyph>≬</span> <tr id=entity-Bfr><td> <code>Bfr;</code> <td> U+1D505 <td> <span class=glyph>𝔅</span> <tr id=entity-bfr><td> <code>bfr;</code> <td> U+1D51F <td> <span class=glyph>𝔟</span> <tr id=entity-bigcap><td> <code>bigcap;</code> <td> U+022C2 <td> <span class=glyph>⋂</span> <tr id=entity-bigcirc><td> <code>bigcirc;</code> <td> U+025EF <td> <span class=glyph>◯</span> <tr id=entity-bigcup><td> <code>bigcup;</code> <td> U+022C3 <td> <span class=glyph>⋃</span> <tr id=entity-bigodot><td> <code>bigodot;</code> <td> U+02A00 <td> <span class=glyph>⨀</span> <tr id=entity-bigoplus><td> <code>bigoplus;</code> <td> U+02A01 <td> <span class=glyph>⨁</span> <tr id=entity-bigotimes><td> <code>bigotimes;</code> <td> U+02A02 <td> <span class=glyph>⨂</span> <tr id=entity-bigsqcup><td> <code>bigsqcup;</code> <td> U+02A06 <td> <span class=glyph>⨆</span> <tr id=entity-bigstar><td> <code>bigstar;</code> <td> U+02605 <td> <span class=glyph>★</span> <tr id=entity-bigtriangledown><td> <code>bigtriangledown;</code> <td> U+025BD <td> <span class=glyph>▽</span> <tr id=entity-bigtriangleup><td> <code>bigtriangleup;</code> <td> U+025B3 <td> <span class=glyph>△</span> <tr id=entity-biguplus><td> <code>biguplus;</code> <td> U+02A04 <td> <span class=glyph>⨄</span> <tr id=entity-bigvee><td> <code>bigvee;</code> <td> U+022C1 <td> <span class=glyph>⋁</span> <tr id=entity-bigwedge><td> <code>bigwedge;</code> <td> U+022C0 <td> <span class=glyph>⋀</span> <tr id=entity-bkarow><td> <code>bkarow;</code> <td> U+0290D <td> <span class=glyph>⤍</span> <tr id=entity-blacklozenge><td> <code>blacklozenge;</code> <td> U+029EB <td> <span class=glyph>⧫</span> <tr id=entity-blacksquare><td> <code>blacksquare;</code> <td> U+025AA <td> <span class=glyph>▪</span> <tr id=entity-blacktriangle><td> <code>blacktriangle;</code> <td> U+025B4 <td> <span class=glyph>▴</span> <tr id=entity-blacktriangledown><td> <code>blacktriangledown;</code> <td> U+025BE <td> <span class=glyph>▾</span> <tr id=entity-blacktriangleleft><td> <code>blacktriangleleft;</code> <td> U+025C2 <td> <span class=glyph>◂</span> <tr id=entity-blacktriangleright><td> <code>blacktriangleright;</code> <td> U+025B8 <td> <span class=glyph>▸</span> <tr id=entity-blank><td> <code>blank;</code> <td> U+02423 <td> <span class=glyph>␣</span> <tr id=entity-blk12><td> <code>blk12;</code> <td> U+02592 <td> <span class=glyph>▒</span> <tr id=entity-blk14><td> <code>blk14;</code> <td> U+02591 <td> <span class=glyph>░</span> <tr id=entity-blk34><td> <code>blk34;</code> <td> U+02593 <td> <span class=glyph>▓</span> <tr id=entity-block><td> <code>block;</code> <td> U+02588 <td> <span class=glyph>█</span> <tr id=entity-bne><td> <code>bne;</code> <td> U+0003D U+020E5 <td> <span class="glyph compound">=⃥</span> <tr id=entity-bnequiv><td> <code>bnequiv;</code> <td> U+02261 U+020E5 <td> <span class="glyph compound">≡⃥</span> <tr id=entity-bNot><td> <code>bNot;</code> <td> U+02AED <td> <span class=glyph>⫭</span> <tr id=entity-bnot><td> <code>bnot;</code> <td> U+02310 <td> <span class=glyph>⌐</span> <tr id=entity-Bopf><td> <code>Bopf;</code> <td> U+1D539 <td> <span class=glyph>𝔹</span> <tr id=entity-bopf><td> <code>bopf;</code> <td> U+1D553 <td> <span class=glyph>𝕓</span> <tr id=entity-bot><td> <code>bot;</code> <td> U+022A5 <td> <span class=glyph>⊥</span> <tr id=entity-bottom><td> <code>bottom;</code> <td> U+022A5 <td> <span class=glyph>⊥</span> <tr id=entity-bowtie><td> <code>bowtie;</code> <td> U+022C8 <td> <span class=glyph>⋈</span> <tr id=entity-boxbox><td> <code>boxbox;</code> <td> U+029C9 <td> <span class=glyph>⧉</span> <tr id=entity-boxDL><td> <code>boxDL;</code> <td> U+02557 <td> <span class=glyph>╗</span> <tr id=entity-boxDl><td> <code>boxDl;</code> <td> U+02556 <td> <span class=glyph>╖</span> <tr id=entity-boxdL><td> <code>boxdL;</code> <td> U+02555 <td> <span class=glyph>╕</span> <tr id=entity-boxdl><td> <code>boxdl;</code> <td> U+02510 <td> <span class=glyph>┐</span> <tr id=entity-boxDR><td> <code>boxDR;</code> <td> U+02554 <td> <span class=glyph>╔</span> <tr id=entity-boxDr><td> <code>boxDr;</code> <td> U+02553 <td> <span class=glyph>╓</span> <tr id=entity-boxdR><td> <code>boxdR;</code> <td> U+02552 <td> <span class=glyph>╒</span> <tr id=entity-boxdr><td> <code>boxdr;</code> <td> U+0250C <td> <span class=glyph>┌</span> <tr id=entity-boxH><td> <code>boxH;</code> <td> U+02550 <td> <span class=glyph>═</span> <tr id=entity-boxh><td> <code>boxh;</code> <td> U+02500 <td> <span class=glyph>─</span> <tr id=entity-boxHD><td> <code>boxHD;</code> <td> U+02566 <td> <span class=glyph>╦</span> <tr id=entity-boxHd><td> <code>boxHd;</code> <td> U+02564 <td> <span class=glyph>╤</span> <tr id=entity-boxhD><td> <code>boxhD;</code> <td> U+02565 <td> <span class=glyph>╥</span> <tr id=entity-boxhd><td> <code>boxhd;</code> <td> U+0252C <td> <span class=glyph>┬</span> <tr id=entity-boxHU><td> <code>boxHU;</code> <td> U+02569 <td> <span class=glyph>╩</span> <tr id=entity-boxHu><td> <code>boxHu;</code> <td> U+02567 <td> <span class=glyph>╧</span> <tr id=entity-boxhU><td> <code>boxhU;</code> <td> U+02568 <td> <span class=glyph>╨</span> <tr id=entity-boxhu><td> <code>boxhu;</code> <td> U+02534 <td> <span class=glyph>┴</span> <tr id=entity-boxminus><td> <code>boxminus;</code> <td> U+0229F <td> <span class=glyph>⊟</span> <tr id=entity-boxplus><td> <code>boxplus;</code> <td> U+0229E <td> <span class=glyph>⊞</span> <tr id=entity-boxtimes><td> <code>boxtimes;</code> <td> U+022A0 <td> <span class=glyph>⊠</span> <tr id=entity-boxUL><td> <code>boxUL;</code> <td> U+0255D <td> <span class=glyph>╝</span> <tr id=entity-boxUl><td> <code>boxUl;</code> <td> U+0255C <td> <span class=glyph>╜</span> <tr id=entity-boxuL><td> <code>boxuL;</code> <td> U+0255B <td> <span class=glyph>╛</span> <tr id=entity-boxul><td> <code>boxul;</code> <td> U+02518 <td> <span class=glyph>┘</span> <tr id=entity-boxUR><td> <code>boxUR;</code> <td> U+0255A <td> <span class=glyph>╚</span> <tr id=entity-boxUr><td> <code>boxUr;</code> <td> U+02559 <td> <span class=glyph>╙</span> <tr id=entity-boxuR><td> <code>boxuR;</code> <td> U+02558 <td> <span class=glyph>╘</span> <tr id=entity-boxur><td> <code>boxur;</code> <td> U+02514 <td> <span class=glyph>└</span> <tr id=entity-boxV><td> <code>boxV;</code> <td> U+02551 <td> <span class=glyph>║</span> <tr id=entity-boxv><td> <code>boxv;</code> <td> U+02502 <td> <span class=glyph>│</span> <tr id=entity-boxVH><td> <code>boxVH;</code> <td> U+0256C <td> <span class=glyph>╬</span> <tr id=entity-boxVh><td> <code>boxVh;</code> <td> U+0256B <td> <span class=glyph>╫</span> <tr id=entity-boxvH><td> <code>boxvH;</code> <td> U+0256A <td> <span class=glyph>╪</span> <tr id=entity-boxvh><td> <code>boxvh;</code> <td> U+0253C <td> <span class=glyph>┼</span> <tr id=entity-boxVL><td> <code>boxVL;</code> <td> U+02563 <td> <span class=glyph>╣</span> <tr id=entity-boxVl><td> <code>boxVl;</code> <td> U+02562 <td> <span class=glyph>╢</span> <tr id=entity-boxvL><td> <code>boxvL;</code> <td> U+02561 <td> <span class=glyph>╡</span> <tr id=entity-boxvl><td> <code>boxvl;</code> <td> U+02524 <td> <span class=glyph>┤</span> <tr id=entity-boxVR><td> <code>boxVR;</code> <td> U+02560 <td> <span class=glyph>╠</span> <tr id=entity-boxVr><td> <code>boxVr;</code> <td> U+0255F <td> <span class=glyph>╟</span> <tr id=entity-boxvR><td> <code>boxvR;</code> <td> U+0255E <td> <span class=glyph>╞</span> <tr id=entity-boxvr><td> <code>boxvr;</code> <td> U+0251C <td> <span class=glyph>├</span> <tr id=entity-bprime><td> <code>bprime;</code> <td> U+02035 <td> <span class=glyph>‵</span> <tr id=entity-Breve><td> <code>Breve;</code> <td> U+002D8 <td> <span class=glyph>˘</span> <tr id=entity-breve><td> <code>breve;</code> <td> U+002D8 <td> <span class=glyph>˘</span> <tr id=entity-brvbar><td> <code>brvbar;</code> <td> U+000A6 <td> <span class=glyph>¦</span> <tr id=entity-brvbar-legacy class=impl><td> <code>brvbar</code> <td> U+000A6 <td> <span>¦</span> <tr id=entity-Bscr><td> <code>Bscr;</code> <td> U+0212C <td> <span class=glyph>ℬ</span> <tr id=entity-bscr><td> <code>bscr;</code> <td> U+1D4B7 <td> <span class=glyph>𝒷</span> <tr id=entity-bsemi><td> <code>bsemi;</code> <td> U+0204F <td> <span class=glyph>⁏</span> <tr id=entity-bsim><td> <code>bsim;</code> <td> U+0223D <td> <span class=glyph>∽</span> <tr id=entity-bsime><td> <code>bsime;</code> <td> U+022CD <td> <span class=glyph>⋍</span> <tr id=entity-bsol><td> <code>bsol;</code> <td> U+0005C <td> <span class=glyph>\</span> <tr id=entity-bsolb><td> <code>bsolb;</code> <td> U+029C5 <td> <span class=glyph>⧅</span> <tr id=entity-bsolhsub><td> <code>bsolhsub;</code> <td> U+027C8 <td> <span class=glyph>⟈</span> <tr id=entity-bull><td> <code>bull;</code> <td> U+02022 <td> <span class=glyph>•</span> <tr id=entity-bullet><td> <code>bullet;</code> <td> U+02022 <td> <span class=glyph>•</span> <tr id=entity-bump><td> <code>bump;</code> <td> U+0224E <td> <span class=glyph>≎</span> <tr id=entity-bumpE><td> <code>bumpE;</code> <td> U+02AAE <td> <span class=glyph>⪮</span> <tr id=entity-bumpe><td> <code>bumpe;</code> <td> U+0224F <td> <span class=glyph>≏</span> <tr id=entity-Bumpeq><td> <code>Bumpeq;</code> <td> U+0224E <td> <span class=glyph>≎</span> <tr id=entity-bumpeq><td> <code>bumpeq;</code> <td> U+0224F <td> <span class=glyph>≏</span> <tr id=entity-Cacute><td> <code>Cacute;</code> <td> U+00106 <td> <span class=glyph>Ć</span> <tr id=entity-cacute><td> <code>cacute;</code> <td> U+00107 <td> <span class=glyph>ć</span> <tr id=entity-Cap><td> <code>Cap;</code> <td> U+022D2 <td> <span class=glyph>⋒</span> <tr id=entity-cap><td> <code>cap;</code> <td> U+02229 <td> <span class=glyph>∩</span> <tr id=entity-capand><td> <code>capand;</code> <td> U+02A44 <td> <span class=glyph>⩄</span> <tr id=entity-capbrcup><td> <code>capbrcup;</code> <td> U+02A49 <td> <span class=glyph>⩉</span> <tr id=entity-capcap><td> <code>capcap;</code> <td> U+02A4B <td> <span class=glyph>⩋</span> <tr id=entity-capcup><td> <code>capcup;</code> <td> U+02A47 <td> <span class=glyph>⩇</span> <tr id=entity-capdot><td> <code>capdot;</code> <td> U+02A40 <td> <span class=glyph>⩀</span> <tr id=entity-CapitalDifferentialD><td> <code>CapitalDifferentialD;</code> <td> U+02145 <td> <span class=glyph>ⅅ</span> <tr id=entity-caps><td> <code>caps;</code> <td> U+02229 U+0FE00 <td> <span class="glyph compound">∩︀</span> <tr id=entity-caret><td> <code>caret;</code> <td> U+02041 <td> <span class=glyph>⁁</span> <tr id=entity-caron><td> <code>caron;</code> <td> U+002C7 <td> <span class=glyph>ˇ</span> <tr id=entity-Cayleys><td> <code>Cayleys;</code> <td> U+0212D <td> <span class=glyph>ℭ</span> <tr id=entity-ccaps><td> <code>ccaps;</code> <td> U+02A4D <td> <span class=glyph>⩍</span> <tr id=entity-Ccaron><td> <code>Ccaron;</code> <td> U+0010C <td> <span class=glyph>Č</span> <tr id=entity-ccaron><td> <code>ccaron;</code> <td> U+0010D <td> <span class=glyph>č</span> <tr id=entity-Ccedil><td> <code>Ccedil;</code> <td> U+000C7 <td> <span class=glyph>Ç</span> <tr id=entity-Ccedil-legacy class=impl><td> <code>Ccedil</code> <td> U+000C7 <td> <span>Ç</span> <tr id=entity-ccedil><td> <code>ccedil;</code> <td> U+000E7 <td> <span class=glyph>ç</span> <tr id=entity-ccedil-legacy class=impl><td> <code>ccedil</code> <td> U+000E7 <td> <span>ç</span> <tr id=entity-Ccirc><td> <code>Ccirc;</code> <td> U+00108 <td> <span class=glyph>Ĉ</span> <tr id=entity-ccirc><td> <code>ccirc;</code> <td> U+00109 <td> <span class=glyph>ĉ</span> <tr id=entity-Cconint><td> <code>Cconint;</code> <td> U+02230 <td> <span class=glyph>∰</span> <tr id=entity-ccups><td> <code>ccups;</code> <td> U+02A4C <td> <span class=glyph>⩌</span> <tr id=entity-ccupssm><td> <code>ccupssm;</code> <td> U+02A50 <td> <span class=glyph>⩐</span> <tr id=entity-Cdot><td> <code>Cdot;</code> <td> U+0010A <td> <span class=glyph>Ċ</span> <tr id=entity-cdot><td> <code>cdot;</code> <td> U+0010B <td> <span class=glyph>ċ</span> <tr id=entity-cedil><td> <code>cedil;</code> <td> U+000B8 <td> <span class=glyph>¸</span> <tr id=entity-cedil-legacy class=impl><td> <code>cedil</code> <td> U+000B8 <td> <span>¸</span> <tr id=entity-Cedilla><td> <code>Cedilla;</code> <td> U+000B8 <td> <span class=glyph>¸</span> <tr id=entity-cemptyv><td> <code>cemptyv;</code> <td> U+029B2 <td> <span class=glyph>⦲</span> <tr id=entity-cent><td> <code>cent;</code> <td> U+000A2 <td> <span class=glyph>¢</span> <tr id=entity-cent-legacy class=impl><td> <code>cent</code> <td> U+000A2 <td> <span>¢</span> <tr id=entity-CenterDot><td> <code>CenterDot;</code> <td> U+000B7 <td> <span class=glyph>·</span> <tr id=entity-centerdot><td> <code>centerdot;</code> <td> U+000B7 <td> <span class=glyph>·</span> <tr id=entity-Cfr><td> <code>Cfr;</code> <td> U+0212D <td> <span class=glyph>ℭ</span> <tr id=entity-cfr><td> <code>cfr;</code> <td> U+1D520 <td> <span class=glyph>𝔠</span> <tr id=entity-CHcy><td> <code>CHcy;</code> <td> U+00427 <td> <span class=glyph>Ч</span> <tr id=entity-chcy><td> <code>chcy;</code> <td> U+00447 <td> <span class=glyph>ч</span> <tr id=entity-check><td> <code>check;</code> <td> U+02713 <td> <span class=glyph>✓</span> <tr id=entity-checkmark><td> <code>checkmark;</code> <td> U+02713 <td> <span class=glyph>✓</span> <tr id=entity-Chi><td> <code>Chi;</code> <td> U+003A7 <td> <span class=glyph>Χ</span> <tr id=entity-chi><td> <code>chi;</code> <td> U+003C7 <td> <span class=glyph>χ</span> <tr id=entity-cir><td> <code>cir;</code> <td> U+025CB <td> <span class=glyph>○</span> <tr id=entity-circ><td> <code>circ;</code> <td> U+002C6 <td> <span class=glyph>ˆ</span> <tr id=entity-circeq><td> <code>circeq;</code> <td> U+02257 <td> <span class=glyph>≗</span> <tr id=entity-circlearrowleft><td> <code>circlearrowleft;</code> <td> U+021BA <td> <span class=glyph>↺</span> <tr id=entity-circlearrowright><td> <code>circlearrowright;</code> <td> U+021BB <td> <span class=glyph>↻</span> <tr id=entity-circledast><td> <code>circledast;</code> <td> U+0229B <td> <span class=glyph>⊛</span> <tr id=entity-circledcirc><td> <code>circledcirc;</code> <td> U+0229A <td> <span class=glyph>⊚</span> <tr id=entity-circleddash><td> <code>circleddash;</code> <td> U+0229D <td> <span class=glyph>⊝</span> <tr id=entity-CircleDot><td> <code>CircleDot;</code> <td> U+02299 <td> <span class=glyph>⊙</span> <tr id=entity-circledR><td> <code>circledR;</code> <td> U+000AE <td> <span class=glyph>®</span> <tr id=entity-circledS><td> <code>circledS;</code> <td> U+024C8 <td> <span class=glyph>Ⓢ</span> <tr id=entity-CircleMinus><td> <code>CircleMinus;</code> <td> U+02296 <td> <span class=glyph>⊖</span> <tr id=entity-CirclePlus><td> <code>CirclePlus;</code> <td> U+02295 <td> <span class=glyph>⊕</span> <tr id=entity-CircleTimes><td> <code>CircleTimes;</code> <td> U+02297 <td> <span class=glyph>⊗</span> <tr id=entity-cirE><td> <code>cirE;</code> <td> U+029C3 <td> <span class=glyph>⧃</span> <tr id=entity-cire><td> <code>cire;</code> <td> U+02257 <td> <span class=glyph>≗</span> <tr id=entity-cirfnint><td> <code>cirfnint;</code> <td> U+02A10 <td> <span class=glyph>⨐</span> <tr id=entity-cirmid><td> <code>cirmid;</code> <td> U+02AEF <td> <span class=glyph>⫯</span> <tr id=entity-cirscir><td> <code>cirscir;</code> <td> U+029C2 <td> <span class=glyph>⧂</span> <tr id=entity-ClockwiseContourIntegral><td> <code>ClockwiseContourIntegral;</code> <td> U+02232 <td> <span class=glyph>∲</span> <tr id=entity-CloseCurlyDoubleQuote><td> <code>CloseCurlyDoubleQuote;</code> <td> U+0201D <td> <span class=glyph>”</span> <tr id=entity-CloseCurlyQuote><td> <code>CloseCurlyQuote;</code> <td> U+02019 <td> <span class=glyph>’</span> <tr id=entity-clubs><td> <code>clubs;</code> <td> U+02663 <td> <span class=glyph>♣</span> <tr id=entity-clubsuit><td> <code>clubsuit;</code> <td> U+02663 <td> <span class=glyph>♣</span> <tr id=entity-Colon><td> <code>Colon;</code> <td> U+02237 <td> <span class=glyph>∷</span> <tr id=entity-colon><td> <code>colon;</code> <td> U+0003A <td> <span class=glyph>:</span> <tr id=entity-Colone><td> <code>Colone;</code> <td> U+02A74 <td> <span class=glyph>⩴</span> <tr id=entity-colone><td> <code>colone;</code> <td> U+02254 <td> <span class=glyph>≔</span> <tr id=entity-coloneq><td> <code>coloneq;</code> <td> U+02254 <td> <span class=glyph>≔</span> <tr id=entity-comma><td> <code>comma;</code> <td> U+0002C <td> <span class=glyph>,</span> <tr id=entity-commat><td> <code>commat;</code> <td> U+00040 <td> <span class=glyph>@</span> <tr id=entity-comp><td> <code>comp;</code> <td> U+02201 <td> <span class=glyph>∁</span> <tr id=entity-compfn><td> <code>compfn;</code> <td> U+02218 <td> <span class=glyph>∘</span> <tr id=entity-complement><td> <code>complement;</code> <td> U+02201 <td> <span class=glyph>∁</span> <tr id=entity-complexes><td> <code>complexes;</code> <td> U+02102 <td> <span class=glyph>ℂ</span> <tr id=entity-cong><td> <code>cong;</code> <td> U+02245 <td> <span class=glyph>≅</span> <tr id=entity-congdot><td> <code>congdot;</code> <td> U+02A6D <td> <span class=glyph>⩭</span> <tr id=entity-Congruent><td> <code>Congruent;</code> <td> U+02261 <td> <span class=glyph>≡</span> <tr id=entity-Conint><td> <code>Conint;</code> <td> U+0222F <td> <span class=glyph>∯</span> <tr id=entity-conint><td> <code>conint;</code> <td> U+0222E <td> <span class=glyph>∮</span> <tr id=entity-ContourIntegral><td> <code>ContourIntegral;</code> <td> U+0222E <td> <span class=glyph>∮</span> <tr id=entity-Copf><td> <code>Copf;</code> <td> U+02102 <td> <span class=glyph>ℂ</span> <tr id=entity-copf><td> <code>copf;</code> <td> U+1D554 <td> <span class=glyph>𝕔</span> <tr id=entity-coprod><td> <code>coprod;</code> <td> U+02210 <td> <span class=glyph>∐</span> <tr id=entity-Coproduct><td> <code>Coproduct;</code> <td> U+02210 <td> <span class=glyph>∐</span> <tr id=entity-COPY><td> <code>COPY;</code> <td> U+000A9 <td> <span class=glyph>©</span> <tr id=entity-COPY-legacy class=impl><td> <code>COPY</code> <td> U+000A9 <td> <span>©</span> <tr id=entity-copy><td> <code>copy;</code> <td> U+000A9 <td> <span class=glyph>©</span> <tr id=entity-copy-legacy class=impl><td> <code>copy</code> <td> U+000A9 <td> <span>©</span> <tr id=entity-copysr><td> <code>copysr;</code> <td> U+02117 <td> <span class=glyph>℗</span> <tr id=entity-CounterClockwiseContourIntegral><td> <code>CounterClockwiseContourIntegral;</code> <td> U+02233 <td> <span class=glyph>∳</span> <tr id=entity-crarr><td> <code>crarr;</code> <td> U+021B5 <td> <span class=glyph>↵</span> <tr id=entity-Cross><td> <code>Cross;</code> <td> U+02A2F <td> <span class=glyph>⨯</span> <tr id=entity-cross><td> <code>cross;</code> <td> U+02717 <td> <span class=glyph>✗</span> <tr id=entity-Cscr><td> <code>Cscr;</code> <td> U+1D49E <td> <span class=glyph>𝒞</span> <tr id=entity-cscr><td> <code>cscr;</code> <td> U+1D4B8 <td> <span class=glyph>𝒸</span> <tr id=entity-csub><td> <code>csub;</code> <td> U+02ACF <td> <span class=glyph>⫏</span> <tr id=entity-csube><td> <code>csube;</code> <td> U+02AD1 <td> <span class=glyph>⫑</span> <tr id=entity-csup><td> <code>csup;</code> <td> U+02AD0 <td> <span class=glyph>⫐</span> <tr id=entity-csupe><td> <code>csupe;</code> <td> U+02AD2 <td> <span class=glyph>⫒</span> <tr id=entity-ctdot><td> <code>ctdot;</code> <td> U+022EF <td> <span class=glyph>⋯</span> <tr id=entity-cudarrl><td> <code>cudarrl;</code> <td> U+02938 <td> <span class=glyph>⤸</span> <tr id=entity-cudarrr><td> <code>cudarrr;</code> <td> U+02935 <td> <span class=glyph>⤵</span> <tr id=entity-cuepr><td> <code>cuepr;</code> <td> U+022DE <td> <span class=glyph>⋞</span> <tr id=entity-cuesc><td> <code>cuesc;</code> <td> U+022DF <td> <span class=glyph>⋟</span> <tr id=entity-cularr><td> <code>cularr;</code> <td> U+021B6 <td> <span class=glyph>↶</span> <tr id=entity-cularrp><td> <code>cularrp;</code> <td> U+0293D <td> <span class=glyph>⤽</span> <tr id=entity-Cup><td> <code>Cup;</code> <td> U+022D3 <td> <span class=glyph>⋓</span> <tr id=entity-cup><td> <code>cup;</code> <td> U+0222A <td> <span class=glyph>∪</span> <tr id=entity-cupbrcap><td> <code>cupbrcap;</code> <td> U+02A48 <td> <span class=glyph>⩈</span> <tr id=entity-CupCap><td> <code>CupCap;</code> <td> U+0224D <td> <span class=glyph>≍</span> <tr id=entity-cupcap><td> <code>cupcap;</code> <td> U+02A46 <td> <span class=glyph>⩆</span> <tr id=entity-cupcup><td> <code>cupcup;</code> <td> U+02A4A <td> <span class=glyph>⩊</span> <tr id=entity-cupdot><td> <code>cupdot;</code> <td> U+0228D <td> <span class=glyph>⊍</span> <tr id=entity-cupor><td> <code>cupor;</code> <td> U+02A45 <td> <span class=glyph>⩅</span> <tr id=entity-cups><td> <code>cups;</code> <td> U+0222A U+0FE00 <td> <span class="glyph compound">∪︀</span> <tr id=entity-curarr><td> <code>curarr;</code> <td> U+021B7 <td> <span class=glyph>↷</span> <tr id=entity-curarrm><td> <code>curarrm;</code> <td> U+0293C <td> <span class=glyph>⤼</span> <tr id=entity-curlyeqprec><td> <code>curlyeqprec;</code> <td> U+022DE <td> <span class=glyph>⋞</span> <tr id=entity-curlyeqsucc><td> <code>curlyeqsucc;</code> <td> U+022DF <td> <span class=glyph>⋟</span> <tr id=entity-curlyvee><td> <code>curlyvee;</code> <td> U+022CE <td> <span class=glyph>⋎</span> <tr id=entity-curlywedge><td> <code>curlywedge;</code> <td> U+022CF <td> <span class=glyph>⋏</span> <tr id=entity-curren><td> <code>curren;</code> <td> U+000A4 <td> <span class=glyph>¤</span> <tr id=entity-curren-legacy class=impl><td> <code>curren</code> <td> U+000A4 <td> <span>¤</span> <tr id=entity-curvearrowleft><td> <code>curvearrowleft;</code> <td> U+021B6 <td> <span class=glyph>↶</span> <tr id=entity-curvearrowright><td> <code>curvearrowright;</code> <td> U+021B7 <td> <span class=glyph>↷</span> <tr id=entity-cuvee><td> <code>cuvee;</code> <td> U+022CE <td> <span class=glyph>⋎</span> <tr id=entity-cuwed><td> <code>cuwed;</code> <td> U+022CF <td> <span class=glyph>⋏</span> <tr id=entity-cwconint><td> <code>cwconint;</code> <td> U+02232 <td> <span class=glyph>∲</span> <tr id=entity-cwint><td> <code>cwint;</code> <td> U+02231 <td> <span class=glyph>∱</span> <tr id=entity-cylcty><td> <code>cylcty;</code> <td> U+0232D <td> <span class=glyph>⌭</span> <tr id=entity-Dagger><td> <code>Dagger;</code> <td> U+02021 <td> <span class=glyph>‡</span> <tr id=entity-dagger><td> <code>dagger;</code> <td> U+02020 <td> <span class=glyph>†</span> <tr id=entity-daleth><td> <code>daleth;</code> <td> U+02138 <td> <span class=glyph>ℸ</span> <tr id=entity-Darr><td> <code>Darr;</code> <td> U+021A1 <td> <span class=glyph>↡</span> <tr id=entity-dArr><td> <code>dArr;</code> <td> U+021D3 <td> <span class=glyph>⇓</span> <tr id=entity-darr><td> <code>darr;</code> <td> U+02193 <td> <span class=glyph>↓</span> <tr id=entity-dash><td> <code>dash;</code> <td> U+02010 <td> <span class=glyph>‐</span> <tr id=entity-Dashv><td> <code>Dashv;</code> <td> U+02AE4 <td> <span class=glyph>⫤</span> <tr id=entity-dashv><td> <code>dashv;</code> <td> U+022A3 <td> <span class=glyph>⊣</span> <tr id=entity-dbkarow><td> <code>dbkarow;</code> <td> U+0290F <td> <span class=glyph>⤏</span> <tr id=entity-dblac><td> <code>dblac;</code> <td> U+002DD <td> <span class=glyph>˝</span> <tr id=entity-Dcaron><td> <code>Dcaron;</code> <td> U+0010E <td> <span class=glyph>Ď</span> <tr id=entity-dcaron><td> <code>dcaron;</code> <td> U+0010F <td> <span class=glyph>ď</span> <tr id=entity-Dcy><td> <code>Dcy;</code> <td> U+00414 <td> <span class=glyph>Д</span> <tr id=entity-dcy><td> <code>dcy;</code> <td> U+00434 <td> <span class=glyph>д</span> <tr id=entity-DD><td> <code>DD;</code> <td> U+02145 <td> <span class=glyph>ⅅ</span> <tr id=entity-dd><td> <code>dd;</code> <td> U+02146 <td> <span class=glyph>ⅆ</span> <tr id=entity-ddagger><td> <code>ddagger;</code> <td> U+02021 <td> <span class=glyph>‡</span> <tr id=entity-ddarr><td> <code>ddarr;</code> <td> U+021CA <td> <span class=glyph>⇊</span> <tr id=entity-DDotrahd><td> <code>DDotrahd;</code> <td> U+02911 <td> <span class=glyph>⤑</span> <tr id=entity-ddotseq><td> <code>ddotseq;</code> <td> U+02A77 <td> <span class=glyph>⩷</span> <tr id=entity-deg><td> <code>deg;</code> <td> U+000B0 <td> <span class=glyph>°</span> <tr id=entity-deg-legacy class=impl><td> <code>deg</code> <td> U+000B0 <td> <span>°</span> <tr id=entity-Del><td> <code>Del;</code> <td> U+02207 <td> <span class=glyph>∇</span> <tr id=entity-Delta><td> <code>Delta;</code> <td> U+00394 <td> <span class=glyph>Δ</span> <tr id=entity-delta><td> <code>delta;</code> <td> U+003B4 <td> <span class=glyph>δ</span> <tr id=entity-demptyv><td> <code>demptyv;</code> <td> U+029B1 <td> <span class=glyph>⦱</span> <tr id=entity-dfisht><td> <code>dfisht;</code> <td> U+0297F <td> <span class=glyph>⥿</span> <tr id=entity-Dfr><td> <code>Dfr;</code> <td> U+1D507 <td> <span class=glyph>𝔇</span> <tr id=entity-dfr><td> <code>dfr;</code> <td> U+1D521 <td> <span class=glyph>𝔡</span> <tr id=entity-dHar><td> <code>dHar;</code> <td> U+02965 <td> <span class=glyph>⥥</span> <tr id=entity-dharl><td> <code>dharl;</code> <td> U+021C3 <td> <span class=glyph>⇃</span> <tr id=entity-dharr><td> <code>dharr;</code> <td> U+021C2 <td> <span class=glyph>⇂</span> <tr id=entity-DiacriticalAcute><td> <code>DiacriticalAcute;</code> <td> U+000B4 <td> <span class=glyph>´</span> <tr id=entity-DiacriticalDot><td> <code>DiacriticalDot;</code> <td> U+002D9 <td> <span class=glyph>˙</span> <tr id=entity-DiacriticalDoubleAcute><td> <code>DiacriticalDoubleAcute;</code> <td> U+002DD <td> <span class=glyph>˝</span> <tr id=entity-DiacriticalGrave><td> <code>DiacriticalGrave;</code> <td> U+00060 <td> <span class=glyph>`</span> <tr id=entity-DiacriticalTilde><td> <code>DiacriticalTilde;</code> <td> U+002DC <td> <span class=glyph>˜</span> <tr id=entity-diam><td> <code>diam;</code> <td> U+022C4 <td> <span class=glyph>⋄</span> <tr id=entity-Diamond><td> <code>Diamond;</code> <td> U+022C4 <td> <span class=glyph>⋄</span> <tr id=entity-diamond><td> <code>diamond;</code> <td> U+022C4 <td> <span class=glyph>⋄</span> <tr id=entity-diamondsuit><td> <code>diamondsuit;</code> <td> U+02666 <td> <span class=glyph>♦</span> <tr id=entity-diams><td> <code>diams;</code> <td> U+02666 <td> <span class=glyph>♦</span> <tr id=entity-die><td> <code>die;</code> <td> U+000A8 <td> <span class=glyph>¨</span> <tr id=entity-DifferentialD><td> <code>DifferentialD;</code> <td> U+02146 <td> <span class=glyph>ⅆ</span> <tr id=entity-digamma><td> <code>digamma;</code> <td> U+003DD <td> <span class=glyph>ϝ</span> <tr id=entity-disin><td> <code>disin;</code> <td> U+022F2 <td> <span class=glyph>⋲</span> <tr id=entity-div><td> <code>div;</code> <td> U+000F7 <td> <span class=glyph>÷</span> <tr id=entity-divide><td> <code>divide;</code> <td> U+000F7 <td> <span class=glyph>÷</span> <tr id=entity-divide-legacy class=impl><td> <code>divide</code> <td> U+000F7 <td> <span>÷</span> <tr id=entity-divideontimes><td> <code>divideontimes;</code> <td> U+022C7 <td> <span class=glyph>⋇</span> <tr id=entity-divonx><td> <code>divonx;</code> <td> U+022C7 <td> <span class=glyph>⋇</span> <tr id=entity-DJcy><td> <code>DJcy;</code> <td> U+00402 <td> <span class=glyph>Ђ</span> <tr id=entity-djcy><td> <code>djcy;</code> <td> U+00452 <td> <span class=glyph>ђ</span> <tr id=entity-dlcorn><td> <code>dlcorn;</code> <td> U+0231E <td> <span class=glyph>⌞</span> <tr id=entity-dlcrop><td> <code>dlcrop;</code> <td> U+0230D <td> <span class=glyph>⌍</span> <tr id=entity-dollar><td> <code>dollar;</code> <td> U+00024 <td> <span class=glyph>$</span> <tr id=entity-Dopf><td> <code>Dopf;</code> <td> U+1D53B <td> <span class=glyph>𝔻</span> <tr id=entity-dopf><td> <code>dopf;</code> <td> U+1D555 <td> <span class=glyph>𝕕</span> <tr id=entity-Dot><td> <code>Dot;</code> <td> U+000A8 <td> <span class=glyph>¨</span> <tr id=entity-dot><td> <code>dot;</code> <td> U+002D9 <td> <span class=glyph>˙</span> <tr id=entity-DotDot><td> <code>DotDot;</code> <td> U+020DC <td> <span class="glyph composition">◌⃜</span> <tr id=entity-doteq><td> <code>doteq;</code> <td> U+02250 <td> <span class=glyph>≐</span> <tr id=entity-doteqdot><td> <code>doteqdot;</code> <td> U+02251 <td> <span class=glyph>≑</span> <tr id=entity-DotEqual><td> <code>DotEqual;</code> <td> U+02250 <td> <span class=glyph>≐</span> <tr id=entity-dotminus><td> <code>dotminus;</code> <td> U+02238 <td> <span class=glyph>∸</span> <tr id=entity-dotplus><td> <code>dotplus;</code> <td> U+02214 <td> <span class=glyph>∔</span> <tr id=entity-dotsquare><td> <code>dotsquare;</code> <td> U+022A1 <td> <span class=glyph>⊡</span> <tr id=entity-doublebarwedge><td> <code>doublebarwedge;</code> <td> U+02306 <td> <span class=glyph>⌆</span> <tr id=entity-DoubleContourIntegral><td> <code>DoubleContourIntegral;</code> <td> U+0222F <td> <span class=glyph>∯</span> <tr id=entity-DoubleDot><td> <code>DoubleDot;</code> <td> U+000A8 <td> <span class=glyph>¨</span> <tr id=entity-DoubleDownArrow><td> <code>DoubleDownArrow;</code> <td> U+021D3 <td> <span class=glyph>⇓</span> <tr id=entity-DoubleLeftArrow><td> <code>DoubleLeftArrow;</code> <td> U+021D0 <td> <span class=glyph>⇐</span> <tr id=entity-DoubleLeftRightArrow><td> <code>DoubleLeftRightArrow;</code> <td> U+021D4 <td> <span class=glyph>⇔</span> <tr id=entity-DoubleLeftTee><td> <code>DoubleLeftTee;</code> <td> U+02AE4 <td> <span class=glyph>⫤</span> <tr id=entity-DoubleLongLeftArrow><td> <code>DoubleLongLeftArrow;</code> <td> U+027F8 <td> <span class=glyph>⟸</span> <tr id=entity-DoubleLongLeftRightArrow><td> <code>DoubleLongLeftRightArrow;</code> <td> U+027FA <td> <span class=glyph>⟺</span> <tr id=entity-DoubleLongRightArrow><td> <code>DoubleLongRightArrow;</code> <td> U+027F9 <td> <span class=glyph>⟹</span> <tr id=entity-DoubleRightArrow><td> <code>DoubleRightArrow;</code> <td> U+021D2 <td> <span class=glyph>⇒</span> <tr id=entity-DoubleRightTee><td> <code>DoubleRightTee;</code> <td> U+022A8 <td> <span class=glyph>⊨</span> <tr id=entity-DoubleUpArrow><td> <code>DoubleUpArrow;</code> <td> U+021D1 <td> <span class=glyph>⇑</span> <tr id=entity-DoubleUpDownArrow><td> <code>DoubleUpDownArrow;</code> <td> U+021D5 <td> <span class=glyph>⇕</span> <tr id=entity-DoubleVerticalBar><td> <code>DoubleVerticalBar;</code> <td> U+02225 <td> <span class=glyph>∥</span> <tr id=entity-DownArrow><td> <code>DownArrow;</code> <td> U+02193 <td> <span class=glyph>↓</span> <tr id=entity-Downarrow><td> <code>Downarrow;</code> <td> U+021D3 <td> <span class=glyph>⇓</span> <tr id=entity-downarrow><td> <code>downarrow;</code> <td> U+02193 <td> <span class=glyph>↓</span> <tr id=entity-DownArrowBar><td> <code>DownArrowBar;</code> <td> U+02913 <td> <span class=glyph>⤓</span> <tr id=entity-DownArrowUpArrow><td> <code>DownArrowUpArrow;</code> <td> U+021F5 <td> <span class=glyph>⇵</span> <tr id=entity-DownBreve><td> <code>DownBreve;</code> <td> U+00311 <td> <span class="glyph composition">◌̑</span> <tr id=entity-downdownarrows><td> <code>downdownarrows;</code> <td> U+021CA <td> <span class=glyph>⇊</span> <tr id=entity-downharpoonleft><td> <code>downharpoonleft;</code> <td> U+021C3 <td> <span class=glyph>⇃</span> <tr id=entity-downharpoonright><td> <code>downharpoonright;</code> <td> U+021C2 <td> <span class=glyph>⇂</span> <tr id=entity-DownLeftRightVector><td> <code>DownLeftRightVector;</code> <td> U+02950 <td> <span class=glyph>⥐</span> <tr id=entity-DownLeftTeeVector><td> <code>DownLeftTeeVector;</code> <td> U+0295E <td> <span class=glyph>⥞</span> <tr id=entity-DownLeftVector><td> <code>DownLeftVector;</code> <td> U+021BD <td> <span class=glyph>↽</span> <tr id=entity-DownLeftVectorBar><td> <code>DownLeftVectorBar;</code> <td> U+02956 <td> <span class=glyph>⥖</span> <tr id=entity-DownRightTeeVector><td> <code>DownRightTeeVector;</code> <td> U+0295F <td> <span class=glyph>⥟</span> <tr id=entity-DownRightVector><td> <code>DownRightVector;</code> <td> U+021C1 <td> <span class=glyph>⇁</span> <tr id=entity-DownRightVectorBar><td> <code>DownRightVectorBar;</code> <td> U+02957 <td> <span class=glyph>⥗</span> <tr id=entity-DownTee><td> <code>DownTee;</code> <td> U+022A4 <td> <span class=glyph>⊤</span> <tr id=entity-DownTeeArrow><td> <code>DownTeeArrow;</code> <td> U+021A7 <td> <span class=glyph>↧</span> <tr id=entity-drbkarow><td> <code>drbkarow;</code> <td> U+02910 <td> <span class=glyph>⤐</span> <tr id=entity-drcorn><td> <code>drcorn;</code> <td> U+0231F <td> <span class=glyph>⌟</span> <tr id=entity-drcrop><td> <code>drcrop;</code> <td> U+0230C <td> <span class=glyph>⌌</span> <tr id=entity-Dscr><td> <code>Dscr;</code> <td> U+1D49F <td> <span class=glyph>𝒟</span> <tr id=entity-dscr><td> <code>dscr;</code> <td> U+1D4B9 <td> <span class=glyph>𝒹</span> <tr id=entity-DScy><td> <code>DScy;</code> <td> U+00405 <td> <span class=glyph>Ѕ</span> <tr id=entity-dscy><td> <code>dscy;</code> <td> U+00455 <td> <span class=glyph>ѕ</span> <tr id=entity-dsol><td> <code>dsol;</code> <td> U+029F6 <td> <span class=glyph>⧶</span> <tr id=entity-Dstrok><td> <code>Dstrok;</code> <td> U+00110 <td> <span class=glyph>Đ</span> <tr id=entity-dstrok><td> <code>dstrok;</code> <td> U+00111 <td> <span class=glyph>đ</span> <tr id=entity-dtdot><td> <code>dtdot;</code> <td> U+022F1 <td> <span class=glyph>⋱</span> <tr id=entity-dtri><td> <code>dtri;</code> <td> U+025BF <td> <span class=glyph>▿</span> <tr id=entity-dtrif><td> <code>dtrif;</code> <td> U+025BE <td> <span class=glyph>▾</span> <tr id=entity-duarr><td> <code>duarr;</code> <td> U+021F5 <td> <span class=glyph>⇵</span> <tr id=entity-duhar><td> <code>duhar;</code> <td> U+0296F <td> <span class=glyph>⥯</span> <tr id=entity-dwangle><td> <code>dwangle;</code> <td> U+029A6 <td> <span class=glyph>⦦</span> <tr id=entity-DZcy><td> <code>DZcy;</code> <td> U+0040F <td> <span class=glyph>Џ</span> <tr id=entity-dzcy><td> <code>dzcy;</code> <td> U+0045F <td> <span class=glyph>џ</span> <tr id=entity-dzigrarr><td> <code>dzigrarr;</code> <td> U+027FF <td> <span class=glyph>⟿</span> <tr id=entity-Eacute><td> <code>Eacute;</code> <td> U+000C9 <td> <span class=glyph>É</span> <tr id=entity-Eacute-legacy class=impl><td> <code>Eacute</code> <td> U+000C9 <td> <span>É</span> <tr id=entity-eacute><td> <code>eacute;</code> <td> U+000E9 <td> <span class=glyph>é</span> <tr id=entity-eacute-legacy class=impl><td> <code>eacute</code> <td> U+000E9 <td> <span>é</span> <tr id=entity-easter><td> <code>easter;</code> <td> U+02A6E <td> <span class=glyph>⩮</span> <tr id=entity-Ecaron><td> <code>Ecaron;</code> <td> U+0011A <td> <span class=glyph>Ě</span> <tr id=entity-ecaron><td> <code>ecaron;</code> <td> U+0011B <td> <span class=glyph>ě</span> <tr id=entity-ecir><td> <code>ecir;</code> <td> U+02256 <td> <span class=glyph>≖</span> <tr id=entity-Ecirc><td> <code>Ecirc;</code> <td> U+000CA <td> <span class=glyph>Ê</span> <tr id=entity-Ecirc-legacy class=impl><td> <code>Ecirc</code> <td> U+000CA <td> <span>Ê</span> <tr id=entity-ecirc><td> <code>ecirc;</code> <td> U+000EA <td> <span class=glyph>ê</span> <tr id=entity-ecirc-legacy class=impl><td> <code>ecirc</code> <td> U+000EA <td> <span>ê</span> <tr id=entity-ecolon><td> <code>ecolon;</code> <td> U+02255 <td> <span class=glyph>≕</span> <tr id=entity-Ecy><td> <code>Ecy;</code> <td> U+0042D <td> <span class=glyph>Э</span> <tr id=entity-ecy><td> <code>ecy;</code> <td> U+0044D <td> <span class=glyph>э</span> <tr id=entity-eDDot><td> <code>eDDot;</code> <td> U+02A77 <td> <span class=glyph>⩷</span> <tr id=entity-Edot><td> <code>Edot;</code> <td> U+00116 <td> <span class=glyph>Ė</span> <tr id=entity-eDot><td> <code>eDot;</code> <td> U+02251 <td> <span class=glyph>≑</span> <tr id=entity-edot><td> <code>edot;</code> <td> U+00117 <td> <span class=glyph>ė</span> <tr id=entity-ee><td> <code>ee;</code> <td> U+02147 <td> <span class=glyph>ⅇ</span> <tr id=entity-efDot><td> <code>efDot;</code> <td> U+02252 <td> <span class=glyph>≒</span> <tr id=entity-Efr><td> <code>Efr;</code> <td> U+1D508 <td> <span class=glyph>𝔈</span> <tr id=entity-efr><td> <code>efr;</code> <td> U+1D522 <td> <span class=glyph>𝔢</span> <tr id=entity-eg><td> <code>eg;</code> <td> U+02A9A <td> <span class=glyph>⪚</span> <tr id=entity-Egrave><td> <code>Egrave;</code> <td> U+000C8 <td> <span class=glyph>È</span> <tr id=entity-Egrave-legacy class=impl><td> <code>Egrave</code> <td> U+000C8 <td> <span>È</span> <tr id=entity-egrave><td> <code>egrave;</code> <td> U+000E8 <td> <span class=glyph>è</span> <tr id=entity-egrave-legacy class=impl><td> <code>egrave</code> <td> U+000E8 <td> <span>è</span> <tr id=entity-egs><td> <code>egs;</code> <td> U+02A96 <td> <span class=glyph>⪖</span> <tr id=entity-egsdot><td> <code>egsdot;</code> <td> U+02A98 <td> <span class=glyph>⪘</span> <tr id=entity-el><td> <code>el;</code> <td> U+02A99 <td> <span class=glyph>⪙</span> <tr id=entity-Element><td> <code>Element;</code> <td> U+02208 <td> <span class=glyph>∈</span> <tr id=entity-elinters><td> <code>elinters;</code> <td> U+023E7 <td> <span class=glyph>⏧</span> <tr id=entity-ell><td> <code>ell;</code> <td> U+02113 <td> <span class=glyph>ℓ</span> <tr id=entity-els><td> <code>els;</code> <td> U+02A95 <td> <span class=glyph>⪕</span> <tr id=entity-elsdot><td> <code>elsdot;</code> <td> U+02A97 <td> <span class=glyph>⪗</span> <tr id=entity-Emacr><td> <code>Emacr;</code> <td> U+00112 <td> <span class=glyph>Ē</span> <tr id=entity-emacr><td> <code>emacr;</code> <td> U+00113 <td> <span class=glyph>ē</span> <tr id=entity-empty><td> <code>empty;</code> <td> U+02205 <td> <span class=glyph>∅</span> <tr id=entity-emptyset><td> <code>emptyset;</code> <td> U+02205 <td> <span class=glyph>∅</span> <tr id=entity-EmptySmallSquare><td> <code>EmptySmallSquare;</code> <td> U+025FB <td> <span class=glyph>◻</span> <tr id=entity-emptyv><td> <code>emptyv;</code> <td> U+02205 <td> <span class=glyph>∅</span> <tr id=entity-EmptyVerySmallSquare><td> <code>EmptyVerySmallSquare;</code> <td> U+025AB <td> <span class=glyph>▫</span> <tr id=entity-emsp><td> <code>emsp;</code> <td> U+02003 <td> <span class=glyph> </span> <tr id=entity-emsp13><td> <code>emsp13;</code> <td> U+02004 <td> <span class=glyph> </span> <tr id=entity-emsp14><td> <code>emsp14;</code> <td> U+02005 <td> <span class=glyph> </span> <tr id=entity-ENG><td> <code>ENG;</code> <td> U+0014A <td> <span class=glyph>Ŋ</span> <tr id=entity-eng><td> <code>eng;</code> <td> U+0014B <td> <span class=glyph>ŋ</span> <tr id=entity-ensp><td> <code>ensp;</code> <td> U+02002 <td> <span class=glyph> </span> <tr id=entity-Eogon><td> <code>Eogon;</code> <td> U+00118 <td> <span class=glyph>Ę</span> <tr id=entity-eogon><td> <code>eogon;</code> <td> U+00119 <td> <span class=glyph>ę</span> <tr id=entity-Eopf><td> <code>Eopf;</code> <td> U+1D53C <td> <span class=glyph>𝔼</span> <tr id=entity-eopf><td> <code>eopf;</code> <td> U+1D556 <td> <span class=glyph>𝕖</span> <tr id=entity-epar><td> <code>epar;</code> <td> U+022D5 <td> <span class=glyph>⋕</span> <tr id=entity-eparsl><td> <code>eparsl;</code> <td> U+029E3 <td> <span class=glyph>⧣</span> <tr id=entity-eplus><td> <code>eplus;</code> <td> U+02A71 <td> <span class=glyph>⩱</span> <tr id=entity-epsi><td> <code>epsi;</code> <td> U+003B5 <td> <span class=glyph>ε</span> <tr id=entity-Epsilon><td> <code>Epsilon;</code> <td> U+00395 <td> <span class=glyph>Ε</span> <tr id=entity-epsilon><td> <code>epsilon;</code> <td> U+003B5 <td> <span class=glyph>ε</span> <tr id=entity-epsiv><td> <code>epsiv;</code> <td> U+003F5 <td> <span class=glyph>ϵ</span> <tr id=entity-eqcirc><td> <code>eqcirc;</code> <td> U+02256 <td> <span class=glyph>≖</span> <tr id=entity-eqcolon><td> <code>eqcolon;</code> <td> U+02255 <td> <span class=glyph>≕</span> <tr id=entity-eqsim><td> <code>eqsim;</code> <td> U+02242 <td> <span class=glyph>≂</span> <tr id=entity-eqslantgtr><td> <code>eqslantgtr;</code> <td> U+02A96 <td> <span class=glyph>⪖</span> <tr id=entity-eqslantless><td> <code>eqslantless;</code> <td> U+02A95 <td> <span class=glyph>⪕</span> <tr id=entity-Equal><td> <code>Equal;</code> <td> U+02A75 <td> <span class=glyph>⩵</span> <tr id=entity-equals><td> <code>equals;</code> <td> U+0003D <td> <span class=glyph>=</span> <tr id=entity-EqualTilde><td> <code>EqualTilde;</code> <td> U+02242 <td> <span class=glyph>≂</span> <tr id=entity-equest><td> <code>equest;</code> <td> U+0225F <td> <span class=glyph>≟</span> <tr id=entity-Equilibrium><td> <code>Equilibrium;</code> <td> U+021CC <td> <span class=glyph>⇌</span> <tr id=entity-equiv><td> <code>equiv;</code> <td> U+02261 <td> <span class=glyph>≡</span> <tr id=entity-equivDD><td> <code>equivDD;</code> <td> U+02A78 <td> <span class=glyph>⩸</span> <tr id=entity-eqvparsl><td> <code>eqvparsl;</code> <td> U+029E5 <td> <span class=glyph>⧥</span> <tr id=entity-erarr><td> <code>erarr;</code> <td> U+02971 <td> <span class=glyph>⥱</span> <tr id=entity-erDot><td> <code>erDot;</code> <td> U+02253 <td> <span class=glyph>≓</span> <tr id=entity-Escr><td> <code>Escr;</code> <td> U+02130 <td> <span class=glyph>ℰ</span> <tr id=entity-escr><td> <code>escr;</code> <td> U+0212F <td> <span class=glyph>ℯ</span> <tr id=entity-esdot><td> <code>esdot;</code> <td> U+02250 <td> <span class=glyph>≐</span> <tr id=entity-Esim><td> <code>Esim;</code> <td> U+02A73 <td> <span class=glyph>⩳</span> <tr id=entity-esim><td> <code>esim;</code> <td> U+02242 <td> <span class=glyph>≂</span> <tr id=entity-Eta><td> <code>Eta;</code> <td> U+00397 <td> <span class=glyph>Η</span> <tr id=entity-eta><td> <code>eta;</code> <td> U+003B7 <td> <span class=glyph>η</span> <tr id=entity-ETH><td> <code>ETH;</code> <td> U+000D0 <td> <span class=glyph>Ð</span> <tr id=entity-ETH-legacy class=impl><td> <code>ETH</code> <td> U+000D0 <td> <span>Ð</span> <tr id=entity-eth><td> <code>eth;</code> <td> U+000F0 <td> <span class=glyph>ð</span> <tr id=entity-eth-legacy class=impl><td> <code>eth</code> <td> U+000F0 <td> <span>ð</span> <tr id=entity-Euml><td> <code>Euml;</code> <td> U+000CB <td> <span class=glyph>Ë</span> <tr id=entity-Euml-legacy class=impl><td> <code>Euml</code> <td> U+000CB <td> <span>Ë</span> <tr id=entity-euml><td> <code>euml;</code> <td> U+000EB <td> <span class=glyph>ë</span> <tr id=entity-euml-legacy class=impl><td> <code>euml</code> <td> U+000EB <td> <span>ë</span> <tr id=entity-euro><td> <code>euro;</code> <td> U+020AC <td> <span class=glyph>€</span> <tr id=entity-excl><td> <code>excl;</code> <td> U+00021 <td> <span class=glyph>!</span> <tr id=entity-exist><td> <code>exist;</code> <td> U+02203 <td> <span class=glyph>∃</span> <tr id=entity-Exists><td> <code>Exists;</code> <td> U+02203 <td> <span class=glyph>∃</span> <tr id=entity-expectation><td> <code>expectation;</code> <td> U+02130 <td> <span class=glyph>ℰ</span> <tr id=entity-ExponentialE><td> <code>ExponentialE;</code> <td> U+02147 <td> <span class=glyph>ⅇ</span> <tr id=entity-exponentiale><td> <code>exponentiale;</code> <td> U+02147 <td> <span class=glyph>ⅇ</span> <tr id=entity-fallingdotseq><td> <code>fallingdotseq;</code> <td> U+02252 <td> <span class=glyph>≒</span> <tr id=entity-Fcy><td> <code>Fcy;</code> <td> U+00424 <td> <span class=glyph>Ф</span> <tr id=entity-fcy><td> <code>fcy;</code> <td> U+00444 <td> <span class=glyph>ф</span> <tr id=entity-female><td> <code>female;</code> <td> U+02640 <td> <span class=glyph>♀</span> <tr id=entity-ffilig><td> <code>ffilig;</code> <td> U+0FB03 <td> <span class=glyph>ffi</span> <tr id=entity-fflig><td> <code>fflig;</code> <td> U+0FB00 <td> <span class=glyph>ff</span> <tr id=entity-ffllig><td> <code>ffllig;</code> <td> U+0FB04 <td> <span class=glyph>ffl</span> <tr id=entity-Ffr><td> <code>Ffr;</code> <td> U+1D509 <td> <span class=glyph>𝔉</span> <tr id=entity-ffr><td> <code>ffr;</code> <td> U+1D523 <td> <span class=glyph>𝔣</span> <tr id=entity-filig><td> <code>filig;</code> <td> U+0FB01 <td> <span class=glyph>fi</span> <tr id=entity-FilledSmallSquare><td> <code>FilledSmallSquare;</code> <td> U+025FC <td> <span class=glyph>◼</span> <tr id=entity-FilledVerySmallSquare><td> <code>FilledVerySmallSquare;</code> <td> U+025AA <td> <span class=glyph>▪</span> <tr id=entity-fjlig><td> <code>fjlig;</code> <td> U+00066 U+0006A <td> <span class="glyph compound">fj</span> <tr id=entity-flat><td> <code>flat;</code> <td> U+0266D <td> <span class=glyph>♭</span> <tr id=entity-fllig><td> <code>fllig;</code> <td> U+0FB02 <td> <span class=glyph>fl</span> <tr id=entity-fltns><td> <code>fltns;</code> <td> U+025B1 <td> <span class=glyph>▱</span> <tr id=entity-fnof><td> <code>fnof;</code> <td> U+00192 <td> <span class=glyph>ƒ</span> <tr id=entity-Fopf><td> <code>Fopf;</code> <td> U+1D53D <td> <span class=glyph>𝔽</span> <tr id=entity-fopf><td> <code>fopf;</code> <td> U+1D557 <td> <span class=glyph>𝕗</span> <tr id=entity-ForAll><td> <code>ForAll;</code> <td> U+02200 <td> <span class=glyph>∀</span> <tr id=entity-forall><td> <code>forall;</code> <td> U+02200 <td> <span class=glyph>∀</span> <tr id=entity-fork><td> <code>fork;</code> <td> U+022D4 <td> <span class=glyph>⋔</span> <tr id=entity-forkv><td> <code>forkv;</code> <td> U+02AD9 <td> <span class=glyph>⫙</span> <tr id=entity-Fouriertrf><td> <code>Fouriertrf;</code> <td> U+02131 <td> <span class=glyph>ℱ</span> <tr id=entity-fpartint><td> <code>fpartint;</code> <td> U+02A0D <td> <span class=glyph>⨍</span> <tr id=entity-frac12><td> <code>frac12;</code> <td> U+000BD <td> <span class=glyph>½</span> <tr id=entity-frac12-legacy class=impl><td> <code>frac12</code> <td> U+000BD <td> <span>½</span> <tr id=entity-frac13><td> <code>frac13;</code> <td> U+02153 <td> <span class=glyph>⅓</span> <tr id=entity-frac14><td> <code>frac14;</code> <td> U+000BC <td> <span class=glyph>¼</span> <tr id=entity-frac14-legacy class=impl><td> <code>frac14</code> <td> U+000BC <td> <span>¼</span> <tr id=entity-frac15><td> <code>frac15;</code> <td> U+02155 <td> <span class=glyph>⅕</span> <tr id=entity-frac16><td> <code>frac16;</code> <td> U+02159 <td> <span class=glyph>⅙</span> <tr id=entity-frac18><td> <code>frac18;</code> <td> U+0215B <td> <span class=glyph>⅛</span> <tr id=entity-frac23><td> <code>frac23;</code> <td> U+02154 <td> <span class=glyph>⅔</span> <tr id=entity-frac25><td> <code>frac25;</code> <td> U+02156 <td> <span class=glyph>⅖</span> <tr id=entity-frac34><td> <code>frac34;</code> <td> U+000BE <td> <span class=glyph>¾</span> <tr id=entity-frac34-legacy class=impl><td> <code>frac34</code> <td> U+000BE <td> <span>¾</span> <tr id=entity-frac35><td> <code>frac35;</code> <td> U+02157 <td> <span class=glyph>⅗</span> <tr id=entity-frac38><td> <code>frac38;</code> <td> U+0215C <td> <span class=glyph>⅜</span> <tr id=entity-frac45><td> <code>frac45;</code> <td> U+02158 <td> <span class=glyph>⅘</span> <tr id=entity-frac56><td> <code>frac56;</code> <td> U+0215A <td> <span class=glyph>⅚</span> <tr id=entity-frac58><td> <code>frac58;</code> <td> U+0215D <td> <span class=glyph>⅝</span> <tr id=entity-frac78><td> <code>frac78;</code> <td> U+0215E <td> <span class=glyph>⅞</span> <tr id=entity-frasl><td> <code>frasl;</code> <td> U+02044 <td> <span class=glyph>⁄</span> <tr id=entity-frown><td> <code>frown;</code> <td> U+02322 <td> <span class=glyph>⌢</span> <tr id=entity-Fscr><td> <code>Fscr;</code> <td> U+02131 <td> <span class=glyph>ℱ</span> <tr id=entity-fscr><td> <code>fscr;</code> <td> U+1D4BB <td> <span class=glyph>𝒻</span> <tr id=entity-gacute><td> <code>gacute;</code> <td> U+001F5 <td> <span class=glyph>ǵ</span> <tr id=entity-Gamma><td> <code>Gamma;</code> <td> U+00393 <td> <span class=glyph>Γ</span> <tr id=entity-gamma><td> <code>gamma;</code> <td> U+003B3 <td> <span class=glyph>γ</span> <tr id=entity-Gammad><td> <code>Gammad;</code> <td> U+003DC <td> <span class=glyph>Ϝ</span> <tr id=entity-gammad><td> <code>gammad;</code> <td> U+003DD <td> <span class=glyph>ϝ</span> <tr id=entity-gap><td> <code>gap;</code> <td> U+02A86 <td> <span class=glyph>⪆</span> <tr id=entity-Gbreve><td> <code>Gbreve;</code> <td> U+0011E <td> <span class=glyph>Ğ</span> <tr id=entity-gbreve><td> <code>gbreve;</code> <td> U+0011F <td> <span class=glyph>ğ</span> <tr id=entity-Gcedil><td> <code>Gcedil;</code> <td> U+00122 <td> <span class=glyph>Ģ</span> <tr id=entity-Gcirc><td> <code>Gcirc;</code> <td> U+0011C <td> <span class=glyph>Ĝ</span> <tr id=entity-gcirc><td> <code>gcirc;</code> <td> U+0011D <td> <span class=glyph>ĝ</span> <tr id=entity-Gcy><td> <code>Gcy;</code> <td> U+00413 <td> <span class=glyph>Г</span> <tr id=entity-gcy><td> <code>gcy;</code> <td> U+00433 <td> <span class=glyph>г</span> <tr id=entity-Gdot><td> <code>Gdot;</code> <td> U+00120 <td> <span class=glyph>Ġ</span> <tr id=entity-gdot><td> <code>gdot;</code> <td> U+00121 <td> <span class=glyph>ġ</span> <tr id=entity-gE><td> <code>gE;</code> <td> U+02267 <td> <span class=glyph>≧</span> <tr id=entity-ge><td> <code>ge;</code> <td> U+02265 <td> <span class=glyph>≥</span> <tr id=entity-gEl><td> <code>gEl;</code> <td> U+02A8C <td> <span class=glyph>⪌</span> <tr id=entity-gel><td> <code>gel;</code> <td> U+022DB <td> <span class=glyph>⋛</span> <tr id=entity-geq><td> <code>geq;</code> <td> U+02265 <td> <span class=glyph>≥</span> <tr id=entity-geqq><td> <code>geqq;</code> <td> U+02267 <td> <span class=glyph>≧</span> <tr id=entity-geqslant><td> <code>geqslant;</code> <td> U+02A7E <td> <span class=glyph>⩾</span> <tr id=entity-ges><td> <code>ges;</code> <td> U+02A7E <td> <span class=glyph>⩾</span> <tr id=entity-gescc><td> <code>gescc;</code> <td> U+02AA9 <td> <span class=glyph>⪩</span> <tr id=entity-gesdot><td> <code>gesdot;</code> <td> U+02A80 <td> <span class=glyph>⪀</span> <tr id=entity-gesdoto><td> <code>gesdoto;</code> <td> U+02A82 <td> <span class=glyph>⪂</span> <tr id=entity-gesdotol><td> <code>gesdotol;</code> <td> U+02A84 <td> <span class=glyph>⪄</span> <tr id=entity-gesl><td> <code>gesl;</code> <td> U+022DB U+0FE00 <td> <span class="glyph compound">⋛︀</span> <tr id=entity-gesles><td> <code>gesles;</code> <td> U+02A94 <td> <span class=glyph>⪔</span> <tr id=entity-Gfr><td> <code>Gfr;</code> <td> U+1D50A <td> <span class=glyph>𝔊</span> <tr id=entity-gfr><td> <code>gfr;</code> <td> U+1D524 <td> <span class=glyph>𝔤</span> <tr id=entity-Gg><td> <code>Gg;</code> <td> U+022D9 <td> <span class=glyph>⋙</span> <tr id=entity-gg><td> <code>gg;</code> <td> U+0226B <td> <span class=glyph>≫</span> <tr id=entity-ggg><td> <code>ggg;</code> <td> U+022D9 <td> <span class=glyph>⋙</span> <tr id=entity-gimel><td> <code>gimel;</code> <td> U+02137 <td> <span class=glyph>ℷ</span> <tr id=entity-GJcy><td> <code>GJcy;</code> <td> U+00403 <td> <span class=glyph>Ѓ</span> <tr id=entity-gjcy><td> <code>gjcy;</code> <td> U+00453 <td> <span class=glyph>ѓ</span> <tr id=entity-gl><td> <code>gl;</code> <td> U+02277 <td> <span class=glyph>≷</span> <tr id=entity-gla><td> <code>gla;</code> <td> U+02AA5 <td> <span class=glyph>⪥</span> <tr id=entity-glE><td> <code>glE;</code> <td> U+02A92 <td> <span class=glyph>⪒</span> <tr id=entity-glj><td> <code>glj;</code> <td> U+02AA4 <td> <span class=glyph>⪤</span> <tr id=entity-gnap><td> <code>gnap;</code> <td> U+02A8A <td> <span class=glyph>⪊</span> <tr id=entity-gnapprox><td> <code>gnapprox;</code> <td> U+02A8A <td> <span class=glyph>⪊</span> <tr id=entity-gnE><td> <code>gnE;</code> <td> U+02269 <td> <span class=glyph>≩</span> <tr id=entity-gne><td> <code>gne;</code> <td> U+02A88 <td> <span class=glyph>⪈</span> <tr id=entity-gneq><td> <code>gneq;</code> <td> U+02A88 <td> <span class=glyph>⪈</span> <tr id=entity-gneqq><td> <code>gneqq;</code> <td> U+02269 <td> <span class=glyph>≩</span> <tr id=entity-gnsim><td> <code>gnsim;</code> <td> U+022E7 <td> <span class=glyph>⋧</span> <tr id=entity-Gopf><td> <code>Gopf;</code> <td> U+1D53E <td> <span class=glyph>𝔾</span> <tr id=entity-gopf><td> <code>gopf;</code> <td> U+1D558 <td> <span class=glyph>𝕘</span> <tr id=entity-grave><td> <code>grave;</code> <td> U+00060 <td> <span class=glyph>`</span> <tr id=entity-GreaterEqual><td> <code>GreaterEqual;</code> <td> U+02265 <td> <span class=glyph>≥</span> <tr id=entity-GreaterEqualLess><td> <code>GreaterEqualLess;</code> <td> U+022DB <td> <span class=glyph>⋛</span> <tr id=entity-GreaterFullEqual><td> <code>GreaterFullEqual;</code> <td> U+02267 <td> <span class=glyph>≧</span> <tr id=entity-GreaterGreater><td> <code>GreaterGreater;</code> <td> U+02AA2 <td> <span class=glyph>⪢</span> <tr id=entity-GreaterLess><td> <code>GreaterLess;</code> <td> U+02277 <td> <span class=glyph>≷</span> <tr id=entity-GreaterSlantEqual><td> <code>GreaterSlantEqual;</code> <td> U+02A7E <td> <span class=glyph>⩾</span> <tr id=entity-GreaterTilde><td> <code>GreaterTilde;</code> <td> U+02273 <td> <span class=glyph>≳</span> <tr id=entity-Gscr><td> <code>Gscr;</code> <td> U+1D4A2 <td> <span class=glyph>𝒢</span> <tr id=entity-gscr><td> <code>gscr;</code> <td> U+0210A <td> <span class=glyph>ℊ</span> <tr id=entity-gsim><td> <code>gsim;</code> <td> U+02273 <td> <span class=glyph>≳</span> <tr id=entity-gsime><td> <code>gsime;</code> <td> U+02A8E <td> <span class=glyph>⪎</span> <tr id=entity-gsiml><td> <code>gsiml;</code> <td> U+02A90 <td> <span class=glyph>⪐</span> <tr id=entity-GT><td> <code>GT;</code> <td> U+0003E <td> <span class=glyph>></span> <tr id=entity-GT-legacy class=impl><td> <code>GT</code> <td> U+0003E <td> <span>></span> <tr id=entity-Gt><td> <code>Gt;</code> <td> U+0226B <td> <span class=glyph>≫</span> <tr id=entity-gt><td> <code>gt;</code> <td> U+0003E <td> <span class=glyph>></span> <tr id=entity-gt-legacy class=impl><td> <code>gt</code> <td> U+0003E <td> <span>></span> <tr id=entity-gtcc><td> <code>gtcc;</code> <td> U+02AA7 <td> <span class=glyph>⪧</span> <tr id=entity-gtcir><td> <code>gtcir;</code> <td> U+02A7A <td> <span class=glyph>⩺</span> <tr id=entity-gtdot><td> <code>gtdot;</code> <td> U+022D7 <td> <span class=glyph>⋗</span> <tr id=entity-gtlPar><td> <code>gtlPar;</code> <td> U+02995 <td> <span class=glyph>⦕</span> <tr id=entity-gtquest><td> <code>gtquest;</code> <td> U+02A7C <td> <span class=glyph>⩼</span> <tr id=entity-gtrapprox><td> <code>gtrapprox;</code> <td> U+02A86 <td> <span class=glyph>⪆</span> <tr id=entity-gtrarr><td> <code>gtrarr;</code> <td> U+02978 <td> <span class=glyph>⥸</span> <tr id=entity-gtrdot><td> <code>gtrdot;</code> <td> U+022D7 <td> <span class=glyph>⋗</span> <tr id=entity-gtreqless><td> <code>gtreqless;</code> <td> U+022DB <td> <span class=glyph>⋛</span> <tr id=entity-gtreqqless><td> <code>gtreqqless;</code> <td> U+02A8C <td> <span class=glyph>⪌</span> <tr id=entity-gtrless><td> <code>gtrless;</code> <td> U+02277 <td> <span class=glyph>≷</span> <tr id=entity-gtrsim><td> <code>gtrsim;</code> <td> U+02273 <td> <span class=glyph>≳</span> <tr id=entity-gvertneqq><td> <code>gvertneqq;</code> <td> U+02269 U+0FE00 <td> <span class="glyph compound">≩︀</span> <tr id=entity-gvnE><td> <code>gvnE;</code> <td> U+02269 U+0FE00 <td> <span class="glyph compound">≩︀</span> <tr id=entity-Hacek><td> <code>Hacek;</code> <td> U+002C7 <td> <span class=glyph>ˇ</span> <tr id=entity-hairsp><td> <code>hairsp;</code> <td> U+0200A <td> <span class=glyph> </span> <tr id=entity-half><td> <code>half;</code> <td> U+000BD <td> <span class=glyph>½</span> <tr id=entity-hamilt><td> <code>hamilt;</code> <td> U+0210B <td> <span class=glyph>ℋ</span> <tr id=entity-HARDcy><td> <code>HARDcy;</code> <td> U+0042A <td> <span class=glyph>Ъ</span> <tr id=entity-hardcy><td> <code>hardcy;</code> <td> U+0044A <td> <span class=glyph>ъ</span> <tr id=entity-hArr><td> <code>hArr;</code> <td> U+021D4 <td> <span class=glyph>⇔</span> <tr id=entity-harr><td> <code>harr;</code> <td> U+02194 <td> <span class=glyph>↔</span> <tr id=entity-harrcir><td> <code>harrcir;</code> <td> U+02948 <td> <span class=glyph>⥈</span> <tr id=entity-harrw><td> <code>harrw;</code> <td> U+021AD <td> <span class=glyph>↭</span> <tr id=entity-Hat><td> <code>Hat;</code> <td> U+0005E <td> <span class=glyph>^</span> <tr id=entity-hbar><td> <code>hbar;</code> <td> U+0210F <td> <span class=glyph>ℏ</span> <tr id=entity-Hcirc><td> <code>Hcirc;</code> <td> U+00124 <td> <span class=glyph>Ĥ</span> <tr id=entity-hcirc><td> <code>hcirc;</code> <td> U+00125 <td> <span class=glyph>ĥ</span> <tr id=entity-hearts><td> <code>hearts;</code> <td> U+02665 <td> <span class=glyph>♥</span> <tr id=entity-heartsuit><td> <code>heartsuit;</code> <td> U+02665 <td> <span class=glyph>♥</span> <tr id=entity-hellip><td> <code>hellip;</code> <td> U+02026 <td> <span class=glyph>…</span> <tr id=entity-hercon><td> <code>hercon;</code> <td> U+022B9 <td> <span class=glyph>⊹</span> <tr id=entity-Hfr><td> <code>Hfr;</code> <td> U+0210C <td> <span class=glyph>ℌ</span> <tr id=entity-hfr><td> <code>hfr;</code> <td> U+1D525 <td> <span class=glyph>𝔥</span> <tr id=entity-HilbertSpace><td> <code>HilbertSpace;</code> <td> U+0210B <td> <span class=glyph>ℋ</span> <tr id=entity-hksearow><td> <code>hksearow;</code> <td> U+02925 <td> <span class=glyph>⤥</span> <tr id=entity-hkswarow><td> <code>hkswarow;</code> <td> U+02926 <td> <span class=glyph>⤦</span> <tr id=entity-hoarr><td> <code>hoarr;</code> <td> U+021FF <td> <span class=glyph>⇿</span> <tr id=entity-homtht><td> <code>homtht;</code> <td> U+0223B <td> <span class=glyph>∻</span> <tr id=entity-hookleftarrow><td> <code>hookleftarrow;</code> <td> U+021A9 <td> <span class=glyph>↩</span> <tr id=entity-hookrightarrow><td> <code>hookrightarrow;</code> <td> U+021AA <td> <span class=glyph>↪</span> <tr id=entity-Hopf><td> <code>Hopf;</code> <td> U+0210D <td> <span class=glyph>ℍ</span> <tr id=entity-hopf><td> <code>hopf;</code> <td> U+1D559 <td> <span class=glyph>𝕙</span> <tr id=entity-horbar><td> <code>horbar;</code> <td> U+02015 <td> <span class=glyph>―</span> <tr id=entity-HorizontalLine><td> <code>HorizontalLine;</code> <td> U+02500 <td> <span class=glyph>─</span> <tr id=entity-Hscr><td> <code>Hscr;</code> <td> U+0210B <td> <span class=glyph>ℋ</span> <tr id=entity-hscr><td> <code>hscr;</code> <td> U+1D4BD <td> <span class=glyph>𝒽</span> <tr id=entity-hslash><td> <code>hslash;</code> <td> U+0210F <td> <span class=glyph>ℏ</span> <tr id=entity-Hstrok><td> <code>Hstrok;</code> <td> U+00126 <td> <span class=glyph>Ħ</span> <tr id=entity-hstrok><td> <code>hstrok;</code> <td> U+00127 <td> <span class=glyph>ħ</span> <tr id=entity-HumpDownHump><td> <code>HumpDownHump;</code> <td> U+0224E <td> <span class=glyph>≎</span> <tr id=entity-HumpEqual><td> <code>HumpEqual;</code> <td> U+0224F <td> <span class=glyph>≏</span> <tr id=entity-hybull><td> <code>hybull;</code> <td> U+02043 <td> <span class=glyph>⁃</span> <tr id=entity-hyphen><td> <code>hyphen;</code> <td> U+02010 <td> <span class=glyph>‐</span> <tr id=entity-Iacute><td> <code>Iacute;</code> <td> U+000CD <td> <span class=glyph>Í</span> <tr id=entity-Iacute-legacy class=impl><td> <code>Iacute</code> <td> U+000CD <td> <span>Í</span> <tr id=entity-iacute><td> <code>iacute;</code> <td> U+000ED <td> <span class=glyph>í</span> <tr id=entity-iacute-legacy class=impl><td> <code>iacute</code> <td> U+000ED <td> <span>í</span> <tr id=entity-ic><td> <code>ic;</code> <td> U+02063 <td> <span class=glyph>⁣</span> <tr id=entity-Icirc><td> <code>Icirc;</code> <td> U+000CE <td> <span class=glyph>Î</span> <tr id=entity-Icirc-legacy class=impl><td> <code>Icirc</code> <td> U+000CE <td> <span>Î</span> <tr id=entity-icirc><td> <code>icirc;</code> <td> U+000EE <td> <span class=glyph>î</span> <tr id=entity-icirc-legacy class=impl><td> <code>icirc</code> <td> U+000EE <td> <span>î</span> <tr id=entity-Icy><td> <code>Icy;</code> <td> U+00418 <td> <span class=glyph>И</span> <tr id=entity-icy><td> <code>icy;</code> <td> U+00438 <td> <span class=glyph>и</span> <tr id=entity-Idot><td> <code>Idot;</code> <td> U+00130 <td> <span class=glyph>İ</span> <tr id=entity-IEcy><td> <code>IEcy;</code> <td> U+00415 <td> <span class=glyph>Е</span> <tr id=entity-iecy><td> <code>iecy;</code> <td> U+00435 <td> <span class=glyph>е</span> <tr id=entity-iexcl><td> <code>iexcl;</code> <td> U+000A1 <td> <span class=glyph>¡</span> <tr id=entity-iexcl-legacy class=impl><td> <code>iexcl</code> <td> U+000A1 <td> <span>¡</span> <tr id=entity-iff><td> <code>iff;</code> <td> U+021D4 <td> <span class=glyph>⇔</span> <tr id=entity-Ifr><td> <code>Ifr;</code> <td> U+02111 <td> <span class=glyph>ℑ</span> <tr id=entity-ifr><td> <code>ifr;</code> <td> U+1D526 <td> <span class=glyph>𝔦</span> <tr id=entity-Igrave><td> <code>Igrave;</code> <td> U+000CC <td> <span class=glyph>Ì</span> <tr id=entity-Igrave-legacy class=impl><td> <code>Igrave</code> <td> U+000CC <td> <span>Ì</span> <tr id=entity-igrave><td> <code>igrave;</code> <td> U+000EC <td> <span class=glyph>ì</span> <tr id=entity-igrave-legacy class=impl><td> <code>igrave</code> <td> U+000EC <td> <span>ì</span> <tr id=entity-ii><td> <code>ii;</code> <td> U+02148 <td> <span class=glyph>ⅈ</span> <tr id=entity-iiiint><td> <code>iiiint;</code> <td> U+02A0C <td> <span class=glyph>⨌</span> <tr id=entity-iiint><td> <code>iiint;</code> <td> U+0222D <td> <span class=glyph>∭</span> <tr id=entity-iinfin><td> <code>iinfin;</code> <td> U+029DC <td> <span class=glyph>⧜</span> <tr id=entity-iiota><td> <code>iiota;</code> <td> U+02129 <td> <span class=glyph>℩</span> <tr id=entity-IJlig><td> <code>IJlig;</code> <td> U+00132 <td> <span class=glyph>IJ</span> <tr id=entity-ijlig><td> <code>ijlig;</code> <td> U+00133 <td> <span class=glyph>ij</span> <tr id=entity-Im><td> <code>Im;</code> <td> U+02111 <td> <span class=glyph>ℑ</span> <tr id=entity-Imacr><td> <code>Imacr;</code> <td> U+0012A <td> <span class=glyph>Ī</span> <tr id=entity-imacr><td> <code>imacr;</code> <td> U+0012B <td> <span class=glyph>ī</span> <tr id=entity-image><td> <code>image;</code> <td> U+02111 <td> <span class=glyph>ℑ</span> <tr id=entity-ImaginaryI><td> <code>ImaginaryI;</code> <td> U+02148 <td> <span class=glyph>ⅈ</span> <tr id=entity-imagline><td> <code>imagline;</code> <td> U+02110 <td> <span class=glyph>ℐ</span> <tr id=entity-imagpart><td> <code>imagpart;</code> <td> U+02111 <td> <span class=glyph>ℑ</span> <tr id=entity-imath><td> <code>imath;</code> <td> U+00131 <td> <span class=glyph>ı</span> <tr id=entity-imof><td> <code>imof;</code> <td> U+022B7 <td> <span class=glyph>⊷</span> <tr id=entity-imped><td> <code>imped;</code> <td> U+001B5 <td> <span class=glyph>Ƶ</span> <tr id=entity-Implies><td> <code>Implies;</code> <td> U+021D2 <td> <span class=glyph>⇒</span> <tr id=entity-in><td> <code>in;</code> <td> U+02208 <td> <span class=glyph>∈</span> <tr id=entity-incare><td> <code>incare;</code> <td> U+02105 <td> <span class=glyph>℅</span> <tr id=entity-infin><td> <code>infin;</code> <td> U+0221E <td> <span class=glyph>∞</span> <tr id=entity-infintie><td> <code>infintie;</code> <td> U+029DD <td> <span class=glyph>⧝</span> <tr id=entity-inodot><td> <code>inodot;</code> <td> U+00131 <td> <span class=glyph>ı</span> <tr id=entity-Int><td> <code>Int;</code> <td> U+0222C <td> <span class=glyph>∬</span> <tr id=entity-int><td> <code>int;</code> <td> U+0222B <td> <span class=glyph>∫</span> <tr id=entity-intcal><td> <code>intcal;</code> <td> U+022BA <td> <span class=glyph>⊺</span> <tr id=entity-integers><td> <code>integers;</code> <td> U+02124 <td> <span class=glyph>ℤ</span> <tr id=entity-Integral><td> <code>Integral;</code> <td> U+0222B <td> <span class=glyph>∫</span> <tr id=entity-intercal><td> <code>intercal;</code> <td> U+022BA <td> <span class=glyph>⊺</span> <tr id=entity-Intersection><td> <code>Intersection;</code> <td> U+022C2 <td> <span class=glyph>⋂</span> <tr id=entity-intlarhk><td> <code>intlarhk;</code> <td> U+02A17 <td> <span class=glyph>⨗</span> <tr id=entity-intprod><td> <code>intprod;</code> <td> U+02A3C <td> <span class=glyph>⨼</span> <tr id=entity-InvisibleComma><td> <code>InvisibleComma;</code> <td> U+02063 <td> <span class=glyph>⁣</span> <tr id=entity-InvisibleTimes><td> <code>InvisibleTimes;</code> <td> U+02062 <td> <span class=glyph>⁢</span> <tr id=entity-IOcy><td> <code>IOcy;</code> <td> U+00401 <td> <span class=glyph>Ё</span> <tr id=entity-iocy><td> <code>iocy;</code> <td> U+00451 <td> <span class=glyph>ё</span> <tr id=entity-Iogon><td> <code>Iogon;</code> <td> U+0012E <td> <span class=glyph>Į</span> <tr id=entity-iogon><td> <code>iogon;</code> <td> U+0012F <td> <span class=glyph>į</span> <tr id=entity-Iopf><td> <code>Iopf;</code> <td> U+1D540 <td> <span class=glyph>𝕀</span> <tr id=entity-iopf><td> <code>iopf;</code> <td> U+1D55A <td> <span class=glyph>𝕚</span> <tr id=entity-Iota><td> <code>Iota;</code> <td> U+00399 <td> <span class=glyph>Ι</span> <tr id=entity-iota><td> <code>iota;</code> <td> U+003B9 <td> <span class=glyph>ι</span> <tr id=entity-iprod><td> <code>iprod;</code> <td> U+02A3C <td> <span class=glyph>⨼</span> <tr id=entity-iquest><td> <code>iquest;</code> <td> U+000BF <td> <span class=glyph>¿</span> <tr id=entity-iquest-legacy class=impl><td> <code>iquest</code> <td> U+000BF <td> <span>¿</span> <tr id=entity-Iscr><td> <code>Iscr;</code> <td> U+02110 <td> <span class=glyph>ℐ</span> <tr id=entity-iscr><td> <code>iscr;</code> <td> U+1D4BE <td> <span class=glyph>𝒾</span> <tr id=entity-isin><td> <code>isin;</code> <td> U+02208 <td> <span class=glyph>∈</span> <tr id=entity-isindot><td> <code>isindot;</code> <td> U+022F5 <td> <span class=glyph>⋵</span> <tr id=entity-isinE><td> <code>isinE;</code> <td> U+022F9 <td> <span class=glyph>⋹</span> <tr id=entity-isins><td> <code>isins;</code> <td> U+022F4 <td> <span class=glyph>⋴</span> <tr id=entity-isinsv><td> <code>isinsv;</code> <td> U+022F3 <td> <span class=glyph>⋳</span> <tr id=entity-isinv><td> <code>isinv;</code> <td> U+02208 <td> <span class=glyph>∈</span> <tr id=entity-it><td> <code>it;</code> <td> U+02062 <td> <span class=glyph>⁢</span> <tr id=entity-Itilde><td> <code>Itilde;</code> <td> U+00128 <td> <span class=glyph>Ĩ</span> <tr id=entity-itilde><td> <code>itilde;</code> <td> U+00129 <td> <span class=glyph>ĩ</span> <tr id=entity-Iukcy><td> <code>Iukcy;</code> <td> U+00406 <td> <span class=glyph>І</span> <tr id=entity-iukcy><td> <code>iukcy;</code> <td> U+00456 <td> <span class=glyph>і</span> <tr id=entity-Iuml><td> <code>Iuml;</code> <td> U+000CF <td> <span class=glyph>Ï</span> <tr id=entity-Iuml-legacy class=impl><td> <code>Iuml</code> <td> U+000CF <td> <span>Ï</span> <tr id=entity-iuml><td> <code>iuml;</code> <td> U+000EF <td> <span class=glyph>ï</span> <tr id=entity-iuml-legacy class=impl><td> <code>iuml</code> <td> U+000EF <td> <span>ï</span> <tr id=entity-Jcirc><td> <code>Jcirc;</code> <td> U+00134 <td> <span class=glyph>Ĵ</span> <tr id=entity-jcirc><td> <code>jcirc;</code> <td> U+00135 <td> <span class=glyph>ĵ</span> <tr id=entity-Jcy><td> <code>Jcy;</code> <td> U+00419 <td> <span class=glyph>Й</span> <tr id=entity-jcy><td> <code>jcy;</code> <td> U+00439 <td> <span class=glyph>й</span> <tr id=entity-Jfr><td> <code>Jfr;</code> <td> U+1D50D <td> <span class=glyph>𝔍</span> <tr id=entity-jfr><td> <code>jfr;</code> <td> U+1D527 <td> <span class=glyph>𝔧</span> <tr id=entity-jmath><td> <code>jmath;</code> <td> U+00237 <td> <span class=glyph>ȷ</span> <tr id=entity-Jopf><td> <code>Jopf;</code> <td> U+1D541 <td> <span class=glyph>𝕁</span> <tr id=entity-jopf><td> <code>jopf;</code> <td> U+1D55B <td> <span class=glyph>𝕛</span> <tr id=entity-Jscr><td> <code>Jscr;</code> <td> U+1D4A5 <td> <span class=glyph>𝒥</span> <tr id=entity-jscr><td> <code>jscr;</code> <td> U+1D4BF <td> <span class=glyph>𝒿</span> <tr id=entity-Jsercy><td> <code>Jsercy;</code> <td> U+00408 <td> <span class=glyph>Ј</span> <tr id=entity-jsercy><td> <code>jsercy;</code> <td> U+00458 <td> <span class=glyph>ј</span> <tr id=entity-Jukcy><td> <code>Jukcy;</code> <td> U+00404 <td> <span class=glyph>Є</span> <tr id=entity-jukcy><td> <code>jukcy;</code> <td> U+00454 <td> <span class=glyph>є</span> <tr id=entity-Kappa><td> <code>Kappa;</code> <td> U+0039A <td> <span class=glyph>Κ</span> <tr id=entity-kappa><td> <code>kappa;</code> <td> U+003BA <td> <span class=glyph>κ</span> <tr id=entity-kappav><td> <code>kappav;</code> <td> U+003F0 <td> <span class=glyph>ϰ</span> <tr id=entity-Kcedil><td> <code>Kcedil;</code> <td> U+00136 <td> <span class=glyph>Ķ</span> <tr id=entity-kcedil><td> <code>kcedil;</code> <td> U+00137 <td> <span class=glyph>ķ</span> <tr id=entity-Kcy><td> <code>Kcy;</code> <td> U+0041A <td> <span class=glyph>К</span> <tr id=entity-kcy><td> <code>kcy;</code> <td> U+0043A <td> <span class=glyph>к</span> <tr id=entity-Kfr><td> <code>Kfr;</code> <td> U+1D50E <td> <span class=glyph>𝔎</span> <tr id=entity-kfr><td> <code>kfr;</code> <td> U+1D528 <td> <span class=glyph>𝔨</span> <tr id=entity-kgreen><td> <code>kgreen;</code> <td> U+00138 <td> <span class=glyph>ĸ</span> <tr id=entity-KHcy><td> <code>KHcy;</code> <td> U+00425 <td> <span class=glyph>Х</span> <tr id=entity-khcy><td> <code>khcy;</code> <td> U+00445 <td> <span class=glyph>х</span> <tr id=entity-KJcy><td> <code>KJcy;</code> <td> U+0040C <td> <span class=glyph>Ќ</span> <tr id=entity-kjcy><td> <code>kjcy;</code> <td> U+0045C <td> <span class=glyph>ќ</span> <tr id=entity-Kopf><td> <code>Kopf;</code> <td> U+1D542 <td> <span class=glyph>𝕂</span> <tr id=entity-kopf><td> <code>kopf;</code> <td> U+1D55C <td> <span class=glyph>𝕜</span> <tr id=entity-Kscr><td> <code>Kscr;</code> <td> U+1D4A6 <td> <span class=glyph>𝒦</span> <tr id=entity-kscr><td> <code>kscr;</code> <td> U+1D4C0 <td> <span class=glyph>𝓀</span> <tr id=entity-lAarr><td> <code>lAarr;</code> <td> U+021DA <td> <span class=glyph>⇚</span> <tr id=entity-Lacute><td> <code>Lacute;</code> <td> U+00139 <td> <span class=glyph>Ĺ</span> <tr id=entity-lacute><td> <code>lacute;</code> <td> U+0013A <td> <span class=glyph>ĺ</span> <tr id=entity-laemptyv><td> <code>laemptyv;</code> <td> U+029B4 <td> <span class=glyph>⦴</span> <tr id=entity-lagran><td> <code>lagran;</code> <td> U+02112 <td> <span class=glyph>ℒ</span> <tr id=entity-Lambda><td> <code>Lambda;</code> <td> U+0039B <td> <span class=glyph>Λ</span> <tr id=entity-lambda><td> <code>lambda;</code> <td> U+003BB <td> <span class=glyph>λ</span> <tr id=entity-Lang><td> <code>Lang;</code> <td> U+027EA <td> <span class=glyph>⟪</span> <tr id=entity-lang><td> <code>lang;</code> <td> U+027E8 <td> <span class=glyph>⟨</span> <tr id=entity-langd><td> <code>langd;</code> <td> U+02991 <td> <span class=glyph>⦑</span> <tr id=entity-langle><td> <code>langle;</code> <td> U+027E8 <td> <span class=glyph>⟨</span> <tr id=entity-lap><td> <code>lap;</code> <td> U+02A85 <td> <span class=glyph>⪅</span> <tr id=entity-Laplacetrf><td> <code>Laplacetrf;</code> <td> U+02112 <td> <span class=glyph>ℒ</span> <tr id=entity-laquo><td> <code>laquo;</code> <td> U+000AB <td> <span class=glyph>«</span> <tr id=entity-laquo-legacy class=impl><td> <code>laquo</code> <td> U+000AB <td> <span>«</span> <tr id=entity-Larr><td> <code>Larr;</code> <td> U+0219E <td> <span class=glyph>↞</span> <tr id=entity-lArr><td> <code>lArr;</code> <td> U+021D0 <td> <span class=glyph>⇐</span> <tr id=entity-larr><td> <code>larr;</code> <td> U+02190 <td> <span class=glyph>←</span> <tr id=entity-larrb><td> <code>larrb;</code> <td> U+021E4 <td> <span class=glyph>⇤</span> <tr id=entity-larrbfs><td> <code>larrbfs;</code> <td> U+0291F <td> <span class=glyph>⤟</span> <tr id=entity-larrfs><td> <code>larrfs;</code> <td> U+0291D <td> <span class=glyph>⤝</span> <tr id=entity-larrhk><td> <code>larrhk;</code> <td> U+021A9 <td> <span class=glyph>↩</span> <tr id=entity-larrlp><td> <code>larrlp;</code> <td> U+021AB <td> <span class=glyph>↫</span> <tr id=entity-larrpl><td> <code>larrpl;</code> <td> U+02939 <td> <span class=glyph>⤹</span> <tr id=entity-larrsim><td> <code>larrsim;</code> <td> U+02973 <td> <span class=glyph>⥳</span> <tr id=entity-larrtl><td> <code>larrtl;</code> <td> U+021A2 <td> <span class=glyph>↢</span> <tr id=entity-lat><td> <code>lat;</code> <td> U+02AAB <td> <span class=glyph>⪫</span> <tr id=entity-lAtail><td> <code>lAtail;</code> <td> U+0291B <td> <span class=glyph>⤛</span> <tr id=entity-latail><td> <code>latail;</code> <td> U+02919 <td> <span class=glyph>⤙</span> <tr id=entity-late><td> <code>late;</code> <td> U+02AAD <td> <span class=glyph>⪭</span> <tr id=entity-lates><td> <code>lates;</code> <td> U+02AAD U+0FE00 <td> <span class="glyph compound">⪭︀</span> <tr id=entity-lBarr><td> <code>lBarr;</code> <td> U+0290E <td> <span class=glyph>⤎</span> <tr id=entity-lbarr><td> <code>lbarr;</code> <td> U+0290C <td> <span class=glyph>⤌</span> <tr id=entity-lbbrk><td> <code>lbbrk;</code> <td> U+02772 <td> <span class=glyph>❲</span> <tr id=entity-lbrace><td> <code>lbrace;</code> <td> U+0007B <td> <span class=glyph>{</span> <tr id=entity-lbrack><td> <code>lbrack;</code> <td> U+0005B <td> <span class=glyph>[</span> <tr id=entity-lbrke><td> <code>lbrke;</code> <td> U+0298B <td> <span class=glyph>⦋</span> <tr id=entity-lbrksld><td> <code>lbrksld;</code> <td> U+0298F <td> <span class=glyph>⦏</span> <tr id=entity-lbrkslu><td> <code>lbrkslu;</code> <td> U+0298D <td> <span class=glyph>⦍</span> <tr id=entity-Lcaron><td> <code>Lcaron;</code> <td> U+0013D <td> <span class=glyph>Ľ</span> <tr id=entity-lcaron><td> <code>lcaron;</code> <td> U+0013E <td> <span class=glyph>ľ</span> <tr id=entity-Lcedil><td> <code>Lcedil;</code> <td> U+0013B <td> <span class=glyph>Ļ</span> <tr id=entity-lcedil><td> <code>lcedil;</code> <td> U+0013C <td> <span class=glyph>ļ</span> <tr id=entity-lceil><td> <code>lceil;</code> <td> U+02308 <td> <span class=glyph>⌈</span> <tr id=entity-lcub><td> <code>lcub;</code> <td> U+0007B <td> <span class=glyph>{</span> <tr id=entity-Lcy><td> <code>Lcy;</code> <td> U+0041B <td> <span class=glyph>Л</span> <tr id=entity-lcy><td> <code>lcy;</code> <td> U+0043B <td> <span class=glyph>л</span> <tr id=entity-ldca><td> <code>ldca;</code> <td> U+02936 <td> <span class=glyph>⤶</span> <tr id=entity-ldquo><td> <code>ldquo;</code> <td> U+0201C <td> <span class=glyph>“</span> <tr id=entity-ldquor><td> <code>ldquor;</code> <td> U+0201E <td> <span class=glyph>„</span> <tr id=entity-ldrdhar><td> <code>ldrdhar;</code> <td> U+02967 <td> <span class=glyph>⥧</span> <tr id=entity-ldrushar><td> <code>ldrushar;</code> <td> U+0294B <td> <span class=glyph>⥋</span> <tr id=entity-ldsh><td> <code>ldsh;</code> <td> U+021B2 <td> <span class=glyph>↲</span> <tr id=entity-lE><td> <code>lE;</code> <td> U+02266 <td> <span class=glyph>≦</span> <tr id=entity-le><td> <code>le;</code> <td> U+02264 <td> <span class=glyph>≤</span> <tr id=entity-LeftAngleBracket><td> <code>LeftAngleBracket;</code> <td> U+027E8 <td> <span class=glyph>⟨</span> <tr id=entity-LeftArrow><td> <code>LeftArrow;</code> <td> U+02190 <td> <span class=glyph>←</span> <tr id=entity-Leftarrow><td> <code>Leftarrow;</code> <td> U+021D0 <td> <span class=glyph>⇐</span> <tr id=entity-leftarrow><td> <code>leftarrow;</code> <td> U+02190 <td> <span class=glyph>←</span> <tr id=entity-LeftArrowBar><td> <code>LeftArrowBar;</code> <td> U+021E4 <td> <span class=glyph>⇤</span> <tr id=entity-LeftArrowRightArrow><td> <code>LeftArrowRightArrow;</code> <td> U+021C6 <td> <span class=glyph>⇆</span> <tr id=entity-leftarrowtail><td> <code>leftarrowtail;</code> <td> U+021A2 <td> <span class=glyph>↢</span> <tr id=entity-LeftCeiling><td> <code>LeftCeiling;</code> <td> U+02308 <td> <span class=glyph>⌈</span> <tr id=entity-LeftDoubleBracket><td> <code>LeftDoubleBracket;</code> <td> U+027E6 <td> <span class=glyph>⟦</span> <tr id=entity-LeftDownTeeVector><td> <code>LeftDownTeeVector;</code> <td> U+02961 <td> <span class=glyph>⥡</span> <tr id=entity-LeftDownVector><td> <code>LeftDownVector;</code> <td> U+021C3 <td> <span class=glyph>⇃</span> <tr id=entity-LeftDownVectorBar><td> <code>LeftDownVectorBar;</code> <td> U+02959 <td> <span class=glyph>⥙</span> <tr id=entity-LeftFloor><td> <code>LeftFloor;</code> <td> U+0230A <td> <span class=glyph>⌊</span> <tr id=entity-leftharpoondown><td> <code>leftharpoondown;</code> <td> U+021BD <td> <span class=glyph>↽</span> <tr id=entity-leftharpoonup><td> <code>leftharpoonup;</code> <td> U+021BC <td> <span class=glyph>↼</span> <tr id=entity-leftleftarrows><td> <code>leftleftarrows;</code> <td> U+021C7 <td> <span class=glyph>⇇</span> <tr id=entity-LeftRightArrow><td> <code>LeftRightArrow;</code> <td> U+02194 <td> <span class=glyph>↔</span> <tr id=entity-Leftrightarrow><td> <code>Leftrightarrow;</code> <td> U+021D4 <td> <span class=glyph>⇔</span> <tr id=entity-leftrightarrow><td> <code>leftrightarrow;</code> <td> U+02194 <td> <span class=glyph>↔</span> <tr id=entity-leftrightarrows><td> <code>leftrightarrows;</code> <td> U+021C6 <td> <span class=glyph>⇆</span> <tr id=entity-leftrightharpoons><td> <code>leftrightharpoons;</code> <td> U+021CB <td> <span class=glyph>⇋</span> <tr id=entity-leftrightsquigarrow><td> <code>leftrightsquigarrow;</code> <td> U+021AD <td> <span class=glyph>↭</span> <tr id=entity-LeftRightVector><td> <code>LeftRightVector;</code> <td> U+0294E <td> <span class=glyph>⥎</span> <tr id=entity-LeftTee><td> <code>LeftTee;</code> <td> U+022A3 <td> <span class=glyph>⊣</span> <tr id=entity-LeftTeeArrow><td> <code>LeftTeeArrow;</code> <td> U+021A4 <td> <span class=glyph>↤</span> <tr id=entity-LeftTeeVector><td> <code>LeftTeeVector;</code> <td> U+0295A <td> <span class=glyph>⥚</span> <tr id=entity-leftthreetimes><td> <code>leftthreetimes;</code> <td> U+022CB <td> <span class=glyph>⋋</span> <tr id=entity-LeftTriangle><td> <code>LeftTriangle;</code> <td> U+022B2 <td> <span class=glyph>⊲</span> <tr id=entity-LeftTriangleBar><td> <code>LeftTriangleBar;</code> <td> U+029CF <td> <span class=glyph>⧏</span> <tr id=entity-LeftTriangleEqual><td> <code>LeftTriangleEqual;</code> <td> U+022B4 <td> <span class=glyph>⊴</span> <tr id=entity-LeftUpDownVector><td> <code>LeftUpDownVector;</code> <td> U+02951 <td> <span class=glyph>⥑</span> <tr id=entity-LeftUpTeeVector><td> <code>LeftUpTeeVector;</code> <td> U+02960 <td> <span class=glyph>⥠</span> <tr id=entity-LeftUpVector><td> <code>LeftUpVector;</code> <td> U+021BF <td> <span class=glyph>↿</span> <tr id=entity-LeftUpVectorBar><td> <code>LeftUpVectorBar;</code> <td> U+02958 <td> <span class=glyph>⥘</span> <tr id=entity-LeftVector><td> <code>LeftVector;</code> <td> U+021BC <td> <span class=glyph>↼</span> <tr id=entity-LeftVectorBar><td> <code>LeftVectorBar;</code> <td> U+02952 <td> <span class=glyph>⥒</span> <tr id=entity-lEg><td> <code>lEg;</code> <td> U+02A8B <td> <span class=glyph>⪋</span> <tr id=entity-leg><td> <code>leg;</code> <td> U+022DA <td> <span class=glyph>⋚</span> <tr id=entity-leq><td> <code>leq;</code> <td> U+02264 <td> <span class=glyph>≤</span> <tr id=entity-leqq><td> <code>leqq;</code> <td> U+02266 <td> <span class=glyph>≦</span> <tr id=entity-leqslant><td> <code>leqslant;</code> <td> U+02A7D <td> <span class=glyph>⩽</span> <tr id=entity-les><td> <code>les;</code> <td> U+02A7D <td> <span class=glyph>⩽</span> <tr id=entity-lescc><td> <code>lescc;</code> <td> U+02AA8 <td> <span class=glyph>⪨</span> <tr id=entity-lesdot><td> <code>lesdot;</code> <td> U+02A7F <td> <span class=glyph>⩿</span> <tr id=entity-lesdoto><td> <code>lesdoto;</code> <td> U+02A81 <td> <span class=glyph>⪁</span> <tr id=entity-lesdotor><td> <code>lesdotor;</code> <td> U+02A83 <td> <span class=glyph>⪃</span> <tr id=entity-lesg><td> <code>lesg;</code> <td> U+022DA U+0FE00 <td> <span class="glyph compound">⋚︀</span> <tr id=entity-lesges><td> <code>lesges;</code> <td> U+02A93 <td> <span class=glyph>⪓</span> <tr id=entity-lessapprox><td> <code>lessapprox;</code> <td> U+02A85 <td> <span class=glyph>⪅</span> <tr id=entity-lessdot><td> <code>lessdot;</code> <td> U+022D6 <td> <span class=glyph>⋖</span> <tr id=entity-lesseqgtr><td> <code>lesseqgtr;</code> <td> U+022DA <td> <span class=glyph>⋚</span> <tr id=entity-lesseqqgtr><td> <code>lesseqqgtr;</code> <td> U+02A8B <td> <span class=glyph>⪋</span> <tr id=entity-LessEqualGreater><td> <code>LessEqualGreater;</code> <td> U+022DA <td> <span class=glyph>⋚</span> <tr id=entity-LessFullEqual><td> <code>LessFullEqual;</code> <td> U+02266 <td> <span class=glyph>≦</span> <tr id=entity-LessGreater><td> <code>LessGreater;</code> <td> U+02276 <td> <span class=glyph>≶</span> <tr id=entity-lessgtr><td> <code>lessgtr;</code> <td> U+02276 <td> <span class=glyph>≶</span> <tr id=entity-LessLess><td> <code>LessLess;</code> <td> U+02AA1 <td> <span class=glyph>⪡</span> <tr id=entity-lesssim><td> <code>lesssim;</code> <td> U+02272 <td> <span class=glyph>≲</span> <tr id=entity-LessSlantEqual><td> <code>LessSlantEqual;</code> <td> U+02A7D <td> <span class=glyph>⩽</span> <tr id=entity-LessTilde><td> <code>LessTilde;</code> <td> U+02272 <td> <span class=glyph>≲</span> <tr id=entity-lfisht><td> <code>lfisht;</code> <td> U+0297C <td> <span class=glyph>⥼</span> <tr id=entity-lfloor><td> <code>lfloor;</code> <td> U+0230A <td> <span class=glyph>⌊</span> <tr id=entity-Lfr><td> <code>Lfr;</code> <td> U+1D50F <td> <span class=glyph>𝔏</span> <tr id=entity-lfr><td> <code>lfr;</code> <td> U+1D529 <td> <span class=glyph>𝔩</span> <tr id=entity-lg><td> <code>lg;</code> <td> U+02276 <td> <span class=glyph>≶</span> <tr id=entity-lgE><td> <code>lgE;</code> <td> U+02A91 <td> <span class=glyph>⪑</span> <tr id=entity-lHar><td> <code>lHar;</code> <td> U+02962 <td> <span class=glyph>⥢</span> <tr id=entity-lhard><td> <code>lhard;</code> <td> U+021BD <td> <span class=glyph>↽</span> <tr id=entity-lharu><td> <code>lharu;</code> <td> U+021BC <td> <span class=glyph>↼</span> <tr id=entity-lharul><td> <code>lharul;</code> <td> U+0296A <td> <span class=glyph>⥪</span> <tr id=entity-lhblk><td> <code>lhblk;</code> <td> U+02584 <td> <span class=glyph>▄</span> <tr id=entity-LJcy><td> <code>LJcy;</code> <td> U+00409 <td> <span class=glyph>Љ</span> <tr id=entity-ljcy><td> <code>ljcy;</code> <td> U+00459 <td> <span class=glyph>љ</span> <tr id=entity-Ll><td> <code>Ll;</code> <td> U+022D8 <td> <span class=glyph>⋘</span> <tr id=entity-ll><td> <code>ll;</code> <td> U+0226A <td> <span class=glyph>≪</span> <tr id=entity-llarr><td> <code>llarr;</code> <td> U+021C7 <td> <span class=glyph>⇇</span> <tr id=entity-llcorner><td> <code>llcorner;</code> <td> U+0231E <td> <span class=glyph>⌞</span> <tr id=entity-Lleftarrow><td> <code>Lleftarrow;</code> <td> U+021DA <td> <span class=glyph>⇚</span> <tr id=entity-llhard><td> <code>llhard;</code> <td> U+0296B <td> <span class=glyph>⥫</span> <tr id=entity-lltri><td> <code>lltri;</code> <td> U+025FA <td> <span class=glyph>◺</span> <tr id=entity-Lmidot><td> <code>Lmidot;</code> <td> U+0013F <td> <span class=glyph>Ŀ</span> <tr id=entity-lmidot><td> <code>lmidot;</code> <td> U+00140 <td> <span class=glyph>ŀ</span> <tr id=entity-lmoust><td> <code>lmoust;</code> <td> U+023B0 <td> <span class=glyph>⎰</span> <tr id=entity-lmoustache><td> <code>lmoustache;</code> <td> U+023B0 <td> <span class=glyph>⎰</span> <tr id=entity-lnap><td> <code>lnap;</code> <td> U+02A89 <td> <span class=glyph>⪉</span> <tr id=entity-lnapprox><td> <code>lnapprox;</code> <td> U+02A89 <td> <span class=glyph>⪉</span> <tr id=entity-lnE><td> <code>lnE;</code> <td> U+02268 <td> <span class=glyph>≨</span> <tr id=entity-lne><td> <code>lne;</code> <td> U+02A87 <td> <span class=glyph>⪇</span> <tr id=entity-lneq><td> <code>lneq;</code> <td> U+02A87 <td> <span class=glyph>⪇</span> <tr id=entity-lneqq><td> <code>lneqq;</code> <td> U+02268 <td> <span class=glyph>≨</span> <tr id=entity-lnsim><td> <code>lnsim;</code> <td> U+022E6 <td> <span class=glyph>⋦</span> <tr id=entity-loang><td> <code>loang;</code> <td> U+027EC <td> <span class=glyph>⟬</span> <tr id=entity-loarr><td> <code>loarr;</code> <td> U+021FD <td> <span class=glyph>⇽</span> <tr id=entity-lobrk><td> <code>lobrk;</code> <td> U+027E6 <td> <span class=glyph>⟦</span> <tr id=entity-LongLeftArrow><td> <code>LongLeftArrow;</code> <td> U+027F5 <td> <span class=glyph>⟵</span> <tr id=entity-Longleftarrow><td> <code>Longleftarrow;</code> <td> U+027F8 <td> <span class=glyph>⟸</span> <tr id=entity-longleftarrow><td> <code>longleftarrow;</code> <td> U+027F5 <td> <span class=glyph>⟵</span> <tr id=entity-LongLeftRightArrow><td> <code>LongLeftRightArrow;</code> <td> U+027F7 <td> <span class=glyph>⟷</span> <tr id=entity-Longleftrightarrow><td> <code>Longleftrightarrow;</code> <td> U+027FA <td> <span class=glyph>⟺</span> <tr id=entity-longleftrightarrow><td> <code>longleftrightarrow;</code> <td> U+027F7 <td> <span class=glyph>⟷</span> <tr id=entity-longmapsto><td> <code>longmapsto;</code> <td> U+027FC <td> <span class=glyph>⟼</span> <tr id=entity-LongRightArrow><td> <code>LongRightArrow;</code> <td> U+027F6 <td> <span class=glyph>⟶</span> <tr id=entity-Longrightarrow><td> <code>Longrightarrow;</code> <td> U+027F9 <td> <span class=glyph>⟹</span> <tr id=entity-longrightarrow><td> <code>longrightarrow;</code> <td> U+027F6 <td> <span class=glyph>⟶</span> <tr id=entity-looparrowleft><td> <code>looparrowleft;</code> <td> U+021AB <td> <span class=glyph>↫</span> <tr id=entity-looparrowright><td> <code>looparrowright;</code> <td> U+021AC <td> <span class=glyph>↬</span> <tr id=entity-lopar><td> <code>lopar;</code> <td> U+02985 <td> <span class=glyph>⦅</span> <tr id=entity-Lopf><td> <code>Lopf;</code> <td> U+1D543 <td> <span class=glyph>𝕃</span> <tr id=entity-lopf><td> <code>lopf;</code> <td> U+1D55D <td> <span class=glyph>𝕝</span> <tr id=entity-loplus><td> <code>loplus;</code> <td> U+02A2D <td> <span class=glyph>⨭</span> <tr id=entity-lotimes><td> <code>lotimes;</code> <td> U+02A34 <td> <span class=glyph>⨴</span> <tr id=entity-lowast><td> <code>lowast;</code> <td> U+02217 <td> <span class=glyph>∗</span> <tr id=entity-lowbar><td> <code>lowbar;</code> <td> U+0005F <td> <span class=glyph>_</span> <tr id=entity-LowerLeftArrow><td> <code>LowerLeftArrow;</code> <td> U+02199 <td> <span class=glyph>↙</span> <tr id=entity-LowerRightArrow><td> <code>LowerRightArrow;</code> <td> U+02198 <td> <span class=glyph>↘</span> <tr id=entity-loz><td> <code>loz;</code> <td> U+025CA <td> <span class=glyph>◊</span> <tr id=entity-lozenge><td> <code>lozenge;</code> <td> U+025CA <td> <span class=glyph>◊</span> <tr id=entity-lozf><td> <code>lozf;</code> <td> U+029EB <td> <span class=glyph>⧫</span> <tr id=entity-lpar><td> <code>lpar;</code> <td> U+00028 <td> <span class=glyph>(</span> <tr id=entity-lparlt><td> <code>lparlt;</code> <td> U+02993 <td> <span class=glyph>⦓</span> <tr id=entity-lrarr><td> <code>lrarr;</code> <td> U+021C6 <td> <span class=glyph>⇆</span> <tr id=entity-lrcorner><td> <code>lrcorner;</code> <td> U+0231F <td> <span class=glyph>⌟</span> <tr id=entity-lrhar><td> <code>lrhar;</code> <td> U+021CB <td> <span class=glyph>⇋</span> <tr id=entity-lrhard><td> <code>lrhard;</code> <td> U+0296D <td> <span class=glyph>⥭</span> <tr id=entity-lrm><td> <code>lrm;</code> <td> U+0200E <td> <span class=glyph>‎</span> <tr id=entity-lrtri><td> <code>lrtri;</code> <td> U+022BF <td> <span class=glyph>⊿</span> <tr id=entity-lsaquo><td> <code>lsaquo;</code> <td> U+02039 <td> <span class=glyph>‹</span> <tr id=entity-Lscr><td> <code>Lscr;</code> <td> U+02112 <td> <span class=glyph>ℒ</span> <tr id=entity-lscr><td> <code>lscr;</code> <td> U+1D4C1 <td> <span class=glyph>𝓁</span> <tr id=entity-Lsh><td> <code>Lsh;</code> <td> U+021B0 <td> <span class=glyph>↰</span> <tr id=entity-lsh><td> <code>lsh;</code> <td> U+021B0 <td> <span class=glyph>↰</span> <tr id=entity-lsim><td> <code>lsim;</code> <td> U+02272 <td> <span class=glyph>≲</span> <tr id=entity-lsime><td> <code>lsime;</code> <td> U+02A8D <td> <span class=glyph>⪍</span> <tr id=entity-lsimg><td> <code>lsimg;</code> <td> U+02A8F <td> <span class=glyph>⪏</span> <tr id=entity-lsqb><td> <code>lsqb;</code> <td> U+0005B <td> <span class=glyph>[</span> <tr id=entity-lsquo><td> <code>lsquo;</code> <td> U+02018 <td> <span class=glyph>‘</span> <tr id=entity-lsquor><td> <code>lsquor;</code> <td> U+0201A <td> <span class=glyph>‚</span> <tr id=entity-Lstrok><td> <code>Lstrok;</code> <td> U+00141 <td> <span class=glyph>Ł</span> <tr id=entity-lstrok><td> <code>lstrok;</code> <td> U+00142 <td> <span class=glyph>ł</span> <tr id=entity-LT><td> <code>LT;</code> <td> U+0003C <td> <span class=glyph>&lt;</span> <tr id=entity-LT-legacy class=impl><td> <code>LT</code> <td> U+0003C <td> <span>&lt;</span> <tr id=entity-Lt><td> <code>Lt;</code> <td> U+0226A <td> <span class=glyph>≪</span> <tr id=entity-lt><td> <code>lt;</code> <td> U+0003C <td> <span class=glyph>&lt;</span> <tr id=entity-lt-legacy class=impl><td> <code>lt</code> <td> U+0003C <td> <span>&lt;</span> <tr id=entity-ltcc><td> <code>ltcc;</code> <td> U+02AA6 <td> <span class=glyph>⪦</span> <tr id=entity-ltcir><td> <code>ltcir;</code> <td> U+02A79 <td> <span class=glyph>⩹</span> <tr id=entity-ltdot><td> <code>ltdot;</code> <td> U+022D6 <td> <span class=glyph>⋖</span> <tr id=entity-lthree><td> <code>lthree;</code> <td> U+022CB <td> <span class=glyph>⋋</span> <tr id=entity-ltimes><td> <code>ltimes;</code> <td> U+022C9 <td> <span class=glyph>⋉</span> <tr id=entity-ltlarr><td> <code>ltlarr;</code> <td> U+02976 <td> <span class=glyph>⥶</span> <tr id=entity-ltquest><td> <code>ltquest;</code> <td> U+02A7B <td> <span class=glyph>⩻</span> <tr id=entity-ltri><td> <code>ltri;</code> <td> U+025C3 <td> <span class=glyph>◃</span> <tr id=entity-ltrie><td> <code>ltrie;</code> <td> U+022B4 <td> <span class=glyph>⊴</span> <tr id=entity-ltrif><td> <code>ltrif;</code> <td> U+025C2 <td> <span class=glyph>◂</span> <tr id=entity-ltrPar><td> <code>ltrPar;</code> <td> U+02996 <td> <span class=glyph>⦖</span> <tr id=entity-lurdshar><td> <code>lurdshar;</code> <td> U+0294A <td> <span class=glyph>⥊</span> <tr id=entity-luruhar><td> <code>luruhar;</code> <td> U+02966 <td> <span class=glyph>⥦</span> <tr id=entity-lvertneqq><td> <code>lvertneqq;</code> <td> U+02268 U+0FE00 <td> <span class="glyph compound">≨︀</span> <tr id=entity-lvnE><td> <code>lvnE;</code> <td> U+02268 U+0FE00 <td> <span class="glyph compound">≨︀</span> <tr id=entity-macr><td> <code>macr;</code> <td> U+000AF <td> <span class=glyph>¯</span> <tr id=entity-macr-legacy class=impl><td> <code>macr</code> <td> U+000AF <td> <span>¯</span> <tr id=entity-male><td> <code>male;</code> <td> U+02642 <td> <span class=glyph>♂</span> <tr id=entity-malt><td> <code>malt;</code> <td> U+02720 <td> <span class=glyph>✠</span> <tr id=entity-maltese><td> <code>maltese;</code> <td> U+02720 <td> <span class=glyph>✠</span> <tr id=entity-Map><td> <code>Map;</code> <td> U+02905 <td> <span class=glyph>⤅</span> <tr id=entity-map><td> <code>map;</code> <td> U+021A6 <td> <span class=glyph>↦</span> <tr id=entity-mapsto><td> <code>mapsto;</code> <td> U+021A6 <td> <span class=glyph>↦</span> <tr id=entity-mapstodown><td> <code>mapstodown;</code> <td> U+021A7 <td> <span class=glyph>↧</span> <tr id=entity-mapstoleft><td> <code>mapstoleft;</code> <td> U+021A4 <td> <span class=glyph>↤</span> <tr id=entity-mapstoup><td> <code>mapstoup;</code> <td> U+021A5 <td> <span class=glyph>↥</span> <tr id=entity-marker><td> <code>marker;</code> <td> U+025AE <td> <span class=glyph>▮</span> <tr id=entity-mcomma><td> <code>mcomma;</code> <td> U+02A29 <td> <span class=glyph>⨩</span> <tr id=entity-Mcy><td> <code>Mcy;</code> <td> U+0041C <td> <span class=glyph>М</span> <tr id=entity-mcy><td> <code>mcy;</code> <td> U+0043C <td> <span class=glyph>м</span> <tr id=entity-mdash><td> <code>mdash;</code> <td> U+02014 <td> <span class=glyph>—</span> <tr id=entity-mDDot><td> <code>mDDot;</code> <td> U+0223A <td> <span class=glyph>∺</span> <tr id=entity-measuredangle><td> <code>measuredangle;</code> <td> U+02221 <td> <span class=glyph>∡</span> <tr id=entity-MediumSpace><td> <code>MediumSpace;</code> <td> U+0205F <td> <span class=glyph> </span> <tr id=entity-Mellintrf><td> <code>Mellintrf;</code> <td> U+02133 <td> <span class=glyph>ℳ</span> <tr id=entity-Mfr><td> <code>Mfr;</code> <td> U+1D510 <td> <span class=glyph>𝔐</span> <tr id=entity-mfr><td> <code>mfr;</code> <td> U+1D52A <td> <span class=glyph>𝔪</span> <tr id=entity-mho><td> <code>mho;</code> <td> U+02127 <td> <span class=glyph>℧</span> <tr id=entity-micro><td> <code>micro;</code> <td> U+000B5 <td> <span class=glyph>µ</span> <tr id=entity-micro-legacy class=impl><td> <code>micro</code> <td> U+000B5 <td> <span>µ</span> <tr id=entity-mid><td> <code>mid;</code> <td> U+02223 <td> <span class=glyph>∣</span> <tr id=entity-midast><td> <code>midast;</code> <td> U+0002A <td> <span class=glyph>*</span> <tr id=entity-midcir><td> <code>midcir;</code> <td> U+02AF0 <td> <span class=glyph>⫰</span> <tr id=entity-middot><td> <code>middot;</code> <td> U+000B7 <td> <span class=glyph>·</span> <tr id=entity-middot-legacy class=impl><td> <code>middot</code> <td> U+000B7 <td> <span>·</span> <tr id=entity-minus><td> <code>minus;</code> <td> U+02212 <td> <span class=glyph>−</span> <tr id=entity-minusb><td> <code>minusb;</code> <td> U+0229F <td> <span class=glyph>⊟</span> <tr id=entity-minusd><td> <code>minusd;</code> <td> U+02238 <td> <span class=glyph>∸</span> <tr id=entity-minusdu><td> <code>minusdu;</code> <td> U+02A2A <td> <span class=glyph>⨪</span> <tr id=entity-MinusPlus><td> <code>MinusPlus;</code> <td> U+02213 <td> <span class=glyph>∓</span> <tr id=entity-mlcp><td> <code>mlcp;</code> <td> U+02ADB <td> <span class=glyph>⫛</span> <tr id=entity-mldr><td> <code>mldr;</code> <td> U+02026 <td> <span class=glyph>…</span> <tr id=entity-mnplus><td> <code>mnplus;</code> <td> U+02213 <td> <span class=glyph>∓</span> <tr id=entity-models><td> <code>models;</code> <td> U+022A7 <td> <span class=glyph>⊧</span> <tr id=entity-Mopf><td> <code>Mopf;</code> <td> U+1D544 <td> <span class=glyph>𝕄</span> <tr id=entity-mopf><td> <code>mopf;</code> <td> U+1D55E <td> <span class=glyph>𝕞</span> <tr id=entity-mp><td> <code>mp;</code> <td> U+02213 <td> <span class=glyph>∓</span> <tr id=entity-Mscr><td> <code>Mscr;</code> <td> U+02133 <td> <span class=glyph>ℳ</span> <tr id=entity-mscr><td> <code>mscr;</code> <td> U+1D4C2 <td> <span class=glyph>𝓂</span> <tr id=entity-mstpos><td> <code>mstpos;</code> <td> U+0223E <td> <span class=glyph>∾</span> <tr id=entity-Mu><td> <code>Mu;</code> <td> U+0039C <td> <span class=glyph>Μ</span> <tr id=entity-mu><td> <code>mu;</code> <td> U+003BC <td> <span class=glyph>μ</span> <tr id=entity-multimap><td> <code>multimap;</code> <td> U+022B8 <td> <span class=glyph>⊸</span> <tr id=entity-mumap><td> <code>mumap;</code> <td> U+022B8 <td> <span class=glyph>⊸</span> <tr id=entity-nabla><td> <code>nabla;</code> <td> U+02207 <td> <span class=glyph>∇</span> <tr id=entity-Nacute><td> <code>Nacute;</code> <td> U+00143 <td> <span class=glyph>Ń</span> <tr id=entity-nacute><td> <code>nacute;</code> <td> U+00144 <td> <span class=glyph>ń</span> <tr id=entity-nang><td> <code>nang;</code> <td> U+02220 U+020D2 <td> <span class="glyph compound">∠⃒</span> <tr id=entity-nap><td> <code>nap;</code> <td> U+02249 <td> <span class=glyph>≉</span> <tr id=entity-napE><td> <code>napE;</code> <td> U+02A70 U+00338 <td> <span class="glyph compound">⩰̸</span> <tr id=entity-napid><td> <code>napid;</code> <td> U+0224B U+00338 <td> <span class="glyph compound">≋̸</span> <tr id=entity-napos><td> <code>napos;</code> <td> U+00149 <td> <span class=glyph>ʼn</span> <tr id=entity-napprox><td> <code>napprox;</code> <td> U+02249 <td> <span class=glyph>≉</span> <tr id=entity-natur><td> <code>natur;</code> <td> U+0266E <td> <span class=glyph>♮</span> <tr id=entity-natural><td> <code>natural;</code> <td> U+0266E <td> <span class=glyph>♮</span> <tr id=entity-naturals><td> <code>naturals;</code> <td> U+02115 <td> <span class=glyph>ℕ</span> <tr id=entity-nbsp><td> <code>nbsp;</code> <td> U+000A0 <td> <span class=glyph> </span> <tr id=entity-nbsp-legacy class=impl><td> <code>nbsp</code> <td> U+000A0 <td> <span> </span> <tr id=entity-nbump><td> <code>nbump;</code> <td> U+0224E U+00338 <td> <span class="glyph compound">≎̸</span> <tr id=entity-nbumpe><td> <code>nbumpe;</code> <td> U+0224F U+00338 <td> <span class="glyph compound">≏̸</span> <tr id=entity-ncap><td> <code>ncap;</code> <td> U+02A43 <td> <span class=glyph>⩃</span> <tr id=entity-Ncaron><td> <code>Ncaron;</code> <td> U+00147 <td> <span class=glyph>Ň</span> <tr id=entity-ncaron><td> <code>ncaron;</code> <td> U+00148 <td> <span class=glyph>ň</span> <tr id=entity-Ncedil><td> <code>Ncedil;</code> <td> U+00145 <td> <span class=glyph>Ņ</span> <tr id=entity-ncedil><td> <code>ncedil;</code> <td> U+00146 <td> <span class=glyph>ņ</span> <tr id=entity-ncong><td> <code>ncong;</code> <td> U+02247 <td> <span class=glyph>≇</span> <tr id=entity-ncongdot><td> <code>ncongdot;</code> <td> U+02A6D U+00338 <td> <span class="glyph compound">⩭̸</span> <tr id=entity-ncup><td> <code>ncup;</code> <td> U+02A42 <td> <span class=glyph>⩂</span> <tr id=entity-Ncy><td> <code>Ncy;</code> <td> U+0041D <td> <span class=glyph>Н</span> <tr id=entity-ncy><td> <code>ncy;</code> <td> U+0043D <td> <span class=glyph>н</span> <tr id=entity-ndash><td> <code>ndash;</code> <td> U+02013 <td> <span class=glyph>–</span> <tr id=entity-ne><td> <code>ne;</code> <td> U+02260 <td> <span class=glyph>≠</span> <tr id=entity-nearhk><td> <code>nearhk;</code> <td> U+02924 <td> <span class=glyph>⤤</span> <tr id=entity-neArr><td> <code>neArr;</code> <td> U+021D7 <td> <span class=glyph>⇗</span> <tr id=entity-nearr><td> <code>nearr;</code> <td> U+02197 <td> <span class=glyph>↗</span> <tr id=entity-nearrow><td> <code>nearrow;</code> <td> U+02197 <td> <span class=glyph>↗</span> <tr id=entity-nedot><td> <code>nedot;</code> <td> U+02250 U+00338 <td> <span class="glyph compound">≐̸</span> <tr id=entity-NegativeMediumSpace><td> <code>NegativeMediumSpace;</code> <td> U+0200B <td> <span class=glyph>​</span> <tr id=entity-NegativeThickSpace><td> <code>NegativeThickSpace;</code> <td> U+0200B <td> <span class=glyph>​</span> <tr id=entity-NegativeThinSpace><td> <code>NegativeThinSpace;</code> <td> U+0200B <td> <span class=glyph>​</span> <tr id=entity-NegativeVeryThinSpace><td> <code>NegativeVeryThinSpace;</code> <td> U+0200B <td> <span class=glyph>​</span> <tr id=entity-nequiv><td> <code>nequiv;</code> <td> U+02262 <td> <span class=glyph>≢</span> <tr id=entity-nesear><td> <code>nesear;</code> <td> U+02928 <td> <span class=glyph>⤨</span> <tr id=entity-nesim><td> <code>nesim;</code> <td> U+02242 U+00338 <td> <span class="glyph compound">≂̸</span> <tr id=entity-NestedGreaterGreater><td> <code>NestedGreaterGreater;</code> <td> U+0226B <td> <span class=glyph>≫</span> <tr id=entity-NestedLessLess><td> <code>NestedLessLess;</code> <td> U+0226A <td> <span class=glyph>≪</span> <tr id=entity-NewLine><td> <code>NewLine;</code> <td> U+0000A <td> <span class="glyph control">␊</span> <tr id=entity-nexist><td> <code>nexist;</code> <td> U+02204 <td> <span class=glyph>∄</span> <tr id=entity-nexists><td> <code>nexists;</code> <td> U+02204 <td> <span class=glyph>∄</span> <tr id=entity-Nfr><td> <code>Nfr;</code> <td> U+1D511 <td> <span class=glyph>𝔑</span> <tr id=entity-nfr><td> <code>nfr;</code> <td> U+1D52B <td> <span class=glyph>𝔫</span> <tr id=entity-ngE><td> <code>ngE;</code> <td> U+02267 U+00338 <td> <span class="glyph compound">≧̸</span> <tr id=entity-nge><td> <code>nge;</code> <td> U+02271 <td> <span class=glyph>≱</span> <tr id=entity-ngeq><td> <code>ngeq;</code> <td> U+02271 <td> <span class=glyph>≱</span> <tr id=entity-ngeqq><td> <code>ngeqq;</code> <td> U+02267 U+00338 <td> <span class="glyph compound">≧̸</span> <tr id=entity-ngeqslant><td> <code>ngeqslant;</code> <td> U+02A7E U+00338 <td> <span class="glyph compound">⩾̸</span> <tr id=entity-nges><td> <code>nges;</code> <td> U+02A7E U+00338 <td> <span class="glyph compound">⩾̸</span> <tr id=entity-nGg><td> <code>nGg;</code> <td> U+022D9 U+00338 <td> <span class="glyph compound">⋙̸</span> <tr id=entity-ngsim><td> <code>ngsim;</code> <td> U+02275 <td> <span class=glyph>≵</span> <tr id=entity-nGt><td> <code>nGt;</code> <td> U+0226B U+020D2 <td> <span class="glyph compound">≫⃒</span> <tr id=entity-ngt><td> <code>ngt;</code> <td> U+0226F <td> <span class=glyph>≯</span> <tr id=entity-ngtr><td> <code>ngtr;</code> <td> U+0226F <td> <span class=glyph>≯</span> <tr id=entity-nGtv><td> <code>nGtv;</code> <td> U+0226B U+00338 <td> <span class="glyph compound">≫̸</span> <tr id=entity-nhArr><td> <code>nhArr;</code> <td> U+021CE <td> <span class=glyph>⇎</span> <tr id=entity-nharr><td> <code>nharr;</code> <td> U+021AE <td> <span class=glyph>↮</span> <tr id=entity-nhpar><td> <code>nhpar;</code> <td> U+02AF2 <td> <span class=glyph>⫲</span> <tr id=entity-ni><td> <code>ni;</code> <td> U+0220B <td> <span class=glyph>∋</span> <tr id=entity-nis><td> <code>nis;</code> <td> U+022FC <td> <span class=glyph>⋼</span> <tr id=entity-nisd><td> <code>nisd;</code> <td> U+022FA <td> <span class=glyph>⋺</span> <tr id=entity-niv><td> <code>niv;</code> <td> U+0220B <td> <span class=glyph>∋</span> <tr id=entity-NJcy><td> <code>NJcy;</code> <td> U+0040A <td> <span class=glyph>Њ</span> <tr id=entity-njcy><td> <code>njcy;</code> <td> U+0045A <td> <span class=glyph>њ</span> <tr id=entity-nlArr><td> <code>nlArr;</code> <td> U+021CD <td> <span class=glyph>⇍</span> <tr id=entity-nlarr><td> <code>nlarr;</code> <td> U+0219A <td> <span class=glyph>↚</span> <tr id=entity-nldr><td> <code>nldr;</code> <td> U+02025 <td> <span class=glyph>‥</span> <tr id=entity-nlE><td> <code>nlE;</code> <td> U+02266 U+00338 <td> <span class="glyph compound">≦̸</span> <tr id=entity-nle><td> <code>nle;</code> <td> U+02270 <td> <span class=glyph>≰</span> <tr id=entity-nLeftarrow><td> <code>nLeftarrow;</code> <td> U+021CD <td> <span class=glyph>⇍</span> <tr id=entity-nleftarrow><td> <code>nleftarrow;</code> <td> U+0219A <td> <span class=glyph>↚</span> <tr id=entity-nLeftrightarrow><td> <code>nLeftrightarrow;</code> <td> U+021CE <td> <span class=glyph>⇎</span> <tr id=entity-nleftrightarrow><td> <code>nleftrightarrow;</code> <td> U+021AE <td> <span class=glyph>↮</span> <tr id=entity-nleq><td> <code>nleq;</code> <td> U+02270 <td> <span class=glyph>≰</span> <tr id=entity-nleqq><td> <code>nleqq;</code> <td> U+02266 U+00338 <td> <span class="glyph compound">≦̸</span> <tr id=entity-nleqslant><td> <code>nleqslant;</code> <td> U+02A7D U+00338 <td> <span class="glyph compound">⩽̸</span> <tr id=entity-nles><td> <code>nles;</code> <td> U+02A7D U+00338 <td> <span class="glyph compound">⩽̸</span> <tr id=entity-nless><td> <code>nless;</code> <td> U+0226E <td> <span class=glyph>≮</span> <tr id=entity-nLl><td> <code>nLl;</code> <td> U+022D8 U+00338 <td> <span class="glyph compound">⋘̸</span> <tr id=entity-nlsim><td> <code>nlsim;</code> <td> U+02274 <td> <span class=glyph>≴</span> <tr id=entity-nLt><td> <code>nLt;</code> <td> U+0226A U+020D2 <td> <span class="glyph compound">≪⃒</span> <tr id=entity-nlt><td> <code>nlt;</code> <td> U+0226E <td> <span class=glyph>≮</span> <tr id=entity-nltri><td> <code>nltri;</code> <td> U+022EA <td> <span class=glyph>⋪</span> <tr id=entity-nltrie><td> <code>nltrie;</code> <td> U+022EC <td> <span class=glyph>⋬</span> <tr id=entity-nLtv><td> <code>nLtv;</code> <td> U+0226A U+00338 <td> <span class="glyph compound">≪̸</span> <tr id=entity-nmid><td> <code>nmid;</code> <td> U+02224 <td> <span class=glyph>∤</span> <tr id=entity-NoBreak><td> <code>NoBreak;</code> <td> U+02060 <td> <span class=glyph>⁠</span> <tr id=entity-NonBreakingSpace><td> <code>NonBreakingSpace;</code> <td> U+000A0 <td> <span class=glyph> </span> <tr id=entity-Nopf><td> <code>Nopf;</code> <td> U+02115 <td> <span class=glyph>ℕ</span> <tr id=entity-nopf><td> <code>nopf;</code> <td> U+1D55F <td> <span class=glyph>𝕟</span> <tr id=entity-Not><td> <code>Not;</code> <td> U+02AEC <td> <span class=glyph>⫬</span> <tr id=entity-not><td> <code>not;</code> <td> U+000AC <td> <span class=glyph>¬</span> <tr id=entity-not-legacy class=impl><td> <code>not</code> <td> U+000AC <td> <span>¬</span> <tr id=entity-NotCongruent><td> <code>NotCongruent;</code> <td> U+02262 <td> <span class=glyph>≢</span> <tr id=entity-NotCupCap><td> <code>NotCupCap;</code> <td> U+0226D <td> <span class=glyph>≭</span> <tr id=entity-NotDoubleVerticalBar><td> <code>NotDoubleVerticalBar;</code> <td> U+02226 <td> <span class=glyph>∦</span> <tr id=entity-NotElement><td> <code>NotElement;</code> <td> U+02209 <td> <span class=glyph>∉</span> <tr id=entity-NotEqual><td> <code>NotEqual;</code> <td> U+02260 <td> <span class=glyph>≠</span> <tr id=entity-NotEqualTilde><td> <code>NotEqualTilde;</code> <td> U+02242 U+00338 <td> <span class="glyph compound">≂̸</span> <tr id=entity-NotExists><td> <code>NotExists;</code> <td> U+02204 <td> <span class=glyph>∄</span> <tr id=entity-NotGreater><td> <code>NotGreater;</code> <td> U+0226F <td> <span class=glyph>≯</span> <tr id=entity-NotGreaterEqual><td> <code>NotGreaterEqual;</code> <td> U+02271 <td> <span class=glyph>≱</span> <tr id=entity-NotGreaterFullEqual><td> <code>NotGreaterFullEqual;</code> <td> U+02267 U+00338 <td> <span class="glyph compound">≧̸</span> <tr id=entity-NotGreaterGreater><td> <code>NotGreaterGreater;</code> <td> U+0226B U+00338 <td> <span class="glyph compound">≫̸</span> <tr id=entity-NotGreaterLess><td> <code>NotGreaterLess;</code> <td> U+02279 <td> <span class=glyph>≹</span> <tr id=entity-NotGreaterSlantEqual><td> <code>NotGreaterSlantEqual;</code> <td> U+02A7E U+00338 <td> <span class="glyph compound">⩾̸</span> <tr id=entity-NotGreaterTilde><td> <code>NotGreaterTilde;</code> <td> U+02275 <td> <span class=glyph>≵</span> <tr id=entity-NotHumpDownHump><td> <code>NotHumpDownHump;</code> <td> U+0224E U+00338 <td> <span class="glyph compound">≎̸</span> <tr id=entity-NotHumpEqual><td> <code>NotHumpEqual;</code> <td> U+0224F U+00338 <td> <span class="glyph compound">≏̸</span> <tr id=entity-notin><td> <code>notin;</code> <td> U+02209 <td> <span class=glyph>∉</span> <tr id=entity-notindot><td> <code>notindot;</code> <td> U+022F5 U+00338 <td> <span class="glyph compound">⋵̸</span> <tr id=entity-notinE><td> <code>notinE;</code> <td> U+022F9 U+00338 <td> <span class="glyph compound">⋹̸</span> <tr id=entity-notinva><td> <code>notinva;</code> <td> U+02209 <td> <span class=glyph>∉</span> <tr id=entity-notinvb><td> <code>notinvb;</code> <td> U+022F7 <td> <span class=glyph>⋷</span> <tr id=entity-notinvc><td> <code>notinvc;</code> <td> U+022F6 <td> <span class=glyph>⋶</span> <tr id=entity-NotLeftTriangle><td> <code>NotLeftTriangle;</code> <td> U+022EA <td> <span class=glyph>⋪</span> <tr id=entity-NotLeftTriangleBar><td> <code>NotLeftTriangleBar;</code> <td> U+029CF U+00338 <td> <span class="glyph compound">⧏̸</span> <tr id=entity-NotLeftTriangleEqual><td> <code>NotLeftTriangleEqual;</code> <td> U+022EC <td> <span class=glyph>⋬</span> <tr id=entity-NotLess><td> <code>NotLess;</code> <td> U+0226E <td> <span class=glyph>≮</span> <tr id=entity-NotLessEqual><td> <code>NotLessEqual;</code> <td> U+02270 <td> <span class=glyph>≰</span> <tr id=entity-NotLessGreater><td> <code>NotLessGreater;</code> <td> U+02278 <td> <span class=glyph>≸</span> <tr id=entity-NotLessLess><td> <code>NotLessLess;</code> <td> U+0226A U+00338 <td> <span class="glyph compound">≪̸</span> <tr id=entity-NotLessSlantEqual><td> <code>NotLessSlantEqual;</code> <td> U+02A7D U+00338 <td> <span class="glyph compound">⩽̸</span> <tr id=entity-NotLessTilde><td> <code>NotLessTilde;</code> <td> U+02274 <td> <span class=glyph>≴</span> <tr id=entity-NotNestedGreaterGreater><td> <code>NotNestedGreaterGreater;</code> <td> U+02AA2 U+00338 <td> <span class="glyph compound">⪢̸</span> <tr id=entity-NotNestedLessLess><td> <code>NotNestedLessLess;</code> <td> U+02AA1 U+00338 <td> <span class="glyph compound">⪡̸</span> <tr id=entity-notni><td> <code>notni;</code> <td> U+0220C <td> <span class=glyph>∌</span> <tr id=entity-notniva><td> <code>notniva;</code> <td> U+0220C <td> <span class=glyph>∌</span> <tr id=entity-notnivb><td> <code>notnivb;</code> <td> U+022FE <td> <span class=glyph>⋾</span> <tr id=entity-notnivc><td> <code>notnivc;</code> <td> U+022FD <td> <span class=glyph>⋽</span> <tr id=entity-NotPrecedes><td> <code>NotPrecedes;</code> <td> U+02280 <td> <span class=glyph>⊀</span> <tr id=entity-NotPrecedesEqual><td> <code>NotPrecedesEqual;</code> <td> U+02AAF U+00338 <td> <span class="glyph compound">⪯̸</span> <tr id=entity-NotPrecedesSlantEqual><td> <code>NotPrecedesSlantEqual;</code> <td> U+022E0 <td> <span class=glyph>⋠</span> <tr id=entity-NotReverseElement><td> <code>NotReverseElement;</code> <td> U+0220C <td> <span class=glyph>∌</span> <tr id=entity-NotRightTriangle><td> <code>NotRightTriangle;</code> <td> U+022EB <td> <span class=glyph>⋫</span> <tr id=entity-NotRightTriangleBar><td> <code>NotRightTriangleBar;</code> <td> U+029D0 U+00338 <td> <span class="glyph compound">⧐̸</span> <tr id=entity-NotRightTriangleEqual><td> <code>NotRightTriangleEqual;</code> <td> U+022ED <td> <span class=glyph>⋭</span> <tr id=entity-NotSquareSubset><td> <code>NotSquareSubset;</code> <td> U+0228F U+00338 <td> <span class="glyph compound">⊏̸</span> <tr id=entity-NotSquareSubsetEqual><td> <code>NotSquareSubsetEqual;</code> <td> U+022E2 <td> <span class=glyph>⋢</span> <tr id=entity-NotSquareSuperset><td> <code>NotSquareSuperset;</code> <td> U+02290 U+00338 <td> <span class="glyph compound">⊐̸</span> <tr id=entity-NotSquareSupersetEqual><td> <code>NotSquareSupersetEqual;</code> <td> U+022E3 <td> <span class=glyph>⋣</span> <tr id=entity-NotSubset><td> <code>NotSubset;</code> <td> U+02282 U+020D2 <td> <span class="glyph compound">⊂⃒</span> <tr id=entity-NotSubsetEqual><td> <code>NotSubsetEqual;</code> <td> U+02288 <td> <span class=glyph>⊈</span> <tr id=entity-NotSucceeds><td> <code>NotSucceeds;</code> <td> U+02281 <td> <span class=glyph>⊁</span> <tr id=entity-NotSucceedsEqual><td> <code>NotSucceedsEqual;</code> <td> U+02AB0 U+00338 <td> <span class="glyph compound">⪰̸</span> <tr id=entity-NotSucceedsSlantEqual><td> <code>NotSucceedsSlantEqual;</code> <td> U+022E1 <td> <span class=glyph>⋡</span> <tr id=entity-NotSucceedsTilde><td> <code>NotSucceedsTilde;</code> <td> U+0227F U+00338 <td> <span class="glyph compound">≿̸</span> <tr id=entity-NotSuperset><td> <code>NotSuperset;</code> <td> U+02283 U+020D2 <td> <span class="glyph compound">⊃⃒</span> <tr id=entity-NotSupersetEqual><td> <code>NotSupersetEqual;</code> <td> U+02289 <td> <span class=glyph>⊉</span> <tr id=entity-NotTilde><td> <code>NotTilde;</code> <td> U+02241 <td> <span class=glyph>≁</span> <tr id=entity-NotTildeEqual><td> <code>NotTildeEqual;</code> <td> U+02244 <td> <span class=glyph>≄</span> <tr id=entity-NotTildeFullEqual><td> <code>NotTildeFullEqual;</code> <td> U+02247 <td> <span class=glyph>≇</span> <tr id=entity-NotTildeTilde><td> <code>NotTildeTilde;</code> <td> U+02249 <td> <span class=glyph>≉</span> <tr id=entity-NotVerticalBar><td> <code>NotVerticalBar;</code> <td> U+02224 <td> <span class=glyph>∤</span> <tr id=entity-npar><td> <code>npar;</code> <td> U+02226 <td> <span class=glyph>∦</span> <tr id=entity-nparallel><td> <code>nparallel;</code> <td> U+02226 <td> <span class=glyph>∦</span> <tr id=entity-nparsl><td> <code>nparsl;</code> <td> U+02AFD U+020E5 <td> <span class="glyph compound">⫽⃥</span> <tr id=entity-npart><td> <code>npart;</code> <td> U+02202 U+00338 <td> <span class="glyph compound">∂̸</span> <tr id=entity-npolint><td> <code>npolint;</code> <td> U+02A14 <td> <span class=glyph>⨔</span> <tr id=entity-npr><td> <code>npr;</code> <td> U+02280 <td> <span class=glyph>⊀</span> <tr id=entity-nprcue><td> <code>nprcue;</code> <td> U+022E0 <td> <span class=glyph>⋠</span> <tr id=entity-npre><td> <code>npre;</code> <td> U+02AAF U+00338 <td> <span class="glyph compound">⪯̸</span> <tr id=entity-nprec><td> <code>nprec;</code> <td> U+02280 <td> <span class=glyph>⊀</span> <tr id=entity-npreceq><td> <code>npreceq;</code> <td> U+02AAF U+00338 <td> <span class="glyph compound">⪯̸</span> <tr id=entity-nrArr><td> <code>nrArr;</code> <td> U+021CF <td> <span class=glyph>⇏</span> <tr id=entity-nrarr><td> <code>nrarr;</code> <td> U+0219B <td> <span class=glyph>↛</span> <tr id=entity-nrarrc><td> <code>nrarrc;</code> <td> U+02933 U+00338 <td> <span class="glyph compound">⤳̸</span> <tr id=entity-nrarrw><td> <code>nrarrw;</code> <td> U+0219D U+00338 <td> <span class="glyph compound">↝̸</span> <tr id=entity-nRightarrow><td> <code>nRightarrow;</code> <td> U+021CF <td> <span class=glyph>⇏</span> <tr id=entity-nrightarrow><td> <code>nrightarrow;</code> <td> U+0219B <td> <span class=glyph>↛</span> <tr id=entity-nrtri><td> <code>nrtri;</code> <td> U+022EB <td> <span class=glyph>⋫</span> <tr id=entity-nrtrie><td> <code>nrtrie;</code> <td> U+022ED <td> <span class=glyph>⋭</span> <tr id=entity-nsc><td> <code>nsc;</code> <td> U+02281 <td> <span class=glyph>⊁</span> <tr id=entity-nsccue><td> <code>nsccue;</code> <td> U+022E1 <td> <span class=glyph>⋡</span> <tr id=entity-nsce><td> <code>nsce;</code> <td> U+02AB0 U+00338 <td> <span class="glyph compound">⪰̸</span> <tr id=entity-Nscr><td> <code>Nscr;</code> <td> U+1D4A9 <td> <span class=glyph>𝒩</span> <tr id=entity-nscr><td> <code>nscr;</code> <td> U+1D4C3 <td> <span class=glyph>𝓃</span> <tr id=entity-nshortmid><td> <code>nshortmid;</code> <td> U+02224 <td> <span class=glyph>∤</span> <tr id=entity-nshortparallel><td> <code>nshortparallel;</code> <td> U+02226 <td> <span class=glyph>∦</span> <tr id=entity-nsim><td> <code>nsim;</code> <td> U+02241 <td> <span class=glyph>≁</span> <tr id=entity-nsime><td> <code>nsime;</code> <td> U+02244 <td> <span class=glyph>≄</span> <tr id=entity-nsimeq><td> <code>nsimeq;</code> <td> U+02244 <td> <span class=glyph>≄</span> <tr id=entity-nsmid><td> <code>nsmid;</code> <td> U+02224 <td> <span class=glyph>∤</span> <tr id=entity-nspar><td> <code>nspar;</code> <td> U+02226 <td> <span class=glyph>∦</span> <tr id=entity-nsqsube><td> <code>nsqsube;</code> <td> U+022E2 <td> <span class=glyph>⋢</span> <tr id=entity-nsqsupe><td> <code>nsqsupe;</code> <td> U+022E3 <td> <span class=glyph>⋣</span> <tr id=entity-nsub><td> <code>nsub;</code> <td> U+02284 <td> <span class=glyph>⊄</span> <tr id=entity-nsubE><td> <code>nsubE;</code> <td> U+02AC5 U+00338 <td> <span class="glyph compound">⫅̸</span> <tr id=entity-nsube><td> <code>nsube;</code> <td> U+02288 <td> <span class=glyph>⊈</span> <tr id=entity-nsubset><td> <code>nsubset;</code> <td> U+02282 U+020D2 <td> <span class="glyph compound">⊂⃒</span> <tr id=entity-nsubseteq><td> <code>nsubseteq;</code> <td> U+02288 <td> <span class=glyph>⊈</span> <tr id=entity-nsubseteqq><td> <code>nsubseteqq;</code> <td> U+02AC5 U+00338 <td> <span class="glyph compound">⫅̸</span> <tr id=entity-nsucc><td> <code>nsucc;</code> <td> U+02281 <td> <span class=glyph>⊁</span> <tr id=entity-nsucceq><td> <code>nsucceq;</code> <td> U+02AB0 U+00338 <td> <span class="glyph compound">⪰̸</span> <tr id=entity-nsup><td> <code>nsup;</code> <td> U+02285 <td> <span class=glyph>⊅</span> <tr id=entity-nsupE><td> <code>nsupE;</code> <td> U+02AC6 U+00338 <td> <span class="glyph compound">⫆̸</span> <tr id=entity-nsupe><td> <code>nsupe;</code> <td> U+02289 <td> <span class=glyph>⊉</span> <tr id=entity-nsupset><td> <code>nsupset;</code> <td> U+02283 U+020D2 <td> <span class="glyph compound">⊃⃒</span> <tr id=entity-nsupseteq><td> <code>nsupseteq;</code> <td> U+02289 <td> <span class=glyph>⊉</span> <tr id=entity-nsupseteqq><td> <code>nsupseteqq;</code> <td> U+02AC6 U+00338 <td> <span class="glyph compound">⫆̸</span> <tr id=entity-ntgl><td> <code>ntgl;</code> <td> U+02279 <td> <span class=glyph>≹</span> <tr id=entity-Ntilde><td> <code>Ntilde;</code> <td> U+000D1 <td> <span class=glyph>Ñ</span> <tr id=entity-Ntilde-legacy class=impl><td> <code>Ntilde</code> <td> U+000D1 <td> <span>Ñ</span> <tr id=entity-ntilde><td> <code>ntilde;</code> <td> U+000F1 <td> <span class=glyph>ñ</span> <tr id=entity-ntilde-legacy class=impl><td> <code>ntilde</code> <td> U+000F1 <td> <span>ñ</span> <tr id=entity-ntlg><td> <code>ntlg;</code> <td> U+02278 <td> <span class=glyph>≸</span> <tr id=entity-ntriangleleft><td> <code>ntriangleleft;</code> <td> U+022EA <td> <span class=glyph>⋪</span> <tr id=entity-ntrianglelefteq><td> <code>ntrianglelefteq;</code> <td> U+022EC <td> <span class=glyph>⋬</span> <tr id=entity-ntriangleright><td> <code>ntriangleright;</code> <td> U+022EB <td> <span class=glyph>⋫</span> <tr id=entity-ntrianglerighteq><td> <code>ntrianglerighteq;</code> <td> U+022ED <td> <span class=glyph>⋭</span> <tr id=entity-Nu><td> <code>Nu;</code> <td> U+0039D <td> <span class=glyph>Ν</span> <tr id=entity-nu><td> <code>nu;</code> <td> U+003BD <td> <span class=glyph>ν</span> <tr id=entity-num><td> <code>num;</code> <td> U+00023 <td> <span class=glyph>#</span> <tr id=entity-numero><td> <code>numero;</code> <td> U+02116 <td> <span class=glyph>№</span> <tr id=entity-numsp><td> <code>numsp;</code> <td> U+02007 <td> <span class=glyph> </span> <tr id=entity-nvap><td> <code>nvap;</code> <td> U+0224D U+020D2 <td> <span class="glyph compound">≍⃒</span> <tr id=entity-nVDash><td> <code>nVDash;</code> <td> U+022AF <td> <span class=glyph>⊯</span> <tr id=entity-nVdash><td> <code>nVdash;</code> <td> U+022AE <td> <span class=glyph>⊮</span> <tr id=entity-nvDash><td> <code>nvDash;</code> <td> U+022AD <td> <span class=glyph>⊭</span> <tr id=entity-nvdash><td> <code>nvdash;</code> <td> U+022AC <td> <span class=glyph>⊬</span> <tr id=entity-nvge><td> <code>nvge;</code> <td> U+02265 U+020D2 <td> <span class="glyph compound">≥⃒</span> <tr id=entity-nvgt><td> <code>nvgt;</code> <td> U+0003E U+020D2 <td> <span class="glyph compound">>⃒</span> <tr id=entity-nvHarr><td> <code>nvHarr;</code> <td> U+02904 <td> <span class=glyph>⤄</span> <tr id=entity-nvinfin><td> <code>nvinfin;</code> <td> U+029DE <td> <span class=glyph>⧞</span> <tr id=entity-nvlArr><td> <code>nvlArr;</code> <td> U+02902 <td> <span class=glyph>⤂</span> <tr id=entity-nvle><td> <code>nvle;</code> <td> U+02264 U+020D2 <td> <span class="glyph compound">≤⃒</span> <tr id=entity-nvlt><td> <code>nvlt;</code> <td> U+0003C U+020D2 <td> <span class="glyph compound">&lt;⃒</span> <tr id=entity-nvltrie><td> <code>nvltrie;</code> <td> U+022B4 U+020D2 <td> <span class="glyph compound">⊴⃒</span> <tr id=entity-nvrArr><td> <code>nvrArr;</code> <td> U+02903 <td> <span class=glyph>⤃</span> <tr id=entity-nvrtrie><td> <code>nvrtrie;</code> <td> U+022B5 U+020D2 <td> <span class="glyph compound">⊵⃒</span> <tr id=entity-nvsim><td> <code>nvsim;</code> <td> U+0223C U+020D2 <td> <span class="glyph compound">∼⃒</span> <tr id=entity-nwarhk><td> <code>nwarhk;</code> <td> U+02923 <td> <span class=glyph>⤣</span> <tr id=entity-nwArr><td> <code>nwArr;</code> <td> U+021D6 <td> <span class=glyph>⇖</span> <tr id=entity-nwarr><td> <code>nwarr;</code> <td> U+02196 <td> <span class=glyph>↖</span> <tr id=entity-nwarrow><td> <code>nwarrow;</code> <td> U+02196 <td> <span class=glyph>↖</span> <tr id=entity-nwnear><td> <code>nwnear;</code> <td> U+02927 <td> <span class=glyph>⤧</span> <tr id=entity-Oacute><td> <code>Oacute;</code> <td> U+000D3 <td> <span class=glyph>Ó</span> <tr id=entity-Oacute-legacy class=impl><td> <code>Oacute</code> <td> U+000D3 <td> <span>Ó</span> <tr id=entity-oacute><td> <code>oacute;</code> <td> U+000F3 <td> <span class=glyph>ó</span> <tr id=entity-oacute-legacy class=impl><td> <code>oacute</code> <td> U+000F3 <td> <span>ó</span> <tr id=entity-oast><td> <code>oast;</code> <td> U+0229B <td> <span class=glyph>⊛</span> <tr id=entity-ocir><td> <code>ocir;</code> <td> U+0229A <td> <span class=glyph>⊚</span> <tr id=entity-Ocirc><td> <code>Ocirc;</code> <td> U+000D4 <td> <span class=glyph>Ô</span> <tr id=entity-Ocirc-legacy class=impl><td> <code>Ocirc</code> <td> U+000D4 <td> <span>Ô</span> <tr id=entity-ocirc><td> <code>ocirc;</code> <td> U+000F4 <td> <span class=glyph>ô</span> <tr id=entity-ocirc-legacy class=impl><td> <code>ocirc</code> <td> U+000F4 <td> <span>ô</span> <tr id=entity-Ocy><td> <code>Ocy;</code> <td> U+0041E <td> <span class=glyph>О</span> <tr id=entity-ocy><td> <code>ocy;</code> <td> U+0043E <td> <span class=glyph>о</span> <tr id=entity-odash><td> <code>odash;</code> <td> U+0229D <td> <span class=glyph>⊝</span> <tr id=entity-Odblac><td> <code>Odblac;</code> <td> U+00150 <td> <span class=glyph>Ő</span> <tr id=entity-odblac><td> <code>odblac;</code> <td> U+00151 <td> <span class=glyph>ő</span> <tr id=entity-odiv><td> <code>odiv;</code> <td> U+02A38 <td> <span class=glyph>⨸</span> <tr id=entity-odot><td> <code>odot;</code> <td> U+02299 <td> <span class=glyph>⊙</span> <tr id=entity-odsold><td> <code>odsold;</code> <td> U+029BC <td> <span class=glyph>⦼</span> <tr id=entity-OElig><td> <code>OElig;</code> <td> U+00152 <td> <span class=glyph>Œ</span> <tr id=entity-oelig><td> <code>oelig;</code> <td> U+00153 <td> <span class=glyph>œ</span> <tr id=entity-ofcir><td> <code>ofcir;</code> <td> U+029BF <td> <span class=glyph>⦿</span> <tr id=entity-Ofr><td> <code>Ofr;</code> <td> U+1D512 <td> <span class=glyph>𝔒</span> <tr id=entity-ofr><td> <code>ofr;</code> <td> U+1D52C <td> <span class=glyph>𝔬</span> <tr id=entity-ogon><td> <code>ogon;</code> <td> U+002DB <td> <span class=glyph>˛</span> <tr id=entity-Ograve><td> <code>Ograve;</code> <td> U+000D2 <td> <span class=glyph>Ò</span> <tr id=entity-Ograve-legacy class=impl><td> <code>Ograve</code> <td> U+000D2 <td> <span>Ò</span> <tr id=entity-ograve><td> <code>ograve;</code> <td> U+000F2 <td> <span class=glyph>ò</span> <tr id=entity-ograve-legacy class=impl><td> <code>ograve</code> <td> U+000F2 <td> <span>ò</span> <tr id=entity-ogt><td> <code>ogt;</code> <td> U+029C1 <td> <span class=glyph>⧁</span> <tr id=entity-ohbar><td> <code>ohbar;</code> <td> U+029B5 <td> <span class=glyph>⦵</span> <tr id=entity-ohm><td> <code>ohm;</code> <td> U+003A9 <td> <span class=glyph>Ω</span> <tr id=entity-oint><td> <code>oint;</code> <td> U+0222E <td> <span class=glyph>∮</span> <tr id=entity-olarr><td> <code>olarr;</code> <td> U+021BA <td> <span class=glyph>↺</span> <tr id=entity-olcir><td> <code>olcir;</code> <td> U+029BE <td> <span class=glyph>⦾</span> <tr id=entity-olcross><td> <code>olcross;</code> <td> U+029BB <td> <span class=glyph>⦻</span> <tr id=entity-oline><td> <code>oline;</code> <td> U+0203E <td> <span class=glyph>‾</span> <tr id=entity-olt><td> <code>olt;</code> <td> U+029C0 <td> <span class=glyph>⧀</span> <tr id=entity-Omacr><td> <code>Omacr;</code> <td> U+0014C <td> <span class=glyph>Ō</span> <tr id=entity-omacr><td> <code>omacr;</code> <td> U+0014D <td> <span class=glyph>ō</span> <tr id=entity-Omega><td> <code>Omega;</code> <td> U+003A9 <td> <span class=glyph>Ω</span> <tr id=entity-omega><td> <code>omega;</code> <td> U+003C9 <td> <span class=glyph>ω</span> <tr id=entity-Omicron><td> <code>Omicron;</code> <td> U+0039F <td> <span class=glyph>Ο</span> <tr id=entity-omicron><td> <code>omicron;</code> <td> U+003BF <td> <span class=glyph>ο</span> <tr id=entity-omid><td> <code>omid;</code> <td> U+029B6 <td> <span class=glyph>⦶</span> <tr id=entity-ominus><td> <code>ominus;</code> <td> U+02296 <td> <span class=glyph>⊖</span> <tr id=entity-Oopf><td> <code>Oopf;</code> <td> U+1D546 <td> <span class=glyph>𝕆</span> <tr id=entity-oopf><td> <code>oopf;</code> <td> U+1D560 <td> <span class=glyph>𝕠</span> <tr id=entity-opar><td> <code>opar;</code> <td> U+029B7 <td> <span class=glyph>⦷</span> <tr id=entity-OpenCurlyDoubleQuote><td> <code>OpenCurlyDoubleQuote;</code> <td> U+0201C <td> <span class=glyph>“</span> <tr id=entity-OpenCurlyQuote><td> <code>OpenCurlyQuote;</code> <td> U+02018 <td> <span class=glyph>‘</span> <tr id=entity-operp><td> <code>operp;</code> <td> U+029B9 <td> <span class=glyph>⦹</span> <tr id=entity-oplus><td> <code>oplus;</code> <td> U+02295 <td> <span class=glyph>⊕</span> <tr id=entity-Or><td> <code>Or;</code> <td> U+02A54 <td> <span class=glyph>⩔</span> <tr id=entity-or><td> <code>or;</code> <td> U+02228 <td> <span class=glyph>∨</span> <tr id=entity-orarr><td> <code>orarr;</code> <td> U+021BB <td> <span class=glyph>↻</span> <tr id=entity-ord><td> <code>ord;</code> <td> U+02A5D <td> <span class=glyph>⩝</span> <tr id=entity-order><td> <code>order;</code> <td> U+02134 <td> <span class=glyph>ℴ</span> <tr id=entity-orderof><td> <code>orderof;</code> <td> U+02134 <td> <span class=glyph>ℴ</span> <tr id=entity-ordf><td> <code>ordf;</code> <td> U+000AA <td> <span class=glyph>ª</span> <tr id=entity-ordf-legacy class=impl><td> <code>ordf</code> <td> U+000AA <td> <span>ª</span> <tr id=entity-ordm><td> <code>ordm;</code> <td> U+000BA <td> <span class=glyph>º</span> <tr id=entity-ordm-legacy class=impl><td> <code>ordm</code> <td> U+000BA <td> <span>º</span> <tr id=entity-origof><td> <code>origof;</code> <td> U+022B6 <td> <span class=glyph>⊶</span> <tr id=entity-oror><td> <code>oror;</code> <td> U+02A56 <td> <span class=glyph>⩖</span> <tr id=entity-orslope><td> <code>orslope;</code> <td> U+02A57 <td> <span class=glyph>⩗</span> <tr id=entity-orv><td> <code>orv;</code> <td> U+02A5B <td> <span class=glyph>⩛</span> <tr id=entity-oS><td> <code>oS;</code> <td> U+024C8 <td> <span class=glyph>Ⓢ</span> <tr id=entity-Oscr><td> <code>Oscr;</code> <td> U+1D4AA <td> <span class=glyph>𝒪</span> <tr id=entity-oscr><td> <code>oscr;</code> <td> U+02134 <td> <span class=glyph>ℴ</span> <tr id=entity-Oslash><td> <code>Oslash;</code> <td> U+000D8 <td> <span class=glyph>Ø</span> <tr id=entity-Oslash-legacy class=impl><td> <code>Oslash</code> <td> U+000D8 <td> <span>Ø</span> <tr id=entity-oslash><td> <code>oslash;</code> <td> U+000F8 <td> <span class=glyph>ø</span> <tr id=entity-oslash-legacy class=impl><td> <code>oslash</code> <td> U+000F8 <td> <span>ø</span> <tr id=entity-osol><td> <code>osol;</code> <td> U+02298 <td> <span class=glyph>⊘</span> <tr id=entity-Otilde><td> <code>Otilde;</code> <td> U+000D5 <td> <span class=glyph>Õ</span> <tr id=entity-Otilde-legacy class=impl><td> <code>Otilde</code> <td> U+000D5 <td> <span>Õ</span> <tr id=entity-otilde><td> <code>otilde;</code> <td> U+000F5 <td> <span class=glyph>õ</span> <tr id=entity-otilde-legacy class=impl><td> <code>otilde</code> <td> U+000F5 <td> <span>õ</span> <tr id=entity-Otimes><td> <code>Otimes;</code> <td> U+02A37 <td> <span class=glyph>⨷</span> <tr id=entity-otimes><td> <code>otimes;</code> <td> U+02297 <td> <span class=glyph>⊗</span> <tr id=entity-otimesas><td> <code>otimesas;</code> <td> U+02A36 <td> <span class=glyph>⨶</span> <tr id=entity-Ouml><td> <code>Ouml;</code> <td> U+000D6 <td> <span class=glyph>Ö</span> <tr id=entity-Ouml-legacy class=impl><td> <code>Ouml</code> <td> U+000D6 <td> <span>Ö</span> <tr id=entity-ouml><td> <code>ouml;</code> <td> U+000F6 <td> <span class=glyph>ö</span> <tr id=entity-ouml-legacy class=impl><td> <code>ouml</code> <td> U+000F6 <td> <span>ö</span> <tr id=entity-ovbar><td> <code>ovbar;</code> <td> U+0233D <td> <span class=glyph>⌽</span> <tr id=entity-OverBar><td> <code>OverBar;</code> <td> U+0203E <td> <span class=glyph>‾</span> <tr id=entity-OverBrace><td> <code>OverBrace;</code> <td> U+023DE <td> <span class=glyph>⏞</span> <tr id=entity-OverBracket><td> <code>OverBracket;</code> <td> U+023B4 <td> <span class=glyph>⎴</span> <tr id=entity-OverParenthesis><td> <code>OverParenthesis;</code> <td> U+023DC <td> <span class=glyph>⏜</span> <tr id=entity-par><td> <code>par;</code> <td> U+02225 <td> <span class=glyph>∥</span> <tr id=entity-para><td> <code>para;</code> <td> U+000B6 <td> <span class=glyph>¶</span> <tr id=entity-para-legacy class=impl><td> <code>para</code> <td> U+000B6 <td> <span>¶</span> <tr id=entity-parallel><td> <code>parallel;</code> <td> U+02225 <td> <span class=glyph>∥</span> <tr id=entity-parsim><td> <code>parsim;</code> <td> U+02AF3 <td> <span class=glyph>⫳</span> <tr id=entity-parsl><td> <code>parsl;</code> <td> U+02AFD <td> <span class=glyph>⫽</span> <tr id=entity-part><td> <code>part;</code> <td> U+02202 <td> <span class=glyph>∂</span> <tr id=entity-PartialD><td> <code>PartialD;</code> <td> U+02202 <td> <span class=glyph>∂</span> <tr id=entity-Pcy><td> <code>Pcy;</code> <td> U+0041F <td> <span class=glyph>П</span> <tr id=entity-pcy><td> <code>pcy;</code> <td> U+0043F <td> <span class=glyph>п</span> <tr id=entity-percnt><td> <code>percnt;</code> <td> U+00025 <td> <span class=glyph>%</span> <tr id=entity-period><td> <code>period;</code> <td> U+0002E <td> <span class=glyph>.</span> <tr id=entity-permil><td> <code>permil;</code> <td> U+02030 <td> <span class=glyph>‰</span> <tr id=entity-perp><td> <code>perp;</code> <td> U+022A5 <td> <span class=glyph>⊥</span> <tr id=entity-pertenk><td> <code>pertenk;</code> <td> U+02031 <td> <span class=glyph>‱</span> <tr id=entity-Pfr><td> <code>Pfr;</code> <td> U+1D513 <td> <span class=glyph>𝔓</span> <tr id=entity-pfr><td> <code>pfr;</code> <td> U+1D52D <td> <span class=glyph>𝔭</span> <tr id=entity-Phi><td> <code>Phi;</code> <td> U+003A6 <td> <span class=glyph>Φ</span> <tr id=entity-phi><td> <code>phi;</code> <td> U+003C6 <td> <span class=glyph>φ</span> <tr id=entity-phiv><td> <code>phiv;</code> <td> U+003D5 <td> <span class=glyph>ϕ</span> <tr id=entity-phmmat><td> <code>phmmat;</code> <td> U+02133 <td> <span class=glyph>ℳ</span> <tr id=entity-phone><td> <code>phone;</code> <td> U+0260E <td> <span class=glyph>☎</span> <tr id=entity-Pi><td> <code>Pi;</code> <td> U+003A0 <td> <span class=glyph>Π</span> <tr id=entity-pi><td> <code>pi;</code> <td> U+003C0 <td> <span class=glyph>π</span> <tr id=entity-pitchfork><td> <code>pitchfork;</code> <td> U+022D4 <td> <span class=glyph>⋔</span> <tr id=entity-piv><td> <code>piv;</code> <td> U+003D6 <td> <span class=glyph>ϖ</span> <tr id=entity-planck><td> <code>planck;</code> <td> U+0210F <td> <span class=glyph>ℏ</span> <tr id=entity-planckh><td> <code>planckh;</code> <td> U+0210E <td> <span class=glyph>ℎ</span> <tr id=entity-plankv><td> <code>plankv;</code> <td> U+0210F <td> <span class=glyph>ℏ</span> <tr id=entity-plus><td> <code>plus;</code> <td> U+0002B <td> <span class=glyph>+</span> <tr id=entity-plusacir><td> <code>plusacir;</code> <td> U+02A23 <td> <span class=glyph>⨣</span> <tr id=entity-plusb><td> <code>plusb;</code> <td> U+0229E <td> <span class=glyph>⊞</span> <tr id=entity-pluscir><td> <code>pluscir;</code> <td> U+02A22 <td> <span class=glyph>⨢</span> <tr id=entity-plusdo><td> <code>plusdo;</code> <td> U+02214 <td> <span class=glyph>∔</span> <tr id=entity-plusdu><td> <code>plusdu;</code> <td> U+02A25 <td> <span class=glyph>⨥</span> <tr id=entity-pluse><td> <code>pluse;</code> <td> U+02A72 <td> <span class=glyph>⩲</span> <tr id=entity-PlusMinus><td> <code>PlusMinus;</code> <td> U+000B1 <td> <span class=glyph>±</span> <tr id=entity-plusmn><td> <code>plusmn;</code> <td> U+000B1 <td> <span class=glyph>±</span> <tr id=entity-plusmn-legacy class=impl><td> <code>plusmn</code> <td> U+000B1 <td> <span>±</span> <tr id=entity-plussim><td> <code>plussim;</code> <td> U+02A26 <td> <span class=glyph>⨦</span> <tr id=entity-plustwo><td> <code>plustwo;</code> <td> U+02A27 <td> <span class=glyph>⨧</span> <tr id=entity-pm><td> <code>pm;</code> <td> U+000B1 <td> <span class=glyph>±</span> <tr id=entity-Poincareplane><td> <code>Poincareplane;</code> <td> U+0210C <td> <span class=glyph>ℌ</span> <tr id=entity-pointint><td> <code>pointint;</code> <td> U+02A15 <td> <span class=glyph>⨕</span> <tr id=entity-Popf><td> <code>Popf;</code> <td> U+02119 <td> <span class=glyph>ℙ</span> <tr id=entity-popf><td> <code>popf;</code> <td> U+1D561 <td> <span class=glyph>𝕡</span> <tr id=entity-pound><td> <code>pound;</code> <td> U+000A3 <td> <span class=glyph>£</span> <tr id=entity-pound-legacy class=impl><td> <code>pound</code> <td> U+000A3 <td> <span>£</span> <tr id=entity-Pr><td> <code>Pr;</code> <td> U+02ABB <td> <span class=glyph>⪻</span> <tr id=entity-pr><td> <code>pr;</code> <td> U+0227A <td> <span class=glyph>≺</span> <tr id=entity-prap><td> <code>prap;</code> <td> U+02AB7 <td> <span class=glyph>⪷</span> <tr id=entity-prcue><td> <code>prcue;</code> <td> U+0227C <td> <span class=glyph>≼</span> <tr id=entity-prE><td> <code>prE;</code> <td> U+02AB3 <td> <span class=glyph>⪳</span> <tr id=entity-pre><td> <code>pre;</code> <td> U+02AAF <td> <span class=glyph>⪯</span> <tr id=entity-prec><td> <code>prec;</code> <td> U+0227A <td> <span class=glyph>≺</span> <tr id=entity-precapprox><td> <code>precapprox;</code> <td> U+02AB7 <td> <span class=glyph>⪷</span> <tr id=entity-preccurlyeq><td> <code>preccurlyeq;</code> <td> U+0227C <td> <span class=glyph>≼</span> <tr id=entity-Precedes><td> <code>Precedes;</code> <td> U+0227A <td> <span class=glyph>≺</span> <tr id=entity-PrecedesEqual><td> <code>PrecedesEqual;</code> <td> U+02AAF <td> <span class=glyph>⪯</span> <tr id=entity-PrecedesSlantEqual><td> <code>PrecedesSlantEqual;</code> <td> U+0227C <td> <span class=glyph>≼</span> <tr id=entity-PrecedesTilde><td> <code>PrecedesTilde;</code> <td> U+0227E <td> <span class=glyph>≾</span> <tr id=entity-preceq><td> <code>preceq;</code> <td> U+02AAF <td> <span class=glyph>⪯</span> <tr id=entity-precnapprox><td> <code>precnapprox;</code> <td> U+02AB9 <td> <span class=glyph>⪹</span> <tr id=entity-precneqq><td> <code>precneqq;</code> <td> U+02AB5 <td> <span class=glyph>⪵</span> <tr id=entity-precnsim><td> <code>precnsim;</code> <td> U+022E8 <td> <span class=glyph>⋨</span> <tr id=entity-precsim><td> <code>precsim;</code> <td> U+0227E <td> <span class=glyph>≾</span> <tr id=entity-Prime><td> <code>Prime;</code> <td> U+02033 <td> <span class=glyph>″</span> <tr id=entity-prime><td> <code>prime;</code> <td> U+02032 <td> <span class=glyph>′</span> <tr id=entity-primes><td> <code>primes;</code> <td> U+02119 <td> <span class=glyph>ℙ</span> <tr id=entity-prnap><td> <code>prnap;</code> <td> U+02AB9 <td> <span class=glyph>⪹</span> <tr id=entity-prnE><td> <code>prnE;</code> <td> U+02AB5 <td> <span class=glyph>⪵</span> <tr id=entity-prnsim><td> <code>prnsim;</code> <td> U+022E8 <td> <span class=glyph>⋨</span> <tr id=entity-prod><td> <code>prod;</code> <td> U+0220F <td> <span class=glyph>∏</span> <tr id=entity-Product><td> <code>Product;</code> <td> U+0220F <td> <span class=glyph>∏</span> <tr id=entity-profalar><td> <code>profalar;</code> <td> U+0232E <td> <span class=glyph>⌮</span> <tr id=entity-profline><td> <code>profline;</code> <td> U+02312 <td> <span class=glyph>⌒</span> <tr id=entity-profsurf><td> <code>profsurf;</code> <td> U+02313 <td> <span class=glyph>⌓</span> <tr id=entity-prop><td> <code>prop;</code> <td> U+0221D <td> <span class=glyph>∝</span> <tr id=entity-Proportion><td> <code>Proportion;</code> <td> U+02237 <td> <span class=glyph>∷</span> <tr id=entity-Proportional><td> <code>Proportional;</code> <td> U+0221D <td> <span class=glyph>∝</span> <tr id=entity-propto><td> <code>propto;</code> <td> U+0221D <td> <span class=glyph>∝</span> <tr id=entity-prsim><td> <code>prsim;</code> <td> U+0227E <td> <span class=glyph>≾</span> <tr id=entity-prurel><td> <code>prurel;</code> <td> U+022B0 <td> <span class=glyph>⊰</span> <tr id=entity-Pscr><td> <code>Pscr;</code> <td> U+1D4AB <td> <span class=glyph>𝒫</span> <tr id=entity-pscr><td> <code>pscr;</code> <td> U+1D4C5 <td> <span class=glyph>𝓅</span> <tr id=entity-Psi><td> <code>Psi;</code> <td> U+003A8 <td> <span class=glyph>Ψ</span> <tr id=entity-psi><td> <code>psi;</code> <td> U+003C8 <td> <span class=glyph>ψ</span> <tr id=entity-puncsp><td> <code>puncsp;</code> <td> U+02008 <td> <span class=glyph> </span> <tr id=entity-Qfr><td> <code>Qfr;</code> <td> U+1D514 <td> <span class=glyph>𝔔</span> <tr id=entity-qfr><td> <code>qfr;</code> <td> U+1D52E <td> <span class=glyph>𝔮</span> <tr id=entity-qint><td> <code>qint;</code> <td> U+02A0C <td> <span class=glyph>⨌</span> <tr id=entity-Qopf><td> <code>Qopf;</code> <td> U+0211A <td> <span class=glyph>ℚ</span> <tr id=entity-qopf><td> <code>qopf;</code> <td> U+1D562 <td> <span class=glyph>𝕢</span> <tr id=entity-qprime><td> <code>qprime;</code> <td> U+02057 <td> <span class=glyph>⁗</span> <tr id=entity-Qscr><td> <code>Qscr;</code> <td> U+1D4AC <td> <span class=glyph>𝒬</span> <tr id=entity-qscr><td> <code>qscr;</code> <td> U+1D4C6 <td> <span class=glyph>𝓆</span> <tr id=entity-quaternions><td> <code>quaternions;</code> <td> U+0210D <td> <span class=glyph>ℍ</span> <tr id=entity-quatint><td> <code>quatint;</code> <td> U+02A16 <td> <span class=glyph>⨖</span> <tr id=entity-quest><td> <code>quest;</code> <td> U+0003F <td> <span class=glyph>?</span> <tr id=entity-questeq><td> <code>questeq;</code> <td> U+0225F <td> <span class=glyph>≟</span> <tr id=entity-QUOT><td> <code>QUOT;</code> <td> U+00022 <td> <span class=glyph>"</span> <tr id=entity-QUOT-legacy class=impl><td> <code>QUOT</code> <td> U+00022 <td> <span>"</span> <tr id=entity-quot><td> <code>quot;</code> <td> U+00022 <td> <span class=glyph>"</span> <tr id=entity-quot-legacy class=impl><td> <code>quot</code> <td> U+00022 <td> <span>"</span> <tr id=entity-rAarr><td> <code>rAarr;</code> <td> U+021DB <td> <span class=glyph>⇛</span> <tr id=entity-race><td> <code>race;</code> <td> U+0223D U+00331 <td> <span class="glyph compound">∽̱</span> <tr id=entity-Racute><td> <code>Racute;</code> <td> U+00154 <td> <span class=glyph>Ŕ</span> <tr id=entity-racute><td> <code>racute;</code> <td> U+00155 <td> <span class=glyph>ŕ</span> <tr id=entity-radic><td> <code>radic;</code> <td> U+0221A <td> <span class=glyph>√</span> <tr id=entity-raemptyv><td> <code>raemptyv;</code> <td> U+029B3 <td> <span class=glyph>⦳</span> <tr id=entity-Rang><td> <code>Rang;</code> <td> U+027EB <td> <span class=glyph>⟫</span> <tr id=entity-rang><td> <code>rang;</code> <td> U+027E9 <td> <span class=glyph>⟩</span> <tr id=entity-rangd><td> <code>rangd;</code> <td> U+02992 <td> <span class=glyph>⦒</span> <tr id=entity-range><td> <code>range;</code> <td> U+029A5 <td> <span class=glyph>⦥</span> <tr id=entity-rangle><td> <code>rangle;</code> <td> U+027E9 <td> <span class=glyph>⟩</span> <tr id=entity-raquo><td> <code>raquo;</code> <td> U+000BB <td> <span class=glyph>»</span> <tr id=entity-raquo-legacy class=impl><td> <code>raquo</code> <td> U+000BB <td> <span>»</span> <tr id=entity-Rarr><td> <code>Rarr;</code> <td> U+021A0 <td> <span class=glyph>↠</span> <tr id=entity-rArr><td> <code>rArr;</code> <td> U+021D2 <td> <span class=glyph>⇒</span> <tr id=entity-rarr><td> <code>rarr;</code> <td> U+02192 <td> <span class=glyph>→</span> <tr id=entity-rarrap><td> <code>rarrap;</code> <td> U+02975 <td> <span class=glyph>⥵</span> <tr id=entity-rarrb><td> <code>rarrb;</code> <td> U+021E5 <td> <span class=glyph>⇥</span> <tr id=entity-rarrbfs><td> <code>rarrbfs;</code> <td> U+02920 <td> <span class=glyph>⤠</span> <tr id=entity-rarrc><td> <code>rarrc;</code> <td> U+02933 <td> <span class=glyph>⤳</span> <tr id=entity-rarrfs><td> <code>rarrfs;</code> <td> U+0291E <td> <span class=glyph>⤞</span> <tr id=entity-rarrhk><td> <code>rarrhk;</code> <td> U+021AA <td> <span class=glyph>↪</span> <tr id=entity-rarrlp><td> <code>rarrlp;</code> <td> U+021AC <td> <span class=glyph>↬</span> <tr id=entity-rarrpl><td> <code>rarrpl;</code> <td> U+02945 <td> <span class=glyph>⥅</span> <tr id=entity-rarrsim><td> <code>rarrsim;</code> <td> U+02974 <td> <span class=glyph>⥴</span> <tr id=entity-Rarrtl><td> <code>Rarrtl;</code> <td> U+02916 <td> <span class=glyph>⤖</span> <tr id=entity-rarrtl><td> <code>rarrtl;</code> <td> U+021A3 <td> <span class=glyph>↣</span> <tr id=entity-rarrw><td> <code>rarrw;</code> <td> U+0219D <td> <span class=glyph>↝</span> <tr id=entity-rAtail><td> <code>rAtail;</code> <td> U+0291C <td> <span class=glyph>⤜</span> <tr id=entity-ratail><td> <code>ratail;</code> <td> U+0291A <td> <span class=glyph>⤚</span> <tr id=entity-ratio><td> <code>ratio;</code> <td> U+02236 <td> <span class=glyph>∶</span> <tr id=entity-rationals><td> <code>rationals;</code> <td> U+0211A <td> <span class=glyph>ℚ</span> <tr id=entity-RBarr><td> <code>RBarr;</code> <td> U+02910 <td> <span class=glyph>⤐</span> <tr id=entity-rBarr><td> <code>rBarr;</code> <td> U+0290F <td> <span class=glyph>⤏</span> <tr id=entity-rbarr><td> <code>rbarr;</code> <td> U+0290D <td> <span class=glyph>⤍</span> <tr id=entity-rbbrk><td> <code>rbbrk;</code> <td> U+02773 <td> <span class=glyph>❳</span> <tr id=entity-rbrace><td> <code>rbrace;</code> <td> U+0007D <td> <span class=glyph>}</span> <tr id=entity-rbrack><td> <code>rbrack;</code> <td> U+0005D <td> <span class=glyph>]</span> <tr id=entity-rbrke><td> <code>rbrke;</code> <td> U+0298C <td> <span class=glyph>⦌</span> <tr id=entity-rbrksld><td> <code>rbrksld;</code> <td> U+0298E <td> <span class=glyph>⦎</span> <tr id=entity-rbrkslu><td> <code>rbrkslu;</code> <td> U+02990 <td> <span class=glyph>⦐</span> <tr id=entity-Rcaron><td> <code>Rcaron;</code> <td> U+00158 <td> <span class=glyph>Ř</span> <tr id=entity-rcaron><td> <code>rcaron;</code> <td> U+00159 <td> <span class=glyph>ř</span> <tr id=entity-Rcedil><td> <code>Rcedil;</code> <td> U+00156 <td> <span class=glyph>Ŗ</span> <tr id=entity-rcedil><td> <code>rcedil;</code> <td> U+00157 <td> <span class=glyph>ŗ</span> <tr id=entity-rceil><td> <code>rceil;</code> <td> U+02309 <td> <span class=glyph>⌉</span> <tr id=entity-rcub><td> <code>rcub;</code> <td> U+0007D <td> <span class=glyph>}</span> <tr id=entity-Rcy><td> <code>Rcy;</code> <td> U+00420 <td> <span class=glyph>Р</span> <tr id=entity-rcy><td> <code>rcy;</code> <td> U+00440 <td> <span class=glyph>р</span> <tr id=entity-rdca><td> <code>rdca;</code> <td> U+02937 <td> <span class=glyph>⤷</span> <tr id=entity-rdldhar><td> <code>rdldhar;</code> <td> U+02969 <td> <span class=glyph>⥩</span> <tr id=entity-rdquo><td> <code>rdquo;</code> <td> U+0201D <td> <span class=glyph>”</span> <tr id=entity-rdquor><td> <code>rdquor;</code> <td> U+0201D <td> <span class=glyph>”</span> <tr id=entity-rdsh><td> <code>rdsh;</code> <td> U+021B3 <td> <span class=glyph>↳</span> <tr id=entity-Re><td> <code>Re;</code> <td> U+0211C <td> <span class=glyph>ℜ</span> <tr id=entity-real><td> <code>real;</code> <td> U+0211C <td> <span class=glyph>ℜ</span> <tr id=entity-realine><td> <code>realine;</code> <td> U+0211B <td> <span class=glyph>ℛ</span> <tr id=entity-realpart><td> <code>realpart;</code> <td> U+0211C <td> <span class=glyph>ℜ</span> <tr id=entity-reals><td> <code>reals;</code> <td> U+0211D <td> <span class=glyph>ℝ</span> <tr id=entity-rect><td> <code>rect;</code> <td> U+025AD <td> <span class=glyph>▭</span> <tr id=entity-REG><td> <code>REG;</code> <td> U+000AE <td> <span class=glyph>®</span> <tr id=entity-REG-legacy class=impl><td> <code>REG</code> <td> U+000AE <td> <span>®</span> <tr id=entity-reg><td> <code>reg;</code> <td> U+000AE <td> <span class=glyph>®</span> <tr id=entity-reg-legacy class=impl><td> <code>reg</code> <td> U+000AE <td> <span>®</span> <tr id=entity-ReverseElement><td> <code>ReverseElement;</code> <td> U+0220B <td> <span class=glyph>∋</span> <tr id=entity-ReverseEquilibrium><td> <code>ReverseEquilibrium;</code> <td> U+021CB <td> <span class=glyph>⇋</span> <tr id=entity-ReverseUpEquilibrium><td> <code>ReverseUpEquilibrium;</code> <td> U+0296F <td> <span class=glyph>⥯</span> <tr id=entity-rfisht><td> <code>rfisht;</code> <td> U+0297D <td> <span class=glyph>⥽</span> <tr id=entity-rfloor><td> <code>rfloor;</code> <td> U+0230B <td> <span class=glyph>⌋</span> <tr id=entity-Rfr><td> <code>Rfr;</code> <td> U+0211C <td> <span class=glyph>ℜ</span> <tr id=entity-rfr><td> <code>rfr;</code> <td> U+1D52F <td> <span class=glyph>𝔯</span> <tr id=entity-rHar><td> <code>rHar;</code> <td> U+02964 <td> <span class=glyph>⥤</span> <tr id=entity-rhard><td> <code>rhard;</code> <td> U+021C1 <td> <span class=glyph>⇁</span> <tr id=entity-rharu><td> <code>rharu;</code> <td> U+021C0 <td> <span class=glyph>⇀</span> <tr id=entity-rharul><td> <code>rharul;</code> <td> U+0296C <td> <span class=glyph>⥬</span> <tr id=entity-Rho><td> <code>Rho;</code> <td> U+003A1 <td> <span class=glyph>Ρ</span> <tr id=entity-rho><td> <code>rho;</code> <td> U+003C1 <td> <span class=glyph>ρ</span> <tr id=entity-rhov><td> <code>rhov;</code> <td> U+003F1 <td> <span class=glyph>ϱ</span> <tr id=entity-RightAngleBracket><td> <code>RightAngleBracket;</code> <td> U+027E9 <td> <span class=glyph>⟩</span> <tr id=entity-RightArrow><td> <code>RightArrow;</code> <td> U+02192 <td> <span class=glyph>→</span> <tr id=entity-Rightarrow><td> <code>Rightarrow;</code> <td> U+021D2 <td> <span class=glyph>⇒</span> <tr id=entity-rightarrow><td> <code>rightarrow;</code> <td> U+02192 <td> <span class=glyph>→</span> <tr id=entity-RightArrowBar><td> <code>RightArrowBar;</code> <td> U+021E5 <td> <span class=glyph>⇥</span> <tr id=entity-RightArrowLeftArrow><td> <code>RightArrowLeftArrow;</code> <td> U+021C4 <td> <span class=glyph>⇄</span> <tr id=entity-rightarrowtail><td> <code>rightarrowtail;</code> <td> U+021A3 <td> <span class=glyph>↣</span> <tr id=entity-RightCeiling><td> <code>RightCeiling;</code> <td> U+02309 <td> <span class=glyph>⌉</span> <tr id=entity-RightDoubleBracket><td> <code>RightDoubleBracket;</code> <td> U+027E7 <td> <span class=glyph>⟧</span> <tr id=entity-RightDownTeeVector><td> <code>RightDownTeeVector;</code> <td> U+0295D <td> <span class=glyph>⥝</span> <tr id=entity-RightDownVector><td> <code>RightDownVector;</code> <td> U+021C2 <td> <span class=glyph>⇂</span> <tr id=entity-RightDownVectorBar><td> <code>RightDownVectorBar;</code> <td> U+02955 <td> <span class=glyph>⥕</span> <tr id=entity-RightFloor><td> <code>RightFloor;</code> <td> U+0230B <td> <span class=glyph>⌋</span> <tr id=entity-rightharpoondown><td> <code>rightharpoondown;</code> <td> U+021C1 <td> <span class=glyph>⇁</span> <tr id=entity-rightharpoonup><td> <code>rightharpoonup;</code> <td> U+021C0 <td> <span class=glyph>⇀</span> <tr id=entity-rightleftarrows><td> <code>rightleftarrows;</code> <td> U+021C4 <td> <span class=glyph>⇄</span> <tr id=entity-rightleftharpoons><td> <code>rightleftharpoons;</code> <td> U+021CC <td> <span class=glyph>⇌</span> <tr id=entity-rightrightarrows><td> <code>rightrightarrows;</code> <td> U+021C9 <td> <span class=glyph>⇉</span> <tr id=entity-rightsquigarrow><td> <code>rightsquigarrow;</code> <td> U+0219D <td> <span class=glyph>↝</span> <tr id=entity-RightTee><td> <code>RightTee;</code> <td> U+022A2 <td> <span class=glyph>⊢</span> <tr id=entity-RightTeeArrow><td> <code>RightTeeArrow;</code> <td> U+021A6 <td> <span class=glyph>↦</span> <tr id=entity-RightTeeVector><td> <code>RightTeeVector;</code> <td> U+0295B <td> <span class=glyph>⥛</span> <tr id=entity-rightthreetimes><td> <code>rightthreetimes;</code> <td> U+022CC <td> <span class=glyph>⋌</span> <tr id=entity-RightTriangle><td> <code>RightTriangle;</code> <td> U+022B3 <td> <span class=glyph>⊳</span> <tr id=entity-RightTriangleBar><td> <code>RightTriangleBar;</code> <td> U+029D0 <td> <span class=glyph>⧐</span> <tr id=entity-RightTriangleEqual><td> <code>RightTriangleEqual;</code> <td> U+022B5 <td> <span class=glyph>⊵</span> <tr id=entity-RightUpDownVector><td> <code>RightUpDownVector;</code> <td> U+0294F <td> <span class=glyph>⥏</span> <tr id=entity-RightUpTeeVector><td> <code>RightUpTeeVector;</code> <td> U+0295C <td> <span class=glyph>⥜</span> <tr id=entity-RightUpVector><td> <code>RightUpVector;</code> <td> U+021BE <td> <span class=glyph>↾</span> <tr id=entity-RightUpVectorBar><td> <code>RightUpVectorBar;</code> <td> U+02954 <td> <span class=glyph>⥔</span> <tr id=entity-RightVector><td> <code>RightVector;</code> <td> U+021C0 <td> <span class=glyph>⇀</span> <tr id=entity-RightVectorBar><td> <code>RightVectorBar;</code> <td> U+02953 <td> <span class=glyph>⥓</span> <tr id=entity-ring><td> <code>ring;</code> <td> U+002DA <td> <span class=glyph>˚</span> <tr id=entity-risingdotseq><td> <code>risingdotseq;</code> <td> U+02253 <td> <span class=glyph>≓</span> <tr id=entity-rlarr><td> <code>rlarr;</code> <td> U+021C4 <td> <span class=glyph>⇄</span> <tr id=entity-rlhar><td> <code>rlhar;</code> <td> U+021CC <td> <span class=glyph>⇌</span> <tr id=entity-rlm><td> <code>rlm;</code> <td> U+0200F <td> <span class=glyph>‏</span> <tr id=entity-rmoust><td> <code>rmoust;</code> <td> U+023B1 <td> <span class=glyph>⎱</span> <tr id=entity-rmoustache><td> <code>rmoustache;</code> <td> U+023B1 <td> <span class=glyph>⎱</span> <tr id=entity-rnmid><td> <code>rnmid;</code> <td> U+02AEE <td> <span class=glyph>⫮</span> <tr id=entity-roang><td> <code>roang;</code> <td> U+027ED <td> <span class=glyph>⟭</span> <tr id=entity-roarr><td> <code>roarr;</code> <td> U+021FE <td> <span class=glyph>⇾</span> <tr id=entity-robrk><td> <code>robrk;</code> <td> U+027E7 <td> <span class=glyph>⟧</span> <tr id=entity-ropar><td> <code>ropar;</code> <td> U+02986 <td> <span class=glyph>⦆</span> <tr id=entity-Ropf><td> <code>Ropf;</code> <td> U+0211D <td> <span class=glyph>ℝ</span> <tr id=entity-ropf><td> <code>ropf;</code> <td> U+1D563 <td> <span class=glyph>𝕣</span> <tr id=entity-roplus><td> <code>roplus;</code> <td> U+02A2E <td> <span class=glyph>⨮</span> <tr id=entity-rotimes><td> <code>rotimes;</code> <td> U+02A35 <td> <span class=glyph>⨵</span> <tr id=entity-RoundImplies><td> <code>RoundImplies;</code> <td> U+02970 <td> <span class=glyph>⥰</span> <tr id=entity-rpar><td> <code>rpar;</code> <td> U+00029 <td> <span class=glyph>)</span> <tr id=entity-rpargt><td> <code>rpargt;</code> <td> U+02994 <td> <span class=glyph>⦔</span> <tr id=entity-rppolint><td> <code>rppolint;</code> <td> U+02A12 <td> <span class=glyph>⨒</span> <tr id=entity-rrarr><td> <code>rrarr;</code> <td> U+021C9 <td> <span class=glyph>⇉</span> <tr id=entity-Rrightarrow><td> <code>Rrightarrow;</code> <td> U+021DB <td> <span class=glyph>⇛</span> <tr id=entity-rsaquo><td> <code>rsaquo;</code> <td> U+0203A <td> <span class=glyph>›</span> <tr id=entity-Rscr><td> <code>Rscr;</code> <td> U+0211B <td> <span class=glyph>ℛ</span> <tr id=entity-rscr><td> <code>rscr;</code> <td> U+1D4C7 <td> <span class=glyph>𝓇</span> <tr id=entity-Rsh><td> <code>Rsh;</code> <td> U+021B1 <td> <span class=glyph>↱</span> <tr id=entity-rsh><td> <code>rsh;</code> <td> U+021B1 <td> <span class=glyph>↱</span> <tr id=entity-rsqb><td> <code>rsqb;</code> <td> U+0005D <td> <span class=glyph>]</span> <tr id=entity-rsquo><td> <code>rsquo;</code> <td> U+02019 <td> <span class=glyph>’</span> <tr id=entity-rsquor><td> <code>rsquor;</code> <td> U+02019 <td> <span class=glyph>’</span> <tr id=entity-rthree><td> <code>rthree;</code> <td> U+022CC <td> <span class=glyph>⋌</span> <tr id=entity-rtimes><td> <code>rtimes;</code> <td> U+022CA <td> <span class=glyph>⋊</span> <tr id=entity-rtri><td> <code>rtri;</code> <td> U+025B9 <td> <span class=glyph>▹</span> <tr id=entity-rtrie><td> <code>rtrie;</code> <td> U+022B5 <td> <span class=glyph>⊵</span> <tr id=entity-rtrif><td> <code>rtrif;</code> <td> U+025B8 <td> <span class=glyph>▸</span> <tr id=entity-rtriltri><td> <code>rtriltri;</code> <td> U+029CE <td> <span class=glyph>⧎</span> <tr id=entity-RuleDelayed><td> <code>RuleDelayed;</code> <td> U+029F4 <td> <span class=glyph>⧴</span> <tr id=entity-ruluhar><td> <code>ruluhar;</code> <td> U+02968 <td> <span class=glyph>⥨</span> <tr id=entity-rx><td> <code>rx;</code> <td> U+0211E <td> <span class=glyph>℞</span> <tr id=entity-Sacute><td> <code>Sacute;</code> <td> U+0015A <td> <span class=glyph>Ś</span> <tr id=entity-sacute><td> <code>sacute;</code> <td> U+0015B <td> <span class=glyph>ś</span> <tr id=entity-sbquo><td> <code>sbquo;</code> <td> U+0201A <td> <span class=glyph>‚</span> <tr id=entity-Sc><td> <code>Sc;</code> <td> U+02ABC <td> <span class=glyph>⪼</span> <tr id=entity-sc><td> <code>sc;</code> <td> U+0227B <td> <span class=glyph>≻</span> <tr id=entity-scap><td> <code>scap;</code> <td> U+02AB8 <td> <span class=glyph>⪸</span> <tr id=entity-Scaron><td> <code>Scaron;</code> <td> U+00160 <td> <span class=glyph>Š</span> <tr id=entity-scaron><td> <code>scaron;</code> <td> U+00161 <td> <span class=glyph>š</span> <tr id=entity-sccue><td> <code>sccue;</code> <td> U+0227D <td> <span class=glyph>≽</span> <tr id=entity-scE><td> <code>scE;</code> <td> U+02AB4 <td> <span class=glyph>⪴</span> <tr id=entity-sce><td> <code>sce;</code> <td> U+02AB0 <td> <span class=glyph>⪰</span> <tr id=entity-Scedil><td> <code>Scedil;</code> <td> U+0015E <td> <span class=glyph>Ş</span> <tr id=entity-scedil><td> <code>scedil;</code> <td> U+0015F <td> <span class=glyph>ş</span> <tr id=entity-Scirc><td> <code>Scirc;</code> <td> U+0015C <td> <span class=glyph>Ŝ</span> <tr id=entity-scirc><td> <code>scirc;</code> <td> U+0015D <td> <span class=glyph>ŝ</span> <tr id=entity-scnap><td> <code>scnap;</code> <td> U+02ABA <td> <span class=glyph>⪺</span> <tr id=entity-scnE><td> <code>scnE;</code> <td> U+02AB6 <td> <span class=glyph>⪶</span> <tr id=entity-scnsim><td> <code>scnsim;</code> <td> U+022E9 <td> <span class=glyph>⋩</span> <tr id=entity-scpolint><td> <code>scpolint;</code> <td> U+02A13 <td> <span class=glyph>⨓</span> <tr id=entity-scsim><td> <code>scsim;</code> <td> U+0227F <td> <span class=glyph>≿</span> <tr id=entity-Scy><td> <code>Scy;</code> <td> U+00421 <td> <span class=glyph>С</span> <tr id=entity-scy><td> <code>scy;</code> <td> U+00441 <td> <span class=glyph>с</span> <tr id=entity-sdot><td> <code>sdot;</code> <td> U+022C5 <td> <span class=glyph>⋅</span> <tr id=entity-sdotb><td> <code>sdotb;</code> <td> U+022A1 <td> <span class=glyph>⊡</span> <tr id=entity-sdote><td> <code>sdote;</code> <td> U+02A66 <td> <span class=glyph>⩦</span> <tr id=entity-searhk><td> <code>searhk;</code> <td> U+02925 <td> <span class=glyph>⤥</span> <tr id=entity-seArr><td> <code>seArr;</code> <td> U+021D8 <td> <span class=glyph>⇘</span> <tr id=entity-searr><td> <code>searr;</code> <td> U+02198 <td> <span class=glyph>↘</span> <tr id=entity-searrow><td> <code>searrow;</code> <td> U+02198 <td> <span class=glyph>↘</span> <tr id=entity-sect><td> <code>sect;</code> <td> U+000A7 <td> <span class=glyph>§</span> <tr id=entity-sect-legacy class=impl><td> <code>sect</code> <td> U+000A7 <td> <span>§</span> <tr id=entity-semi><td> <code>semi;</code> <td> U+0003B <td> <span class=glyph>;</span> <tr id=entity-seswar><td> <code>seswar;</code> <td> U+02929 <td> <span class=glyph>⤩</span> <tr id=entity-setminus><td> <code>setminus;</code> <td> U+02216 <td> <span class=glyph>∖</span> <tr id=entity-setmn><td> <code>setmn;</code> <td> U+02216 <td> <span class=glyph>∖</span> <tr id=entity-sext><td> <code>sext;</code> <td> U+02736 <td> <span class=glyph>✶</span> <tr id=entity-Sfr><td> <code>Sfr;</code> <td> U+1D516 <td> <span class=glyph>𝔖</span> <tr id=entity-sfr><td> <code>sfr;</code> <td> U+1D530 <td> <span class=glyph>𝔰</span> <tr id=entity-sfrown><td> <code>sfrown;</code> <td> U+02322 <td> <span class=glyph>⌢</span> <tr id=entity-sharp><td> <code>sharp;</code> <td> U+0266F <td> <span class=glyph>♯</span> <tr id=entity-SHCHcy><td> <code>SHCHcy;</code> <td> U+00429 <td> <span class=glyph>Щ</span> <tr id=entity-shchcy><td> <code>shchcy;</code> <td> U+00449 <td> <span class=glyph>щ</span> <tr id=entity-SHcy><td> <code>SHcy;</code> <td> U+00428 <td> <span class=glyph>Ш</span> <tr id=entity-shcy><td> <code>shcy;</code> <td> U+00448 <td> <span class=glyph>ш</span> <tr id=entity-ShortDownArrow><td> <code>ShortDownArrow;</code> <td> U+02193 <td> <span class=glyph>↓</span> <tr id=entity-ShortLeftArrow><td> <code>ShortLeftArrow;</code> <td> U+02190 <td> <span class=glyph>←</span> <tr id=entity-shortmid><td> <code>shortmid;</code> <td> U+02223 <td> <span class=glyph>∣</span> <tr id=entity-shortparallel><td> <code>shortparallel;</code> <td> U+02225 <td> <span class=glyph>∥</span> <tr id=entity-ShortRightArrow><td> <code>ShortRightArrow;</code> <td> U+02192 <td> <span class=glyph>→</span> <tr id=entity-ShortUpArrow><td> <code>ShortUpArrow;</code> <td> U+02191 <td> <span class=glyph>↑</span> <tr id=entity-shy><td> <code>shy;</code> <td> U+000AD <td> <span class=glyph>­</span> <tr id=entity-shy-legacy class=impl><td> <code>shy</code> <td> U+000AD <td> <span>­</span> <tr id=entity-Sigma><td> <code>Sigma;</code> <td> U+003A3 <td> <span class=glyph>Σ</span> <tr id=entity-sigma><td> <code>sigma;</code> <td> U+003C3 <td> <span class=glyph>σ</span> <tr id=entity-sigmaf><td> <code>sigmaf;</code> <td> U+003C2 <td> <span class=glyph>ς</span> <tr id=entity-sigmav><td> <code>sigmav;</code> <td> U+003C2 <td> <span class=glyph>ς</span> <tr id=entity-sim><td> <code>sim;</code> <td> U+0223C <td> <span class=glyph>∼</span> <tr id=entity-simdot><td> <code>simdot;</code> <td> U+02A6A <td> <span class=glyph>⩪</span> <tr id=entity-sime><td> <code>sime;</code> <td> U+02243 <td> <span class=glyph>≃</span> <tr id=entity-simeq><td> <code>simeq;</code> <td> U+02243 <td> <span class=glyph>≃</span> <tr id=entity-simg><td> <code>simg;</code> <td> U+02A9E <td> <span class=glyph>⪞</span> <tr id=entity-simgE><td> <code>simgE;</code> <td> U+02AA0 <td> <span class=glyph>⪠</span> <tr id=entity-siml><td> <code>siml;</code> <td> U+02A9D <td> <span class=glyph>⪝</span> <tr id=entity-simlE><td> <code>simlE;</code> <td> U+02A9F <td> <span class=glyph>⪟</span> <tr id=entity-simne><td> <code>simne;</code> <td> U+02246 <td> <span class=glyph>≆</span> <tr id=entity-simplus><td> <code>simplus;</code> <td> U+02A24 <td> <span class=glyph>⨤</span> <tr id=entity-simrarr><td> <code>simrarr;</code> <td> U+02972 <td> <span class=glyph>⥲</span> <tr id=entity-slarr><td> <code>slarr;</code> <td> U+02190 <td> <span class=glyph>←</span> <tr id=entity-SmallCircle><td> <code>SmallCircle;</code> <td> U+02218 <td> <span class=glyph>∘</span> <tr id=entity-smallsetminus><td> <code>smallsetminus;</code> <td> U+02216 <td> <span class=glyph>∖</span> <tr id=entity-smashp><td> <code>smashp;</code> <td> U+02A33 <td> <span class=glyph>⨳</span> <tr id=entity-smeparsl><td> <code>smeparsl;</code> <td> U+029E4 <td> <span class=glyph>⧤</span> <tr id=entity-smid><td> <code>smid;</code> <td> U+02223 <td> <span class=glyph>∣</span> <tr id=entity-smile><td> <code>smile;</code> <td> U+02323 <td> <span class=glyph>⌣</span> <tr id=entity-smt><td> <code>smt;</code> <td> U+02AAA <td> <span class=glyph>⪪</span> <tr id=entity-smte><td> <code>smte;</code> <td> U+02AAC <td> <span class=glyph>⪬</span> <tr id=entity-smtes><td> <code>smtes;</code> <td> U+02AAC U+0FE00 <td> <span class="glyph compound">⪬︀</span> <tr id=entity-SOFTcy><td> <code>SOFTcy;</code> <td> U+0042C <td> <span class=glyph>Ь</span> <tr id=entity-softcy><td> <code>softcy;</code> <td> U+0044C <td> <span class=glyph>ь</span> <tr id=entity-sol><td> <code>sol;</code> <td> U+0002F <td> <span class=glyph>/</span> <tr id=entity-solb><td> <code>solb;</code> <td> U+029C4 <td> <span class=glyph>⧄</span> <tr id=entity-solbar><td> <code>solbar;</code> <td> U+0233F <td> <span class=glyph>⌿</span> <tr id=entity-Sopf><td> <code>Sopf;</code> <td> U+1D54A <td> <span class=glyph>𝕊</span> <tr id=entity-sopf><td> <code>sopf;</code> <td> U+1D564 <td> <span class=glyph>𝕤</span> <tr id=entity-spades><td> <code>spades;</code> <td> U+02660 <td> <span class=glyph>♠</span> <tr id=entity-spadesuit><td> <code>spadesuit;</code> <td> U+02660 <td> <span class=glyph>♠</span> <tr id=entity-spar><td> <code>spar;</code> <td> U+02225 <td> <span class=glyph>∥</span> <tr id=entity-sqcap><td> <code>sqcap;</code> <td> U+02293 <td> <span class=glyph>⊓</span> <tr id=entity-sqcaps><td> <code>sqcaps;</code> <td> U+02293 U+0FE00 <td> <span class="glyph compound">⊓︀</span> <tr id=entity-sqcup><td> <code>sqcup;</code> <td> U+02294 <td> <span class=glyph>⊔</span> <tr id=entity-sqcups><td> <code>sqcups;</code> <td> U+02294 U+0FE00 <td> <span class="glyph compound">⊔︀</span> <tr id=entity-Sqrt><td> <code>Sqrt;</code> <td> U+0221A <td> <span class=glyph>√</span> <tr id=entity-sqsub><td> <code>sqsub;</code> <td> U+0228F <td> <span class=glyph>⊏</span> <tr id=entity-sqsube><td> <code>sqsube;</code> <td> U+02291 <td> <span class=glyph>⊑</span> <tr id=entity-sqsubset><td> <code>sqsubset;</code> <td> U+0228F <td> <span class=glyph>⊏</span> <tr id=entity-sqsubseteq><td> <code>sqsubseteq;</code> <td> U+02291 <td> <span class=glyph>⊑</span> <tr id=entity-sqsup><td> <code>sqsup;</code> <td> U+02290 <td> <span class=glyph>⊐</span> <tr id=entity-sqsupe><td> <code>sqsupe;</code> <td> U+02292 <td> <span class=glyph>⊒</span> <tr id=entity-sqsupset><td> <code>sqsupset;</code> <td> U+02290 <td> <span class=glyph>⊐</span> <tr id=entity-sqsupseteq><td> <code>sqsupseteq;</code> <td> U+02292 <td> <span class=glyph>⊒</span> <tr id=entity-squ><td> <code>squ;</code> <td> U+025A1 <td> <span class=glyph>□</span> <tr id=entity-Square><td> <code>Square;</code> <td> U+025A1 <td> <span class=glyph>□</span> <tr id=entity-square><td> <code>square;</code> <td> U+025A1 <td> <span class=glyph>□</span> <tr id=entity-SquareIntersection><td> <code>SquareIntersection;</code> <td> U+02293 <td> <span class=glyph>⊓</span> <tr id=entity-SquareSubset><td> <code>SquareSubset;</code> <td> U+0228F <td> <span class=glyph>⊏</span> <tr id=entity-SquareSubsetEqual><td> <code>SquareSubsetEqual;</code> <td> U+02291 <td> <span class=glyph>⊑</span> <tr id=entity-SquareSuperset><td> <code>SquareSuperset;</code> <td> U+02290 <td> <span class=glyph>⊐</span> <tr id=entity-SquareSupersetEqual><td> <code>SquareSupersetEqual;</code> <td> U+02292 <td> <span class=glyph>⊒</span> <tr id=entity-SquareUnion><td> <code>SquareUnion;</code> <td> U+02294 <td> <span class=glyph>⊔</span> <tr id=entity-squarf><td> <code>squarf;</code> <td> U+025AA <td> <span class=glyph>▪</span> <tr id=entity-squf><td> <code>squf;</code> <td> U+025AA <td> <span class=glyph>▪</span> <tr id=entity-srarr><td> <code>srarr;</code> <td> U+02192 <td> <span class=glyph>→</span> <tr id=entity-Sscr><td> <code>Sscr;</code> <td> U+1D4AE <td> <span class=glyph>𝒮</span> <tr id=entity-sscr><td> <code>sscr;</code> <td> U+1D4C8 <td> <span class=glyph>𝓈</span> <tr id=entity-ssetmn><td> <code>ssetmn;</code> <td> U+02216 <td> <span class=glyph>∖</span> <tr id=entity-ssmile><td> <code>ssmile;</code> <td> U+02323 <td> <span class=glyph>⌣</span> <tr id=entity-sstarf><td> <code>sstarf;</code> <td> U+022C6 <td> <span class=glyph>⋆</span> <tr id=entity-Star><td> <code>Star;</code> <td> U+022C6 <td> <span class=glyph>⋆</span> <tr id=entity-star><td> <code>star;</code> <td> U+02606 <td> <span class=glyph>☆</span> <tr id=entity-starf><td> <code>starf;</code> <td> U+02605 <td> <span class=glyph>★</span> <tr id=entity-straightepsilon><td> <code>straightepsilon;</code> <td> U+003F5 <td> <span class=glyph>ϵ</span> <tr id=entity-straightphi><td> <code>straightphi;</code> <td> U+003D5 <td> <span class=glyph>ϕ</span> <tr id=entity-strns><td> <code>strns;</code> <td> U+000AF <td> <span class=glyph>¯</span> <tr id=entity-Sub><td> <code>Sub;</code> <td> U+022D0 <td> <span class=glyph>⋐</span> <tr id=entity-sub><td> <code>sub;</code> <td> U+02282 <td> <span class=glyph>⊂</span> <tr id=entity-subdot><td> <code>subdot;</code> <td> U+02ABD <td> <span class=glyph>⪽</span> <tr id=entity-subE><td> <code>subE;</code> <td> U+02AC5 <td> <span class=glyph>⫅</span> <tr id=entity-sube><td> <code>sube;</code> <td> U+02286 <td> <span class=glyph>⊆</span> <tr id=entity-subedot><td> <code>subedot;</code> <td> U+02AC3 <td> <span class=glyph>⫃</span> <tr id=entity-submult><td> <code>submult;</code> <td> U+02AC1 <td> <span class=glyph>⫁</span> <tr id=entity-subnE><td> <code>subnE;</code> <td> U+02ACB <td> <span class=glyph>⫋</span> <tr id=entity-subne><td> <code>subne;</code> <td> U+0228A <td> <span class=glyph>⊊</span> <tr id=entity-subplus><td> <code>subplus;</code> <td> U+02ABF <td> <span class=glyph>⪿</span> <tr id=entity-subrarr><td> <code>subrarr;</code> <td> U+02979 <td> <span class=glyph>⥹</span> <tr id=entity-Subset><td> <code>Subset;</code> <td> U+022D0 <td> <span class=glyph>⋐</span> <tr id=entity-subset><td> <code>subset;</code> <td> U+02282 <td> <span class=glyph>⊂</span> <tr id=entity-subseteq><td> <code>subseteq;</code> <td> U+02286 <td> <span class=glyph>⊆</span> <tr id=entity-subseteqq><td> <code>subseteqq;</code> <td> U+02AC5 <td> <span class=glyph>⫅</span> <tr id=entity-SubsetEqual><td> <code>SubsetEqual;</code> <td> U+02286 <td> <span class=glyph>⊆</span> <tr id=entity-subsetneq><td> <code>subsetneq;</code> <td> U+0228A <td> <span class=glyph>⊊</span> <tr id=entity-subsetneqq><td> <code>subsetneqq;</code> <td> U+02ACB <td> <span class=glyph>⫋</span> <tr id=entity-subsim><td> <code>subsim;</code> <td> U+02AC7 <td> <span class=glyph>⫇</span> <tr id=entity-subsub><td> <code>subsub;</code> <td> U+02AD5 <td> <span class=glyph>⫕</span> <tr id=entity-subsup><td> <code>subsup;</code> <td> U+02AD3 <td> <span class=glyph>⫓</span> <tr id=entity-succ><td> <code>succ;</code> <td> U+0227B <td> <span class=glyph>≻</span> <tr id=entity-succapprox><td> <code>succapprox;</code> <td> U+02AB8 <td> <span class=glyph>⪸</span> <tr id=entity-succcurlyeq><td> <code>succcurlyeq;</code> <td> U+0227D <td> <span class=glyph>≽</span> <tr id=entity-Succeeds><td> <code>Succeeds;</code> <td> U+0227B <td> <span class=glyph>≻</span> <tr id=entity-SucceedsEqual><td> <code>SucceedsEqual;</code> <td> U+02AB0 <td> <span class=glyph>⪰</span> <tr id=entity-SucceedsSlantEqual><td> <code>SucceedsSlantEqual;</code> <td> U+0227D <td> <span class=glyph>≽</span> <tr id=entity-SucceedsTilde><td> <code>SucceedsTilde;</code> <td> U+0227F <td> <span class=glyph>≿</span> <tr id=entity-succeq><td> <code>succeq;</code> <td> U+02AB0 <td> <span class=glyph>⪰</span> <tr id=entity-succnapprox><td> <code>succnapprox;</code> <td> U+02ABA <td> <span class=glyph>⪺</span> <tr id=entity-succneqq><td> <code>succneqq;</code> <td> U+02AB6 <td> <span class=glyph>⪶</span> <tr id=entity-succnsim><td> <code>succnsim;</code> <td> U+022E9 <td> <span class=glyph>⋩</span> <tr id=entity-succsim><td> <code>succsim;</code> <td> U+0227F <td> <span class=glyph>≿</span> <tr id=entity-SuchThat><td> <code>SuchThat;</code> <td> U+0220B <td> <span class=glyph>∋</span> <tr id=entity-Sum><td> <code>Sum;</code> <td> U+02211 <td> <span class=glyph>∑</span> <tr id=entity-sum><td> <code>sum;</code> <td> U+02211 <td> <span class=glyph>∑</span> <tr id=entity-sung><td> <code>sung;</code> <td> U+0266A <td> <span class=glyph>♪</span> <tr id=entity-Sup><td> <code>Sup;</code> <td> U+022D1 <td> <span class=glyph>⋑</span> <tr id=entity-sup><td> <code>sup;</code> <td> U+02283 <td> <span class=glyph>⊃</span> <tr id=entity-sup1><td> <code>sup1;</code> <td> U+000B9 <td> <span class=glyph>¹</span> <tr id=entity-sup1-legacy class=impl><td> <code>sup1</code> <td> U+000B9 <td> <span>¹</span> <tr id=entity-sup2><td> <code>sup2;</code> <td> U+000B2 <td> <span class=glyph>²</span> <tr id=entity-sup2-legacy class=impl><td> <code>sup2</code> <td> U+000B2 <td> <span>²</span> <tr id=entity-sup3><td> <code>sup3;</code> <td> U+000B3 <td> <span class=glyph>³</span> <tr id=entity-sup3-legacy class=impl><td> <code>sup3</code> <td> U+000B3 <td> <span>³</span> <tr id=entity-supdot><td> <code>supdot;</code> <td> U+02ABE <td> <span class=glyph>⪾</span> <tr id=entity-supdsub><td> <code>supdsub;</code> <td> U+02AD8 <td> <span class=glyph>⫘</span> <tr id=entity-supE><td> <code>supE;</code> <td> U+02AC6 <td> <span class=glyph>⫆</span> <tr id=entity-supe><td> <code>supe;</code> <td> U+02287 <td> <span class=glyph>⊇</span> <tr id=entity-supedot><td> <code>supedot;</code> <td> U+02AC4 <td> <span class=glyph>⫄</span> <tr id=entity-Superset><td> <code>Superset;</code> <td> U+02283 <td> <span class=glyph>⊃</span> <tr id=entity-SupersetEqual><td> <code>SupersetEqual;</code> <td> U+02287 <td> <span class=glyph>⊇</span> <tr id=entity-suphsol><td> <code>suphsol;</code> <td> U+027C9 <td> <span class=glyph>⟉</span> <tr id=entity-suphsub><td> <code>suphsub;</code> <td> U+02AD7 <td> <span class=glyph>⫗</span> <tr id=entity-suplarr><td> <code>suplarr;</code> <td> U+0297B <td> <span class=glyph>⥻</span> <tr id=entity-supmult><td> <code>supmult;</code> <td> U+02AC2 <td> <span class=glyph>⫂</span> <tr id=entity-supnE><td> <code>supnE;</code> <td> U+02ACC <td> <span class=glyph>⫌</span> <tr id=entity-supne><td> <code>supne;</code> <td> U+0228B <td> <span class=glyph>⊋</span> <tr id=entity-supplus><td> <code>supplus;</code> <td> U+02AC0 <td> <span class=glyph>⫀</span> <tr id=entity-Supset><td> <code>Supset;</code> <td> U+022D1 <td> <span class=glyph>⋑</span> <tr id=entity-supset><td> <code>supset;</code> <td> U+02283 <td> <span class=glyph>⊃</span> <tr id=entity-supseteq><td> <code>supseteq;</code> <td> U+02287 <td> <span class=glyph>⊇</span> <tr id=entity-supseteqq><td> <code>supseteqq;</code> <td> U+02AC6 <td> <span class=glyph>⫆</span> <tr id=entity-supsetneq><td> <code>supsetneq;</code> <td> U+0228B <td> <span class=glyph>⊋</span> <tr id=entity-supsetneqq><td> <code>supsetneqq;</code> <td> U+02ACC <td> <span class=glyph>⫌</span> <tr id=entity-supsim><td> <code>supsim;</code> <td> U+02AC8 <td> <span class=glyph>⫈</span> <tr id=entity-supsub><td> <code>supsub;</code> <td> U+02AD4 <td> <span class=glyph>⫔</span> <tr id=entity-supsup><td> <code>supsup;</code> <td> U+02AD6 <td> <span class=glyph>⫖</span> <tr id=entity-swarhk><td> <code>swarhk;</code> <td> U+02926 <td> <span class=glyph>⤦</span> <tr id=entity-swArr><td> <code>swArr;</code> <td> U+021D9 <td> <span class=glyph>⇙</span> <tr id=entity-swarr><td> <code>swarr;</code> <td> U+02199 <td> <span class=glyph>↙</span> <tr id=entity-swarrow><td> <code>swarrow;</code> <td> U+02199 <td> <span class=glyph>↙</span> <tr id=entity-swnwar><td> <code>swnwar;</code> <td> U+0292A <td> <span class=glyph>⤪</span> <tr id=entity-szlig><td> <code>szlig;</code> <td> U+000DF <td> <span class=glyph>ß</span> <tr id=entity-szlig-legacy class=impl><td> <code>szlig</code> <td> U+000DF <td> <span>ß</span> <tr id=entity-Tab><td> <code>Tab;</code> <td> U+00009 <td> <span class="glyph control">␉</span> <tr id=entity-target><td> <code>target;</code> <td> U+02316 <td> <span class=glyph>⌖</span> <tr id=entity-Tau><td> <code>Tau;</code> <td> U+003A4 <td> <span class=glyph>Τ</span> <tr id=entity-tau><td> <code>tau;</code> <td> U+003C4 <td> <span class=glyph>τ</span> <tr id=entity-tbrk><td> <code>tbrk;</code> <td> U+023B4 <td> <span class=glyph>⎴</span> <tr id=entity-Tcaron><td> <code>Tcaron;</code> <td> U+00164 <td> <span class=glyph>Ť</span> <tr id=entity-tcaron><td> <code>tcaron;</code> <td> U+00165 <td> <span class=glyph>ť</span> <tr id=entity-Tcedil><td> <code>Tcedil;</code> <td> U+00162 <td> <span class=glyph>Ţ</span> <tr id=entity-tcedil><td> <code>tcedil;</code> <td> U+00163 <td> <span class=glyph>ţ</span> <tr id=entity-Tcy><td> <code>Tcy;</code> <td> U+00422 <td> <span class=glyph>Т</span> <tr id=entity-tcy><td> <code>tcy;</code> <td> U+00442 <td> <span class=glyph>т</span> <tr id=entity-tdot><td> <code>tdot;</code> <td> U+020DB <td> <span class="glyph composition">◌⃛</span> <tr id=entity-telrec><td> <code>telrec;</code> <td> U+02315 <td> <span class=glyph>⌕</span> <tr id=entity-Tfr><td> <code>Tfr;</code> <td> U+1D517 <td> <span class=glyph>𝔗</span> <tr id=entity-tfr><td> <code>tfr;</code> <td> U+1D531 <td> <span class=glyph>𝔱</span> <tr id=entity-there4><td> <code>there4;</code> <td> U+02234 <td> <span class=glyph>∴</span> <tr id=entity-Therefore><td> <code>Therefore;</code> <td> U+02234 <td> <span class=glyph>∴</span> <tr id=entity-therefore><td> <code>therefore;</code> <td> U+02234 <td> <span class=glyph>∴</span> <tr id=entity-Theta><td> <code>Theta;</code> <td> U+00398 <td> <span class=glyph>Θ</span> <tr id=entity-theta><td> <code>theta;</code> <td> U+003B8 <td> <span class=glyph>θ</span> <tr id=entity-thetasym><td> <code>thetasym;</code> <td> U+003D1 <td> <span class=glyph>ϑ</span> <tr id=entity-thetav><td> <code>thetav;</code> <td> U+003D1 <td> <span class=glyph>ϑ</span> <tr id=entity-thickapprox><td> <code>thickapprox;</code> <td> U+02248 <td> <span class=glyph>≈</span> <tr id=entity-thicksim><td> <code>thicksim;</code> <td> U+0223C <td> <span class=glyph>∼</span> <tr id=entity-ThickSpace><td> <code>ThickSpace;</code> <td> U+0205F U+0200A <td> <span class="glyph compound">  </span> <tr id=entity-thinsp><td> <code>thinsp;</code> <td> U+02009 <td> <span class=glyph> </span> <tr id=entity-ThinSpace><td> <code>ThinSpace;</code> <td> U+02009 <td> <span class=glyph> </span> <tr id=entity-thkap><td> <code>thkap;</code> <td> U+02248 <td> <span class=glyph>≈</span> <tr id=entity-thksim><td> <code>thksim;</code> <td> U+0223C <td> <span class=glyph>∼</span> <tr id=entity-THORN><td> <code>THORN;</code> <td> U+000DE <td> <span class=glyph>Þ</span> <tr id=entity-THORN-legacy class=impl><td> <code>THORN</code> <td> U+000DE <td> <span>Þ</span> <tr id=entity-thorn><td> <code>thorn;</code> <td> U+000FE <td> <span class=glyph>þ</span> <tr id=entity-thorn-legacy class=impl><td> <code>thorn</code> <td> U+000FE <td> <span>þ</span> <tr id=entity-Tilde><td> <code>Tilde;</code> <td> U+0223C <td> <span class=glyph>∼</span> <tr id=entity-tilde><td> <code>tilde;</code> <td> U+002DC <td> <span class=glyph>˜</span> <tr id=entity-TildeEqual><td> <code>TildeEqual;</code> <td> U+02243 <td> <span class=glyph>≃</span> <tr id=entity-TildeFullEqual><td> <code>TildeFullEqual;</code> <td> U+02245 <td> <span class=glyph>≅</span> <tr id=entity-TildeTilde><td> <code>TildeTilde;</code> <td> U+02248 <td> <span class=glyph>≈</span> <tr id=entity-times><td> <code>times;</code> <td> U+000D7 <td> <span class=glyph>×</span> <tr id=entity-times-legacy class=impl><td> <code>times</code> <td> U+000D7 <td> <span>×</span> <tr id=entity-timesb><td> <code>timesb;</code> <td> U+022A0 <td> <span class=glyph>⊠</span> <tr id=entity-timesbar><td> <code>timesbar;</code> <td> U+02A31 <td> <span class=glyph>⨱</span> <tr id=entity-timesd><td> <code>timesd;</code> <td> U+02A30 <td> <span class=glyph>⨰</span> <tr id=entity-tint><td> <code>tint;</code> <td> U+0222D <td> <span class=glyph>∭</span> <tr id=entity-toea><td> <code>toea;</code> <td> U+02928 <td> <span class=glyph>⤨</span> <tr id=entity-top><td> <code>top;</code> <td> U+022A4 <td> <span class=glyph>⊤</span> <tr id=entity-topbot><td> <code>topbot;</code> <td> U+02336 <td> <span class=glyph>⌶</span> <tr id=entity-topcir><td> <code>topcir;</code> <td> U+02AF1 <td> <span class=glyph>⫱</span> <tr id=entity-Topf><td> <code>Topf;</code> <td> U+1D54B <td> <span class=glyph>𝕋</span> <tr id=entity-topf><td> <code>topf;</code> <td> U+1D565 <td> <span class=glyph>𝕥</span> <tr id=entity-topfork><td> <code>topfork;</code> <td> U+02ADA <td> <span class=glyph>⫚</span> <tr id=entity-tosa><td> <code>tosa;</code> <td> U+02929 <td> <span class=glyph>⤩</span> <tr id=entity-tprime><td> <code>tprime;</code> <td> U+02034 <td> <span class=glyph>‴</span> <tr id=entity-TRADE><td> <code>TRADE;</code> <td> U+02122 <td> <span class=glyph>™</span> <tr id=entity-trade><td> <code>trade;</code> <td> U+02122 <td> <span class=glyph>™</span> <tr id=entity-triangle><td> <code>triangle;</code> <td> U+025B5 <td> <span class=glyph>▵</span> <tr id=entity-triangledown><td> <code>triangledown;</code> <td> U+025BF <td> <span class=glyph>▿</span> <tr id=entity-triangleleft><td> <code>triangleleft;</code> <td> U+025C3 <td> <span class=glyph>◃</span> <tr id=entity-trianglelefteq><td> <code>trianglelefteq;</code> <td> U+022B4 <td> <span class=glyph>⊴</span> <tr id=entity-triangleq><td> <code>triangleq;</code> <td> U+0225C <td> <span class=glyph>≜</span> <tr id=entity-triangleright><td> <code>triangleright;</code> <td> U+025B9 <td> <span class=glyph>▹</span> <tr id=entity-trianglerighteq><td> <code>trianglerighteq;</code> <td> U+022B5 <td> <span class=glyph>⊵</span> <tr id=entity-tridot><td> <code>tridot;</code> <td> U+025EC <td> <span class=glyph>◬</span> <tr id=entity-trie><td> <code>trie;</code> <td> U+0225C <td> <span class=glyph>≜</span> <tr id=entity-triminus><td> <code>triminus;</code> <td> U+02A3A <td> <span class=glyph>⨺</span> <tr id=entity-TripleDot><td> <code>TripleDot;</code> <td> U+020DB <td> <span class="glyph composition">◌⃛</span> <tr id=entity-triplus><td> <code>triplus;</code> <td> U+02A39 <td> <span class=glyph>⨹</span> <tr id=entity-trisb><td> <code>trisb;</code> <td> U+029CD <td> <span class=glyph>⧍</span> <tr id=entity-tritime><td> <code>tritime;</code> <td> U+02A3B <td> <span class=glyph>⨻</span> <tr id=entity-trpezium><td> <code>trpezium;</code> <td> U+023E2 <td> <span class=glyph>⏢</span> <tr id=entity-Tscr><td> <code>Tscr;</code> <td> U+1D4AF <td> <span class=glyph>𝒯</span> <tr id=entity-tscr><td> <code>tscr;</code> <td> U+1D4C9 <td> <span class=glyph>𝓉</span> <tr id=entity-TScy><td> <code>TScy;</code> <td> U+00426 <td> <span class=glyph>Ц</span> <tr id=entity-tscy><td> <code>tscy;</code> <td> U+00446 <td> <span class=glyph>ц</span> <tr id=entity-TSHcy><td> <code>TSHcy;</code> <td> U+0040B <td> <span class=glyph>Ћ</span> <tr id=entity-tshcy><td> <code>tshcy;</code> <td> U+0045B <td> <span class=glyph>ћ</span> <tr id=entity-Tstrok><td> <code>Tstrok;</code> <td> U+00166 <td> <span class=glyph>Ŧ</span> <tr id=entity-tstrok><td> <code>tstrok;</code> <td> U+00167 <td> <span class=glyph>ŧ</span> <tr id=entity-twixt><td> <code>twixt;</code> <td> U+0226C <td> <span class=glyph>≬</span> <tr id=entity-twoheadleftarrow><td> <code>twoheadleftarrow;</code> <td> U+0219E <td> <span class=glyph>↞</span> <tr id=entity-twoheadrightarrow><td> <code>twoheadrightarrow;</code> <td> U+021A0 <td> <span class=glyph>↠</span> <tr id=entity-Uacute><td> <code>Uacute;</code> <td> U+000DA <td> <span class=glyph>Ú</span> <tr id=entity-Uacute-legacy class=impl><td> <code>Uacute</code> <td> U+000DA <td> <span>Ú</span> <tr id=entity-uacute><td> <code>uacute;</code> <td> U+000FA <td> <span class=glyph>ú</span> <tr id=entity-uacute-legacy class=impl><td> <code>uacute</code> <td> U+000FA <td> <span>ú</span> <tr id=entity-Uarr><td> <code>Uarr;</code> <td> U+0219F <td> <span class=glyph>↟</span> <tr id=entity-uArr><td> <code>uArr;</code> <td> U+021D1 <td> <span class=glyph>⇑</span> <tr id=entity-uarr><td> <code>uarr;</code> <td> U+02191 <td> <span class=glyph>↑</span> <tr id=entity-Uarrocir><td> <code>Uarrocir;</code> <td> U+02949 <td> <span class=glyph>⥉</span> <tr id=entity-Ubrcy><td> <code>Ubrcy;</code> <td> U+0040E <td> <span class=glyph>Ў</span> <tr id=entity-ubrcy><td> <code>ubrcy;</code> <td> U+0045E <td> <span class=glyph>ў</span> <tr id=entity-Ubreve><td> <code>Ubreve;</code> <td> U+0016C <td> <span class=glyph>Ŭ</span> <tr id=entity-ubreve><td> <code>ubreve;</code> <td> U+0016D <td> <span class=glyph>ŭ</span> <tr id=entity-Ucirc><td> <code>Ucirc;</code> <td> U+000DB <td> <span class=glyph>Û</span> <tr id=entity-Ucirc-legacy class=impl><td> <code>Ucirc</code> <td> U+000DB <td> <span>Û</span> <tr id=entity-ucirc><td> <code>ucirc;</code> <td> U+000FB <td> <span class=glyph>û</span> <tr id=entity-ucirc-legacy class=impl><td> <code>ucirc</code> <td> U+000FB <td> <span>û</span> <tr id=entity-Ucy><td> <code>Ucy;</code> <td> U+00423 <td> <span class=glyph>У</span> <tr id=entity-ucy><td> <code>ucy;</code> <td> U+00443 <td> <span class=glyph>у</span> <tr id=entity-udarr><td> <code>udarr;</code> <td> U+021C5 <td> <span class=glyph>⇅</span> <tr id=entity-Udblac><td> <code>Udblac;</code> <td> U+00170 <td> <span class=glyph>Ű</span> <tr id=entity-udblac><td> <code>udblac;</code> <td> U+00171 <td> <span class=glyph>ű</span> <tr id=entity-udhar><td> <code>udhar;</code> <td> U+0296E <td> <span class=glyph>⥮</span> <tr id=entity-ufisht><td> <code>ufisht;</code> <td> U+0297E <td> <span class=glyph>⥾</span> <tr id=entity-Ufr><td> <code>Ufr;</code> <td> U+1D518 <td> <span class=glyph>𝔘</span> <tr id=entity-ufr><td> <code>ufr;</code> <td> U+1D532 <td> <span class=glyph>𝔲</span> <tr id=entity-Ugrave><td> <code>Ugrave;</code> <td> U+000D9 <td> <span class=glyph>Ù</span> <tr id=entity-Ugrave-legacy class=impl><td> <code>Ugrave</code> <td> U+000D9 <td> <span>Ù</span> <tr id=entity-ugrave><td> <code>ugrave;</code> <td> U+000F9 <td> <span class=glyph>ù</span> <tr id=entity-ugrave-legacy class=impl><td> <code>ugrave</code> <td> U+000F9 <td> <span>ù</span> <tr id=entity-uHar><td> <code>uHar;</code> <td> U+02963 <td> <span class=glyph>⥣</span> <tr id=entity-uharl><td> <code>uharl;</code> <td> U+021BF <td> <span class=glyph>↿</span> <tr id=entity-uharr><td> <code>uharr;</code> <td> U+021BE <td> <span class=glyph>↾</span> <tr id=entity-uhblk><td> <code>uhblk;</code> <td> U+02580 <td> <span class=glyph>▀</span> <tr id=entity-ulcorn><td> <code>ulcorn;</code> <td> U+0231C <td> <span class=glyph>⌜</span> <tr id=entity-ulcorner><td> <code>ulcorner;</code> <td> U+0231C <td> <span class=glyph>⌜</span> <tr id=entity-ulcrop><td> <code>ulcrop;</code> <td> U+0230F <td> <span class=glyph>⌏</span> <tr id=entity-ultri><td> <code>ultri;</code> <td> U+025F8 <td> <span class=glyph>◸</span> <tr id=entity-Umacr><td> <code>Umacr;</code> <td> U+0016A <td> <span class=glyph>Ū</span> <tr id=entity-umacr><td> <code>umacr;</code> <td> U+0016B <td> <span class=glyph>ū</span> <tr id=entity-uml><td> <code>uml;</code> <td> U+000A8 <td> <span class=glyph>¨</span> <tr id=entity-uml-legacy class=impl><td> <code>uml</code> <td> U+000A8 <td> <span>¨</span> <tr id=entity-UnderBar><td> <code>UnderBar;</code> <td> U+0005F <td> <span class=glyph>_</span> <tr id=entity-UnderBrace><td> <code>UnderBrace;</code> <td> U+023DF <td> <span class=glyph>⏟</span> <tr id=entity-UnderBracket><td> <code>UnderBracket;</code> <td> U+023B5 <td> <span class=glyph>⎵</span> <tr id=entity-UnderParenthesis><td> <code>UnderParenthesis;</code> <td> U+023DD <td> <span class=glyph>⏝</span> <tr id=entity-Union><td> <code>Union;</code> <td> U+022C3 <td> <span class=glyph>⋃</span> <tr id=entity-UnionPlus><td> <code>UnionPlus;</code> <td> U+0228E <td> <span class=glyph>⊎</span> <tr id=entity-Uogon><td> <code>Uogon;</code> <td> U+00172 <td> <span class=glyph>Ų</span> <tr id=entity-uogon><td> <code>uogon;</code> <td> U+00173 <td> <span class=glyph>ų</span> <tr id=entity-Uopf><td> <code>Uopf;</code> <td> U+1D54C <td> <span class=glyph>𝕌</span> <tr id=entity-uopf><td> <code>uopf;</code> <td> U+1D566 <td> <span class=glyph>𝕦</span> <tr id=entity-UpArrow><td> <code>UpArrow;</code> <td> U+02191 <td> <span class=glyph>↑</span> <tr id=entity-Uparrow><td> <code>Uparrow;</code> <td> U+021D1 <td> <span class=glyph>⇑</span> <tr id=entity-uparrow><td> <code>uparrow;</code> <td> U+02191 <td> <span class=glyph>↑</span> <tr id=entity-UpArrowBar><td> <code>UpArrowBar;</code> <td> U+02912 <td> <span class=glyph>⤒</span> <tr id=entity-UpArrowDownArrow><td> <code>UpArrowDownArrow;</code> <td> U+021C5 <td> <span class=glyph>⇅</span> <tr id=entity-UpDownArrow><td> <code>UpDownArrow;</code> <td> U+02195 <td> <span class=glyph>↕</span> <tr id=entity-Updownarrow><td> <code>Updownarrow;</code> <td> U+021D5 <td> <span class=glyph>⇕</span> <tr id=entity-updownarrow><td> <code>updownarrow;</code> <td> U+02195 <td> <span class=glyph>↕</span> <tr id=entity-UpEquilibrium><td> <code>UpEquilibrium;</code> <td> U+0296E <td> <span class=glyph>⥮</span> <tr id=entity-upharpoonleft><td> <code>upharpoonleft;</code> <td> U+021BF <td> <span class=glyph>↿</span> <tr id=entity-upharpoonright><td> <code>upharpoonright;</code> <td> U+021BE <td> <span class=glyph>↾</span> <tr id=entity-uplus><td> <code>uplus;</code> <td> U+0228E <td> <span class=glyph>⊎</span> <tr id=entity-UpperLeftArrow><td> <code>UpperLeftArrow;</code> <td> U+02196 <td> <span class=glyph>↖</span> <tr id=entity-UpperRightArrow><td> <code>UpperRightArrow;</code> <td> U+02197 <td> <span class=glyph>↗</span> <tr id=entity-Upsi><td> <code>Upsi;</code> <td> U+003D2 <td> <span class=glyph>ϒ</span> <tr id=entity-upsi><td> <code>upsi;</code> <td> U+003C5 <td> <span class=glyph>υ</span> <tr id=entity-upsih><td> <code>upsih;</code> <td> U+003D2 <td> <span class=glyph>ϒ</span> <tr id=entity-Upsilon><td> <code>Upsilon;</code> <td> U+003A5 <td> <span class=glyph>Υ</span> <tr id=entity-upsilon><td> <code>upsilon;</code> <td> U+003C5 <td> <span class=glyph>υ</span> <tr id=entity-UpTee><td> <code>UpTee;</code> <td> U+022A5 <td> <span class=glyph>⊥</span> <tr id=entity-UpTeeArrow><td> <code>UpTeeArrow;</code> <td> U+021A5 <td> <span class=glyph>↥</span> <tr id=entity-upuparrows><td> <code>upuparrows;</code> <td> U+021C8 <td> <span class=glyph>⇈</span> <tr id=entity-urcorn><td> <code>urcorn;</code> <td> U+0231D <td> <span class=glyph>⌝</span> <tr id=entity-urcorner><td> <code>urcorner;</code> <td> U+0231D <td> <span class=glyph>⌝</span> <tr id=entity-urcrop><td> <code>urcrop;</code> <td> U+0230E <td> <span class=glyph>⌎</span> <tr id=entity-Uring><td> <code>Uring;</code> <td> U+0016E <td> <span class=glyph>Ů</span> <tr id=entity-uring><td> <code>uring;</code> <td> U+0016F <td> <span class=glyph>ů</span> <tr id=entity-urtri><td> <code>urtri;</code> <td> U+025F9 <td> <span class=glyph>◹</span> <tr id=entity-Uscr><td> <code>Uscr;</code> <td> U+1D4B0 <td> <span class=glyph>𝒰</span> <tr id=entity-uscr><td> <code>uscr;</code> <td> U+1D4CA <td> <span class=glyph>𝓊</span> <tr id=entity-utdot><td> <code>utdot;</code> <td> U+022F0 <td> <span class=glyph>⋰</span> <tr id=entity-Utilde><td> <code>Utilde;</code> <td> U+00168 <td> <span class=glyph>Ũ</span> <tr id=entity-utilde><td> <code>utilde;</code> <td> U+00169 <td> <span class=glyph>ũ</span> <tr id=entity-utri><td> <code>utri;</code> <td> U+025B5 <td> <span class=glyph>▵</span> <tr id=entity-utrif><td> <code>utrif;</code> <td> U+025B4 <td> <span class=glyph>▴</span> <tr id=entity-uuarr><td> <code>uuarr;</code> <td> U+021C8 <td> <span class=glyph>⇈</span> <tr id=entity-Uuml><td> <code>Uuml;</code> <td> U+000DC <td> <span class=glyph>Ü</span> <tr id=entity-Uuml-legacy class=impl><td> <code>Uuml</code> <td> U+000DC <td> <span>Ü</span> <tr id=entity-uuml><td> <code>uuml;</code> <td> U+000FC <td> <span class=glyph>ü</span> <tr id=entity-uuml-legacy class=impl><td> <code>uuml</code> <td> U+000FC <td> <span>ü</span> <tr id=entity-uwangle><td> <code>uwangle;</code> <td> U+029A7 <td> <span class=glyph>⦧</span> <tr id=entity-vangrt><td> <code>vangrt;</code> <td> U+0299C <td> <span class=glyph>⦜</span> <tr id=entity-varepsilon><td> <code>varepsilon;</code> <td> U+003F5 <td> <span class=glyph>ϵ</span> <tr id=entity-varkappa><td> <code>varkappa;</code> <td> U+003F0 <td> <span class=glyph>ϰ</span> <tr id=entity-varnothing><td> <code>varnothing;</code> <td> U+02205 <td> <span class=glyph>∅</span> <tr id=entity-varphi><td> <code>varphi;</code> <td> U+003D5 <td> <span class=glyph>ϕ</span> <tr id=entity-varpi><td> <code>varpi;</code> <td> U+003D6 <td> <span class=glyph>ϖ</span> <tr id=entity-varpropto><td> <code>varpropto;</code> <td> U+0221D <td> <span class=glyph>∝</span> <tr id=entity-vArr><td> <code>vArr;</code> <td> U+021D5 <td> <span class=glyph>⇕</span> <tr id=entity-varr><td> <code>varr;</code> <td> U+02195 <td> <span class=glyph>↕</span> <tr id=entity-varrho><td> <code>varrho;</code> <td> U+003F1 <td> <span class=glyph>ϱ</span> <tr id=entity-varsigma><td> <code>varsigma;</code> <td> U+003C2 <td> <span class=glyph>ς</span> <tr id=entity-varsubsetneq><td> <code>varsubsetneq;</code> <td> U+0228A U+0FE00 <td> <span class="glyph compound">⊊︀</span> <tr id=entity-varsubsetneqq><td> <code>varsubsetneqq;</code> <td> U+02ACB U+0FE00 <td> <span class="glyph compound">⫋︀</span> <tr id=entity-varsupsetneq><td> <code>varsupsetneq;</code> <td> U+0228B U+0FE00 <td> <span class="glyph compound">⊋︀</span> <tr id=entity-varsupsetneqq><td> <code>varsupsetneqq;</code> <td> U+02ACC U+0FE00 <td> <span class="glyph compound">⫌︀</span> <tr id=entity-vartheta><td> <code>vartheta;</code> <td> U+003D1 <td> <span class=glyph>ϑ</span> <tr id=entity-vartriangleleft><td> <code>vartriangleleft;</code> <td> U+022B2 <td> <span class=glyph>⊲</span> <tr id=entity-vartriangleright><td> <code>vartriangleright;</code> <td> U+022B3 <td> <span class=glyph>⊳</span> <tr id=entity-Vbar><td> <code>Vbar;</code> <td> U+02AEB <td> <span class=glyph>⫫</span> <tr id=entity-vBar><td> <code>vBar;</code> <td> U+02AE8 <td> <span class=glyph>⫨</span> <tr id=entity-vBarv><td> <code>vBarv;</code> <td> U+02AE9 <td> <span class=glyph>⫩</span> <tr id=entity-Vcy><td> <code>Vcy;</code> <td> U+00412 <td> <span class=glyph>В</span> <tr id=entity-vcy><td> <code>vcy;</code> <td> U+00432 <td> <span class=glyph>в</span> <tr id=entity-VDash><td> <code>VDash;</code> <td> U+022AB <td> <span class=glyph>⊫</span> <tr id=entity-Vdash><td> <code>Vdash;</code> <td> U+022A9 <td> <span class=glyph>⊩</span> <tr id=entity-vDash><td> <code>vDash;</code> <td> U+022A8 <td> <span class=glyph>⊨</span> <tr id=entity-vdash><td> <code>vdash;</code> <td> U+022A2 <td> <span class=glyph>⊢</span> <tr id=entity-Vdashl><td> <code>Vdashl;</code> <td> U+02AE6 <td> <span class=glyph>⫦</span> <tr id=entity-Vee><td> <code>Vee;</code> <td> U+022C1 <td> <span class=glyph>⋁</span> <tr id=entity-vee><td> <code>vee;</code> <td> U+02228 <td> <span class=glyph>∨</span> <tr id=entity-veebar><td> <code>veebar;</code> <td> U+022BB <td> <span class=glyph>⊻</span> <tr id=entity-veeeq><td> <code>veeeq;</code> <td> U+0225A <td> <span class=glyph>≚</span> <tr id=entity-vellip><td> <code>vellip;</code> <td> U+022EE <td> <span class=glyph>⋮</span> <tr id=entity-Verbar><td> <code>Verbar;</code> <td> U+02016 <td> <span class=glyph>‖</span> <tr id=entity-verbar><td> <code>verbar;</code> <td> U+0007C <td> <span class=glyph>|</span> <tr id=entity-Vert><td> <code>Vert;</code> <td> U+02016 <td> <span class=glyph>‖</span> <tr id=entity-vert><td> <code>vert;</code> <td> U+0007C <td> <span class=glyph>|</span> <tr id=entity-VerticalBar><td> <code>VerticalBar;</code> <td> U+02223 <td> <span class=glyph>∣</span> <tr id=entity-VerticalLine><td> <code>VerticalLine;</code> <td> U+0007C <td> <span class=glyph>|</span> <tr id=entity-VerticalSeparator><td> <code>VerticalSeparator;</code> <td> U+02758 <td> <span class=glyph>❘</span> <tr id=entity-VerticalTilde><td> <code>VerticalTilde;</code> <td> U+02240 <td> <span class=glyph>≀</span> <tr id=entity-VeryThinSpace><td> <code>VeryThinSpace;</code> <td> U+0200A <td> <span class=glyph> </span> <tr id=entity-Vfr><td> <code>Vfr;</code> <td> U+1D519 <td> <span class=glyph>𝔙</span> <tr id=entity-vfr><td> <code>vfr;</code> <td> U+1D533 <td> <span class=glyph>𝔳</span> <tr id=entity-vltri><td> <code>vltri;</code> <td> U+022B2 <td> <span class=glyph>⊲</span> <tr id=entity-vnsub><td> <code>vnsub;</code> <td> U+02282 U+020D2 <td> <span class="glyph compound">⊂⃒</span> <tr id=entity-vnsup><td> <code>vnsup;</code> <td> U+02283 U+020D2 <td> <span class="glyph compound">⊃⃒</span> <tr id=entity-Vopf><td> <code>Vopf;</code> <td> U+1D54D <td> <span class=glyph>𝕍</span> <tr id=entity-vopf><td> <code>vopf;</code> <td> U+1D567 <td> <span class=glyph>𝕧</span> <tr id=entity-vprop><td> <code>vprop;</code> <td> U+0221D <td> <span class=glyph>∝</span> <tr id=entity-vrtri><td> <code>vrtri;</code> <td> U+022B3 <td> <span class=glyph>⊳</span> <tr id=entity-Vscr><td> <code>Vscr;</code> <td> U+1D4B1 <td> <span class=glyph>𝒱</span> <tr id=entity-vscr><td> <code>vscr;</code> <td> U+1D4CB <td> <span class=glyph>𝓋</span> <tr id=entity-vsubnE><td> <code>vsubnE;</code> <td> U+02ACB U+0FE00 <td> <span class="glyph compound">⫋︀</span> <tr id=entity-vsubne><td> <code>vsubne;</code> <td> U+0228A U+0FE00 <td> <span class="glyph compound">⊊︀</span> <tr id=entity-vsupnE><td> <code>vsupnE;</code> <td> U+02ACC U+0FE00 <td> <span class="glyph compound">⫌︀</span> <tr id=entity-vsupne><td> <code>vsupne;</code> <td> U+0228B U+0FE00 <td> <span class="glyph compound">⊋︀</span> <tr id=entity-Vvdash><td> <code>Vvdash;</code> <td> U+022AA <td> <span class=glyph>⊪</span> <tr id=entity-vzigzag><td> <code>vzigzag;</code> <td> U+0299A <td> <span class=glyph>⦚</span> <tr id=entity-Wcirc><td> <code>Wcirc;</code> <td> U+00174 <td> <span class=glyph>Ŵ</span> <tr id=entity-wcirc><td> <code>wcirc;</code> <td> U+00175 <td> <span class=glyph>ŵ</span> <tr id=entity-wedbar><td> <code>wedbar;</code> <td> U+02A5F <td> <span class=glyph>⩟</span> <tr id=entity-Wedge><td> <code>Wedge;</code> <td> U+022C0 <td> <span class=glyph>⋀</span> <tr id=entity-wedge><td> <code>wedge;</code> <td> U+02227 <td> <span class=glyph>∧</span> <tr id=entity-wedgeq><td> <code>wedgeq;</code> <td> U+02259 <td> <span class=glyph>≙</span> <tr id=entity-weierp><td> <code>weierp;</code> <td> U+02118 <td> <span class=glyph>℘</span> <tr id=entity-Wfr><td> <code>Wfr;</code> <td> U+1D51A <td> <span class=glyph>𝔚</span> <tr id=entity-wfr><td> <code>wfr;</code> <td> U+1D534 <td> <span class=glyph>𝔴</span> <tr id=entity-Wopf><td> <code>Wopf;</code> <td> U+1D54E <td> <span class=glyph>𝕎</span> <tr id=entity-wopf><td> <code>wopf;</code> <td> U+1D568 <td> <span class=glyph>𝕨</span> <tr id=entity-wp><td> <code>wp;</code> <td> U+02118 <td> <span class=glyph>℘</span> <tr id=entity-wr><td> <code>wr;</code> <td> U+02240 <td> <span class=glyph>≀</span> <tr id=entity-wreath><td> <code>wreath;</code> <td> U+02240 <td> <span class=glyph>≀</span> <tr id=entity-Wscr><td> <code>Wscr;</code> <td> U+1D4B2 <td> <span class=glyph>𝒲</span> <tr id=entity-wscr><td> <code>wscr;</code> <td> U+1D4CC <td> <span class=glyph>𝓌</span> <tr id=entity-xcap><td> <code>xcap;</code> <td> U+022C2 <td> <span class=glyph>⋂</span> <tr id=entity-xcirc><td> <code>xcirc;</code> <td> U+025EF <td> <span class=glyph>◯</span> <tr id=entity-xcup><td> <code>xcup;</code> <td> U+022C3 <td> <span class=glyph>⋃</span> <tr id=entity-xdtri><td> <code>xdtri;</code> <td> U+025BD <td> <span class=glyph>▽</span> <tr id=entity-Xfr><td> <code>Xfr;</code> <td> U+1D51B <td> <span class=glyph>𝔛</span> <tr id=entity-xfr><td> <code>xfr;</code> <td> U+1D535 <td> <span class=glyph>𝔵</span> <tr id=entity-xhArr><td> <code>xhArr;</code> <td> U+027FA <td> <span class=glyph>⟺</span> <tr id=entity-xharr><td> <code>xharr;</code> <td> U+027F7 <td> <span class=glyph>⟷</span> <tr id=entity-Xi><td> <code>Xi;</code> <td> U+0039E <td> <span class=glyph>Ξ</span> <tr id=entity-xi><td> <code>xi;</code> <td> U+003BE <td> <span class=glyph>ξ</span> <tr id=entity-xlArr><td> <code>xlArr;</code> <td> U+027F8 <td> <span class=glyph>⟸</span> <tr id=entity-xlarr><td> <code>xlarr;</code> <td> U+027F5 <td> <span class=glyph>⟵</span> <tr id=entity-xmap><td> <code>xmap;</code> <td> U+027FC <td> <span class=glyph>⟼</span> <tr id=entity-xnis><td> <code>xnis;</code> <td> U+022FB <td> <span class=glyph>⋻</span> <tr id=entity-xodot><td> <code>xodot;</code> <td> U+02A00 <td> <span class=glyph>⨀</span> <tr id=entity-Xopf><td> <code>Xopf;</code> <td> U+1D54F <td> <span class=glyph>𝕏</span> <tr id=entity-xopf><td> <code>xopf;</code> <td> U+1D569 <td> <span class=glyph>𝕩</span> <tr id=entity-xoplus><td> <code>xoplus;</code> <td> U+02A01 <td> <span class=glyph>⨁</span> <tr id=entity-xotime><td> <code>xotime;</code> <td> U+02A02 <td> <span class=glyph>⨂</span> <tr id=entity-xrArr><td> <code>xrArr;</code> <td> U+027F9 <td> <span class=glyph>⟹</span> <tr id=entity-xrarr><td> <code>xrarr;</code> <td> U+027F6 <td> <span class=glyph>⟶</span> <tr id=entity-Xscr><td> <code>Xscr;</code> <td> U+1D4B3 <td> <span class=glyph>𝒳</span> <tr id=entity-xscr><td> <code>xscr;</code> <td> U+1D4CD <td> <span class=glyph>𝓍</span> <tr id=entity-xsqcup><td> <code>xsqcup;</code> <td> U+02A06 <td> <span class=glyph>⨆</span> <tr id=entity-xuplus><td> <code>xuplus;</code> <td> U+02A04 <td> <span class=glyph>⨄</span> <tr id=entity-xutri><td> <code>xutri;</code> <td> U+025B3 <td> <span class=glyph>△</span> <tr id=entity-xvee><td> <code>xvee;</code> <td> U+022C1 <td> <span class=glyph>⋁</span> <tr id=entity-xwedge><td> <code>xwedge;</code> <td> U+022C0 <td> <span class=glyph>⋀</span> <tr id=entity-Yacute><td> <code>Yacute;</code> <td> U+000DD <td> <span class=glyph>Ý</span> <tr id=entity-Yacute-legacy class=impl><td> <code>Yacute</code> <td> U+000DD <td> <span>Ý</span> <tr id=entity-yacute><td> <code>yacute;</code> <td> U+000FD <td> <span class=glyph>ý</span> <tr id=entity-yacute-legacy class=impl><td> <code>yacute</code> <td> U+000FD <td> <span>ý</span> <tr id=entity-YAcy><td> <code>YAcy;</code> <td> U+0042F <td> <span class=glyph>Я</span> <tr id=entity-yacy><td> <code>yacy;</code> <td> U+0044F <td> <span class=glyph>я</span> <tr id=entity-Ycirc><td> <code>Ycirc;</code> <td> U+00176 <td> <span class=glyph>Ŷ</span> <tr id=entity-ycirc><td> <code>ycirc;</code> <td> U+00177 <td> <span class=glyph>ŷ</span> <tr id=entity-Ycy><td> <code>Ycy;</code> <td> U+0042B <td> <span class=glyph>Ы</span> <tr id=entity-ycy><td> <code>ycy;</code> <td> U+0044B <td> <span class=glyph>ы</span> <tr id=entity-yen><td> <code>yen;</code> <td> U+000A5 <td> <span class=glyph>¥</span> <tr id=entity-yen-legacy class=impl><td> <code>yen</code> <td> U+000A5 <td> <span>¥</span> <tr id=entity-Yfr><td> <code>Yfr;</code> <td> U+1D51C <td> <span class=glyph>𝔜</span> <tr id=entity-yfr><td> <code>yfr;</code> <td> U+1D536 <td> <span class=glyph>𝔶</span> <tr id=entity-YIcy><td> <code>YIcy;</code> <td> U+00407 <td> <span class=glyph>Ї</span> <tr id=entity-yicy><td> <code>yicy;</code> <td> U+00457 <td> <span class=glyph>ї</span> <tr id=entity-Yopf><td> <code>Yopf;</code> <td> U+1D550 <td> <span class=glyph>𝕐</span> <tr id=entity-yopf><td> <code>yopf;</code> <td> U+1D56A <td> <span class=glyph>𝕪</span> <tr id=entity-Yscr><td> <code>Yscr;</code> <td> U+1D4B4 <td> <span class=glyph>𝒴</span> <tr id=entity-yscr><td> <code>yscr;</code> <td> U+1D4CE <td> <span class=glyph>𝓎</span> <tr id=entity-YUcy><td> <code>YUcy;</code> <td> U+0042E <td> <span class=glyph>Ю</span> <tr id=entity-yucy><td> <code>yucy;</code> <td> U+0044E <td> <span class=glyph>ю</span> <tr id=entity-Yuml><td> <code>Yuml;</code> <td> U+00178 <td> <span class=glyph>Ÿ</span> <tr id=entity-yuml><td> <code>yuml;</code> <td> U+000FF <td> <span class=glyph>ÿ</span> <tr id=entity-yuml-legacy class=impl><td> <code>yuml</code> <td> U+000FF <td> <span>ÿ</span> <tr id=entity-Zacute><td> <code>Zacute;</code> <td> U+00179 <td> <span class=glyph>Ź</span> <tr id=entity-zacute><td> <code>zacute;</code> <td> U+0017A <td> <span class=glyph>ź</span> <tr id=entity-Zcaron><td> <code>Zcaron;</code> <td> U+0017D <td> <span class=glyph>Ž</span> <tr id=entity-zcaron><td> <code>zcaron;</code> <td> U+0017E <td> <span class=glyph>ž</span> <tr id=entity-Zcy><td> <code>Zcy;</code> <td> U+00417 <td> <span class=glyph>З</span> <tr id=entity-zcy><td> <code>zcy;</code> <td> U+00437 <td> <span class=glyph>з</span> <tr id=entity-Zdot><td> <code>Zdot;</code> <td> U+0017B <td> <span class=glyph>Ż</span> <tr id=entity-zdot><td> <code>zdot;</code> <td> U+0017C <td> <span class=glyph>ż</span> <tr id=entity-zeetrf><td> <code>zeetrf;</code> <td> U+02128 <td> <span class=glyph>ℨ</span> <tr id=entity-ZeroWidthSpace><td> <code>ZeroWidthSpace;</code> <td> U+0200B <td> <span class=glyph>​</span> <tr id=entity-Zeta><td> <code>Zeta;</code> <td> U+00396 <td> <span class=glyph>Ζ</span> <tr id=entity-zeta><td> <code>zeta;</code> <td> U+003B6 <td> <span class=glyph>ζ</span> <tr id=entity-Zfr><td> <code>Zfr;</code> <td> U+02128 <td> <span class=glyph>ℨ</span> <tr id=entity-zfr><td> <code>zfr;</code> <td> U+1D537 <td> <span class=glyph>𝔷</span> <tr id=entity-ZHcy><td> <code>ZHcy;</code> <td> U+00416 <td> <span class=glyph>Ж</span> <tr id=entity-zhcy><td> <code>zhcy;</code> <td> U+00436 <td> <span class=glyph>ж</span> <tr id=entity-zigrarr><td> <code>zigrarr;</code> <td> U+021DD <td> <span class=glyph>⇝</span> <tr id=entity-Zopf><td> <code>Zopf;</code> <td> U+02124 <td> <span class=glyph>ℤ</span> <tr id=entity-zopf><td> <code>zopf;</code> <td> U+1D56B <td> <span class=glyph>𝕫</span> <tr id=entity-Zscr><td> <code>Zscr;</code> <td> U+1D4B5 <td> <span class=glyph>𝒵</span> <tr id=entity-zscr><td> <code>zscr;</code> <td> U+1D4CF <td> <span class=glyph>𝓏</span> <tr id=entity-zwj><td> <code>zwj;</code> <td> U+0200D <td> <span class=glyph>‍</span> <tr id=entity-zwnj><td> <code>zwnj;</code> <td> U+0200C <td> <span class=glyph>‌</span> </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 the Unicode specifications for formal
  definitions of the characters listed above.</i></p>

  <p class=note>The character reference names originate from the <cite>XML Entity Definitions for
  Characters</cite> specification, though only the above is considered normative. <a href=#refsXMLENTITY>[XMLENTITY]</a></p>


  <h2 id=the-xhtml-syntax><span class=secno>13</span> <dfn id=xhtml>The XML syntax</dfn><a href=#the-xhtml-syntax class=self-link></a></h2><div class=status><input onclick=toggleStatus(this) value=⋰ type=button><p class=support><strong>Support:</strong> xhtml<span class="and_chr yes"><span>Chrome for Android</span> <span>67+</span></span><span class="chrome yes"><span>Chrome</span> <span>4+</span></span><span class="ios_saf yes"><span>iOS Safari</span> <span>3.2+</span></span><span class="and_uc yes"><span>UC Browser for Android</span> <span>11.8+</span></span><span class="firefox yes"><span>Firefox</span> <span>2+</span></span><span class="ie yes"><span>IE</span> <span>9+</span></span><span class="op_mini yes"><span>Opera Mini</span> <span>all+</span></span><span class="safari yes"><span>Safari</span> <span>3.1+</span></span><span class="edge yes"><span>Edge</span> <span>12+</span></span><span class="samsung yes"><span>Samsung Internet</span> <span>4+</span></span><span class="opera yes"><span>Opera</span> <span>9+</span></span><span class="android yes"><span>Android Browser</span> <span>2.1+</span></span><p class=caniuse>Source: <a href="https://caniuse.com/#feat=xhtml">caniuse.com</a></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>

  

  <h3 id=writing-xhtml-documents><span class=secno>13.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 the XML and Namespaces in XML specifications. <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 the XML specification, 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>13.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 the XML specification 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 the XML specification, the Namespaces
  in XML specification, and the WHATWG DOM standard. 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 datastructures 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>DOM mutation events must not fire 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, but 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
  the WHATWG DOM standard'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 (unlike mutation events). <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, e.g. by the <code id=parsing-xhtml-documents:the-object-element><a href=#the-object-element>object</a></code> element to avoid instantiating plugins
  before the <code id=parsing-xhtml-documents:the-param-element><a href=#the-param-element>param</a></code> element children have been parsed.</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><code>-//W3C//DTD XHTML 1.1//EN</code><li><code>-//W3C//DTD XHTML 1.0 Strict//EN</code><li><code>-//W3C//DTD XHTML 1.0 Frameset//EN</code><li><code>-//W3C//DTD XHTML Basic 1.0//EN</code><li><code>-//W3C//DTD XHTML 1.1 plus MathML 2.0//EN</code><li><code>-//W3C//DTD XHTML 1.1 plus MathML 2.0 plus SVG 1.1//EN</code><li><code>-//W3C//DTD MathML 2.0//EN</code><li><code>-//WAPFORUM//DTD XHTML Mobile 1.0//EN</code></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=#willful-violation id=parsing-xhtml-documents:willful-violation>violation</a> of the XML
  specification, but it does contradict the spirit of the XML specification'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>

  <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 be marked as being <a href=#parser-inserted id=parsing-xhtml-documents:parser-inserted>"parser-inserted"</a> and its <a href=#non-blocking id=parsing-xhtml-documents:non-blocking>"non-blocking"</a> flag
  must be unset. If the parser was originally created for the <a href=#xml-fragment-parsing-algorithm id=parsing-xhtml-documents:xml-fragment-parsing-algorithm>XML fragment parsing
  algorithm</a>, then the element must be marked as <a href=#already-started id=parsing-xhtml-documents:already-started>"already started"</a> also. 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-a-script id=parsing-xhtml-documents:prepare-a-script>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.<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> flag is set.<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.<li><p><a href=#execute-the-script-block id=parsing-xhtml-documents:execute-the-script-block>Execute</a> the <a href=#pending-parsing-blocking-script id=parsing-xhtml-documents:pending-parsing-blocking-script-3>pending parsing-blocking
   script</a>.<li><p>There is no longer a <a href=#pending-parsing-blocking-script id=parsing-xhtml-documents:pending-parsing-blocking-script-4>pending parsing-blocking script</a>.</ol>

  <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 href=#willful-violation id=parsing-xhtml-documents:willful-violation-2>willful violation</a> of the XML specification; 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>

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

  <p>Certain algorithms in this specification <dfn id=feed-the-parser>spoon-feed the
  parser</dfn> characters one string 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>

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

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

  <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<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.<dt>For all other nodes<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.</dl>

  <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://heycam.github.io/webidl/#invalidstateerror data-x-internal=invalidstateerror>"<code>InvalidStateError</code>"</a> <code id=serialising-xhtml-fragments:domexception><a data-x-internal=domexception href=https://heycam.github.io/webidl/#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>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>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>A node with a  local name containing a U+003A COLON (:).<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>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>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>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>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>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>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>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>?></code>".</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://heycam.github.io/webidl/#hierarchyrequesterror data-x-internal=hierarchyrequesterror>"<code>HierarchyRequestError</code>"</a> <code id=serialising-xhtml-fragments:domexception-2><a data-x-internal=domexception href=https://heycam.github.io/webidl/#dfn-DOMException>DOMException</a></code>.</p>



  <h3 id=parsing-xhtml-fragments><span class=secno>13.4</span> Parsing XML fragments<a href=#parsing-xhtml-fragments class=self-link></a></h3>

  <p>The <dfn id=xml-fragment-parsing-algorithm>XML fragment parsing algorithm</dfn> either returns a <code id=parsing-xhtml-fragments:document><a href=#document>Document</a></code> or throws
  a <a id=parsing-xhtml-fragments:syntaxerror href=https://heycam.github.io/webidl/#syntaxerror data-x-internal=syntaxerror>"<code>SyntaxError</code>"</a> <code id=parsing-xhtml-fragments:domexception><a data-x-internal=domexception href=https://heycam.github.io/webidl/#dfn-DOMException>DOMException</a></code>. Given a string
  <var>input</var> and a context element <var id=parsing-xhtml-fragments:concept-frag-parse-context><a href=#concept-frag-parse-context>context</a></var>, the
  algorithm is as follows:</p>

  <ol><li>

    <p>Create a new <a href=#xml-parser id=parsing-xhtml-fragments:xml-parser>XML parser</a>.</p>

   <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 the <var id=parsing-xhtml-fragments:concept-frag-parse-context-2><a href=#concept-frag-parse-context>context</a></var> element, 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>

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

    <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 the <var id=parsing-xhtml-fragments:concept-frag-parse-context-3><a href=#concept-frag-parse-context>context</a></var> element.</p>

   <li>

    <p>If there is an XML well-formedness or XML namespace well-formedness error, then throw a
    <a id=parsing-xhtml-fragments:syntaxerror-2 href=https://heycam.github.io/webidl/#syntaxerror data-x-internal=syntaxerror>"<code>SyntaxError</code>"</a> <code id=parsing-xhtml-fragments:domexception-2><a data-x-internal=domexception href=https://heycam.github.io/webidl/#dfn-DOMException>DOMException</a></code>.</p>

   <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-2><a href=#document>Document</a></code> has any sibling
    nodes, then throw a <a id=parsing-xhtml-fragments:syntaxerror-3 href=https://heycam.github.io/webidl/#syntaxerror data-x-internal=syntaxerror>"<code>SyntaxError</code>"</a> <code id=parsing-xhtml-fragments:domexception-3><a data-x-internal=domexception href=https://heycam.github.io/webidl/#dfn-DOMException>DOMException</a></code>.</p>

    

   <li><p>Return the child nodes of the <a id=parsing-xhtml-fragments:document-element-2 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-3><a href=#document>Document</a></code>, 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>.</ol>

  



  

  <h2 id=rendering><span class=secno>14</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 "expected" in this section has the same conformance
  implications as "must".</i></p>


  <h3 id=introduction-16><span class=secno>14.1</span> Introduction<a href=#introduction-16 class=self-link></a></h3>

  <p>In general, user agents are expected to support CSS, and many of the suggestions in this
  section are expressed in CSS terms. User agents that use other presentation mechanisms can derive
  their expected behavior by translating from the CSS rules given in this section.</p>

  <p>In the absence of style-layer rules to the contrary (e.g. author style sheets), user agents are
  expected 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>

  <p>An element is <dfn id=being-rendered>being rendered</dfn> if it has any associated CSS layout boxes, SVG layout
  boxes, or some equivalent in other styling languages.</p>

  <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:the-hidden-attribute><a href=#the-hidden-attribute>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>

  <hr>

  <p>User agents that do not honor author-level CSS style sheets are nonetheless expected 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/visuren.html#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>14.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, expected 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>presentational hints</dfn>.</p>

  <hr>

  <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 expected 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>

  <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 expected 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>

  <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 expected 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>

  <p>When a user agent is to <dfn id=align-descendants>align descendants</dfn> of a node, the user agent is expected 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 expected to override the others.
  Aligned elements are expected 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>



  <h3 id=non-replaced-elements><span class=secno>14.3</span> Non-replaced elements<a href=#non-replaced-elements class=self-link></a></h3>


  <h4 id=hidden-elements><span class=secno>14.3.1</span> Hidden elements<a href=#hidden-elements class=self-link></a></h4>

  <pre><code class='css'><c- n>@namespace</c-> <c- nf>url</c-><c- p>(</c-><c- s>http://www.w3.org/1999/xhtml</c-><c- p>);</c->

<span id='hiddenCSS'><c- f>[hidden]</c-></span><c- f>, area, base, basefont, datalist, head, link, meta, noembed,</c->
<c- f>noframes, param, rp, script, source, style, template, track, title </c-><c- p>{</c->
  <c- k>display</c-><c- p>:</c-> none<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>14.3.2</span> The page<a href=#the-page class=self-link></a></h4>

  <pre><code class='css'><c- n>@namespace</c-> <c- nf>url</c-><c- p>(</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>


  

  <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 expected to be used for that
  property instead.</p>
  <table><thead><tr><th>Property
     <th>Source
   <tbody><tr><td rowspan=3><a id="the-page:'margin-top'" href=https://drafts.csswg.org/css2/box.html#propdef-margin-top data-x-internal="'margin-top'">'margin-top'</a>
     <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
    <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
    <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
   <tbody><tr><td rowspan=3><a id="the-page:'margin-right'" href=https://drafts.csswg.org/css2/box.html#propdef-margin-right data-x-internal="'margin-right'">'margin-right'</a>
     <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
    <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
    <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
   <tbody><tr><td rowspan=3><a id="the-page:'margin-bottom'" href=https://drafts.csswg.org/css2/box.html#propdef-margin-bottom data-x-internal="'margin-bottom'">'margin-bottom'</a>
     <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
    <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
    <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
   <tbody><tr><td rowspan=3><a id="the-page:'margin-left'" href=https://drafts.csswg.org/css2/box.html#propdef-margin-left data-x-internal="'margin-left'">'margin-left'</a>
     <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
    <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
    <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
  </table>

  <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=#concept-document-bc id=the-page:concept-document-bc>browsing context</a> is a <a href=#nested-browsing-context id=the-page:nested-browsing-context>nested browsing context</a>,
  and the <a href=#browsing-context-container id=the-page:browsing-context-container>browsing context container</a> of that <a href=#nested-browsing-context id=the-page:nested-browsing-context-2>nested browsing context</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>

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

  <p>If a <code id=the-page:document><a href=#document>Document</a></code> is in a <a href=#nested-browsing-context id=the-page:nested-browsing-context-3>nested browsing context</a>, it is expected to be
  positioned and sized to fit inside the <a id=the-page:content-box href=https://drafts.csswg.org/css2/box.html#x10 data-x-internal=content-box>content box</a> of its <a href=#browsing-context-container id=the-page:browsing-context-container-2>browsing context
  container</a>. If a <a href=#browsing-context id=the-page:browsing-context>browsing context</a>'s <a href=#browsing-context-container id=the-page:browsing-context-container-3>browsing context container</a> is
  not <a href=#being-rendered id=the-page:being-rendered>being rendered</a>, the <a href=#browsing-context id=the-page:browsing-context-2>browsing context</a> is expected to have a
  <a id=the-page:viewport href=https://drafts.csswg.org/css2/visuren.html#viewport data-x-internal=viewport>viewport</a> with zero width and zero height.</p>

  <p>If the <code id=the-page:document-2><a href=#document>Document</a></code> is in a <a href=#nested-browsing-context id=the-page:nested-browsing-context-4>nested browsing context</a>, and the
  <a href=#browsing-context-container id=the-page:browsing-context-container-4>browsing context container</a> of that <a href=#nested-browsing-context id=the-page:nested-browsing-context-5>nested browsing context</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, and 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 expected to
  prevent any scroll bars from being shown for the <a id=the-page:viewport-2 href=https://drafts.csswg.org/css2/visuren.html#viewport data-x-internal=viewport>viewport</a> of the
  <a href=#nested-browsing-context id=the-page:nested-browsing-context-6>nested browsing context</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/visuren.html#viewport data-x-internal=viewport>viewport</a>.</p>

  <hr>

  <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 expected to be <a href=#parse-a-url id=the-page:parse-a-url>parsed</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 this is
  successful, the user agent is expected 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/#the-background-image data-x-internal="'background-image'">'background-image'</a> property
  to the <a href=#resulting-url-string id=the-page:resulting-url-string>resulting URL string</a>.</p>

  <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 expected 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 an error, the user agent is expected 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/#the-background-color data-x-internal="'background-color'">'background-color'</a> property to the resulting color.</p>

  <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 expected 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 an error, the user agent is expected 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>

  <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 expected 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 an error, the user agent is expected 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-3><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>

  <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 expected 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 an error, the user agent is expected 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-4><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>

  <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 expected 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 an error, the user agent is expected 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-5><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>



  <h4 id=flow-content-3><span class=secno>14.3.3</span> Flow content<a href=#flow-content-3 class=self-link></a></h4>

  

  <pre><code class='css'><c- n>@namespace</c-> <c- nf>url</c-><c- p>(</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, 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-start</c-><c- p>:</c-> <c- m>1</c-><c- l>em</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->

<c- f>blockquote, figure </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- k>margin-inline-end</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>offset-inline-start</c-><c- p>:</c-> <c- m>0</c-><c- p>;</c-> <c- k>offset-inline-end</c-><c- p>:</c-> <c- m>0</c-><c- p>;</c->
  <c- k>width</c-><c- p>:</c-> fit-content<c- p>;</c->
  <c- k>height</c-><c- p>:</c-> fit-content<c- p>;</c->
  <c- k>margin</c-><c- p>:</c-> auto<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</c-><c- p>:</c-> white<c- p>;</c->
  <c- k>color</c-><c- p>:</c-> black<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>slot </c-><c- p>{</c->
  <c- k>display</c-><c- p>:</c-> contents<c- p>;</c->
<c- p>}</c-></code></pre>

  <p>The following rules are also expected 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- nf>url</c-><c- p>(</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 expected to apply:</p>

  <pre><code class='css'><c- n>@namespace</c-> <c- nf>url</c-><c- p>(</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>

  <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 expected 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>

  <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 expected 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>

  <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 expected 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>

  <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 expected 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>



  <h4 id=phrasing-content-3><span class=secno>14.3.4</span> Phrasing content<a href=#phrasing-content-3 class=self-link></a></h4>

  <pre><code class='css'><c- n>@namespace</c-> <c- nf>url</c-><c- p>(</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 </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 expected 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- nf>url</c-><c- p>(</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 expected to be wrapped in anonymous boxes
  whose <a id="phrasing-content-3:'display'" href=https://drafts.csswg.org/css2/visuren.html#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 expected 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 expected to support the <a id="phrasing-content-3:'clear'" href=https://drafts.csswg.org/css2/visuren.html#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 the CSS
  specification.</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 expected to be black. The initial
  value for the <a id="phrasing-content-3:'background-color'" href=https://drafts.csswg.org/css-backgrounds/#the-background-color data-x-internal="'background-color'">'background-color'</a> property is expected to be 'transparent'. The
  canvas's background is expected to be white.</p>

  <hr>

  <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 expected 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 an error, the user agent is expected 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>

  <p id=the-font-element-text-decoration-color-quirk>The <code id=phrasing-content-3:font-2><a href=#font>font</a></code> element is expected to
  override the color of any text decoration that spans the text of the element to the
  <a id=phrasing-content-3:used-value href=https://drafts.csswg.org/css-cascade/#used-value data-x-internal=used-value>used value</a> of the element's <a id="phrasing-content-3:'color'-3" href=https://drafts.csswg.org/css-color/#the-color-property data-x-internal="'color'">'color'</a> property.</p>

  <p>When a <code id=phrasing-content-3:font-3><a href=#font>font</a></code> element has a <code>face</code>
  attribute, the user agent is expected 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>

  

  <p>When a <code id=phrasing-content-3:font-4><a href=#font>font</a></code> element has a <code>size</code>
  attribute, the user agent is expected 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.<li><p>Let <var>position</var> be a pointer into <var>input</var>, initially pointing at the
   start of the string.<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>.<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.<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>.<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 the resulting sequence be
   <var>digits</var>.<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.<li><p>Interpret <var>digits</var> as a base-ten integer. Let <var>value</var> be the resulting
   number.<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><p>If <var>value</var> is greater than 7, let it be 7.<li><p>If <var>value</var> is less than 1, let it be 1.<li>

    <p>Set <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> 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><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>Notes
     <tbody><tr><td>1
       <td>'x-small'
       <td>
      <tr><td>2
       <td>'small'
       <td>
      <tr><td>3
       <td>'medium'
       <td>
      <tr><td>4
       <td>'large'
       <td>
      <tr><td>5
       <td>'x-large'
       <td>
      <tr><td>6
       <td>'xx-large'
       <td>
      <tr><td>7
       <td>'xxx-large'
       <td><i>see below</i>
    </table>

    <p class=tablenote><small>The 'xxx-large' value is a non-CSS value used here to
    indicate a font size 50% larger than 'xx-large'.</small></p>

   </ol>


  <h4 id=bidi-rendering><span class=secno>14.3.5</span> Bidirectional text<a href=#bidi-rendering class=self-link></a></h4>

  <pre><code class='css'><c- n>@namespace</c-> <c- nf>url</c-><c- p>(</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, h1, h2,</c->
<c- f>h3, h4, h5, h6, hgroup, nav, section, 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]:matches([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 &apos;content&apos; 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:the-dir-attribute><a href=#the-dir-attribute>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
  expected 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="#e-mail-state-(type=email)" id="bidi-rendering:e-mail-state-(type=email)">E-mail</a> state) are expected 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 expected to apply, following those above: <a href=#refsENCODING>[ENCODING]</a></p>

  <pre><code class='css'><c- n>@namespace</c-> <c- nf>url</c-><c- p>(</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, h1, h2,</c->
<c- f>h3, h4, h5, h6, hgroup, nav, section, 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=quotes><span class=secno>14.3.6</span> Quotes<a href=#quotes class=self-link></a></h4>

  <p>This block is automatically generated from the Unicode Common Locale Data Repository. <a href=#refsCLDR>[CLDR]</a></p>

  <p>User agents are expected to use either the block below (which will be regularly updated) or to
  automatically generate their own copy directly from the source material. The language codes are
  derived from the CLDR file names. The quotes are derived from the <code>delimiter</code>
  blocks, with fallback handled as specified in the CLDR documentation.</p>

  <pre><code class='css'><c- n>@namespace</c-> <c- nf>url</c-><c- p>(</c-><c- s>http://www.w3.org/1999/xhtml</c-><c- p>);</c->

<c- f>:root                                                         </c-><c- p>{</c-> <c- k>quotes</c-><c- p>:</c-> <c- s>&apos;\201c&apos;</c-> <c- s>&apos;\201d&apos;</c-> <c- s>&apos;\2018&apos;</c-> <c- s>&apos;\2019&apos;</c-> <c- p>}</c-> <c- c>/* “ ” ‘ ’ */</c->
<c- f>:root:lang(af),       :not(:lang(af)) &gt; :lang(af)             </c-><c- p>{</c-> <c- k>quotes</c-><c- p>:</c-> <c- s>&apos;\201c&apos;</c-> <c- s>&apos;\201d&apos;</c-> <c- s>&apos;\2018&apos;</c-> <c- s>&apos;\2019&apos;</c-> <c- p>}</c-> <c- c>/* “ ” ‘ ’ */</c->
<c- f>:root:lang(agq),      :not(:lang(agq)) &gt; :lang(agq)           </c-><c- p>{</c-> <c- k>quotes</c-><c- p>:</c-> <c- s>&apos;\201e&apos;</c-> <c- s>&apos;\201d&apos;</c-> <c- s>&apos;\201a&apos;</c-> <c- s>&apos;\2019&apos;</c-> <c- p>}</c-> <c- c>/* „ ” ‚ ’ */</c->
<c- f>:root:lang(ak),       :not(:lang(ak)) &gt; :lang(ak)             </c-><c- p>{</c-> <c- k>quotes</c-><c- p>:</c-> <c- s>&apos;\201c&apos;</c-> <c- s>&apos;\201d&apos;</c-> <c- s>&apos;\2018&apos;</c-> <c- s>&apos;\2019&apos;</c-> <c- p>}</c-> <c- c>/* “ ” ‘ ’ */</c->
<c- f>:root:lang(am),       :not(:lang(am)) &gt; :lang(am)             </c-><c- p>{</c-> <c- k>quotes</c-><c- p>:</c-> <c- s>&apos;\00ab&apos;</c-> <c- s>&apos;\00bb&apos;</c-> <c- s>&apos;\2039&apos;</c-> <c- s>&apos;\203a&apos;</c-> <c- p>}</c-> <c- c>/* « » ‹ › */</c->
<c- f>:root:lang(ar),       :not(:lang(ar)) &gt; :lang(ar)             </c-><c- p>{</c-> <c- k>quotes</c-><c- p>:</c-> <c- s>&apos;\201d&apos;</c-> <c- s>&apos;\201c&apos;</c-> <c- s>&apos;\2019&apos;</c-> <c- s>&apos;\2018&apos;</c-> <c- p>}</c-> <c- c>/* ” “ ’ ‘ */</c->
<c- f>:root:lang(asa),      :not(:lang(asa)) &gt; :lang(asa)           </c-><c- p>{</c-> <c- k>quotes</c-><c- p>:</c-> <c- s>&apos;\201c&apos;</c-> <c- s>&apos;\201d&apos;</c-> <c- s>&apos;\2018&apos;</c-> <c- s>&apos;\2019&apos;</c-> <c- p>}</c-> <c- c>/* “ ” ‘ ’ */</c->
<c- f>:root:lang(ast),      :not(:lang(ast)) &gt; :lang(ast)           </c-><c- p>{</c-> <c- k>quotes</c-><c- p>:</c-> <c- s>&apos;\00ab&apos;</c-> <c- s>&apos;\00bb&apos;</c-> <c- s>&apos;\201c&apos;</c-> <c- s>&apos;\201d&apos;</c-> <c- p>}</c-> <c- c>/* « » “ ” */</c->
<c- f>:root:lang(az),       :not(:lang(az)) &gt; :lang(az)             </c-><c- p>{</c-> <c- k>quotes</c-><c- p>:</c-> <c- s>&apos;\201c&apos;</c-> <c- s>&apos;\201d&apos;</c-> <c- s>&apos;\2018&apos;</c-> <c- s>&apos;\2019&apos;</c-> <c- p>}</c-> <c- c>/* “ ” ‘ ’ */</c->
<c- f>:root:lang(az-Cyrl),  :not(:lang(az-Cyrl)) &gt; :lang(az-Cyrl)   </c-><c- p>{</c-> <c- k>quotes</c-><c- p>:</c-> <c- s>&apos;\00ab&apos;</c-> <c- s>&apos;\00bb&apos;</c-> <c- s>&apos;\2039&apos;</c-> <c- s>&apos;\203a&apos;</c-> <c- p>}</c-> <c- c>/* « » ‹ › */</c->
<c- f>:root:lang(bas),      :not(:lang(bas)) &gt; :lang(bas)           </c-><c- p>{</c-> <c- k>quotes</c-><c- p>:</c-> <c- s>&apos;\00ab&apos;</c-> <c- s>&apos;\00bb&apos;</c-> <c- s>&apos;\201e&apos;</c-> <c- s>&apos;\201c&apos;</c-> <c- p>}</c-> <c- c>/* « » „ “ */</c->
<c- f>:root:lang(be),       :not(:lang(be)) &gt; :lang(be)             </c-><c- p>{</c-> <c- k>quotes</c-><c- p>:</c-> <c- s>&apos;\00ab&apos;</c-> <c- s>&apos;\00bb&apos;</c-> <c- s>&apos;\201e&apos;</c-> <c- s>&apos;\201c&apos;</c-> <c- p>}</c-> <c- c>/* « » „ “ */</c->
<c- f>:root:lang(bem),      :not(:lang(bem)) &gt; :lang(bem)           </c-><c- p>{</c-> <c- k>quotes</c-><c- p>:</c-> <c- s>&apos;\201c&apos;</c-> <c- s>&apos;\201d&apos;</c-> <c- s>&apos;\2018&apos;</c-> <c- s>&apos;\2019&apos;</c-> <c- p>}</c-> <c- c>/* “ ” ‘ ’ */</c->
<c- f>:root:lang(bez),      :not(:lang(bez)) &gt; :lang(bez)           </c-><c- p>{</c-> <c- k>quotes</c-><c- p>:</c-> <c- s>&apos;\201c&apos;</c-> <c- s>&apos;\201d&apos;</c-> <c- s>&apos;\2018&apos;</c-> <c- s>&apos;\2019&apos;</c-> <c- p>}</c-> <c- c>/* “ ” ‘ ’ */</c->
<c- f>:root:lang(bg),       :not(:lang(bg)) &gt; :lang(bg)             </c-><c- p>{</c-> <c- k>quotes</c-><c- p>:</c-> <c- s>&apos;\201e&apos;</c-> <c- s>&apos;\201c&apos;</c-> <c- s>&apos;\201e&apos;</c-> <c- s>&apos;\201c&apos;</c-> <c- p>}</c-> <c- c>/* „ “ „ “ */</c->
<c- f>:root:lang(bm),       :not(:lang(bm)) &gt; :lang(bm)             </c-><c- p>{</c-> <c- k>quotes</c-><c- p>:</c-> <c- s>&apos;\00ab&apos;</c-> <c- s>&apos;\00bb&apos;</c-> <c- s>&apos;\201c&apos;</c-> <c- s>&apos;\201d&apos;</c-> <c- p>}</c-> <c- c>/* « » “ ” */</c->
<c- f>:root:lang(bn),       :not(:lang(bn)) &gt; :lang(bn)             </c-><c- p>{</c-> <c- k>quotes</c-><c- p>:</c-> <c- s>&apos;\201c&apos;</c-> <c- s>&apos;\201d&apos;</c-> <c- s>&apos;\2018&apos;</c-> <c- s>&apos;\2019&apos;</c-> <c- p>}</c-> <c- c>/* “ ” ‘ ’ */</c->
<c- f>:root:lang(br),       :not(:lang(br)) &gt; :lang(br)             </c-><c- p>{</c-> <c- k>quotes</c-><c- p>:</c-> <c- s>&apos;\00ab&apos;</c-> <c- s>&apos;\00bb&apos;</c-> <c- s>&apos;\201c&apos;</c-> <c- s>&apos;\201d&apos;</c-> <c- p>}</c-> <c- c>/* « » “ ” */</c->
<c- f>:root:lang(brx),      :not(:lang(brx)) &gt; :lang(brx)           </c-><c- p>{</c-> <c- k>quotes</c-><c- p>:</c-> <c- s>&apos;\201c&apos;</c-> <c- s>&apos;\201d&apos;</c-> <c- s>&apos;\2018&apos;</c-> <c- s>&apos;\2019&apos;</c-> <c- p>}</c-> <c- c>/* “ ” ‘ ’ */</c->
<c- f>:root:lang(bs),       :not(:lang(bs)) &gt; :lang(bs)             </c-><c- p>{</c-> <c- k>quotes</c-><c- p>:</c-> <c- s>&apos;\201e&apos;</c-> <c- s>&apos;\201d&apos;</c-> <c- s>&apos;\2018&apos;</c-> <c- s>&apos;\2019&apos;</c-> <c- p>}</c-> <c- c>/* „ ” ‘ ’ */</c->
<c- f>:root:lang(bs-Cyrl),  :not(:lang(bs-Cyrl)) &gt; :lang(bs-Cyrl)   </c-><c- p>{</c-> <c- k>quotes</c-><c- p>:</c-> <c- s>&apos;\201e&apos;</c-> <c- s>&apos;\201c&apos;</c-> <c- s>&apos;\201a&apos;</c-> <c- s>&apos;\2018&apos;</c-> <c- p>}</c-> <c- c>/* „ “ ‚ ‘ */</c->
<c- f>:root:lang(ca),       :not(:lang(ca)) &gt; :lang(ca)             </c-><c- p>{</c-> <c- k>quotes</c-><c- p>:</c-> <c- s>&apos;\00ab&apos;</c-> <c- s>&apos;\00bb&apos;</c-> <c- s>&apos;\201c&apos;</c-> <c- s>&apos;\201d&apos;</c-> <c- p>}</c-> <c- c>/* « » “ ” */</c->
<c- f>:root:lang(cgg),      :not(:lang(cgg)) &gt; :lang(cgg)           </c-><c- p>{</c-> <c- k>quotes</c-><c- p>:</c-> <c- s>&apos;\201c&apos;</c-> <c- s>&apos;\201d&apos;</c-> <c- s>&apos;\2018&apos;</c-> <c- s>&apos;\2019&apos;</c-> <c- p>}</c-> <c- c>/* “ ” ‘ ’ */</c->
<c- f>:root:lang(chr),      :not(:lang(chr)) &gt; :lang(chr)           </c-><c- p>{</c-> <c- k>quotes</c-><c- p>:</c-> <c- s>&apos;\201c&apos;</c-> <c- s>&apos;\201d&apos;</c-> <c- s>&apos;\2018&apos;</c-> <c- s>&apos;\2019&apos;</c-> <c- p>}</c-> <c- c>/* “ ” ‘ ’ */</c->
<c- f>:root:lang(cs),       :not(:lang(cs)) &gt; :lang(cs)             </c-><c- p>{</c-> <c- k>quotes</c-><c- p>:</c-> <c- s>&apos;\201e&apos;</c-> <c- s>&apos;\201c&apos;</c-> <c- s>&apos;\201a&apos;</c-> <c- s>&apos;\2018&apos;</c-> <c- p>}</c-> <c- c>/* „ “ ‚ ‘ */</c->
<c- f>:root:lang(cy),       :not(:lang(cy)) &gt; :lang(cy)             </c-><c- p>{</c-> <c- k>quotes</c-><c- p>:</c-> <c- s>&apos;\201c&apos;</c-> <c- s>&apos;\201d&apos;</c-> <c- s>&apos;\2018&apos;</c-> <c- s>&apos;\2019&apos;</c-> <c- p>}</c-> <c- c>/* “ ” ‘ ’ */</c->
<c- f>:root:lang(da),       :not(:lang(da)) &gt; :lang(da)             </c-><c- p>{</c-> <c- k>quotes</c-><c- p>:</c-> <c- s>&apos;\201c&apos;</c-> <c- s>&apos;\201d&apos;</c-> <c- s>&apos;\2018&apos;</c-> <c- s>&apos;\2019&apos;</c-> <c- p>}</c-> <c- c>/* “ ” ‘ ’ */</c->
<c- f>:root:lang(dav),      :not(:lang(dav)) &gt; :lang(dav)           </c-><c- p>{</c-> <c- k>quotes</c-><c- p>:</c-> <c- s>&apos;\201c&apos;</c-> <c- s>&apos;\201d&apos;</c-> <c- s>&apos;\2018&apos;</c-> <c- s>&apos;\2019&apos;</c-> <c- p>}</c-> <c- c>/* “ ” ‘ ’ */</c->
<c- f>:root:lang(de),       :not(:lang(de)) &gt; :lang(de)             </c-><c- p>{</c-> <c- k>quotes</c-><c- p>:</c-> <c- s>&apos;\201e&apos;</c-> <c- s>&apos;\201c&apos;</c-> <c- s>&apos;\201a&apos;</c-> <c- s>&apos;\2018&apos;</c-> <c- p>}</c-> <c- c>/* „ “ ‚ ‘ */</c->
<c- f>:root:lang(dje),      :not(:lang(dje)) &gt; :lang(dje)           </c-><c- p>{</c-> <c- k>quotes</c-><c- p>:</c-> <c- s>&apos;\201c&apos;</c-> <c- s>&apos;\201d&apos;</c-> <c- s>&apos;\2018&apos;</c-> <c- s>&apos;\2019&apos;</c-> <c- p>}</c-> <c- c>/* “ ” ‘ ’ */</c->
<c- f>:root:lang(dsb),      :not(:lang(dsb)) &gt; :lang(dsb)           </c-><c- p>{</c-> <c- k>quotes</c-><c- p>:</c-> <c- s>&apos;\201e&apos;</c-> <c- s>&apos;\201c&apos;</c-> <c- s>&apos;\201a&apos;</c-> <c- s>&apos;\2018&apos;</c-> <c- p>}</c-> <c- c>/* „ “ ‚ ‘ */</c->
<c- f>:root:lang(dua),      :not(:lang(dua)) &gt; :lang(dua)           </c-><c- p>{</c-> <c- k>quotes</c-><c- p>:</c-> <c- s>&apos;\00ab&apos;</c-> <c- s>&apos;\00bb&apos;</c-> <c- s>&apos;\2018&apos;</c-> <c- s>&apos;\2019&apos;</c-> <c- p>}</c-> <c- c>/* « » ‘ ’ */</c->
<c- f>:root:lang(dyo),      :not(:lang(dyo)) &gt; :lang(dyo)           </c-><c- p>{</c-> <c- k>quotes</c-><c- p>:</c-> <c- s>&apos;\00ab&apos;</c-> <c- s>&apos;\00bb&apos;</c-> <c- s>&apos;\201c&apos;</c-> <c- s>&apos;\201d&apos;</c-> <c- p>}</c-> <c- c>/* « » “ ” */</c->
<c- f>:root:lang(dz),       :not(:lang(dz)) &gt; :lang(dz)             </c-><c- p>{</c-> <c- k>quotes</c-><c- p>:</c-> <c- s>&apos;\201c&apos;</c-> <c- s>&apos;\201d&apos;</c-> <c- s>&apos;\2018&apos;</c-> <c- s>&apos;\2019&apos;</c-> <c- p>}</c-> <c- c>/* “ ” ‘ ’ */</c->
<c- f>:root:lang(ebu),      :not(:lang(ebu)) &gt; :lang(ebu)           </c-><c- p>{</c-> <c- k>quotes</c-><c- p>:</c-> <c- s>&apos;\201c&apos;</c-> <c- s>&apos;\201d&apos;</c-> <c- s>&apos;\2018&apos;</c-> <c- s>&apos;\2019&apos;</c-> <c- p>}</c-> <c- c>/* “ ” ‘ ’ */</c->
<c- f>:root:lang(ee),       :not(:lang(ee)) &gt; :lang(ee)             </c-><c- p>{</c-> <c- k>quotes</c-><c- p>:</c-> <c- s>&apos;\201c&apos;</c-> <c- s>&apos;\201d&apos;</c-> <c- s>&apos;\2018&apos;</c-> <c- s>&apos;\2019&apos;</c-> <c- p>}</c-> <c- c>/* “ ” ‘ ’ */</c->
<c- f>:root:lang(el),       :not(:lang(el)) &gt; :lang(el)             </c-><c- p>{</c-> <c- k>quotes</c-><c- p>:</c-> <c- s>&apos;\00ab&apos;</c-> <c- s>&apos;\00bb&apos;</c-> <c- s>&apos;\201c&apos;</c-> <c- s>&apos;\201d&apos;</c-> <c- p>}</c-> <c- c>/* « » “ ” */</c->
<c- f>:root:lang(en),       :not(:lang(en)) &gt; :lang(en)             </c-><c- p>{</c-> <c- k>quotes</c-><c- p>:</c-> <c- s>&apos;\201c&apos;</c-> <c- s>&apos;\201d&apos;</c-> <c- s>&apos;\2018&apos;</c-> <c- s>&apos;\2019&apos;</c-> <c- p>}</c-> <c- c>/* “ ” ‘ ’ */</c->
<c- f>:root:lang(es),       :not(:lang(es)) &gt; :lang(es)             </c-><c- p>{</c-> <c- k>quotes</c-><c- p>:</c-> <c- s>&apos;\00ab&apos;</c-> <c- s>&apos;\00bb&apos;</c-> <c- s>&apos;\201c&apos;</c-> <c- s>&apos;\201d&apos;</c-> <c- p>}</c-> <c- c>/* « » “ ” */</c->
<c- f>:root:lang(et),       :not(:lang(et)) &gt; :lang(et)             </c-><c- p>{</c-> <c- k>quotes</c-><c- p>:</c-> <c- s>&apos;\201e&apos;</c-> <c- s>&apos;\201c&apos;</c-> <c- s>&apos;\201a&apos;</c-> <c- s>&apos;\2018&apos;</c-> <c- p>}</c-> <c- c>/* „ “ ‚ ‘ */</c->
<c- f>:root:lang(eu),       :not(:lang(eu)) &gt; :lang(eu)             </c-><c- p>{</c-> <c- k>quotes</c-><c- p>:</c-> <c- s>&apos;\201c&apos;</c-> <c- s>&apos;\201d&apos;</c-> <c- s>&apos;\201c&apos;</c-> <c- s>&apos;\201d&apos;</c-> <c- p>}</c-> <c- c>/* “ ” “ ” */</c->
<c- f>:root:lang(ewo),      :not(:lang(ewo)) &gt; :lang(ewo)           </c-><c- p>{</c-> <c- k>quotes</c-><c- p>:</c-> <c- s>&apos;\00ab&apos;</c-> <c- s>&apos;\00bb&apos;</c-> <c- s>&apos;\201c&apos;</c-> <c- s>&apos;\201d&apos;</c-> <c- p>}</c-> <c- c>/* « » “ ” */</c->
<c- f>:root:lang(fa),       :not(:lang(fa)) &gt; :lang(fa)             </c-><c- p>{</c-> <c- k>quotes</c-><c- p>:</c-> <c- s>&apos;\00ab&apos;</c-> <c- s>&apos;\00bb&apos;</c-> <c- s>&apos;\2039&apos;</c-> <c- s>&apos;\203a&apos;</c-> <c- p>}</c-> <c- c>/* « » ‹ › */</c->
<c- f>:root:lang(ff),       :not(:lang(ff)) &gt; :lang(ff)             </c-><c- p>{</c-> <c- k>quotes</c-><c- p>:</c-> <c- s>&apos;\201e&apos;</c-> <c- s>&apos;\201d&apos;</c-> <c- s>&apos;\201a&apos;</c-> <c- s>&apos;\2019&apos;</c-> <c- p>}</c-> <c- c>/* „ ” ‚ ’ */</c->
<c- f>:root:lang(fi),       :not(:lang(fi)) &gt; :lang(fi)             </c-><c- p>{</c-> <c- k>quotes</c-><c- p>:</c-> <c- s>&apos;\201d&apos;</c-> <c- s>&apos;\201d&apos;</c-> <c- s>&apos;\2019&apos;</c-> <c- s>&apos;\2019&apos;</c-> <c- p>}</c-> <c- c>/* ” ” ’ ’ */</c->
<c- f>:root:lang(fil),      :not(:lang(fil)) &gt; :lang(fil)           </c-><c- p>{</c-> <c- k>quotes</c-><c- p>:</c-> <c- s>&apos;\201c&apos;</c-> <c- s>&apos;\201d&apos;</c-> <c- s>&apos;\2018&apos;</c-> <c- s>&apos;\2019&apos;</c-> <c- p>}</c-> <c- c>/* “ ” ‘ ’ */</c->
<c- f>:root:lang(fo),       :not(:lang(fo)) &gt; :lang(fo)             </c-><c- p>{</c-> <c- k>quotes</c-><c- p>:</c-> <c- s>&apos;\201c&apos;</c-> <c- s>&apos;\201d&apos;</c-> <c- s>&apos;\2018&apos;</c-> <c- s>&apos;\2019&apos;</c-> <c- p>}</c-> <c- c>/* “ ” ‘ ’ */</c->
<c- f>:root:lang(fr),       :not(:lang(fr)) &gt; :lang(fr)             </c-><c- p>{</c-> <c- k>quotes</c-><c- p>:</c-> <c- s>&apos;\00ab&apos;</c-> <c- s>&apos;\00bb&apos;</c-> <c- s>&apos;\00ab&apos;</c-> <c- s>&apos;\00bb&apos;</c-> <c- p>}</c-> <c- c>/* « » « » */</c->
<c- f>:root:lang(fr-CH),    :not(:lang(fr-CH)) &gt; :lang(fr-CH)       </c-><c- p>{</c-> <c- k>quotes</c-><c- p>:</c-> <c- s>&apos;\00ab&apos;</c-> <c- s>&apos;\00bb&apos;</c-> <c- s>&apos;\2039&apos;</c-> <c- s>&apos;\203a&apos;</c-> <c- p>}</c-> <c- c>/* « » ‹ › */</c->
<c- f>:root:lang(ga),       :not(:lang(ga)) &gt; :lang(ga)             </c-><c- p>{</c-> <c- k>quotes</c-><c- p>:</c-> <c- s>&apos;\201c&apos;</c-> <c- s>&apos;\201d&apos;</c-> <c- s>&apos;\2018&apos;</c-> <c- s>&apos;\2019&apos;</c-> <c- p>}</c-> <c- c>/* “ ” ‘ ’ */</c->
<c- f>:root:lang(gd),       :not(:lang(gd)) &gt; :lang(gd)             </c-><c- p>{</c-> <c- k>quotes</c-><c- p>:</c-> <c- s>&apos;\201c&apos;</c-> <c- s>&apos;\201d&apos;</c-> <c- s>&apos;\2018&apos;</c-> <c- s>&apos;\2019&apos;</c-> <c- p>}</c-> <c- c>/* “ ” ‘ ’ */</c->
<c- f>:root:lang(gl),       :not(:lang(gl)) &gt; :lang(gl)             </c-><c- p>{</c-> <c- k>quotes</c-><c- p>:</c-> <c- s>&apos;\201c&apos;</c-> <c- s>&apos;\201d&apos;</c-> <c- s>&apos;\2018&apos;</c-> <c- s>&apos;\2019&apos;</c-> <c- p>}</c-> <c- c>/* “ ” ‘ ’ */</c->
<c- f>:root:lang(gsw),      :not(:lang(gsw)) &gt; :lang(gsw)           </c-><c- p>{</c-> <c- k>quotes</c-><c- p>:</c-> <c- s>&apos;\00ab&apos;</c-> <c- s>&apos;\00bb&apos;</c-> <c- s>&apos;\2039&apos;</c-> <c- s>&apos;\203a&apos;</c-> <c- p>}</c-> <c- c>/* « » ‹ › */</c->
<c- f>:root:lang(gu),       :not(:lang(gu)) &gt; :lang(gu)             </c-><c- p>{</c-> <c- k>quotes</c-><c- p>:</c-> <c- s>&apos;\201c&apos;</c-> <c- s>&apos;\201d&apos;</c-> <c- s>&apos;\2018&apos;</c-> <c- s>&apos;\2019&apos;</c-> <c- p>}</c-> <c- c>/* “ ” ‘ ’ */</c->
<c- f>:root:lang(guz),      :not(:lang(guz)) &gt; :lang(guz)           </c-><c- p>{</c-> <c- k>quotes</c-><c- p>:</c-> <c- s>&apos;\201c&apos;</c-> <c- s>&apos;\201d&apos;</c-> <c- s>&apos;\2018&apos;</c-> <c- s>&apos;\2019&apos;</c-> <c- p>}</c-> <c- c>/* “ ” ‘ ’ */</c->
<c- f>:root:lang(ha),       :not(:lang(ha)) &gt; :lang(ha)             </c-><c- p>{</c-> <c- k>quotes</c-><c- p>:</c-> <c- s>&apos;\201c&apos;</c-> <c- s>&apos;\201d&apos;</c-> <c- s>&apos;\2018&apos;</c-> <c- s>&apos;\2019&apos;</c-> <c- p>}</c-> <c- c>/* “ ” ‘ ’ */</c->
<c- f>:root:lang(he),       :not(:lang(he)) &gt; :lang(he)             </c-><c- p>{</c-> <c- k>quotes</c-><c- p>:</c-> <c- s>&apos;\201d&apos;</c-> <c- s>&apos;\201d&apos;</c-> <c- s>&apos;\2019&apos;</c-> <c- s>&apos;\2019&apos;</c-> <c- p>}</c-> <c- c>/* ” ” ’ ’ */</c->
<c- f>:root:lang(hi),       :not(:lang(hi)) &gt; :lang(hi)             </c-><c- p>{</c-> <c- k>quotes</c-><c- p>:</c-> <c- s>&apos;\201c&apos;</c-> <c- s>&apos;\201d&apos;</c-> <c- s>&apos;\2018&apos;</c-> <c- s>&apos;\2019&apos;</c-> <c- p>}</c-> <c- c>/* “ ” ‘ ’ */</c->
<c- f>:root:lang(hr),       :not(:lang(hr)) &gt; :lang(hr)             </c-><c- p>{</c-> <c- k>quotes</c-><c- p>:</c-> <c- s>&apos;\201e&apos;</c-> <c- s>&apos;\201c&apos;</c-> <c- s>&apos;\201a&apos;</c-> <c- s>&apos;\2018&apos;</c-> <c- p>}</c-> <c- c>/* „ “ ‚ ‘ */</c->
<c- f>:root:lang(hsb),      :not(:lang(hsb)) &gt; :lang(hsb)           </c-><c- p>{</c-> <c- k>quotes</c-><c- p>:</c-> <c- s>&apos;\201e&apos;</c-> <c- s>&apos;\201c&apos;</c-> <c- s>&apos;\201a&apos;</c-> <c- s>&apos;\2018&apos;</c-> <c- p>}</c-> <c- c>/* „ “ ‚ ‘ */</c->
<c- f>:root:lang(hu),       :not(:lang(hu)) &gt; :lang(hu)             </c-><c- p>{</c-> <c- k>quotes</c-><c- p>:</c-> <c- s>&apos;\201e&apos;</c-> <c- s>&apos;\201d&apos;</c-> <c- s>&apos;\00bb&apos;</c-> <c- s>&apos;\00ab&apos;</c-> <c- p>}</c-> <c- c>/* „ ” » « */</c->
<c- f>:root:lang(hy),       :not(:lang(hy)) &gt; :lang(hy)             </c-><c- p>{</c-> <c- k>quotes</c-><c- p>:</c-> <c- s>&apos;\00ab&apos;</c-> <c- s>&apos;\00bb&apos;</c-> <c- s>&apos;\00ab&apos;</c-> <c- s>&apos;\00bb&apos;</c-> <c- p>}</c-> <c- c>/* « » « » */</c->
<c- f>:root:lang(id),       :not(:lang(id)) &gt; :lang(id)             </c-><c- p>{</c-> <c- k>quotes</c-><c- p>:</c-> <c- s>&apos;\201c&apos;</c-> <c- s>&apos;\201d&apos;</c-> <c- s>&apos;\2018&apos;</c-> <c- s>&apos;\2019&apos;</c-> <c- p>}</c-> <c- c>/* “ ” ‘ ’ */</c->
<c- f>:root:lang(ig),       :not(:lang(ig)) &gt; :lang(ig)             </c-><c- p>{</c-> <c- k>quotes</c-><c- p>:</c-> <c- s>&apos;\201c&apos;</c-> <c- s>&apos;\201d&apos;</c-> <c- s>&apos;\2018&apos;</c-> <c- s>&apos;\2019&apos;</c-> <c- p>}</c-> <c- c>/* “ ” ‘ ’ */</c->
<c- f>:root:lang(is),       :not(:lang(is)) &gt; :lang(is)             </c-><c- p>{</c-> <c- k>quotes</c-><c- p>:</c-> <c- s>&apos;\201e&apos;</c-> <c- s>&apos;\201c&apos;</c-> <c- s>&apos;\201a&apos;</c-> <c- s>&apos;\2018&apos;</c-> <c- p>}</c-> <c- c>/* „ “ ‚ ‘ */</c->
<c- f>:root:lang(it),       :not(:lang(it)) &gt; :lang(it)             </c-><c- p>{</c-> <c- k>quotes</c-><c- p>:</c-> <c- s>&apos;\00ab&apos;</c-> <c- s>&apos;\00bb&apos;</c-> <c- s>&apos;\201c&apos;</c-> <c- s>&apos;\201d&apos;</c-> <c- p>}</c-> <c- c>/* « » “ ” */</c->
<c- f>:root:lang(ja),       :not(:lang(ja)) &gt; :lang(ja)             </c-><c- p>{</c-> <c- k>quotes</c-><c- p>:</c-> <c- s>&apos;\300c&apos;</c-> <c- s>&apos;\300d&apos;</c-> <c- s>&apos;\300e&apos;</c-> <c- s>&apos;\300f&apos;</c-> <c- p>}</c-> <c- c>/* 「 」 『 』 */</c->
<c- f>:root:lang(jgo),      :not(:lang(jgo)) &gt; :lang(jgo)           </c-><c- p>{</c-> <c- k>quotes</c-><c- p>:</c-> <c- s>&apos;\00ab&apos;</c-> <c- s>&apos;\00bb&apos;</c-> <c- s>&apos;\2039&apos;</c-> <c- s>&apos;\203a&apos;</c-> <c- p>}</c-> <c- c>/* « » ‹ › */</c->
<c- f>:root:lang(jmc),      :not(:lang(jmc)) &gt; :lang(jmc)           </c-><c- p>{</c-> <c- k>quotes</c-><c- p>:</c-> <c- s>&apos;\201c&apos;</c-> <c- s>&apos;\201d&apos;</c-> <c- s>&apos;\2018&apos;</c-> <c- s>&apos;\2019&apos;</c-> <c- p>}</c-> <c- c>/* “ ” ‘ ’ */</c->
<c- f>:root:lang(ka),       :not(:lang(ka)) &gt; :lang(ka)             </c-><c- p>{</c-> <c- k>quotes</c-><c- p>:</c-> <c- s>&apos;\201e&apos;</c-> <c- s>&apos;\201c&apos;</c-> <c- s>&apos;\00ab&apos;</c-> <c- s>&apos;\00bb&apos;</c-> <c- p>}</c-> <c- c>/* „ “ « » */</c->
<c- f>:root:lang(kab),      :not(:lang(kab)) &gt; :lang(kab)           </c-><c- p>{</c-> <c- k>quotes</c-><c- p>:</c-> <c- s>&apos;\00ab&apos;</c-> <c- s>&apos;\00bb&apos;</c-> <c- s>&apos;\201c&apos;</c-> <c- s>&apos;\201d&apos;</c-> <c- p>}</c-> <c- c>/* « » “ ” */</c->
<c- f>:root:lang(kam),      :not(:lang(kam)) &gt; :lang(kam)           </c-><c- p>{</c-> <c- k>quotes</c-><c- p>:</c-> <c- s>&apos;\201c&apos;</c-> <c- s>&apos;\201d&apos;</c-> <c- s>&apos;\2018&apos;</c-> <c- s>&apos;\2019&apos;</c-> <c- p>}</c-> <c- c>/* “ ” ‘ ’ */</c->
<c- f>:root:lang(kde),      :not(:lang(kde)) &gt; :lang(kde)           </c-><c- p>{</c-> <c- k>quotes</c-><c- p>:</c-> <c- s>&apos;\201c&apos;</c-> <c- s>&apos;\201d&apos;</c-> <c- s>&apos;\2018&apos;</c-> <c- s>&apos;\2019&apos;</c-> <c- p>}</c-> <c- c>/* “ ” ‘ ’ */</c->
<c- f>:root:lang(kea),      :not(:lang(kea)) &gt; :lang(kea)           </c-><c- p>{</c-> <c- k>quotes</c-><c- p>:</c-> <c- s>&apos;\201c&apos;</c-> <c- s>&apos;\201d&apos;</c-> <c- s>&apos;\2018&apos;</c-> <c- s>&apos;\2019&apos;</c-> <c- p>}</c-> <c- c>/* “ ” ‘ ’ */</c->
<c- f>:root:lang(khq),      :not(:lang(khq)) &gt; :lang(khq)           </c-><c- p>{</c-> <c- k>quotes</c-><c- p>:</c-> <c- s>&apos;\201c&apos;</c-> <c- s>&apos;\201d&apos;</c-> <c- s>&apos;\2018&apos;</c-> <c- s>&apos;\2019&apos;</c-> <c- p>}</c-> <c- c>/* “ ” ‘ ’ */</c->
<c- f>:root:lang(ki),       :not(:lang(ki)) &gt; :lang(ki)             </c-><c- p>{</c-> <c- k>quotes</c-><c- p>:</c-> <c- s>&apos;\201c&apos;</c-> <c- s>&apos;\201d&apos;</c-> <c- s>&apos;\2018&apos;</c-> <c- s>&apos;\2019&apos;</c-> <c- p>}</c-> <c- c>/* “ ” ‘ ’ */</c->
<c- f>:root:lang(kk),       :not(:lang(kk)) &gt; :lang(kk)             </c-><c- p>{</c-> <c- k>quotes</c-><c- p>:</c-> <c- s>&apos;\00ab&apos;</c-> <c- s>&apos;\00bb&apos;</c-> <c- s>&apos;\201c&apos;</c-> <c- s>&apos;\201d&apos;</c-> <c- p>}</c-> <c- c>/* « » “ ” */</c->
<c- f>:root:lang(kkj),      :not(:lang(kkj)) &gt; :lang(kkj)           </c-><c- p>{</c-> <c- k>quotes</c-><c- p>:</c-> <c- s>&apos;\00ab&apos;</c-> <c- s>&apos;\00bb&apos;</c-> <c- s>&apos;\2039&apos;</c-> <c- s>&apos;\203a&apos;</c-> <c- p>}</c-> <c- c>/* « » ‹ › */</c->
<c- f>:root:lang(kln),      :not(:lang(kln)) &gt; :lang(kln)           </c-><c- p>{</c-> <c- k>quotes</c-><c- p>:</c-> <c- s>&apos;\201c&apos;</c-> <c- s>&apos;\201d&apos;</c-> <c- s>&apos;\2018&apos;</c-> <c- s>&apos;\2019&apos;</c-> <c- p>}</c-> <c- c>/* “ ” ‘ ’ */</c->
<c- f>:root:lang(km),       :not(:lang(km)) &gt; :lang(km)             </c-><c- p>{</c-> <c- k>quotes</c-><c- p>:</c-> <c- s>&apos;\201c&apos;</c-> <c- s>&apos;\201d&apos;</c-> <c- s>&apos;\2018&apos;</c-> <c- s>&apos;\2019&apos;</c-> <c- p>}</c-> <c- c>/* “ ” ‘ ’ */</c->
<c- f>:root:lang(kn),       :not(:lang(kn)) &gt; :lang(kn)             </c-><c- p>{</c-> <c- k>quotes</c-><c- p>:</c-> <c- s>&apos;\201c&apos;</c-> <c- s>&apos;\201d&apos;</c-> <c- s>&apos;\2018&apos;</c-> <c- s>&apos;\2019&apos;</c-> <c- p>}</c-> <c- c>/* “ ” ‘ ’ */</c->
<c- f>:root:lang(ko),       :not(:lang(ko)) &gt; :lang(ko)             </c-><c- p>{</c-> <c- k>quotes</c-><c- p>:</c-> <c- s>&apos;\201c&apos;</c-> <c- s>&apos;\201d&apos;</c-> <c- s>&apos;\2018&apos;</c-> <c- s>&apos;\2019&apos;</c-> <c- p>}</c-> <c- c>/* “ ” ‘ ’ */</c->
<c- f>:root:lang(ksb),      :not(:lang(ksb)) &gt; :lang(ksb)           </c-><c- p>{</c-> <c- k>quotes</c-><c- p>:</c-> <c- s>&apos;\201c&apos;</c-> <c- s>&apos;\201d&apos;</c-> <c- s>&apos;\2018&apos;</c-> <c- s>&apos;\2019&apos;</c-> <c- p>}</c-> <c- c>/* “ ” ‘ ’ */</c->
<c- f>:root:lang(ksf),      :not(:lang(ksf)) &gt; :lang(ksf)           </c-><c- p>{</c-> <c- k>quotes</c-><c- p>:</c-> <c- s>&apos;\00ab&apos;</c-> <c- s>&apos;\00bb&apos;</c-> <c- s>&apos;\2018&apos;</c-> <c- s>&apos;\2019&apos;</c-> <c- p>}</c-> <c- c>/* « » ‘ ’ */</c->
<c- f>:root:lang(ky),       :not(:lang(ky)) &gt; :lang(ky)             </c-><c- p>{</c-> <c- k>quotes</c-><c- p>:</c-> <c- s>&apos;\00ab&apos;</c-> <c- s>&apos;\00bb&apos;</c-> <c- s>&apos;\201e&apos;</c-> <c- s>&apos;\201c&apos;</c-> <c- p>}</c-> <c- c>/* « » „ “ */</c->
<c- f>:root:lang(lag),      :not(:lang(lag)) &gt; :lang(lag)           </c-><c- p>{</c-> <c- k>quotes</c-><c- p>:</c-> <c- s>&apos;\201d&apos;</c-> <c- s>&apos;\201d&apos;</c-> <c- s>&apos;\2019&apos;</c-> <c- s>&apos;\2019&apos;</c-> <c- p>}</c-> <c- c>/* ” ” ’ ’ */</c->
<c- f>:root:lang(lb),       :not(:lang(lb)) &gt; :lang(lb)             </c-><c- p>{</c-> <c- k>quotes</c-><c- p>:</c-> <c- s>&apos;\201e&apos;</c-> <c- s>&apos;\201c&apos;</c-> <c- s>&apos;\201a&apos;</c-> <c- s>&apos;\2018&apos;</c-> <c- p>}</c-> <c- c>/* „ “ ‚ ‘ */</c->
<c- f>:root:lang(lg),       :not(:lang(lg)) &gt; :lang(lg)             </c-><c- p>{</c-> <c- k>quotes</c-><c- p>:</c-> <c- s>&apos;\201c&apos;</c-> <c- s>&apos;\201d&apos;</c-> <c- s>&apos;\2018&apos;</c-> <c- s>&apos;\2019&apos;</c-> <c- p>}</c-> <c- c>/* “ ” ‘ ’ */</c->
<c- f>:root:lang(ln),       :not(:lang(ln)) &gt; :lang(ln)             </c-><c- p>{</c-> <c- k>quotes</c-><c- p>:</c-> <c- s>&apos;\201c&apos;</c-> <c- s>&apos;\201d&apos;</c-> <c- s>&apos;\2018&apos;</c-> <c- s>&apos;\2019&apos;</c-> <c- p>}</c-> <c- c>/* “ ” ‘ ’ */</c->
<c- f>:root:lang(lo),       :not(:lang(lo)) &gt; :lang(lo)             </c-><c- p>{</c-> <c- k>quotes</c-><c- p>:</c-> <c- s>&apos;\201c&apos;</c-> <c- s>&apos;\201d&apos;</c-> <c- s>&apos;\2018&apos;</c-> <c- s>&apos;\2019&apos;</c-> <c- p>}</c-> <c- c>/* “ ” ‘ ’ */</c->
<c- f>:root:lang(lrc),      :not(:lang(lrc)) &gt; :lang(lrc)           </c-><c- p>{</c-> <c- k>quotes</c-><c- p>:</c-> <c- s>&apos;\201c&apos;</c-> <c- s>&apos;\201d&apos;</c-> <c- s>&apos;\2018&apos;</c-> <c- s>&apos;\2019&apos;</c-> <c- p>}</c-> <c- c>/* “ ” ‘ ’ */</c->
<c- f>:root:lang(lt),       :not(:lang(lt)) &gt; :lang(lt)             </c-><c- p>{</c-> <c- k>quotes</c-><c- p>:</c-> <c- s>&apos;\201e&apos;</c-> <c- s>&apos;\201c&apos;</c-> <c- s>&apos;\201e&apos;</c-> <c- s>&apos;\201c&apos;</c-> <c- p>}</c-> <c- c>/* „ “ „ “ */</c->
<c- f>:root:lang(lu),       :not(:lang(lu)) &gt; :lang(lu)             </c-><c- p>{</c-> <c- k>quotes</c-><c- p>:</c-> <c- s>&apos;\201c&apos;</c-> <c- s>&apos;\201d&apos;</c-> <c- s>&apos;\2018&apos;</c-> <c- s>&apos;\2019&apos;</c-> <c- p>}</c-> <c- c>/* “ ” ‘ ’ */</c->
<c- f>:root:lang(luo),      :not(:lang(luo)) &gt; :lang(luo)           </c-><c- p>{</c-> <c- k>quotes</c-><c- p>:</c-> <c- s>&apos;\201c&apos;</c-> <c- s>&apos;\201d&apos;</c-> <c- s>&apos;\2018&apos;</c-> <c- s>&apos;\2019&apos;</c-> <c- p>}</c-> <c- c>/* “ ” ‘ ’ */</c->
<c- f>:root:lang(luy),      :not(:lang(luy)) &gt; :lang(luy)           </c-><c- p>{</c-> <c- k>quotes</c-><c- p>:</c-> <c- s>&apos;\201e&apos;</c-> <c- s>&apos;\201c&apos;</c-> <c- s>&apos;\201a&apos;</c-> <c- s>&apos;\2018&apos;</c-> <c- p>}</c-> <c- c>/* „ “ ‚ ‘ */</c->
<c- f>:root:lang(lv),       :not(:lang(lv)) &gt; :lang(lv)             </c-><c- p>{</c-> <c- k>quotes</c-><c- p>:</c-> <c- s>&apos;\201c&apos;</c-> <c- s>&apos;\201d&apos;</c-> <c- s>&apos;\2018&apos;</c-> <c- s>&apos;\2019&apos;</c-> <c- p>}</c-> <c- c>/* “ ” ‘ ’ */</c->
<c- f>:root:lang(mas),      :not(:lang(mas)) &gt; :lang(mas)           </c-><c- p>{</c-> <c- k>quotes</c-><c- p>:</c-> <c- s>&apos;\201c&apos;</c-> <c- s>&apos;\201d&apos;</c-> <c- s>&apos;\2018&apos;</c-> <c- s>&apos;\2019&apos;</c-> <c- p>}</c-> <c- c>/* “ ” ‘ ’ */</c->
<c- f>:root:lang(mer),      :not(:lang(mer)) &gt; :lang(mer)           </c-><c- p>{</c-> <c- k>quotes</c-><c- p>:</c-> <c- s>&apos;\201c&apos;</c-> <c- s>&apos;\201d&apos;</c-> <c- s>&apos;\2018&apos;</c-> <c- s>&apos;\2019&apos;</c-> <c- p>}</c-> <c- c>/* “ ” ‘ ’ */</c->
<c- f>:root:lang(mfe),      :not(:lang(mfe)) &gt; :lang(mfe)           </c-><c- p>{</c-> <c- k>quotes</c-><c- p>:</c-> <c- s>&apos;\201c&apos;</c-> <c- s>&apos;\201d&apos;</c-> <c- s>&apos;\2018&apos;</c-> <c- s>&apos;\2019&apos;</c-> <c- p>}</c-> <c- c>/* “ ” ‘ ’ */</c->
<c- f>:root:lang(mg),       :not(:lang(mg)) &gt; :lang(mg)             </c-><c- p>{</c-> <c- k>quotes</c-><c- p>:</c-> <c- s>&apos;\00ab&apos;</c-> <c- s>&apos;\00bb&apos;</c-> <c- s>&apos;\201c&apos;</c-> <c- s>&apos;\201d&apos;</c-> <c- p>}</c-> <c- c>/* « » “ ” */</c->
<c- f>:root:lang(mgo),      :not(:lang(mgo)) &gt; :lang(mgo)           </c-><c- p>{</c-> <c- k>quotes</c-><c- p>:</c-> <c- s>&apos;\201c&apos;</c-> <c- s>&apos;\201d&apos;</c-> <c- s>&apos;\2018&apos;</c-> <c- s>&apos;\2019&apos;</c-> <c- p>}</c-> <c- c>/* “ ” ‘ ’ */</c->
<c- f>:root:lang(mk),       :not(:lang(mk)) &gt; :lang(mk)             </c-><c- p>{</c-> <c- k>quotes</c-><c- p>:</c-> <c- s>&apos;\201e&apos;</c-> <c- s>&apos;\201c&apos;</c-> <c- s>&apos;\201a&apos;</c-> <c- s>&apos;\2018&apos;</c-> <c- p>}</c-> <c- c>/* „ “ ‚ ‘ */</c->
<c- f>:root:lang(ml),       :not(:lang(ml)) &gt; :lang(ml)             </c-><c- p>{</c-> <c- k>quotes</c-><c- p>:</c-> <c- s>&apos;\201c&apos;</c-> <c- s>&apos;\201d&apos;</c-> <c- s>&apos;\2018&apos;</c-> <c- s>&apos;\2019&apos;</c-> <c- p>}</c-> <c- c>/* “ ” ‘ ’ */</c->
<c- f>:root:lang(mn),       :not(:lang(mn)) &gt; :lang(mn)             </c-><c- p>{</c-> <c- k>quotes</c-><c- p>:</c-> <c- s>&apos;\201c&apos;</c-> <c- s>&apos;\201d&apos;</c-> <c- s>&apos;\2018&apos;</c-> <c- s>&apos;\2019&apos;</c-> <c- p>}</c-> <c- c>/* “ ” ‘ ’ */</c->
<c- f>:root:lang(mr),       :not(:lang(mr)) &gt; :lang(mr)             </c-><c- p>{</c-> <c- k>quotes</c-><c- p>:</c-> <c- s>&apos;\201c&apos;</c-> <c- s>&apos;\201d&apos;</c-> <c- s>&apos;\2018&apos;</c-> <c- s>&apos;\2019&apos;</c-> <c- p>}</c-> <c- c>/* “ ” ‘ ’ */</c->
<c- f>:root:lang(ms),       :not(:lang(ms)) &gt; :lang(ms)             </c-><c- p>{</c-> <c- k>quotes</c-><c- p>:</c-> <c- s>&apos;\201c&apos;</c-> <c- s>&apos;\201d&apos;</c-> <c- s>&apos;\2018&apos;</c-> <c- s>&apos;\2019&apos;</c-> <c- p>}</c-> <c- c>/* “ ” ‘ ’ */</c->
<c- f>:root:lang(mt),       :not(:lang(mt)) &gt; :lang(mt)             </c-><c- p>{</c-> <c- k>quotes</c-><c- p>:</c-> <c- s>&apos;\201c&apos;</c-> <c- s>&apos;\201d&apos;</c-> <c- s>&apos;\2018&apos;</c-> <c- s>&apos;\2019&apos;</c-> <c- p>}</c-> <c- c>/* “ ” ‘ ’ */</c->
<c- f>:root:lang(mua),      :not(:lang(mua)) &gt; :lang(mua)           </c-><c- p>{</c-> <c- k>quotes</c-><c- p>:</c-> <c- s>&apos;\00ab&apos;</c-> <c- s>&apos;\00bb&apos;</c-> <c- s>&apos;\201c&apos;</c-> <c- s>&apos;\201d&apos;</c-> <c- p>}</c-> <c- c>/* « » “ ” */</c->
<c- f>:root:lang(my),       :not(:lang(my)) &gt; :lang(my)             </c-><c- p>{</c-> <c- k>quotes</c-><c- p>:</c-> <c- s>&apos;\201c&apos;</c-> <c- s>&apos;\201d&apos;</c-> <c- s>&apos;\2018&apos;</c-> <c- s>&apos;\2019&apos;</c-> <c- p>}</c-> <c- c>/* “ ” ‘ ’ */</c->
<c- f>:root:lang(mzn),      :not(:lang(mzn)) &gt; :lang(mzn)           </c-><c- p>{</c-> <c- k>quotes</c-><c- p>:</c-> <c- s>&apos;\00ab&apos;</c-> <c- s>&apos;\00bb&apos;</c-> <c- s>&apos;\2039&apos;</c-> <c- s>&apos;\203a&apos;</c-> <c- p>}</c-> <c- c>/* « » ‹ › */</c->
<c- f>:root:lang(naq),      :not(:lang(naq)) &gt; :lang(naq)           </c-><c- p>{</c-> <c- k>quotes</c-><c- p>:</c-> <c- s>&apos;\201c&apos;</c-> <c- s>&apos;\201d&apos;</c-> <c- s>&apos;\2018&apos;</c-> <c- s>&apos;\2019&apos;</c-> <c- p>}</c-> <c- c>/* “ ” ‘ ’ */</c->
<c- f>:root:lang(nb),       :not(:lang(nb)) &gt; :lang(nb)             </c-><c- p>{</c-> <c- k>quotes</c-><c- p>:</c-> <c- s>&apos;\00ab&apos;</c-> <c- s>&apos;\00bb&apos;</c-> <c- s>&apos;\2018&apos;</c-> <c- s>&apos;\2019&apos;</c-> <c- p>}</c-> <c- c>/* « » ‘ ’ */</c->
<c- f>:root:lang(nd),       :not(:lang(nd)) &gt; :lang(nd)             </c-><c- p>{</c-> <c- k>quotes</c-><c- p>:</c-> <c- s>&apos;\201c&apos;</c-> <c- s>&apos;\201d&apos;</c-> <c- s>&apos;\2018&apos;</c-> <c- s>&apos;\2019&apos;</c-> <c- p>}</c-> <c- c>/* “ ” ‘ ’ */</c->
<c- f>:root:lang(ne),       :not(:lang(ne)) &gt; :lang(ne)             </c-><c- p>{</c-> <c- k>quotes</c-><c- p>:</c-> <c- s>&apos;\201c&apos;</c-> <c- s>&apos;\201d&apos;</c-> <c- s>&apos;\2018&apos;</c-> <c- s>&apos;\2019&apos;</c-> <c- p>}</c-> <c- c>/* “ ” ‘ ’ */</c->
<c- f>:root:lang(nl),       :not(:lang(nl)) &gt; :lang(nl)             </c-><c- p>{</c-> <c- k>quotes</c-><c- p>:</c-> <c- s>&apos;\2018&apos;</c-> <c- s>&apos;\2019&apos;</c-> <c- s>&apos;\201c&apos;</c-> <c- s>&apos;\201d&apos;</c-> <c- p>}</c-> <c- c>/* ‘ ’ “ ” */</c->
<c- f>:root:lang(nmg),      :not(:lang(nmg)) &gt; :lang(nmg)           </c-><c- p>{</c-> <c- k>quotes</c-><c- p>:</c-> <c- s>&apos;\201e&apos;</c-> <c- s>&apos;\201d&apos;</c-> <c- s>&apos;\00ab&apos;</c-> <c- s>&apos;\00bb&apos;</c-> <c- p>}</c-> <c- c>/* „ ” « » */</c->
<c- f>:root:lang(nn),       :not(:lang(nn)) &gt; :lang(nn)             </c-><c- p>{</c-> <c- k>quotes</c-><c- p>:</c-> <c- s>&apos;\00ab&apos;</c-> <c- s>&apos;\00bb&apos;</c-> <c- s>&apos;\2018&apos;</c-> <c- s>&apos;\2019&apos;</c-> <c- p>}</c-> <c- c>/* « » ‘ ’ */</c->
<c- f>:root:lang(nnh),      :not(:lang(nnh)) &gt; :lang(nnh)           </c-><c- p>{</c-> <c- k>quotes</c-><c- p>:</c-> <c- s>&apos;\00ab&apos;</c-> <c- s>&apos;\00bb&apos;</c-> <c- s>&apos;\201c&apos;</c-> <c- s>&apos;\201d&apos;</c-> <c- p>}</c-> <c- c>/* « » “ ” */</c->
<c- f>:root:lang(nus),      :not(:lang(nus)) &gt; :lang(nus)           </c-><c- p>{</c-> <c- k>quotes</c-><c- p>:</c-> <c- s>&apos;\201c&apos;</c-> <c- s>&apos;\201d&apos;</c-> <c- s>&apos;\2018&apos;</c-> <c- s>&apos;\2019&apos;</c-> <c- p>}</c-> <c- c>/* “ ” ‘ ’ */</c->
<c- f>:root:lang(nyn),      :not(:lang(nyn)) &gt; :lang(nyn)           </c-><c- p>{</c-> <c- k>quotes</c-><c- p>:</c-> <c- s>&apos;\201c&apos;</c-> <c- s>&apos;\201d&apos;</c-> <c- s>&apos;\2018&apos;</c-> <c- s>&apos;\2019&apos;</c-> <c- p>}</c-> <c- c>/* “ ” ‘ ’ */</c->
<c- f>:root:lang(pa),       :not(:lang(pa)) &gt; :lang(pa)             </c-><c- p>{</c-> <c- k>quotes</c-><c- p>:</c-> <c- s>&apos;\201c&apos;</c-> <c- s>&apos;\201d&apos;</c-> <c- s>&apos;\2018&apos;</c-> <c- s>&apos;\2019&apos;</c-> <c- p>}</c-> <c- c>/* “ ” ‘ ’ */</c->
<c- f>:root:lang(pl),       :not(:lang(pl)) &gt; :lang(pl)             </c-><c- p>{</c-> <c- k>quotes</c-><c- p>:</c-> <c- s>&apos;\201e&apos;</c-> <c- s>&apos;\201d&apos;</c-> <c- s>&apos;\00ab&apos;</c-> <c- s>&apos;\00bb&apos;</c-> <c- p>}</c-> <c- c>/* „ ” « » */</c->
<c- f>:root:lang(pt),       :not(:lang(pt)) &gt; :lang(pt)             </c-><c- p>{</c-> <c- k>quotes</c-><c- p>:</c-> <c- s>&apos;\201c&apos;</c-> <c- s>&apos;\201d&apos;</c-> <c- s>&apos;\2018&apos;</c-> <c- s>&apos;\2019&apos;</c-> <c- p>}</c-> <c- c>/* “ ” ‘ ’ */</c->
<c- f>:root:lang(pt-PT),    :not(:lang(pt-PT)) &gt; :lang(pt-PT)       </c-><c- p>{</c-> <c- k>quotes</c-><c- p>:</c-> <c- s>&apos;\00ab&apos;</c-> <c- s>&apos;\00bb&apos;</c-> <c- s>&apos;\201c&apos;</c-> <c- s>&apos;\201d&apos;</c-> <c- p>}</c-> <c- c>/* « » “ ” */</c->
<c- f>:root:lang(rn),       :not(:lang(rn)) &gt; :lang(rn)             </c-><c- p>{</c-> <c- k>quotes</c-><c- p>:</c-> <c- s>&apos;\201d&apos;</c-> <c- s>&apos;\201d&apos;</c-> <c- s>&apos;\2019&apos;</c-> <c- s>&apos;\2019&apos;</c-> <c- p>}</c-> <c- c>/* ” ” ’ ’ */</c->
<c- f>:root:lang(ro),       :not(:lang(ro)) &gt; :lang(ro)             </c-><c- p>{</c-> <c- k>quotes</c-><c- p>:</c-> <c- s>&apos;\201e&apos;</c-> <c- s>&apos;\201d&apos;</c-> <c- s>&apos;\00ab&apos;</c-> <c- s>&apos;\00bb&apos;</c-> <c- p>}</c-> <c- c>/* „ ” « » */</c->
<c- f>:root:lang(rof),      :not(:lang(rof)) &gt; :lang(rof)           </c-><c- p>{</c-> <c- k>quotes</c-><c- p>:</c-> <c- s>&apos;\201c&apos;</c-> <c- s>&apos;\201d&apos;</c-> <c- s>&apos;\2018&apos;</c-> <c- s>&apos;\2019&apos;</c-> <c- p>}</c-> <c- c>/* “ ” ‘ ’ */</c->
<c- f>:root:lang(ru),       :not(:lang(ru)) &gt; :lang(ru)             </c-><c- p>{</c-> <c- k>quotes</c-><c- p>:</c-> <c- s>&apos;\00ab&apos;</c-> <c- s>&apos;\00bb&apos;</c-> <c- s>&apos;\201e&apos;</c-> <c- s>&apos;\201c&apos;</c-> <c- p>}</c-> <c- c>/* « » „ “ */</c->
<c- f>:root:lang(rw),       :not(:lang(rw)) &gt; :lang(rw)             </c-><c- p>{</c-> <c- k>quotes</c-><c- p>:</c-> <c- s>&apos;\00ab&apos;</c-> <c- s>&apos;\00bb&apos;</c-> <c- s>&apos;\2018&apos;</c-> <c- s>&apos;\2019&apos;</c-> <c- p>}</c-> <c- c>/* « » ‘ ’ */</c->
<c- f>:root:lang(rwk),      :not(:lang(rwk)) &gt; :lang(rwk)           </c-><c- p>{</c-> <c- k>quotes</c-><c- p>:</c-> <c- s>&apos;\201c&apos;</c-> <c- s>&apos;\201d&apos;</c-> <c- s>&apos;\2018&apos;</c-> <c- s>&apos;\2019&apos;</c-> <c- p>}</c-> <c- c>/* “ ” ‘ ’ */</c->
<c- f>:root:lang(sah),      :not(:lang(sah)) &gt; :lang(sah)           </c-><c- p>{</c-> <c- k>quotes</c-><c- p>:</c-> <c- s>&apos;\00ab&apos;</c-> <c- s>&apos;\00bb&apos;</c-> <c- s>&apos;\201e&apos;</c-> <c- s>&apos;\201c&apos;</c-> <c- p>}</c-> <c- c>/* « » „ “ */</c->
<c- f>:root:lang(saq),      :not(:lang(saq)) &gt; :lang(saq)           </c-><c- p>{</c-> <c- k>quotes</c-><c- p>:</c-> <c- s>&apos;\201c&apos;</c-> <c- s>&apos;\201d&apos;</c-> <c- s>&apos;\2018&apos;</c-> <c- s>&apos;\2019&apos;</c-> <c- p>}</c-> <c- c>/* “ ” ‘ ’ */</c->
<c- f>:root:lang(sbp),      :not(:lang(sbp)) &gt; :lang(sbp)           </c-><c- p>{</c-> <c- k>quotes</c-><c- p>:</c-> <c- s>&apos;\201c&apos;</c-> <c- s>&apos;\201d&apos;</c-> <c- s>&apos;\2018&apos;</c-> <c- s>&apos;\2019&apos;</c-> <c- p>}</c-> <c- c>/* “ ” ‘ ’ */</c->
<c- f>:root:lang(seh),      :not(:lang(seh)) &gt; :lang(seh)           </c-><c- p>{</c-> <c- k>quotes</c-><c- p>:</c-> <c- s>&apos;\201c&apos;</c-> <c- s>&apos;\201d&apos;</c-> <c- s>&apos;\2018&apos;</c-> <c- s>&apos;\2019&apos;</c-> <c- p>}</c-> <c- c>/* “ ” ‘ ’ */</c->
<c- f>:root:lang(ses),      :not(:lang(ses)) &gt; :lang(ses)           </c-><c- p>{</c-> <c- k>quotes</c-><c- p>:</c-> <c- s>&apos;\201c&apos;</c-> <c- s>&apos;\201d&apos;</c-> <c- s>&apos;\2018&apos;</c-> <c- s>&apos;\2019&apos;</c-> <c- p>}</c-> <c- c>/* “ ” ‘ ’ */</c->
<c- f>:root:lang(sg),       :not(:lang(sg)) &gt; :lang(sg)             </c-><c- p>{</c-> <c- k>quotes</c-><c- p>:</c-> <c- s>&apos;\00ab&apos;</c-> <c- s>&apos;\00bb&apos;</c-> <c- s>&apos;\201c&apos;</c-> <c- s>&apos;\201d&apos;</c-> <c- p>}</c-> <c- c>/* « » “ ” */</c->
<c- f>:root:lang(shi),      :not(:lang(shi)) &gt; :lang(shi)           </c-><c- p>{</c-> <c- k>quotes</c-><c- p>:</c-> <c- s>&apos;\00ab&apos;</c-> <c- s>&apos;\00bb&apos;</c-> <c- s>&apos;\201e&apos;</c-> <c- s>&apos;\201d&apos;</c-> <c- p>}</c-> <c- c>/* « » „ ” */</c->
<c- f>:root:lang(shi-Latn), :not(:lang(shi-Latn)) &gt; :lang(shi-Latn) </c-><c- p>{</c-> <c- k>quotes</c-><c- p>:</c-> <c- s>&apos;\00ab&apos;</c-> <c- s>&apos;\00bb&apos;</c-> <c- s>&apos;\201e&apos;</c-> <c- s>&apos;\201d&apos;</c-> <c- p>}</c-> <c- c>/* « » „ ” */</c->
<c- f>:root:lang(si),       :not(:lang(si)) &gt; :lang(si)             </c-><c- p>{</c-> <c- k>quotes</c-><c- p>:</c-> <c- s>&apos;\201c&apos;</c-> <c- s>&apos;\201d&apos;</c-> <c- s>&apos;\2018&apos;</c-> <c- s>&apos;\2019&apos;</c-> <c- p>}</c-> <c- c>/* “ ” ‘ ’ */</c->
<c- f>:root:lang(sk),       :not(:lang(sk)) &gt; :lang(sk)             </c-><c- p>{</c-> <c- k>quotes</c-><c- p>:</c-> <c- s>&apos;\201e&apos;</c-> <c- s>&apos;\201c&apos;</c-> <c- s>&apos;\201a&apos;</c-> <c- s>&apos;\2018&apos;</c-> <c- p>}</c-> <c- c>/* „ “ ‚ ‘ */</c->
<c- f>:root:lang(sl),       :not(:lang(sl)) &gt; :lang(sl)             </c-><c- p>{</c-> <c- k>quotes</c-><c- p>:</c-> <c- s>&apos;\201e&apos;</c-> <c- s>&apos;\201c&apos;</c-> <c- s>&apos;\201a&apos;</c-> <c- s>&apos;\2018&apos;</c-> <c- p>}</c-> <c- c>/* „ “ ‚ ‘ */</c->
<c- f>:root:lang(sn),       :not(:lang(sn)) &gt; :lang(sn)             </c-><c- p>{</c-> <c- k>quotes</c-><c- p>:</c-> <c- s>&apos;\201d&apos;</c-> <c- s>&apos;\201d&apos;</c-> <c- s>&apos;\2019&apos;</c-> <c- s>&apos;\2019&apos;</c-> <c- p>}</c-> <c- c>/* ” ” ’ ’ */</c->
<c- f>:root:lang(so),       :not(:lang(so)) &gt; :lang(so)             </c-><c- p>{</c-> <c- k>quotes</c-><c- p>:</c-> <c- s>&apos;\201c&apos;</c-> <c- s>&apos;\201d&apos;</c-> <c- s>&apos;\2018&apos;</c-> <c- s>&apos;\2019&apos;</c-> <c- p>}</c-> <c- c>/* “ ” ‘ ’ */</c->
<c- f>:root:lang(sq),       :not(:lang(sq)) &gt; :lang(sq)             </c-><c- p>{</c-> <c- k>quotes</c-><c- p>:</c-> <c- s>&apos;\00ab&apos;</c-> <c- s>&apos;\00bb&apos;</c-> <c- s>&apos;\201c&apos;</c-> <c- s>&apos;\201d&apos;</c-> <c- p>}</c-> <c- c>/* « » “ ” */</c->
<c- f>:root:lang(sr),       :not(:lang(sr)) &gt; :lang(sr)             </c-><c- p>{</c-> <c- k>quotes</c-><c- p>:</c-> <c- s>&apos;\201e&apos;</c-> <c- s>&apos;\201c&apos;</c-> <c- s>&apos;\2018&apos;</c-> <c- s>&apos;\2018&apos;</c-> <c- p>}</c-> <c- c>/* „ “ ‘ ‘ */</c->
<c- f>:root:lang(sr-Latn),  :not(:lang(sr-Latn)) &gt; :lang(sr-Latn)   </c-><c- p>{</c-> <c- k>quotes</c-><c- p>:</c-> <c- s>&apos;\201e&apos;</c-> <c- s>&apos;\201c&apos;</c-> <c- s>&apos;\2018&apos;</c-> <c- s>&apos;\2018&apos;</c-> <c- p>}</c-> <c- c>/* „ “ ‘ ‘ */</c->
<c- f>:root:lang(sv),       :not(:lang(sv)) &gt; :lang(sv)             </c-><c- p>{</c-> <c- k>quotes</c-><c- p>:</c-> <c- s>&apos;\201d&apos;</c-> <c- s>&apos;\201d&apos;</c-> <c- s>&apos;\2019&apos;</c-> <c- s>&apos;\2019&apos;</c-> <c- p>}</c-> <c- c>/* ” ” ’ ’ */</c->
<c- f>:root:lang(sw),       :not(:lang(sw)) &gt; :lang(sw)             </c-><c- p>{</c-> <c- k>quotes</c-><c- p>:</c-> <c- s>&apos;\201c&apos;</c-> <c- s>&apos;\201d&apos;</c-> <c- s>&apos;\2018&apos;</c-> <c- s>&apos;\2019&apos;</c-> <c- p>}</c-> <c- c>/* “ ” ‘ ’ */</c->
<c- f>:root:lang(ta),       :not(:lang(ta)) &gt; :lang(ta)             </c-><c- p>{</c-> <c- k>quotes</c-><c- p>:</c-> <c- s>&apos;\201c&apos;</c-> <c- s>&apos;\201d&apos;</c-> <c- s>&apos;\2018&apos;</c-> <c- s>&apos;\2019&apos;</c-> <c- p>}</c-> <c- c>/* “ ” ‘ ’ */</c->
<c- f>:root:lang(te),       :not(:lang(te)) &gt; :lang(te)             </c-><c- p>{</c-> <c- k>quotes</c-><c- p>:</c-> <c- s>&apos;\201c&apos;</c-> <c- s>&apos;\201d&apos;</c-> <c- s>&apos;\2018&apos;</c-> <c- s>&apos;\2019&apos;</c-> <c- p>}</c-> <c- c>/* “ ” ‘ ’ */</c->
<c- f>:root:lang(teo),      :not(:lang(teo)) &gt; :lang(teo)           </c-><c- p>{</c-> <c- k>quotes</c-><c- p>:</c-> <c- s>&apos;\201c&apos;</c-> <c- s>&apos;\201d&apos;</c-> <c- s>&apos;\2018&apos;</c-> <c- s>&apos;\2019&apos;</c-> <c- p>}</c-> <c- c>/* “ ” ‘ ’ */</c->
<c- f>:root:lang(th),       :not(:lang(th)) &gt; :lang(th)             </c-><c- p>{</c-> <c- k>quotes</c-><c- p>:</c-> <c- s>&apos;\201c&apos;</c-> <c- s>&apos;\201d&apos;</c-> <c- s>&apos;\2018&apos;</c-> <c- s>&apos;\2019&apos;</c-> <c- p>}</c-> <c- c>/* “ ” ‘ ’ */</c->
<c- f>:root:lang(ti-ER),    :not(:lang(ti-ER)) &gt; :lang(ti-ER)       </c-><c- p>{</c-> <c- k>quotes</c-><c- p>:</c-> <c- s>&apos;\2018&apos;</c-> <c- s>&apos;\2019&apos;</c-> <c- s>&apos;\201c&apos;</c-> <c- s>&apos;\201d&apos;</c-> <c- p>}</c-> <c- c>/* ‘ ’ “ ” */</c->
<c- f>:root:lang(tk),       :not(:lang(tk)) &gt; :lang(tk)             </c-><c- p>{</c-> <c- k>quotes</c-><c- p>:</c-> <c- s>&apos;\201c&apos;</c-> <c- s>&apos;\201d&apos;</c-> <c- s>&apos;\201c&apos;</c-> <c- s>&apos;\201d&apos;</c-> <c- p>}</c-> <c- c>/* “ ” “ ” */</c->
<c- f>:root:lang(to),       :not(:lang(to)) &gt; :lang(to)             </c-><c- p>{</c-> <c- k>quotes</c-><c- p>:</c-> <c- s>&apos;\201c&apos;</c-> <c- s>&apos;\201d&apos;</c-> <c- s>&apos;\2018&apos;</c-> <c- s>&apos;\2019&apos;</c-> <c- p>}</c-> <c- c>/* “ ” ‘ ’ */</c->
<c- f>:root:lang(tr),       :not(:lang(tr)) &gt; :lang(tr)             </c-><c- p>{</c-> <c- k>quotes</c-><c- p>:</c-> <c- s>&apos;\201c&apos;</c-> <c- s>&apos;\201d&apos;</c-> <c- s>&apos;\2018&apos;</c-> <c- s>&apos;\2019&apos;</c-> <c- p>}</c-> <c- c>/* “ ” ‘ ’ */</c->
<c- f>:root:lang(twq),      :not(:lang(twq)) &gt; :lang(twq)           </c-><c- p>{</c-> <c- k>quotes</c-><c- p>:</c-> <c- s>&apos;\201c&apos;</c-> <c- s>&apos;\201d&apos;</c-> <c- s>&apos;\2018&apos;</c-> <c- s>&apos;\2019&apos;</c-> <c- p>}</c-> <c- c>/* “ ” ‘ ’ */</c->
<c- f>:root:lang(tzm),      :not(:lang(tzm)) &gt; :lang(tzm)           </c-><c- p>{</c-> <c- k>quotes</c-><c- p>:</c-> <c- s>&apos;\201c&apos;</c-> <c- s>&apos;\201d&apos;</c-> <c- s>&apos;\2018&apos;</c-> <c- s>&apos;\2019&apos;</c-> <c- p>}</c-> <c- c>/* “ ” ‘ ’ */</c->
<c- f>:root:lang(uk),       :not(:lang(uk)) &gt; :lang(uk)             </c-><c- p>{</c-> <c- k>quotes</c-><c- p>:</c-> <c- s>&apos;\00ab&apos;</c-> <c- s>&apos;\00bb&apos;</c-> <c- s>&apos;\201e&apos;</c-> <c- s>&apos;\201c&apos;</c-> <c- p>}</c-> <c- c>/* « » „ “ */</c->
<c- f>:root:lang(ur),       :not(:lang(ur)) &gt; :lang(ur)             </c-><c- p>{</c-> <c- k>quotes</c-><c- p>:</c-> <c- s>&apos;\201d&apos;</c-> <c- s>&apos;\201c&apos;</c-> <c- s>&apos;\2019&apos;</c-> <c- s>&apos;\2018&apos;</c-> <c- p>}</c-> <c- c>/* ” “ ’ ‘ */</c->
<c- f>:root:lang(uz),       :not(:lang(uz)) &gt; :lang(uz)             </c-><c- p>{</c-> <c- k>quotes</c-><c- p>:</c-> <c- s>&apos;\201c&apos;</c-> <c- s>&apos;\201d&apos;</c-> <c- s>&apos;\2019&apos;</c-> <c- s>&apos;\2018&apos;</c-> <c- p>}</c-> <c- c>/* “ ” ’ ‘ */</c->
<c- f>:root:lang(uz-Cyrl),  :not(:lang(uz-Cyrl)) &gt; :lang(uz-Cyrl)   </c-><c- p>{</c-> <c- k>quotes</c-><c- p>:</c-> <c- s>&apos;\201c&apos;</c-> <c- s>&apos;\201d&apos;</c-> <c- s>&apos;\2018&apos;</c-> <c- s>&apos;\2019&apos;</c-> <c- p>}</c-> <c- c>/* “ ” ‘ ’ */</c->
<c- f>:root:lang(vai),      :not(:lang(vai)) &gt; :lang(vai)           </c-><c- p>{</c-> <c- k>quotes</c-><c- p>:</c-> <c- s>&apos;\201c&apos;</c-> <c- s>&apos;\201d&apos;</c-> <c- s>&apos;\2018&apos;</c-> <c- s>&apos;\2019&apos;</c-> <c- p>}</c-> <c- c>/* “ ” ‘ ’ */</c->
<c- f>:root:lang(vai-Latn), :not(:lang(vai-Latn)) &gt; :lang(vai-Latn) </c-><c- p>{</c-> <c- k>quotes</c-><c- p>:</c-> <c- s>&apos;\201c&apos;</c-> <c- s>&apos;\201d&apos;</c-> <c- s>&apos;\2018&apos;</c-> <c- s>&apos;\2019&apos;</c-> <c- p>}</c-> <c- c>/* “ ” ‘ ’ */</c->
<c- f>:root:lang(vi),       :not(:lang(vi)) &gt; :lang(vi)             </c-><c- p>{</c-> <c- k>quotes</c-><c- p>:</c-> <c- s>&apos;\201c&apos;</c-> <c- s>&apos;\201d&apos;</c-> <c- s>&apos;\2018&apos;</c-> <c- s>&apos;\2019&apos;</c-> <c- p>}</c-> <c- c>/* “ ” ‘ ’ */</c->
<c- f>:root:lang(vun),      :not(:lang(vun)) &gt; :lang(vun)           </c-><c- p>{</c-> <c- k>quotes</c-><c- p>:</c-> <c- s>&apos;\201c&apos;</c-> <c- s>&apos;\201d&apos;</c-> <c- s>&apos;\2018&apos;</c-> <c- s>&apos;\2019&apos;</c-> <c- p>}</c-> <c- c>/* “ ” ‘ ’ */</c->
<c- f>:root:lang(xog),      :not(:lang(xog)) &gt; :lang(xog)           </c-><c- p>{</c-> <c- k>quotes</c-><c- p>:</c-> <c- s>&apos;\201c&apos;</c-> <c- s>&apos;\201d&apos;</c-> <c- s>&apos;\2018&apos;</c-> <c- s>&apos;\2019&apos;</c-> <c- p>}</c-> <c- c>/* “ ” ‘ ’ */</c->
<c- f>:root:lang(yav),      :not(:lang(yav)) &gt; :lang(yav)           </c-><c- p>{</c-> <c- k>quotes</c-><c- p>:</c-> <c- s>&apos;\00ab&apos;</c-> <c- s>&apos;\00bb&apos;</c-> <c- s>&apos;\00ab&apos;</c-> <c- s>&apos;\00bb&apos;</c-> <c- p>}</c-> <c- c>/* « » « » */</c->
<c- f>:root:lang(yo),       :not(:lang(yo)) &gt; :lang(yo)             </c-><c- p>{</c-> <c- k>quotes</c-><c- p>:</c-> <c- s>&apos;\201c&apos;</c-> <c- s>&apos;\201d&apos;</c-> <c- s>&apos;\2018&apos;</c-> <c- s>&apos;\2019&apos;</c-> <c- p>}</c-> <c- c>/* “ ” ‘ ’ */</c->
<c- f>:root:lang(yue),      :not(:lang(yue)) &gt; :lang(yue)           </c-><c- p>{</c-> <c- k>quotes</c-><c- p>:</c-> <c- s>&apos;\300c&apos;</c-> <c- s>&apos;\300d&apos;</c-> <c- s>&apos;\300e&apos;</c-> <c- s>&apos;\300f&apos;</c-> <c- p>}</c-> <c- c>/* 「 」 『 』 */</c->
<c- f>:root:lang(yue-Hans), :not(:lang(yue-Hans)) &gt; :lang(yue-Hans) </c-><c- p>{</c-> <c- k>quotes</c-><c- p>:</c-> <c- s>&apos;\201c&apos;</c-> <c- s>&apos;\201d&apos;</c-> <c- s>&apos;\2018&apos;</c-> <c- s>&apos;\2019&apos;</c-> <c- p>}</c-> <c- c>/* “ ” ‘ ’ */</c->
<c- f>:root:lang(zgh),      :not(:lang(zgh)) &gt; :lang(zgh)           </c-><c- p>{</c-> <c- k>quotes</c-><c- p>:</c-> <c- s>&apos;\00ab&apos;</c-> <c- s>&apos;\00bb&apos;</c-> <c- s>&apos;\201e&apos;</c-> <c- s>&apos;\201d&apos;</c-> <c- p>}</c-> <c- c>/* « » „ ” */</c->
<c- f>:root:lang(zh),       :not(:lang(zh)) &gt; :lang(zh)             </c-><c- p>{</c-> <c- k>quotes</c-><c- p>:</c-> <c- s>&apos;\201c&apos;</c-> <c- s>&apos;\201d&apos;</c-> <c- s>&apos;\2018&apos;</c-> <c- s>&apos;\2019&apos;</c-> <c- p>}</c-> <c- c>/* “ ” ‘ ’ */</c->
<c- f>:root:lang(zh-Hant),  :not(:lang(zh-Hant)) &gt; :lang(zh-Hant)   </c-><c- p>{</c-> <c- k>quotes</c-><c- p>:</c-> <c- s>&apos;\300c&apos;</c-> <c- s>&apos;\300d&apos;</c-> <c- s>&apos;\300e&apos;</c-> <c- s>&apos;\300f&apos;</c-> <c- p>}</c-> <c- c>/* 「 」 『 』 */</c->
<c- f>:root:lang(zu),       :not(:lang(zu)) &gt; :lang(zu)             </c-><c- p>{</c-> <c- k>quotes</c-><c- p>:</c-> <c- s>&apos;\201c&apos;</c-> <c- s>&apos;\201d&apos;</c-> <c- s>&apos;\2018&apos;</c-> <c- s>&apos;\2019&apos;</c-> <c- p>}</c-> <c- c>/* “ ” ‘ ’ */</c->
</code></pre>


  <h4 id=sections-and-headings><span class=secno>14.3.7</span> Sections and headings<a href=#sections-and-headings class=self-link></a></h4>

  <pre><code class='css'><c- n>@namespace</c-> <c- nf>url</c-><c- p>(</c-><c- s>http://www.w3.org/1999/xhtml</c-><c- p>);</c->

<c- f>article, aside, h1, h2, h3, h4, h5, h6, hgroup, nav, section </c-><c- p>{</c->
  <c- k>display</c-><c- p>:</c-> block<c- p>;</c->
<c- p>}</c->

<c- f>h1 </c-><c- p>{</c-> <c- k>margin-block-start</c-><c- p>:</c-> <c- m>0.67</c-><c- l>em</c-><c- p>;</c-> <c- k>margin-block-end</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- k>font-weight</c-><c- p>:</c-> bold<c- p>;</c-> <c- p>}</c->
<c- f>h2 </c-><c- p>{</c-> <c- k>margin-block-start</c-><c- p>:</c-> <c- m>0.83</c-><c- l>em</c-><c- p>;</c-> <c- k>margin-block-end</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- k>font-weight</c-><c- p>:</c-> bold<c- p>;</c-> <c- p>}</c->
<c- f>h3 </c-><c- p>{</c-> <c- k>margin-block-start</c-><c- p>:</c-> <c- m>1.00</c-><c- l>em</c-><c- p>;</c-> <c- k>margin-block-end</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- k>font-weight</c-><c- p>:</c-> bold<c- p>;</c-> <c- p>}</c->
<c- f>h4 </c-><c- p>{</c-> <c- k>margin-block-start</c-><c- p>:</c-> <c- m>1.33</c-><c- l>em</c-><c- p>;</c-> <c- k>margin-block-end</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- k>font-weight</c-><c- p>:</c-> bold<c- p>;</c-> <c- p>}</c->
<c- f>h5 </c-><c- p>{</c-> <c- k>margin-block-start</c-><c- p>:</c-> <c- m>1.67</c-><c- l>em</c-><c- p>;</c-> <c- k>margin-block-end</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- k>font-weight</c-><c- p>:</c-> bold<c- p>;</c-> <c- p>}</c->
<c- f>h6 </c-><c- p>{</c-> <c- k>margin-block-start</c-><c- p>:</c-> <c- m>2.33</c-><c- l>em</c-><c- p>;</c-> <c- k>margin-block-end</c-><c- p>:</c-> <c- m>2.33</c-><c- l>em</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>font-weight</c-><c- p>:</c-> bold<c- p>;</c-> <c- p>}</c-></code></pre>

  <p>In the following CSS block, <var>x</var> is shorthand for the following selector:
  <code>:matches(article, aside, nav, section)</code></p>

  <pre><code class='css'><c- n>@namespace</c-> <c- nf>url</c-><c- p>(</c-><c- s>http://www.w3.org/1999/xhtml</c-><c- p>);</c->

<var><c- f>x</c-></var><c- f> h1 </c-><c- p>{</c-> <c- k>margin-block-start</c-><c- p>:</c-> <c- m>0.83</c-><c- l>em</c-><c- p>;</c-> <c- k>margin-block-end</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->
<var><c- f>x</c-></var><c- f> </c-><var><c- f>x</c-></var><c- f> h1 </c-><c- p>{</c-> <c- k>margin-block-start</c-><c- p>:</c-> <c- m>1.00</c-><c- l>em</c-><c- p>;</c-> <c- k>margin-block-end</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->
<var><c- f>x</c-></var><c- f> </c-><var><c- f>x</c-></var><c- f> </c-><var><c- f>x</c-></var><c- f> h1 </c-><c- p>{</c-> <c- k>margin-block-start</c-><c- p>:</c-> <c- m>1.33</c-><c- l>em</c-><c- p>;</c-> <c- k>margin-block-end</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->
<var><c- f>x</c-></var><c- f> </c-><var><c- f>x</c-></var><c- f> </c-><var><c- f>x</c-></var><c- f> </c-><var><c- f>x</c-></var><c- f> h1 </c-><c- p>{</c-> <c- k>margin-block-start</c-><c- p>:</c-> <c- m>1.67</c-><c- l>em</c-><c- p>;</c-> <c- k>margin-block-end</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->
<var><c- f>x</c-></var><c- f> </c-><var><c- f>x</c-></var><c- f> </c-><var><c- f>x</c-></var><c- f> </c-><var><c- f>x</c-></var><c- f> </c-><var><c- f>x</c-></var><c- f> h1 </c-><c- p>{</c-> <c- k>margin-block-start</c-><c- p>:</c-> <c- m>2.33</c-><c- l>em</c-><c- p>;</c-> <c- k>margin-block-end</c-><c- p>:</c-> <c- m>2.33</c-><c- l>em</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- p>}</c->

<var><c- f>x</c-></var><c- f> hgroup &gt; h1 ~ h2 </c-><c- p>{</c-> <c- k>margin-block-start</c-><c- p>:</c-> <c- m>1.00</c-><c- l>em</c-><c- p>;</c-> <c- k>margin-block-end</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->
<var><c- f>x</c-></var><c- f> </c-><var><c- f>x</c-></var><c- f> hgroup &gt; h1 ~ h2 </c-><c- p>{</c-> <c- k>margin-block-start</c-><c- p>:</c-> <c- m>1.33</c-><c- l>em</c-><c- p>;</c-> <c- k>margin-block-end</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->
<var><c- f>x</c-></var><c- f> </c-><var><c- f>x</c-></var><c- f> </c-><var><c- f>x</c-></var><c- f> hgroup &gt; h1 ~ h2 </c-><c- p>{</c-> <c- k>margin-block-start</c-><c- p>:</c-> <c- m>1.67</c-><c- l>em</c-><c- p>;</c-> <c- k>margin-block-end</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->
<var><c- f>x</c-></var><c- f> </c-><var><c- f>x</c-></var><c- f> </c-><var><c- f>x</c-></var><c- f> </c-><var><c- f>x</c-></var><c- f> hgroup &gt; h1 ~ h2 </c-><c- p>{</c-> <c- k>margin-block-start</c-><c- p>:</c-> <c- m>2.33</c-><c- l>em</c-><c- p>;</c-> <c- k>margin-block-end</c-><c- p>:</c-> <c- m>2.33</c-><c- l>em</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- p>}</c->

<var><c- f>x</c-></var><c- f> hgroup &gt; h1 ~ h3 </c-><c- p>{</c-> <c- k>margin-block-start</c-><c- p>:</c-> <c- m>1.33</c-><c- l>em</c-><c- p>;</c-> <c- k>margin-block-end</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->
<var><c- f>x</c-></var><c- f> </c-><var><c- f>x</c-></var><c- f> hgroup &gt; h1 ~ h3 </c-><c- p>{</c-> <c- k>margin-block-start</c-><c- p>:</c-> <c- m>1.67</c-><c- l>em</c-><c- p>;</c-> <c- k>margin-block-end</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->
<var><c- f>x</c-></var><c- f> </c-><var><c- f>x</c-></var><c- f> </c-><var><c- f>x</c-></var><c- f> hgroup &gt; h1 ~ h3 </c-><c- p>{</c-> <c- k>margin-block-start</c-><c- p>:</c-> <c- m>2.33</c-><c- l>em</c-><c- p>;</c-> <c- k>margin-block-end</c-><c- p>:</c-> <c- m>2.33</c-><c- l>em</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- p>}</c->

<var><c- f>x</c-></var><c- f> hgroup &gt; h1 ~ h4 </c-><c- p>{</c-> <c- k>margin-block-start</c-><c- p>:</c-> <c- m>1.67</c-><c- l>em</c-><c- p>;</c-> <c- k>margin-block-end</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->
<var><c- f>x</c-></var><c- f> </c-><var><c- f>x</c-></var><c- f> hgroup &gt; h1 ~ h4 </c-><c- p>{</c-> <c- k>margin-block-start</c-><c- p>:</c-> <c- m>2.33</c-><c- l>em</c-><c- p>;</c-> <c- k>margin-block-end</c-><c- p>:</c-> <c- m>2.33</c-><c- l>em</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- p>}</c->

<var><c- f>x</c-></var><c- f> hgroup &gt; h1 ~ h5 </c-><c- p>{</c-> <c- k>margin-block-start</c-><c- p>:</c-> <c- m>2.33</c-><c- l>em</c-><c- p>;</c-> <c- k>margin-block-end</c-><c- p>:</c-> <c- m>2.33</c-><c- l>em</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- p>}</c-></code></pre>

  <p class=note>The shorthand is used to keep this block at least mildly readable.</p>



  <h4 id=lists><span class=secno>14.3.8</span> Lists<a href=#lists class=self-link></a></h4>

  <pre><code class='css'><c- n>@namespace</c-> <c- nf>url</c-><c- p>(</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- p>}</c->

<c- f>dir, dl, menu, ol, ul </c-><c- p>{</c-> <c- k>margin-block-start</c-><c- p>:</c-> <c- m>1</c-><c- l>em</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->

<c- f>:matches(dir, dl, menu, ol, ul) :matches(dir, dl, menu, ol, ul) </c-><c- p>{</c->
  <c- k>margin-block-start</c-><c- p>:</c-> <c- m>0</c-><c- p>;</c-> <c- k>margin-block-end</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 </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>:matches(dir, menu, ol, ul) :matches(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>:matches(dir, menu, ol, ul) :matches(dir, menu, ol, ul) :matches(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 expected to apply, as <a href=#presentational-hints id=lists:presentational-hints>presentational
  hints</a>:</p>

  <pre><code class='css'><c- n>@namespace</c-> <c- nf>url</c-><c- p>(</c-><c- s>http://www.w3.org/1999/xhtml</c-><c- p>);</c->

<c- f>ol[type=&quot;1&quot;], li[type=&quot;1&quot;] </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], li[type=a] </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], li[type=A] </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], li[type=i] </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], li[type=I] </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 id=attribute-selector-case-sensitive>In the above style sheet, the <a href=https://drafts.csswg.org/selectors/#attribute-selector id=lists:attribute-selector data-x-internal=attribute-selector>attribute selectors</a> for the <code id=lists:the-ol-element><a href=#the-ol-element>ol</a></code> and <code id=lists:the-li-element><a href=#the-li-element>li</a></code>
  elements are expected to be treated as <a href=#case-sensitive id=lists:case-sensitive>case-sensitive</a>.</p>

  <p>When rendering <code id=lists:the-li-element-2><a href=#the-li-element>li</a></code> elements, non-CSS user agents are expected to use the
  <a href=#ordinal-value id=lists:ordinal-value>ordinal value</a> of the <code id=lists:the-li-element-3><a href=#the-li-element>li</a></code> element to render the counter in the list item
  marker.</p>

  <p id=css-list-rendering class=critical>This specification does not yet define the
  CSS-specific rules for rendering <code id=lists:the-li-element-4><a href=#the-li-element>li</a></code> elements, because CSS doesn't yet provide
  sufficient hooks for this purpose.</p>


  <h4 id=tables-2><span class=secno>14.3.9</span> Tables<a href=#tables-2 class=self-link></a></h4>

  <pre><code class='css'><c- n>@namespace</c-> <c- nf>url</c-><c- p>(</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>table, td, th </c-><c- p>{</c-> <c- k>border-color</c-><c- p>:</c-> gray<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 expected 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- nf>url</c-><c- p>(</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-start</c-><c- p>:</c-> auto<c- p>;</c-> <c- k>margin-inline-end</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-start-style</c-><c- p>:</c-> none<c- p>;</c->
  <c- k>border-inline-end-style</c-><c- p>:</c-> solid<c- p>;</c->
  <c- k>border-block-end-style</c-><c- p>:</c-> none<c- p>;</c->
  <c- k>border-inline-start-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-start-width</c-><c- p>:</c-> <c- m>1</c-><c- l>px</c-><c- p>;</c->
  <c- k>border-inline-start-style</c-><c- p>:</c-> solid<c- p>;</c->
  <c- k>border-inline-end-width</c-><c- p>:</c-> <c- m>1</c-><c- l>px</c-><c- p>;</c->
  <c- k>border-inline-end-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-start-width</c-><c- p>:</c-> <c- m>1</c-><c- l>px</c-><c- p>;</c->
  <c- k>border-block-start-style</c-><c- p>:</c-> solid<c- p>;</c->
  <c- k>border-block-end-width</c-><c- p>:</c-> <c- m>1</c-><c- l>px</c-><c- p>;</c->
  <c- k>border-block-end-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-start-width</c-><c- p>:</c-> <c- m>1</c-><c- l>px</c-><c- p>;</c->
  <c- k>border-block-start-style</c-><c- p>:</c-> solid<c- p>;</c->
  <c- k>border-block-end-width</c-><c- p>:</c-> <c- m>1</c-><c- l>px</c-><c- p>;</c->
  <c- k>border-block-end-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 expected to apply:</p>

  <pre><code class='css'><c- n>@namespace</c-> <c- nf>url</c-><c- p>(</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 expected 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 expected 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 expected 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 expected to apply:</p>

  <pre><code class='css'><c- n>@namespace</c-> <c- nf>url</c-><c- p>(</c-><c- s>http://www.w3.org/1999/xhtml</c-><c- p>);</c->

<c- f>:matches(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/css2/box.html#propdef-padding-top data-x-internal="'padding-top'">'padding-top'</a>, <a id="tables-2:'padding-right'" href=https://drafts.csswg.org/css2/box.html#propdef-padding-right data-x-internal="'padding-right'">'padding-right'</a>,
  <a id="tables-2:'padding-bottom'" href=https://drafts.csswg.org/css2/box.html#propdef-padding-bottom data-x-internal="'padding-bottom'">'padding-bottom'</a>, and <a id="tables-2:'padding-left'" href=https://drafts.csswg.org/css2/box.html#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-(ignoring-zero) id=tables-2:maps-to-the-dimension-property-(ignoring-zero)>maps to the dimension property (ignoring zero)</a> <a id="tables-2:'height'" href=https://drafts.csswg.org/css2/visudet.html#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)-2>maps to the dimension property (ignoring zero)</a> <a id="tables-2:'width'" href=https://drafts.csswg.org/css2/visudet.html#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-(ignoring-zero) id=tables-2:maps-to-the-dimension-property-(ignoring-zero)-3>maps
  to the dimension property (ignoring zero)</a> <a id="tables-2:'width'-2" href=https://drafts.csswg.org/css2/visudet.html#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-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-(ignoring-zero) id=tables-2:maps-to-the-dimension-property-(ignoring-zero)-4>maps
  to the dimension property (ignoring zero)</a> <a id="tables-2:'height'-2" href=https://drafts.csswg.org/css2/visudet.html#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)-5>map to the dimension
  property (ignoring zero)</a> <a id="tables-2:'height'-3" href=https://drafts.csswg.org/css2/visudet.html#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)-6>map to the dimension
  property (ignoring zero)</a> <a id="tables-2:'width'-3" href=https://drafts.csswg.org/css2/visudet.html#the-width-property data-x-internal="'width'">'width'</a> on the element.</p>

  <hr>

  <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>, <code id=tables-2:the-tfoot-element><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 expected 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>

  <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-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 expected 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>

  <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-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 expected 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>

  <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-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 expected 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>

  <p>User agents are expected 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>

  <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-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-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
  expected to be <a href=#parse-a-url id=tables-2:parse-a-url>parsed</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 this is successful, the user agent is expected 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/#the-background-image data-x-internal="'background-image'">'background-image'</a> property to the <a href=#resulting-url-string id=tables-2:resulting-url-string>resulting URL string</a>.</p>

  <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-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-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 expected 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 an error, the user agent is expected 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/#the-background-color data-x-internal="'background-color'">'background-color'</a> property to the resulting color.</p>

  <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 expected 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 an error, the user agent is expected 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/css2/box.html#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/css2/box.html#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/css2/box.html#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/css2/box.html#propdef-border-left-color data-x-internal="'border-left-color'">'border-left-color'</a> properties to the
  resulting color.</p>

  <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/css2/box.html#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/css2/box.html#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/css2/box.html#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/css2/box.html#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 expected to be used for
  that property instead.</p>

  <p>Rules marked "<dfn id=magic-border-selector>only if border is not equivalent to zero</dfn>"
  in the CSS block above is expected 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>

  <hr>

  <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 expected 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>  

  <h4 id=margin-collapsing-quirks><span class=secno>14.3.10</span> Margin collapsing quirks<a href=#margin-collapsing-quirks class=self-link></a></h4>

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

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

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

  <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 expected 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>

  <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 expected 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>

  <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 expected 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>

  <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 expected
  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>


  <h4 id=form-controls><span class=secno>14.3.11</span> Form controls<a href=#form-controls class=self-link></a></h4>

  <pre><code class='css'><c- n>@namespace</c-> <c- nf>url</c-><c- p>(</c-><c- s>http://www.w3.org/1999/xhtml</c-><c- p>);</c->

<c- f>input, select, option, optgroup, button, textarea </c-><c- p>{</c->
  <c- k>text-indent</c-><c- p>:</c-> initial<c- p>;</c->
<c- p>}</c->

<c- f>input:matches([type=radio i], [type=checkbox i], [type=reset i], [type=button i],</c->
<c- f>[type=submit i], [type=search i]), select, button </c-><c- p>{</c->
  <c- k>box-sizing</c-><c- p>:</c-> border-box<c- p>;</c->
<c- p>}</c->

<c- f>textarea </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=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 expected to apply:</p>

  <pre><code class='css'><c- n>@namespace</c-> <c- nf>url</c-><c- p>(</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>



  <h4 id=the-hr-element-2><span class=secno>14.3.12</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- nf>url</c-><c- p>(</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-start</c-><c- p>:</c-> <c- m>0.5</c-><c- l>em</c-><c- p>;</c->
  <c- k>margin-inline-end</c-><c- p>:</c-> auto<c- p>;</c->
  <c- k>margin-block-end</c-><c- p>:</c-> <c- m>0.5</c-><c- l>em</c-><c- p>;</c->
  <c- k>margin-inline-start</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 expected 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- nf>url</c-><c- p>(</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>

  <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 expected 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/css2/box.html#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/css2/box.html#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/css2/box.html#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/css2/box.html#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 expected 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/css2/box.html#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 expected 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/visudet.html#the-height-property data-x-internal="'height'">'height'</a> property on the element.</p>

  <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/visudet.html#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 expected 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 an error, the user agent is expected 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>14.3.13</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- nf>url</c-><c- p>(</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-start</c-><c- p>:</c-> <c- m>2</c-><c- l>px</c-><c- p>;</c->
  <c- k>margin-inline-end</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-start</c-><c- p>:</c-> <c- m>0.35</c-><c- l>em</c-><c- p>;</c->
  <c- k>padding-inline-end</c-><c- p>:</c-> <c- m>0.75</c-><c- l>em</c-><c- p>;</c->
  <c- k>padding-block-end</c-><c- p>:</c-> <c- m>0.625</c-><c- l>em</c-><c- p>;</c->
  <c- k>padding-inline-start</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-start</c-><c- p>:</c-> <c- m>2</c-><c- l>px</c-><c- p>;</c-> <c- k>padding-inline-end</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>

  <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 box (i.e., is not 'display: none' or
  'display: contents'), is expected to act as follows:</p>

  <ul><li><p>The element is expected to establish a new block formatting context.<li>
    <p>The <a id="the-fieldset-and-legend-elements:'display'" href=https://drafts.csswg.org/css2/visuren.html#display-prop data-x-internal="'display'">'display'</a> property is expected 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/visuren.html#display-prop data-x-internal="'display'">'display'</a> is inline-level, then behave as
     'inline-block'.<li><p>Otherwise, behave as 'flow-root'.</ul>

    <p class=note>This does not change the computed value.</p>
   <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>The child's used value of <a id="the-fieldset-and-legend-elements:'float'" href=https://drafts.csswg.org/css2/visuren.html#float-position data-x-internal="'float'">'float'</a> is 'none'.<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'.</ul>
   <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 expected 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.<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.<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.<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.</ol>
   <li><p>The space allocated for the element's border on the block-start side is expected 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.<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 expected to be
   substracted 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 zero instead.<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 expected to be
   the first child box.<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 expected to appear after the
   <a href=#rendered-legend id=the-fieldset-and-legend-elements:rendered-legend-9>rendered legend</a> and is expected 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.<li><p>The used value of the <a id="the-fieldset-and-legend-elements:'padding-top'" href=https://drafts.csswg.org/css2/box.html#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/css2/box.html#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/css2/box.html#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/css2/box.html#propdef-padding-left data-x-internal="'padding-left'">'padding-left'</a> properties are expected to be
   zero.<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>.<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>.</ul>

  <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 expected to act as
  follows:</p>

  <ul><li><p>The element is expected to establish a new formatting context for its contents. The type
   of this formatting context is determined by its <a id="the-fieldset-and-legend-elements:'display'-3" href=https://drafts.csswg.org/css2/visuren.html#display-prop data-x-internal="'display'">'display'</a> value, as usual.<li>
    <p>The <a id="the-fieldset-and-legend-elements:'display'-4" href=https://drafts.csswg.org/css2/visuren.html#display-prop data-x-internal="'display'">'display'</a> property is expected to behave as if its computed value was
    blockified.</p>

    <p class=note>This does not change the computed value.</p>
   <li><p>In the absence of an explicit inline size, the box should shrink-wrap.<li><p>The element is expected 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).<li>
    <p>The element's box is expected 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><p>The element is expected 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.</ul>


  <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 expected to
  act as follows:</p>

  <ul><li>
    <p>The <a id="the-fieldset-and-legend-elements:'display'-5" href=https://drafts.csswg.org/css2/visuren.html#display-prop data-x-internal="'display'">'display'</a> property is expected 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/visuren.html#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'.<li><p>If the computed value of <a id="the-fieldset-and-legend-elements:'display'-7" href=https://drafts.csswg.org/css2/visuren.html#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'.<li><p>Otherwise, set the used value to 'flow-root'.</ul>
   <li>
    <p>The following properties are expected 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><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><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><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><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><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><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><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><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><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><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><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><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><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><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><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><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><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><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><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><a id="the-fieldset-and-legend-elements:'overflow'" href=https://drafts.csswg.org/css-overflow/#propdef-overflow data-x-internal="'overflow'">'overflow'</a><li><a id="the-fieldset-and-legend-elements:'padding-bottom'-2" href=https://drafts.csswg.org/css2/box.html#propdef-padding-bottom data-x-internal="'padding-bottom'">'padding-bottom'</a><li><a id="the-fieldset-and-legend-elements:'padding-left'-2" href=https://drafts.csswg.org/css2/box.html#propdef-padding-left data-x-internal="'padding-left'">'padding-left'</a><li><a id="the-fieldset-and-legend-elements:'padding-right'-2" href=https://drafts.csswg.org/css2/box.html#propdef-padding-right data-x-internal="'padding-right'">'padding-right'</a><li><a id="the-fieldset-and-legend-elements:'padding-top'-2" href=https://drafts.csswg.org/css2/box.html#propdef-padding-top data-x-internal="'padding-top'">'padding-top'</a><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><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></ul>
   <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 expected to be set to '100%'.<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.</ul>

  <div id=fieldset-layout-model class=note>
   <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>14.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/css2/conform.html#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>14.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 expected to be
  treated as <a href=https://drafts.csswg.org/css2/conform.html#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
  expected to be treated as a <a id=embedded-content-rendering-rules:replaced-element-2 href=https://drafts.csswg.org/css2/conform.html#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:intrinsic-dimensions href=https://drafts.csswg.org/css2/conform.html#intrinsic data-x-internal=intrinsic-dimensions>intrinsic 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 expected
  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 <a href=#nested-browsing-context id=embedded-content-rendering-rules:nested-browsing-context>nested
  browsing context</a> is expected to be treated as a <a id=embedded-content-rendering-rules:replaced-element-3 href=https://drafts.csswg.org/css2/conform.html#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 expected 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 expected to be treated as a
  <a id=embedded-content-rendering-rules:replaced-element-4 href=https://drafts.csswg.org/css2/conform.html#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 expected to force
  its <a id="embedded-content-rendering-rules:'display'" href=https://drafts.csswg.org/css2/visuren.html#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 expected to affect the size of the rendering;
  controls are expected to be overlaid above the page content without causing any layout changes,
  and are expected 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 expected 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 expected 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 expected to be overlayed 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 expected to apply:</p>

  <pre><code class='css'><c- n>@namespace</c-> <c- nf>url</c-><c- p>(</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>14.4.2</span> Images<a href=#images-3 class=self-link></a></h4>

  <p>User agents are expected 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<dd>The user agent is expected to treat the element as a <a id=images-3:replaced-element href=https://drafts.csswg.org/css2/conform.html#replaced-element data-x-internal=replaced-element>replaced element</a> and
   render the image according to the rules for doing so defined in CSS.<dt>

    If the element does not <a href=#represents id=images-3:represents-2>represent</a> an image, but the element
    already has <a id=images-3:intrinsic-dimensions href=https://drafts.csswg.org/css2/conform.html#intrinsic data-x-internal=intrinsic-dimensions>intrinsic dimensions</a> (e.g. from the <a href=#dimension-attributes id=images-3:dimension-attributes>dimension attributes</a>
    or CSS rules), 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>the element has no <code>alt</code> attribute, or

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

    </ul>

   <dd>The user agent is expected to treat the element as a <a id=images-3:replaced-element-2 href=https://drafts.csswg.org/css2/conform.html#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 expected to appear button-like to indicate that the element is a <a href=#concept-button id=images-3:concept-button>button</a>.<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<dd>The user agent is expected 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.<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<dd>The user agent is expected to treat the element as an empty inline element. (In the absence
   of further styles, this will cause the element to essentially not be rendered.)<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<dd>The user agent is expected to treat the element as a <a id=images-3:replaced-element-3 href=https://drafts.csswg.org/css2/conform.html#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:intrinsic-dimensions-2 href=https://drafts.csswg.org/css2/conform.html#intrinsic data-x-internal=intrinsic-dimensions>intrinsic
   dimensions</a> of the button are expected to be about one line in height and whatever width
   is necessary to render the text on one line.</dl>

  <p>The icons mentioned above are expected 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 expected 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
  expected 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>

  <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 expected to restart
  their animation from the beginning.</p>

  <hr>

  <p>The following CSS rules are expected 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- nf>url</c-><c- p>(</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>14.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 expected 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- nf>url</c-><c- p>(</c-><c- s>http://www.w3.org/1999/xhtml</c-><c- p>);</c->

<c- f>iframe[frameborder=0], iframe[frameborder=no i] </c-><c- p>{</c-> <c- k>border</c-><c- p>:</c-> none<c- p>;</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 expected to act as if the element's <a id="attributes-for-embedded-content-and-images:'vertical-align'" href=https://drafts.csswg.org/css2/visudet.html#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-iframe-element-2><a href=#the-iframe-element>iframe</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/css2/box.html#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/css2/box.html#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-iframe-element-3><a href=#the-iframe-element>iframe</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/css2/box.html#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/css2/box.html#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-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
  expected to use the parsed value for eight <a href=#presentational-hints id=attributes-for-embedded-content-and-images:presentational-hints-2>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'" href=https://drafts.csswg.org/css2/box.html#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/css2/box.html#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/css2/box.html#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/css2/box.html#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/css2/box.html#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/css2/box.html#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/css2/box.html#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/css2/box.html#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 <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-4><a href=#the-iframe-element>iframe</a></code>,
  <code id=attributes-for-embedded-content-and-images:the-img-element-5><a href=#the-img-element>img</a></code>, <code id=attributes-for-embedded-content-and-images:the-object-element-5><a href=#the-object-element>object</a></code> or <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-3>map to the dimension properties</a> <a id="attributes-for-embedded-content-and-images:'width'" href=https://drafts.csswg.org/css2/visudet.html#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/visudet.html#the-height-property data-x-internal="'height'">'height'</a> on
  the element respectively.</p>

  


  

  <h4 id=image-maps-2><span class=secno>14.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 expected 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 expected 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:the-style-attribute><a href=#the-style-attribute>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>14.5</span> <span id=bindings></span>Widgets<a href=#widgets class=self-link></a></h3>

  <h4 id=introduction-17><span class=secno>14.5.1</span> Introduction<a href=#introduction-17 class=self-link></a></h4>

  <p>The elements defined in this section can be rendered in a variety of manners, within the
  guidelines provided below. User agents are encouraged to set the <a id="introduction-17:'appearance'" href=https://drafts.csswg.org/css-ui-4/#appearance-switching data-x-internal="'appearance'">'appearance'</a> CSS
  property appropriately to achieve platform-native appearances for widgets, and are expected to
  implement any relevant animations, etc, that are appropriate for the platform.</p>
  

  


  

  <h4 id=the-button-element-2><span class=secno>14.5.2</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 expected to render as an <a id="the-button-element-2:'inline-block'" href=https://drafts.csswg.org/css2/visuren.html#value-def-inline-block data-x-internal="'inline-block'">'inline-block'</a> box
  depicting a button whose contents are the contents of the element.</p>

  


  

  <h4 id=the-details-and-summary-elements><span class=secno>14.5.3</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- nf>url</c-><c- p>(</c-><c- s>http://www.w3.org/1999/xhtml</c-><c- p>);</c->

<c- f>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>details[open] &gt; 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>The <code id=the-details-and-summary-elements:the-details-element-2><a href=#the-details-element>details</a></code> element is expected to render as a <a id=the-details-and-summary-elements:block-box href=https://drafts.csswg.org/css2/visuren.html#x9 data-x-internal=block-box>block box</a>. The
  element's shadow tree is expected to take the 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, and place it in a first <a id=the-details-and-summary-elements:block-box-2 href=https://drafts.csswg.org/css2/visuren.html#x9 data-x-internal=block-box>block box</a> container, and then take the element's
  remaining descendants, if any, and place them in a second <a id=the-details-and-summary-elements:block-box-3 href=https://drafts.csswg.org/css2/visuren.html#x9 data-x-internal=block-box>block box</a> container.</p>

  <p>The first container is expected to allow the user to request the details be shown or
  hidden.</p>

  <p>The second container is expected to be removed from the rendering when the <code id=the-details-and-summary-elements:the-details-element-3><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.</p>

  

  

  

  <h4 id=the-input-element-as-a-text-entry-widget><span class=secno>14.5.4</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>

  <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="#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>, <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="#e-mail-state-(type=email)" id="the-input-element-as-a-text-entry-widget:e-mail-state-(type=email)">E-mail</a> state, is expected to render as an
  <a id="the-input-element-as-a-text-entry-widget:'inline-block'" href=https://drafts.csswg.org/css2/visuren.html#value-def-inline-block data-x-internal="'inline-block'">'inline-block'</a> box depicting a text control. Additionally, the
  <a id="the-input-element-as-a-text-entry-widget:'line-height'" href=https://drafts.csswg.org/css2/visudet.html#propdef-line-height data-x-internal="'line-height'">'line-height'</a> property, if it has a <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> equivalent to a value
  that is less than 1.0, must have a <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 1.0.</p>

  <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="#password-state-(type=password)" id="the-input-element-as-a-text-entry-widget:password-state-(type=password)">Password</a> state is expected to render as an
  <a id="the-input-element-as-a-text-entry-widget:'inline-block'-2" href=https://drafts.csswg.org/css2/visuren.html#value-def-inline-block data-x-internal="'inline-block'">'inline-block'</a> box depicting a text control that obscures data entry.</p>

  <p>If these text controls provide a text selection, then, when the user changes the current
  selection, the user agent is expected to <a href=#queue-a-task id=the-input-element-as-a-text-entry-widget:queue-a-task>queue a task</a>, using 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>, 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>

  <p>If 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 one of the above states 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, then the user agent is expected to use the attribute as a <a href=#presentational-hints id=the-input-element-as-a-text-entry-widget:presentational-hints>presentational hint</a> for the <a id="the-input-element-as-a-text-entry-widget:'width'" href=https://drafts.csswg.org/css2/visudet.html#the-width-property data-x-internal="'width'">'width'</a> property on
  the element, with 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>

  <p>If an <code id=the-input-element-as-a-text-entry-widget:the-input-element-5><a href=#the-input-element>input</a></code> element 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 does <em>not</em> have a <code id=the-input-element-as-a-text-entry-widget:attr-input-size-2><a href=#attr-input-size>size</a></code>
  attribute, then the user agent is expected to act as if it had a user-agent-level style sheet rule
  setting the <a id="the-input-element-as-a-text-entry-widget:'width'-2" href=https://drafts.csswg.org/css2/visudet.html#the-width-property data-x-internal="'width'">'width'</a> property on the element to 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>

  <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> + <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>

  


  

  <h4 id=the-input-element-as-domain-specific-widgets><span class=secno>14.5.5</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>

  <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 expected to render as an
  <a id="the-input-element-as-domain-specific-widgets:'inline-block'" href=https://drafts.csswg.org/css2/visuren.html#value-def-inline-block data-x-internal="'inline-block'">'inline-block'</a> box depicting a date control.</p>

  <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 expected to render as an
  <a id="the-input-element-as-domain-specific-widgets:'inline-block'-2" href=https://drafts.csswg.org/css2/visuren.html#value-def-inline-block data-x-internal="'inline-block'">'inline-block'</a> box depicting a month control.</p>

  <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 expected to render as an
  <a id="the-input-element-as-domain-specific-widgets:'inline-block'-3" href=https://drafts.csswg.org/css2/visuren.html#value-def-inline-block data-x-internal="'inline-block'">'inline-block'</a> box depicting a week control.</p>

  <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 expected to render as an
  <a id="the-input-element-as-domain-specific-widgets:'inline-block'-4" href=https://drafts.csswg.org/css2/visuren.html#value-def-inline-block data-x-internal="'inline-block'">'inline-block'</a> box depicting a time control.</p>

  <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 expected to
  render as an <a id="the-input-element-as-domain-specific-widgets:'inline-block'-5" href=https://drafts.csswg.org/css2/visuren.html#value-def-inline-block data-x-internal="'inline-block'">'inline-block'</a> box depicting a local date and time control.</p>

  <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 expected to render as an
  <a id="the-input-element-as-domain-specific-widgets:'inline-block'-6" href=https://drafts.csswg.org/css2/visuren.html#value-def-inline-block data-x-internal="'inline-block'">'inline-block'</a> box depicting a number control.</p>

  <p>These controls are all expected to be about one line high, and about as wide as necessary to
  show the widest possible value.</p>

  


  

  <h4 id=the-input-element-as-a-range-control><span class=secno>14.5.6</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>

  <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 expected to render as an
  <a id="the-input-element-as-a-range-control:'inline-block'" href=https://drafts.csswg.org/css2/visuren.html#value-def-inline-block data-x-internal="'inline-block'">'inline-block'</a> box depicting a slider control.</p>

  <p>When the control is wider than it is tall (or square), the control is expected to be a
  horizontal slider, with the lowest value 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 on
  this element 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 the
  control is taller than it is wide, it is expected to be a vertical slider, with the lowest value
  on the bottom.</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 expected to be shown as tick marks on the slider, which the slider can snap to.</p>

  <p>User agents are expected to use the <a id=the-input-element-as-a-range-control: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-range-control:'direction'-2" href=https://drafts.csswg.org/css-writing-modes/#direction data-x-internal="'direction'">'direction'</a>
  property on the element to determine the direction in which the slider operates. Typically, a
  left-to-right ('ltr') horizontal control would have the lowest value on the left and the highest
  value on the right, and vice versa.</p>

  


  

  <h4 id=the-input-element-as-a-colour-well><span class=secno>14.5.7</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 expected to render as an
  <a id="the-input-element-as-a-colour-well:'inline-block'" href=https://drafts.csswg.org/css2/visuren.html#value-def-inline-block data-x-internal="'inline-block'">'inline-block'</a> box depicting 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.</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 expected to be shown in the color picker interface, not on the color well
  itself.</p>

  


  

  <h4 id=the-input-element-as-a-checkbox-and-radio-button-widgets><span class=secno>14.5.8</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>

  <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 expected to render as an
  <a id="the-input-element-as-a-checkbox-and-radio-button-widgets:'inline-block'" href=https://drafts.csswg.org/css2/visuren.html#value-def-inline-block data-x-internal="'inline-block'">'inline-block'</a> box containing a single checkbox control, with no label.</p>

  <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 expected 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/visuren.html#value-def-inline-block data-x-internal="'inline-block'">'inline-block'</a> box containing a single radio button control, with no label.</p>

  


  

  <h4 id=the-input-element-as-a-file-upload-control><span class=secno>14.5.9</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 is expected to render as an
  <a id="the-input-element-as-a-file-upload-control:'inline-block'" href=https://drafts.csswg.org/css2/visuren.html#value-def-inline-block data-x-internal="'inline-block'">'inline-block'</a> box containing a span of text giving the file name(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.</p>

  


  

  <h4 id=the-input-element-as-a-button><span class=secno>14.5.10</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 is expected to render as an
  <a id="the-input-element-as-a-button:'inline-block'" href=https://drafts.csswg.org/css2/visuren.html#value-def-inline-block data-x-internal="'inline-block'">'inline-block'</a> box depicting a button, about one line high, containing the contents
  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 a user-agent-defined
  (and probably locale-specific) fashion, if not.</p>

  


  

  <h4 id=the-marquee-element-2><span class=secno>14.5.11</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>

  <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
  expected 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<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/css2/box.html#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/css2/box.html#box-content-area data-x-internal=content-area>content area</a>.</p>

    <p>Once the animation has ended, the user agent is expected 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 expected to restart the animation.</p>

   <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<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/css2/box.html#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/css2/box.html#box-content-area data-x-internal=content-area>content area</a>.</p>

    <p>Once the animation has ended, the user agent is expected 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 expected to restart the animation.</p>

   <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<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/css2/box.html#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/css2/box.html#box-content-area data-x-internal=content-area>content area</a>.</p>

    <p>Once the animation has ended, the user agent is expected 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 expected to continue the animation.</p>

   </dl>

  <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>Direction of animation
     <th>Start edge
     <th>End edge
     <th>Opposite direction
   <tbody><tr><td><a href=#attr-marquee-direction-left id=the-marquee-element-2:attr-marquee-direction-left-4>left</a>
     <td>← Right to left
     <td>Right
     <td>Left
     <td>→ Left to Right
    <tr><td><a href=#attr-marquee-direction-right id=the-marquee-element-2:attr-marquee-direction-right>right</a>
     <td>→ Left to Right
     <td>Left
     <td>Right
     <td>← Right to left
    <tr><td><a href=#attr-marquee-direction-up id=the-marquee-element-2:attr-marquee-direction-up>up</a>
     <td>↑ Up (Bottom to Top)
     <td>Bottom
     <td>Top
     <td>↓ Down (Top to Bottom)
    <tr><td><a href=#attr-marquee-direction-down id=the-marquee-element-2:attr-marquee-direction-down>down</a>
     <td>↓ Down (Top to Bottom)
     <td>Top
     <td>Bottom
     <td>↑ Up (Bottom to Top)
  </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>

  <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 expected 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 an error, the user agent is expected 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/#the-background-color data-x-internal="'background-color'">'background-color'</a> property to the resulting color.</p>

  <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/visudet.html#the-width-property data-x-internal="'width'">'width'</a> and <a id="the-marquee-element-2:'height'" href=https://drafts.csswg.org/css2/visudet.html#the-height-property data-x-internal="'height'">'height'</a> on the element respectively.</p>

  <p>The <a href=#intrinsic-height id=the-marquee-element-2:intrinsic-height>intrinsic 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>

  <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/css2/box.html#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/css2/box.html#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/css2/box.html#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/css2/box.html#propdef-margin-right data-x-internal="'margin-right'">'margin-right'</a> on the element.</p>

  <p>The <a id="the-marquee-element-2:'overflow'" href=https://drafts.csswg.org/css-overflow/#propdef-overflow data-x-internal="'overflow'">'overflow'</a> property on the <code id=the-marquee-element-2:the-marquee-element-21><a href=#the-marquee-element>marquee</a></code> element is expected to be
  ignored; overflow is expected to always be hidden.</p>

  


  

  <h4 id=the-meter-element-2><span class=secno>14.5.12</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>

  <p>The <code id=the-meter-element-2:the-meter-element-2><a href=#the-meter-element>meter</a></code> element is expected to render as an <a id="the-meter-element-2:'inline-block'" href=https://drafts.csswg.org/css2/visuren.html#value-def-inline-block data-x-internal="'inline-block'">'inline-block'</a> box with
  a <a id="the-meter-element-2:'height'" href=https://drafts.csswg.org/css2/visudet.html#the-height-property data-x-internal="'height'">'height'</a> of '1em' and a <a id="the-meter-element-2:'width'" href=https://drafts.csswg.org/css2/visudet.html#the-width-property data-x-internal="'width'">'width'</a> of '5em', a
  <a id="the-meter-element-2:'vertical-align'" href=https://drafts.csswg.org/css2/visudet.html#propdef-vertical-align data-x-internal="'vertical-align'">'vertical-align'</a> of '-0.2em', and with its contents depicting a gauge.</p>

  <p>When the element is wider than it is tall (or square), the depiction is expected to be of a
  horizontal gauge, with the minimum value 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 on
  this element 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 the
  element is taller than it is wide, it is expected to depict a vertical gauge, with the minimum
  value on the bottom.</p>

  <p>User agents are expected 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>

  


  

  <h4 id=the-progress-element-2><span class=secno>14.5.13</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>

  <p>The <code id=the-progress-element-2:the-progress-element-2><a href=#the-progress-element>progress</a></code> element is expected to render as an <a id="the-progress-element-2:'inline-block'" href=https://drafts.csswg.org/css2/visuren.html#value-def-inline-block data-x-internal="'inline-block'">'inline-block'</a> box
  with a <a id="the-progress-element-2:'height'" href=https://drafts.csswg.org/css2/visudet.html#the-height-property data-x-internal="'height'">'height'</a> of '1em' and a <a id="the-progress-element-2:'width'" href=https://drafts.csswg.org/css2/visudet.html#the-width-property data-x-internal="'width'">'width'</a> of '10em', and a
  <a id="the-progress-element-2:'vertical-align'" href=https://drafts.csswg.org/css2/visudet.html#propdef-vertical-align data-x-internal="'vertical-align'">'vertical-align'</a> of '-0.2em'.</p>

  

  <p> <img class=extra width=157 src=/images/sample-progress.png height=103 alt=""> When the
  element is wider than it is tall, the element is expected to be depicted as a horizontal progress
  bar, with the start on the right and the end 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 the element is taller than it is wide, it is expected to be
  depicted as a vertical progress bar, with the lowest value on the bottom. When the element is
  square, it is expected to be depicted as a direction-independent progress widget (e.g. a circular
  progress ring).</p>

  <p>User agents are expected to use a presentation consistent with platform conventions for
  progress bars. In particular, user agents are expected to use different presentations for
  determinate and indeterminate progress bars. User agents are also expected to vary the
  presentation based on the dimensions of the element.</p>

  <p class=example>For example, on some platforms for showing indeterminate progress there is a
  "spinner" progress indicator with square dimensions, which could be used when the element is
  square, and an indeterminate progress bar, which could be used when the element is wide.</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>

  


  

  <h4 id=the-select-element-2><span class=secno>14.5.14</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>A <code id=the-select-element-2:the-select-element-2><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 expected to render as a multi-select list box.</p>

  <p>A <code id=the-select-element-2:the-select-element-3><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 expected to render as a single-select list box.</p>

  <p>When the element renders as a list box, it is expected to render as an
  <a id="the-select-element-2:'inline-block'" href=https://drafts.csswg.org/css2/visuren.html#value-def-inline-block data-x-internal="'inline-block'">'inline-block'</a> box whose <a id="the-select-element-2:'height'" href=https://drafts.csswg.org/css2/visudet.html#the-height-property data-x-internal="'height'">'height'</a> is 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>, or four rows if the attribute is absent, and whose <a id="the-select-element-2:'width'" href=https://drafts.csswg.org/css2/visudet.html#the-width-property data-x-internal="'width'">'width'</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.</p>

  <p>A <code id=the-select-element-2:the-select-element-4><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
  expected to render as a one-line drop down box whose width 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>.</p>

  <p>In either case (list box or drop-down box), the element's items are expected 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>An <code id=the-select-element-2:the-optgroup-element-2><a href=#the-optgroup-element>optgroup</a></code> element is expected 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><a href=#the-option-element>option</a></code> element is expected to be rendered by displaying the element's <a href=#concept-option-label id=the-select-element-2:concept-option-label>label</a>, 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.</p>

  <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-2><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>

  <p>If a <code id=the-select-element-2:the-select-element-5><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 expected to render that <code id=the-select-element-2:the-option-element-3><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>selectedness</a> is true, the control
  is expected to be displayed in a fashion that indicates that no valid option is currently
  selected.</p>

  <p>User agents are expected to render the labels in a <code id=the-select-element-2:the-select-element-6><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>

  


  

  <h4 id=the-textarea-element-2><span class=secno>14.5.15</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>

  <p>The <code id=the-textarea-element-2:the-textarea-element-2><a href=#the-textarea-element>textarea</a></code> element is expected to render as an <a id="the-textarea-element-2:'inline-block'" href=https://drafts.csswg.org/css2/visuren.html#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 expected to <a href=#queue-a-task id=the-textarea-element-2:queue-a-task>queue a
  task</a>, using the <a href=#user-interaction-task-source id=the-textarea-element-2:user-interaction-task-source>user interaction task source</a>, 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>

  <p>If the element has a <code id=the-textarea-element-2:attr-textarea-cols><a href=#attr-textarea-cols>cols</a></code> attribute, and parsing that
  attribute's value using the <a href=#rules-for-parsing-non-negative-integers id=the-textarea-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 expected to use the attribute as a <a href=#presentational-hints id=the-textarea-element-2:presentational-hints>presentational hint</a> for the <a id="the-textarea-element-2:'width'" href=https://drafts.csswg.org/css2/visudet.html#the-width-property data-x-internal="'width'">'width'</a> property on the element, with the
  value being the <a href=#textarea-effective-width id=the-textarea-element-2:textarea-effective-width>textarea effective width</a> (as defined below). Otherwise, the user
  agent is expected to act as if it had a user-agent-level style sheet rule setting the
  <a id="the-textarea-element-2:'width'-2" href=https://drafts.csswg.org/css2/visudet.html#the-width-property data-x-internal="'width'">'width'</a> property on the element to the <a href=#textarea-effective-width id=the-textarea-element-2:textarea-effective-width-2>textarea effective width</a>.</p>

  <p>The <dfn id=textarea-effective-width>textarea effective width</dfn> of a <code id=the-textarea-element-2:the-textarea-element-3><a href=#the-textarea-element>textarea</a></code> element is <span><var>size</var>×<var>avg</var> + <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 scroll bar, 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>

  <p>If the element has a <code id=the-textarea-element-2:attr-textarea-rows><a href=#attr-textarea-rows>rows</a></code> attribute, and parsing that
  attribute's value using the <a href=#rules-for-parsing-non-negative-integers id=the-textarea-element-2:rules-for-parsing-non-negative-integers-2>rules for parsing non-negative integers</a> doesn't generate
  an error, then the user agent is expected to use the attribute as a <a href=#presentational-hints id=the-textarea-element-2:presentational-hints-2>presentational hint</a> for the <a id="the-textarea-element-2:'height'" href=https://drafts.csswg.org/css2/visudet.html#the-height-property data-x-internal="'height'">'height'</a> property on the element, with the
  value being the <a href=#textarea-effective-height id=the-textarea-element-2:textarea-effective-height>textarea effective height</a> (as defined below). Otherwise, the user
  agent is expected to act as if it had a user-agent-level style sheet rule setting the
  <a id="the-textarea-element-2:'height'-2" href=https://drafts.csswg.org/css2/visudet.html#the-height-property data-x-internal="'height'">'height'</a> property on the element to the <a href=#textarea-effective-height id=the-textarea-element-2:textarea-effective-height-2>textarea effective height</a>.</p>

  <p>The <dfn id=textarea-effective-height>textarea effective height</dfn> of a <code id=the-textarea-element-2:the-textarea-element-4><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 specified 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>

  <p>User agents are expected 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-5><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 expected to treat the attribute as a <a href=#presentational-hints id=the-textarea-element-2:presentational-hints-3>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>

  



  

  <h3 id=frames-and-framesets><span class=secno>14.6</span> Frames and framesets<a href=#frames-and-framesets class=self-link></a></h3>

  <p>User agent are expected 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/visuren.html#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>

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

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

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

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

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

    <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=#nested-browsing-context id=frames-and-framesets:nested-browsing-context>nested browsing
        context</a>, positioned and sized to fit the rectangle.</p>

       <li>

        <p>If there are any elements left in <var>children</var>, remove the first element from
        <var>children</var>.</p>

       </ol>

     </ol>

   <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 expected 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.<li><p>Otherwise, if the element has a <code>frameborder</code> attribute, return
     false.<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.<li><p>Otherwise, return true.</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 result
     in an error, then return the color so obtained.<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><p>Otherwise, return gray.</ol>

   </ol>

  <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><p>Let <var>input dimension</var> be the size passed to the algorithm.</p>

   <li>

    <p>Let <var>count percentage</var> be the number of entries in <var>input list</var> whose unit
    is <i>percentage</i>.</p>

    <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>count relative</var> be the number of entries in <var>input list</var> whose unit is
    <i>relative</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>count absolute</var> be the number of entries in <var>input list</var> whose unit is
    <i>absolute</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>

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

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

    <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><p>Return <var>output list</var>.</ol>

  <p>User agents working with integer values for frame widths (as opposed to user agents that can
  lay frames out with subpixel accuracy) are expected 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 expected 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 expected to not
  render the <a href=#nested-browsing-context id=frames-and-framesets:nested-browsing-context-2>nested browsing context</a> in this case, and that <a href=#nested-browsing-context id=frames-and-framesets:nested-browsing-context-3>nested browsing
  context</a> is expected to have a <a id=frames-and-framesets:viewport-2 href=https://drafts.csswg.org/css2/visuren.html#viewport data-x-internal=viewport>viewport</a> with zero width and zero height.</p>

  


  

  <h3 id=interactive-media><span class=secno>14.7</span> Interactive media<a href=#interactive-media class=self-link></a></h3>

  <h4 id=links,-forms,-and-navigation><span class=secno>14.7.1</span> Links, forms, and navigation<a href=#links,-forms,-and-navigation class=self-link></a></h4>

  <p>User agents are expected 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=#browsing-context id=links,-forms,-and-navigation:browsing-context>browsing context</a> is to be
  used for the subsequent <a href=#navigate id=links,-forms,-and-navigation:navigate>navigation</a>.</p>

  <p>User agents are expected 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 expected 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=#browsing-context id=links,-forms,-and-navigation:browsing-context-2>browsing contexts</a> to the URLs <a href=#parse-a-url id=links,-forms,-and-navigation:parse-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.</p>

  <p class=note>While <code id=links,-forms,-and-navigation:the-link-element-2><a href=#the-link-element>link</a></code> elements that create <a href=#hyperlink id=links,-forms,-and-navigation:hyperlink-5>hyperlinks</a> will match the <code id=links,-forms,-and-navigation:selector-link><a href=#selector-link>:link</a></code> or
  <code id=links,-forms,-and-navigation:selector-visited><a href=#selector-visited>:visited</a></code> <a href=https://drafts.csswg.org/selectors/#pseudo-class id=links,-forms,-and-navigation:pseudo-class data-x-internal=pseudo-class>pseudo-classes</a>,
  will react to clicks if visible, and so forth, this does not extend to any browser interface
  constructs that expose those same links. Activating a link through the browser's interface, rather
  than in the page itself, does not trigger <code id=links,-forms,-and-navigation:event-click><a data-x-internal=event-click href=https://w3c.github.io/uievents/#event-type-click>click</a></code> events and the
  like.</p>




  <h4 id=the-title-attribute-2><span class=secno>14.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 expected 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
  expected to make the content available in some other fashion, e.g. by making the element a
  <i>focusable area</i> 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 expected to cause line breaks in the tooltip; U+0009
  CHARACTER TABULATION (tab) characters are expected 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-area id=the-title-attribute-2:focusable-area>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>14.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/execCommand.html#active-range data-x-internal=active-range>active range</a>, if it is empty and in an
  <a id=editing-hosts:editing-host href=https://w3c.github.io/editing/execCommand.html#editing-host data-x-internal=editing-host>editing host</a>), if any, is expected to act like an inline
  <a id=editing-hosts:replaced-element href=https://drafts.csswg.org/css2/conform.html#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/box.html#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>14.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 expected 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, pop-up menus, and tooltips. Text from the contents of elements is expected 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 expected 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>&quot;rtl&quot;</c-> <c- e>lang</c-><c- o>=</c-><c- s>&quot;he&quot;</c-><c- p>&gt;</c->
 <c- p>&lt;</c-><c- f>label</c-><c- p>&gt;</c->
  <span lang='he' dir='rtl'>בחר שפת תכנות:</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>&quot;ltr&quot;</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>&quot;ltr&quot;</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>&quot;ltr&quot;</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>&quot;ltr&quot;</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:the-dir-attribute><a href=#the-dir-attribute>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>&quot;(א&quot;</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>&quot;(א&quot;</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>&quot;(א&quot;</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>&quot;(א&quot;</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>&quot;(א&quot;</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>&quot;(א&quot;</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 expected 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>&apos;\u05DC\u05DE\u05D3 HTML \u05D4\u05D9\u05D5\u05DD!&apos;</c-><c- p>)</c-></code></pre>

   <p>...would always result in a message reading
        "<bdo dir=rtl lang="">למד LMTH היום!</bdo>"
   (not "<bdo dir=ltr lang="">דמל HTML םויה!</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>&apos;What is your name?&apos;</c-><c- p>))</c-> <c- p>{</c->
  alert<c- p>(</c->s <c- o>+</c-> <c- t>&apos;! Ok, Fred, &apos;</c-> <c- o>+</c-> s <c- o>+</c-> <c- t>&apos;, and Wilma will get the car.&apos;</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>لا أفهم</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>لا أفهم! derF ,kO, لا أفهم, rac eht teg lliw amliW 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>&apos;What is your name?&apos;</c-><c- p>))</c-> <c- p>{</c->
  alert<c- p>(</c-><c- t>&apos;</c-><strong><c- t>\u200E</c-></strong><c- t>&apos;</c-> <c- o>+</c-> s <c- o>+</c-> <c- t>&apos;! Ok, Fred, &apos;</c-> <c- o>+</c-> s <c- o>+</c-> <c- t>&apos;, and Wilma will get the car.&apos;</c-><c- p>);</c->
<c- p>}</c-></code></pre>

  </div>



  <h3 id=print-media><span class=secno>14.8</span> Print media<a href=#print-media class=self-link></a></h3>

  <p>User agents are expected 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 expected 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>14.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 expected
  to render <a href=#an-unstyled-document-view id=unstyled-xml-documents:an-unstyled-document-view>an unstyled document view</a>.</p>

  <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>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>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>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>The <code id=unstyled-xml-documents:document-7><a href=#document>Document</a></code> has no <i>focusable area</i> (e.g. from XLink) other than the <a id=unstyled-xml-documents:viewport href=https://drafts.csswg.org/css2/visuren.html#viewport data-x-internal=viewport>viewport</a>.
   <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>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> specifies this <code id=unstyled-xml-documents:document-9><a href=#document>Document</a></code> as the <a href=#responsible-document id=unstyled-xml-documents:responsible-document>responsible document</a>.
   <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.
  </ul>

  <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>15</span> Obsolete features<a href=#obsolete class=self-link></a></h2>

  <h3 id=obsolete-but-conforming-features><span class=secno>15.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>15.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>".<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>".<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>".<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>.<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>".<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.<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.<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.</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>15.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><code>applet</code></dfn><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.<dt><dfn id=acronym><code>acronym</code></dfn><dd><p>Use <code id=non-conforming-features:the-abbr-element><a href=#the-abbr-element>abbr</a></code> instead.<dt><dfn id=bgsound><code>bgsound</code></dfn><dd><p>Use <code id=non-conforming-features:the-audio-element><a href=#the-audio-element>audio</a></code> instead.<dt><dfn id=dir><code>dir</code></dfn><dd><p>Use <code id=non-conforming-features:the-ul-element><a href=#the-ul-element>ul</a></code> instead.<dt><code id=non-conforming-features:frame><a href=#frame>frame</a></code><dt><code id=non-conforming-features:frameset><a href=#frameset>frameset</a></code><dt><dfn id=noframes><code>noframes</code></dfn><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.<dt><dfn id=isindex><code>isindex</code></dfn><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.<dt><dfn id=keygen><code>keygen</code></dfn><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>
   <dt><dfn id=listing><code>listing</code></dfn><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.<dt><dfn id=menuitem><code>menuitem</code></dfn><dd><p>To implement a custom context menu, use script to handle the <code id=non-conforming-features:event-contextmenu><a href=#event-contextmenu>contextmenu</a></code> event.<dt><dfn id=nextid><code>nextid</code></dfn><dd><p>Use GUIDs instead.<dt><dfn id=noembed><code>noembed</code></dfn><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.<dt><dfn id=plaintext><code>plaintext</code></dfn><dd><p>Use the "<code id=non-conforming-features:text/plain><a data-x-internal=text/plain href=https://tools.ietf.org/html/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.<dt><dfn id=rb><code>rb</code></dfn><dt><dfn id=rtc><code>rtc</code></dfn><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.<dt><dfn id=strike><code>strike</code></dfn><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.<dt><dfn id=xmp><code>xmp</code></dfn><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.<dt><dfn id=basefont><code>basefont</code></dfn><dt><dfn id=big><code>big</code></dfn><dt><dfn id=blink><code>blink</code></dfn><dt><dfn id=center><code>center</code></dfn><dt><dfn id=font><code>font</code></dfn><dt><code id=non-conforming-features:the-marquee-element><a href=#the-marquee-element>marquee</a></code><dt><dfn id=multicol><code>multicol</code></dfn><dt><dfn id=nobr><code>nobr</code></dfn><dt><dfn id=spacer><code>spacer</code></dfn><dt><dfn id=tt><code>tt</code></dfn><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>

   </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 id=attr-a-charset><code>charset</code></dfn> on <code id=non-conforming-features:the-a-element><a href=#the-a-element>a</a></code> elements<dt><dfn id=attr-link-charset><code>charset</code></dfn> on <code id=non-conforming-features:the-link-element><a href=#the-link-element>link</a></code> elements<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.<dt><dfn id=attr-script-charset><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)<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.<dt><dfn id=attr-a-coords><code>coords</code></dfn> on <code id=non-conforming-features:the-a-element-2><a href=#the-a-element>a</a></code> elements<dt><dfn id=attr-a-shape><code>shape</code></dfn> on <code id=non-conforming-features:the-a-element-3><a href=#the-a-element>a</a></code> elements<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.<dt><dfn id=attr-a-methods><code>methods</code></dfn> on <code id=non-conforming-features:the-a-element-5><a href=#the-a-element>a</a></code> elements<dt><dfn id=attr-link-methods><code>methods</code></dfn> on <code id=non-conforming-features:the-link-element-2><a href=#the-link-element>link</a></code> elements<dd><p>Use the HTTP OPTIONS feature instead.<dt><dfn id=attr-a-name><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><dfn id=attr-embed-name><code>name</code></dfn> on <code id=non-conforming-features:the-embed-element-3><a href=#the-embed-element>embed</a></code> elements<dt><dfn id=attr-img-name><code>name</code></dfn> on <code id=non-conforming-features:the-img-element><a href=#the-img-element>img</a></code> elements<dt><dfn id=attr-option-name><code>name</code></dfn> on <code id=non-conforming-features:the-option-element><a href=#the-option-element>option</a></code> elements<dd><p>Use the <code id=non-conforming-features:the-id-attribute><a href=#the-id-attribute>id</a></code> attribute instead.<dt><dfn id=attr-a-rev><code>rev</code></dfn> on <code id=non-conforming-features:the-a-element-7><a href=#the-a-element>a</a></code> elements<dt><dfn id=attr-link-rev><code>rev</code></dfn> on <code id=non-conforming-features:the-link-element-3><a href=#the-link-element>link</a></code> elements<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>.)<dt><dfn id=attr-a-urn><code>urn</code></dfn> on <code id=non-conforming-features:the-a-element-8><a href=#the-a-element>a</a></code> elements<dt><dfn id=attr-link-urn><code>urn</code></dfn> on <code id=non-conforming-features:the-link-element-4><a href=#the-link-element>link</a></code> elements<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.<dt><dfn id=attr-form-accept><code>accept</code></dfn> on <code id=non-conforming-features:the-form-element-2><a href=#the-form-element>form</a></code> elements<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.<dt><dfn id=attr-area-hreflang><code>hreflang</code></dfn> on <code id=non-conforming-features:the-area-element-2><a href=#the-area-element>area</a></code>
   elements<dt><dfn id=attr-area-type><code>type</code></dfn> on <code id=non-conforming-features:the-area-element-3><a href=#the-area-element>area</a></code> elements<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.<dt><dfn id=attr-area-nohref><code>nohref</code></dfn> on <code id=non-conforming-features:the-area-element-5><a href=#the-area-element>area</a></code> elements<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.<dt><dfn id=attr-head-profile><code>profile</code></dfn> on <code id=non-conforming-features:the-head-element><a href=#the-head-element>head</a></code> elements<dd><p>Unnecessary. Omit it altogether.<dt><dfn id=attr-html-version><code>version</code></dfn> on <code id=non-conforming-features:the-html-element><a href=#the-html-element>html</a></code> elements<dd><p>Unnecessary. Omit it altogether.<dt><dfn id=attr-input-ismap><code>ismap</code></dfn> on <code id=non-conforming-features:the-input-element-2><a href=#the-input-element>input</a></code> elements<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.<dt><dfn id=attr-input-usemap><code>usemap</code></dfn> on <code id=non-conforming-features:the-input-element-4><a href=#the-input-element>input</a></code> elements<dd><p>Use <code id=non-conforming-features:the-img-element-2><a href=#the-img-element>img</a></code> instead of <code id=non-conforming-features:the-input-element-5><a href=#the-input-element>input</a></code> for image maps.<dt><dfn id=attr-iframe-longdesc><code>longdesc</code></dfn> on <code id=non-conforming-features:the-iframe-element-2><a href=#the-iframe-element>iframe</a></code> elements<dt><dfn id=attr-img-longdesc><code>longdesc</code></dfn> on <code id=non-conforming-features:the-img-element-3><a href=#the-img-element>img</a></code> elements<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.<dt><dfn id=attr-img-lowsrc><code>lowsrc</code></dfn> on <code id=non-conforming-features:the-img-element-4><a href=#the-img-element>img</a></code> elements<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.<dt><dfn id=attr-link-target><code>target</code></dfn> on <code id=non-conforming-features:the-link-element-5><a href=#the-link-element>link</a></code> elements<dd><p>Unnecessary. Omit it altogether.<dt><dfn id=attr-menu-type><code>type</code></dfn> on <code id=non-conforming-features:the-menu-element><a href=#the-menu-element>menu</a></code> elements<dd><p>To implement a custom context menu, use script to handle the <code id=non-conforming-features:event-contextmenu-2><a href=#event-contextmenu>contextmenu</a></code> event. For toolbar menus, omit the
   attribute.<dt><dfn id=attr-menu-label><code>label</code></dfn> on <code id=non-conforming-features:the-menu-element-2><a href=#the-menu-element>menu</a></code> elements<dt><dfn id=attr-contextmenu><code>contextmenu</code></dfn> on all elements<dt><dfn id=handler-onshow><code>onshow</code></dfn> on all elements<dd><p>To implement a custom context menu, use script to handle the <code id=non-conforming-features:event-contextmenu-3><a href=#event-contextmenu>contextmenu</a></code> event.<dt><dfn id=attr-meta-scheme><code>scheme</code></dfn> on <code id=non-conforming-features:the-meta-element><a href=#the-meta-element>meta</a></code> elements<dd><p>Use only one scheme per field, or make the scheme declaration part of the value.<dt><dfn id=attr-object-archive><code>archive</code></dfn> on <code id=non-conforming-features:the-object-element-3><a href=#the-object-element>object</a></code> elements<dt><dfn id=attr-object-classid><code>classid</code></dfn> on <code id=non-conforming-features:the-object-element-4><a href=#the-object-element>object</a></code> elements<dt><dfn id=attr-object-code><code>code</code></dfn> on <code id=non-conforming-features:the-object-element-5><a href=#the-object-element>object</a></code> elements<dt><dfn id=attr-object-codebase><code>codebase</code></dfn> on <code id=non-conforming-features:the-object-element-6><a href=#the-object-element>object</a></code> elements<dt><dfn id=attr-object-codetype><code>codetype</code></dfn> on <code id=non-conforming-features:the-object-element-7><a href=#the-object-element>object</a></code> elements<dd><p>Use the <code id=non-conforming-features:attr-object-data><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>. To set parameters with these names
   in particular, the <code id=non-conforming-features:the-param-element><a href=#the-param-element>param</a></code> element can be used.<dt><dfn id=attr-object-declare><code>declare</code></dfn> on <code id=non-conforming-features:the-object-element-8><a href=#the-object-element>object</a></code> elements<dd><p>Repeat the <code id=non-conforming-features:the-object-element-9><a href=#the-object-element>object</a></code> element completely each time the resource is to be reused.<dt><dfn id=attr-object-standby><code>standby</code></dfn> on <code id=non-conforming-features:the-object-element-10><a href=#the-object-element>object</a></code> elements<dd><p>Optimize the linked resource so that it loads quickly or, at least, incrementally.<dt><dfn id=attr-param-type><code>type</code></dfn> on <code id=non-conforming-features:the-param-element-2><a href=#the-param-element>param</a></code> elements<dt><dfn id=attr-param-valuetype><code>valuetype</code></dfn> on <code id=non-conforming-features:the-param-element-3><a href=#the-param-element>param</a></code> elements<dd><p>Use the <code id=non-conforming-features:attr-param-name><a href=#attr-param-name>name</a></code> and <code id=non-conforming-features:attr-param-value><a href=#attr-param-value>value</a></code> attributes without declaring
   value types.<dt><dfn id=attr-script-language><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)<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.<dt><dfn id=attr-script-event><code>event</code></dfn> on <code id=non-conforming-features:the-script-element-4><a href=#the-script-element>script</a></code> elements<dt><dfn id=attr-script-for><code>for</code></dfn> on <code id=non-conforming-features:the-script-element-5><a href=#the-script-element>script</a></code> elements<dd><p>Use DOM events mechanisms to register event listeners. <a href=#refsDOM>[DOM]</a><dt><dfn id=attr-style-type><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)<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>.<dt><dfn id=attr-table-datapagesize><code>datapagesize</code></dfn> on <code id=non-conforming-features:the-table-element><a href=#the-table-element>table</a></code> elements<dd><p>Unnecessary. Omit it altogether.<dt><dfn id=attr-table-summary><code>summary</code></dfn> on <code id=non-conforming-features:the-table-element-2><a href=#the-table-element>table</a></code> elements<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.<dt><dfn id=attr-td-abbr><code>abbr</code></dfn> on <code id=non-conforming-features:the-td-element><a href=#the-td-element>td</a></code> elements<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>

   <dt><dfn id=attr-tdth-axis><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<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>

   <dt><dfn id=attr-td-scope><code>scope</code></dfn> on <code id=non-conforming-features:the-td-element-3><a href=#the-td-element>td</a></code> elements<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>

   <dt><dfn id=attr-datasrc><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-6><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-11><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><dfn id=attr-datafld><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-7><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-12><a href=#the-object-element>object</a></code>, <code id=non-conforming-features:the-param-element-4><a href=#the-param-element>param</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><dfn id=attr-dataformatas><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-8><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-13><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<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><dt><dfn id=attr-dropzone><code>dropzone</code></dfn> on all elements<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.<dt><dfn id=attr-body-alink><code>alink</code></dfn> on <code id=non-conforming-features:the-body-element><a href=#the-body-element>body</a></code> elements<dt><dfn id=attr-body-bgcolor><code>bgcolor</code></dfn> on <code id=non-conforming-features:the-body-element-2><a href=#the-body-element>body</a></code> elements<dt><dfn id=attr-body-bottommargin><code>bottommargin</code></dfn> on <code id=non-conforming-features:the-body-element-3><a href=#the-body-element>body</a></code> elements<dt><dfn id=attr-body-leftmargin><code>leftmargin</code></dfn> on <code id=non-conforming-features:the-body-element-4><a href=#the-body-element>body</a></code> elements<dt><dfn id=attr-body-link><code>link</code></dfn> on <code id=non-conforming-features:the-body-element-5><a href=#the-body-element>body</a></code> elements<dt><dfn id=attr-body-marginheight><code>marginheight</code></dfn> on <code id=non-conforming-features:the-body-element-6><a href=#the-body-element>body</a></code> elements<dt><dfn id=attr-body-marginwidth><code>marginwidth</code></dfn> on <code id=non-conforming-features:the-body-element-7><a href=#the-body-element>body</a></code> elements<dt><dfn id=attr-body-rightmargin><code>rightmargin</code></dfn> on <code id=non-conforming-features:the-body-element-8><a href=#the-body-element>body</a></code> elements<dt><dfn id=attr-body-text><code>text</code></dfn> on <code id=non-conforming-features:the-body-element-9><a href=#the-body-element>body</a></code> elements<dt><dfn id=attr-body-topmargin><code>topmargin</code></dfn> on <code id=non-conforming-features:the-body-element-10><a href=#the-body-element>body</a></code> elements<dt><dfn id=attr-body-vlink><code>vlink</code></dfn> on <code id=non-conforming-features:the-body-element-11><a href=#the-body-element>body</a></code> elements<dt><dfn id=attr-br-clear><code>clear</code></dfn> on <code id=non-conforming-features:the-br-element><a href=#the-br-element>br</a></code> elements<dt><dfn id=attr-caption-align><code>align</code></dfn> on <code id=non-conforming-features:the-caption-element><a href=#the-caption-element>caption</a></code> elements<dt><dfn id=attr-col-align><code>align</code></dfn> on <code id=non-conforming-features:the-col-element><a href=#the-col-element>col</a></code> elements<dt><dfn id=attr-col-char><code>char</code></dfn> on <code id=non-conforming-features:the-col-element-2><a href=#the-col-element>col</a></code> elements<dt><dfn id=attr-col-charoff><code>charoff</code></dfn> on <code id=non-conforming-features:the-col-element-3><a href=#the-col-element>col</a></code> elements<dt><dfn id=attr-col-valign><code>valign</code></dfn> on <code id=non-conforming-features:the-col-element-4><a href=#the-col-element>col</a></code> elements<dt><dfn id=attr-col-width><code>width</code></dfn> on <code id=non-conforming-features:the-col-element-5><a href=#the-col-element>col</a></code> elements<dt><dfn id=attr-div-align><code>align</code></dfn> on <code id=non-conforming-features:the-div-element-4><a href=#the-div-element>div</a></code> elements<dt><dfn id=attr-dl-compact><code>compact</code></dfn> on <code id=non-conforming-features:the-dl-element><a href=#the-dl-element>dl</a></code> elements<dt><dfn id=attr-embed-align><code>align</code></dfn> on <code id=non-conforming-features:the-embed-element-4><a href=#the-embed-element>embed</a></code> elements<dt><dfn id=attr-embed-hspace><code>hspace</code></dfn> on <code id=non-conforming-features:the-embed-element-5><a href=#the-embed-element>embed</a></code> elements<dt><dfn id=attr-embed-vspace><code>vspace</code></dfn> on <code id=non-conforming-features:the-embed-element-6><a href=#the-embed-element>embed</a></code> elements<dt><dfn id=attr-hr-align><code>align</code></dfn> on <code id=non-conforming-features:the-hr-element><a href=#the-hr-element>hr</a></code> elements<dt><dfn id=attr-hr-color><code>color</code></dfn> on <code id=non-conforming-features:the-hr-element-2><a href=#the-hr-element>hr</a></code> elements<dt><dfn id=attr-hr-noshade><code>noshade</code></dfn> on <code id=non-conforming-features:the-hr-element-3><a href=#the-hr-element>hr</a></code> elements<dt><dfn id=attr-hr-size><code>size</code></dfn> on <code id=non-conforming-features:the-hr-element-4><a href=#the-hr-element>hr</a></code> elements<dt><dfn id=attr-hr-width><code>width</code></dfn> on <code id=non-conforming-features:the-hr-element-5><a href=#the-hr-element>hr</a></code> elements<dt><dfn id=attr-hx-align><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><dfn id=attr-iframe-align><code>align</code></dfn> on <code id=non-conforming-features:the-iframe-element-5><a href=#the-iframe-element>iframe</a></code> elements<dt><dfn id=attr-iframe-allowtransparency><code>allowtransparency</code></dfn> on <code id=non-conforming-features:the-iframe-element-6><a href=#the-iframe-element>iframe</a></code> elements<dt><dfn id=attr-iframe-frameborder><code>frameborder</code></dfn> on <code id=non-conforming-features:the-iframe-element-7><a href=#the-iframe-element>iframe</a></code> elements<dt><dfn id=attr-iframe-framespacing><code>framespacing</code></dfn> on <code id=non-conforming-features:the-iframe-element-8><a href=#the-iframe-element>iframe</a></code> elements<dt><dfn id=attr-iframe-hspace><code>hspace</code></dfn> on <code id=non-conforming-features:the-iframe-element-9><a href=#the-iframe-element>iframe</a></code> elements<dt><dfn id=attr-iframe-marginheight><code>marginheight</code></dfn> on <code id=non-conforming-features:the-iframe-element-10><a href=#the-iframe-element>iframe</a></code> elements<dt><dfn id=attr-iframe-marginwidth><code>marginwidth</code></dfn> on <code id=non-conforming-features:the-iframe-element-11><a href=#the-iframe-element>iframe</a></code> elements<dt><dfn id=attr-iframe-scrolling><code>scrolling</code></dfn> on <code id=non-conforming-features:the-iframe-element-12><a href=#the-iframe-element>iframe</a></code> elements<dt><dfn id=attr-iframe-vspace><code>vspace</code></dfn> on <code id=non-conforming-features:the-iframe-element-13><a href=#the-iframe-element>iframe</a></code> elements<dt><dfn id=attr-input-align><code>align</code></dfn> on <code id=non-conforming-features:the-input-element-9><a href=#the-input-element>input</a></code> elements<dt><dfn id=attr-input-border><code>border</code></dfn> on <code id=non-conforming-features:the-input-element-10><a href=#the-input-element>input</a></code> elements<dt><dfn id=attr-input-hspace><code>hspace</code></dfn> on <code id=non-conforming-features:the-input-element-11><a href=#the-input-element>input</a></code> elements<dt><dfn id=attr-input-vspace><code>vspace</code></dfn> on <code id=non-conforming-features:the-input-element-12><a href=#the-input-element>input</a></code> elements<dt><dfn id=attr-img-align><code>align</code></dfn> on <code id=non-conforming-features:the-img-element-7><a href=#the-img-element>img</a></code> elements<dt><dfn id=attr-img-border><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><dfn id=attr-img-hspace><code>hspace</code></dfn> on <code id=non-conforming-features:the-img-element-9><a href=#the-img-element>img</a></code> elements<dt><dfn id=attr-img-vspace><code>vspace</code></dfn> on <code id=non-conforming-features:the-img-element-10><a href=#the-img-element>img</a></code> elements<dt><dfn id=attr-legend-align><code>align</code></dfn> on <code id=non-conforming-features:the-legend-element-4><a href=#the-legend-element>legend</a></code> elements<dt><dfn id=attr-li-type><code>type</code></dfn> on <code id=non-conforming-features:the-li-element><a href=#the-li-element>li</a></code> elements<dt><dfn id=attr-menu-compact><code>compact</code></dfn> on <code id=non-conforming-features:the-menu-element-3><a href=#the-menu-element>menu</a></code> elements<dt><dfn id=attr-object-align><code>align</code></dfn> on <code id=non-conforming-features:the-object-element-14><a href=#the-object-element>object</a></code> elements<dt><dfn id=attr-object-border><code>border</code></dfn> on <code id=non-conforming-features:the-object-element-15><a href=#the-object-element>object</a></code> elements<dt><dfn id=attr-object-hspace><code>hspace</code></dfn> on <code id=non-conforming-features:the-object-element-16><a href=#the-object-element>object</a></code> elements<dt><dfn id=attr-object-vspace><code>vspace</code></dfn> on <code id=non-conforming-features:the-object-element-17><a href=#the-object-element>object</a></code> elements<dt><dfn id=attr-ol-compact><code>compact</code></dfn> on <code id=non-conforming-features:the-ol-element><a href=#the-ol-element>ol</a></code> elements<dt><dfn id=attr-p-align><code>align</code></dfn> on <code id=non-conforming-features:the-p-element><a href=#the-p-element>p</a></code> elements<dt><dfn id=attr-pre-width><code>width</code></dfn> on <code id=non-conforming-features:the-pre-element-3><a href=#the-pre-element>pre</a></code> elements<dt><dfn id=attr-table-align><code>align</code></dfn> on <code id=non-conforming-features:the-table-element-6><a href=#the-table-element>table</a></code> elements<dt><dfn id=attr-table-bgcolor><code>bgcolor</code></dfn> on <code id=non-conforming-features:the-table-element-7><a href=#the-table-element>table</a></code> elements<dt><dfn id=attr-table-border><code>border</code></dfn> on <code id=non-conforming-features:the-table-element-8><a href=#the-table-element>table</a></code> elements<dt><dfn id=attr-table-bordercolor><code>bordercolor</code></dfn> on <code id=non-conforming-features:the-table-element-9><a href=#the-table-element>table</a></code> elements<dt><dfn id=attr-table-cellpadding><code>cellpadding</code></dfn> on <code id=non-conforming-features:the-table-element-10><a href=#the-table-element>table</a></code> elements<dt><dfn id=attr-table-cellspacing><code>cellspacing</code></dfn> on <code id=non-conforming-features:the-table-element-11><a href=#the-table-element>table</a></code> elements<dt><dfn id=attr-table-frame><code>frame</code></dfn> on <code id=non-conforming-features:the-table-element-12><a href=#the-table-element>table</a></code> elements<dt><dfn id=attr-table-height><code>height</code></dfn> on <code id=non-conforming-features:the-table-element-13><a href=#the-table-element>table</a></code> elements<dt><dfn id=attr-table-rules><code>rules</code></dfn> on <code id=non-conforming-features:the-table-element-14><a href=#the-table-element>table</a></code> elements<dt><dfn id=attr-table-width><code>width</code></dfn> on <code id=non-conforming-features:the-table-element-15><a href=#the-table-element>table</a></code> elements<dt><dfn id=attr-tbody-align><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><dfn id=attr-tbody-char><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><dfn id=attr-tbody-charoff><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><dfn id=attr-tbody-valign><code>valign</code></dfn> on <code id=non-conforming-features:the-tbody-element-4><a href=#the-tbody-element>tbody</a></code>, <code id=non-conforming-features:the-thead-element-4><a href=#the-thead-element>thead</a></code>, and <code id=non-conforming-features:the-tfoot-element-4><a href=#the-tfoot-element>tfoot</a></code> elements<dt><dfn id=attr-tdth-align><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><dfn id=attr-tdth-bgcolor><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><dfn id=attr-tdth-char><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><dfn id=attr-tdth-charoff><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><dfn id=attr-tdth-height><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><dfn id=attr-tdth-nowrap><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><dfn id=attr-tdth-valign><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><dfn id=attr-tdth-width><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><dfn id=attr-tr-align><code>align</code></dfn> on <code id=non-conforming-features:the-tr-element><a href=#the-tr-element>tr</a></code> elements<dt><dfn id=attr-tr-bgcolor><code>bgcolor</code></dfn> on <code id=non-conforming-features:the-tr-element-2><a href=#the-tr-element>tr</a></code> elements<dt><dfn id=attr-tr-char><code>char</code></dfn> on <code id=non-conforming-features:the-tr-element-3><a href=#the-tr-element>tr</a></code> elements<dt><dfn id=attr-tr-charoff><code>charoff</code></dfn> on <code id=non-conforming-features:the-tr-element-4><a href=#the-tr-element>tr</a></code> elements<dt><dfn id=attr-tr-height><code>height</code></dfn> on <code id=non-conforming-features:the-tr-element-5><a href=#the-tr-element>tr</a></code> elements<dt><dfn id=attr-tr-valign><code>valign</code></dfn> on <code id=non-conforming-features:the-tr-element-6><a href=#the-tr-element>tr</a></code> elements<dt><dfn id=attr-ul-compact><code>compact</code></dfn> on <code id=non-conforming-features:the-ul-element-2><a href=#the-ul-element>ul</a></code> elements<dt><dfn id=attr-ul-type><code>type</code></dfn> on <code id=non-conforming-features:the-ul-element-3><a href=#the-ul-element>ul</a></code> elements<dt><dfn id=attr-background><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-5><a href=#the-thead-element>thead</a></code>, <code id=non-conforming-features:the-tbody-element-5><a href=#the-tbody-element>tbody</a></code>, <code id=non-conforming-features:the-tfoot-element-5><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<dd><p>Use CSS instead.</dl>


  

  <h3 id=requirements-for-implementations><span class=secno>15.3</span> Requirements for implementations<a href=#requirements-for-implementations class=self-link></a></h3>

  <h4 id=the-marquee-element><span class=secno>15.3.1</span> The <dfn><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 <a href=#task-source id=the-marquee-element:task-source>task source</a> for tasks mentioned in this section is the <a href=#dom-manipulation-task-source id=the-marquee-element:dom-manipulation-task-source>DOM manipulation
  task source</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->,
 <a href='#htmlconstructor' id='the-marquee-element:htmlconstructor'><c- g>HTMLConstructor</c-></a>]
<c- b>interface</c-> <dfn id='htmlmarqueeelement'><c- g>HTMLMarqueeElement</c-></dfn> : <a href='#htmlelement' id='the-marquee-element:htmlelement'><c- n>HTMLElement</c-></a> {
  [<a href='#cereactions' id='the-marquee-element:cereactions'><c- g>CEReactions</c-></a>] <c- b>attribute</c-> <c- b>DOMString</c-> <a href='#dom-marquee-behavior' id='the-marquee-element:dom-marquee-behavior'><c- g>behavior</c-></a>;
  [<a href='#cereactions' id='the-marquee-element:cereactions-2'><c- g>CEReactions</c-></a>] <c- b>attribute</c-> <c- b>DOMString</c-> <a href='#dom-marquee-bgcolor' id='the-marquee-element:dom-marquee-bgcolor'><c- g>bgColor</c-></a>;
  [<a href='#cereactions' id='the-marquee-element:cereactions-3'><c- g>CEReactions</c-></a>] <c- b>attribute</c-> <c- b>DOMString</c-> <a href='#dom-marquee-direction' id='the-marquee-element:dom-marquee-direction'><c- g>direction</c-></a>;
  [<a href='#cereactions' id='the-marquee-element:cereactions-4'><c- g>CEReactions</c-></a>] <c- b>attribute</c-> <c- b>DOMString</c-> <a href='#dom-marquee-height' id='the-marquee-element:dom-marquee-height'><c- g>height</c-></a>;
  [<a href='#cereactions' id='the-marquee-element:cereactions-5'><c- g>CEReactions</c-></a>] <c- b>attribute</c-> <c- b>unsigned</c-> <c- b>long</c-> <a href='#dom-marquee-hspace' id='the-marquee-element:dom-marquee-hspace'><c- g>hspace</c-></a>;
  [<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>] <c- b>attribute</c-> <c- b>unsigned</c-> <c- b>long</c-> <a href='#dom-marquee-scrollamount' id='the-marquee-element:dom-marquee-scrollamount'><c- g>scrollAmount</c-></a>;
  [<a href='#cereactions' id='the-marquee-element:cereactions-8'><c- g>CEReactions</c-></a>] <c- b>attribute</c-> <c- b>unsigned</c-> <c- b>long</c-> <a href='#dom-marquee-scrolldelay' id='the-marquee-element:dom-marquee-scrolldelay'><c- g>scrollDelay</c-></a>;
  [<a href='#cereactions' id='the-marquee-element:cereactions-9'><c- g>CEReactions</c-></a>] <c- b>attribute</c-> <c- b>boolean</c-> <a href='#dom-marquee-truespeed' id='the-marquee-element:dom-marquee-truespeed'><c- g>trueSpeed</c-></a>;
  [<a href='#cereactions' id='the-marquee-element:cereactions-10'><c- g>CEReactions</c-></a>] <c- b>attribute</c-> <c- b>unsigned</c-> <c- b>long</c-> <a href='#dom-marquee-vspace' id='the-marquee-element:dom-marquee-vspace'><c- g>vspace</c-></a>;
  [<a href='#cereactions' id='the-marquee-element:cereactions-11'><c- g>CEReactions</c-></a>] <c- b>attribute</c-> <c- b>DOMString</c-> <a href='#dom-marquee-width' id='the-marquee-element:dom-marquee-width'><c- g>width</c-></a>;

  <c- b>attribute</c-> <a href='#eventhandler' id='the-marquee-element:eventhandler'><c- n>EventHandler</c-></a> <a href='#handler-marquee-onbounce' id='the-marquee-element:handler-marquee-onbounce'><c- g>onbounce</c-></a>;
  <c- b>attribute</c-> <a href='#eventhandler' id='the-marquee-element:eventhandler-2'><c- n>EventHandler</c-></a> <a href='#handler-marquee-onfinish' id='the-marquee-element:handler-marquee-onfinish'><c- g>onfinish</c-></a>;
  <c- b>attribute</c-> <a href='#eventhandler' id='the-marquee-element:eventhandler-3'><c- n>EventHandler</c-></a> <a href='#handler-marquee-onstart' id='the-marquee-element:handler-marquee-onstart'><c- g>onstart</c-></a>;

  <c- b>void</c-> <a href='#dom-marquee-start' id='the-marquee-element:dom-marquee-start'><c- g>start</c-></a>();
  <c- b>void</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>

  <p>When the <dfn id=dom-marquee-start><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>

  <p>When the <dfn id=dom-marquee-stop><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>

  <p>When a <code id=the-marquee-element:the-marquee-element-6><a href=#the-marquee-element>marquee</a></code> element is created, the user agent must <a href=#queue-a-task id=the-marquee-element:queue-a-task>queue a task</a>
  to <a href=https://dom.spec.whatwg.org/#concept-event-fire id=the-marquee-element:concept-event-fire data-x-internal=concept-event-fire>fire an event</a> named <code>start</code> at the element.</p>

  <hr>

  <p>The <dfn id=attr-marquee-behavior><code>behavior</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>enumerated attribute</a> with the following keywords
  (all non-conforming):</p>

  <table><thead><tr><th>Keyword
     <th>State
   <tbody><tr><td><code>scroll</code>
     <td><dfn id=attr-marquee-behavior-scroll>scroll</dfn>
    <tr><td><code>slide</code>
     <td><dfn id=attr-marquee-behavior-slide>slide</dfn>
    <tr><td><code>alternate</code>
     <td><dfn id=attr-marquee-behavior-alternate>alternate</dfn>
  </table>

  <p>The <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 the <a href=#attr-marquee-behavior-scroll id=the-marquee-element:attr-marquee-behavior-scroll>scroll</a> state.</p>

  <hr>

  <p>The <dfn id=attr-marquee-direction><code>direction</code></dfn> content attribute on
  <code id=the-marquee-element:the-marquee-element-8><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
  (all non-conforming):</p>

  <table><thead><tr><th>Keyword
     <th>State
   <tbody><tr><td><code>left</code>
     <td><dfn id=attr-marquee-direction-left>left</dfn>
    <tr><td><code>right</code>
     <td><dfn id=attr-marquee-direction-right>right</dfn>
    <tr><td><code>up</code>
     <td><dfn id=attr-marquee-direction-up>up</dfn>
    <tr><td><code>down</code>
     <td><dfn id=attr-marquee-direction-down>down</dfn>
  </table>

  <p>The <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 the <a href=#attr-marquee-direction-left id=the-marquee-element:attr-marquee-direction-left>left</a> state.</p>

  <hr>

  <p>The <dfn id=attr-marquee-truespeed><code>truespeed</code></dfn> content attribute on
  <code id=the-marquee-element:the-marquee-element-9><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>

  <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-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.<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.<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.</ol>

  <hr>

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

  <hr>

  <p>A <code id=the-marquee-element:the-marquee-element-12><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 id=attr-marquee-loop><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>

  <p>The <dfn id=dom-marquee-loop><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>

  <p>A <code id=the-marquee-element:the-marquee-element-13><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>

  <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><p>Increment the <a href=#marquee-current-loop-index id=the-marquee-element:marquee-current-loop-index>marquee current loop index</a> by one.<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 equal to or greater than 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-14><a href=#the-marquee-element>marquee</a></code> element and <a href=#queue-a-task id=the-marquee-element:queue-a-task-2>queue a task</a> to <a href=https://dom.spec.whatwg.org/#concept-event-fire id=the-marquee-element:concept-event-fire-2 data-x-internal=concept-event-fire>fire an event</a> named <code>finish</code> at the <code id=the-marquee-element:the-marquee-element-15><a href=#the-marquee-element>marquee</a></code> element.</p>

    <p>Otherwise, if the <code id=the-marquee-element:attr-marquee-behavior><a href=#attr-marquee-behavior>behavior</a></code> attribute is in the
    <a href=#attr-marquee-behavior-alternate id=the-marquee-element:attr-marquee-behavior-alternate>alternate</a> state, then <a href=#queue-a-task id=the-marquee-element:queue-a-task-3>queue a
    task</a> to <a href=https://dom.spec.whatwg.org/#concept-event-fire id=the-marquee-element:concept-event-fire-3 data-x-internal=concept-event-fire>fire an event</a> named <code>bounce</code> at the <code id=the-marquee-element:the-marquee-element-16><a href=#the-marquee-element>marquee</a></code> element.</p>

    <p>Otherwise, <a href=#queue-a-task id=the-marquee-element:queue-a-task-4>queue a task</a> to <a href=https://dom.spec.whatwg.org/#concept-event-fire id=the-marquee-element:concept-event-fire-4 data-x-internal=concept-event-fire>fire an
    event</a> named <code>start</code> at the
    <code id=the-marquee-element:the-marquee-element-17><a href=#the-marquee-element>marquee</a></code> element.</p>

   </ol>

  <hr>

  <p>The following are the <a href=#event-handlers id=the-marquee-element:event-handlers>event handlers</a> (and their corresponding <a href=#event-handler-event-type id=the-marquee-element:event-handler-event-type>event handler event types</a>) that must be supported,
  as <a href=#event-handler-content-attributes id=the-marquee-element:event-handler-content-attributes>event handler content attributes</a> and <a href=#event-handler-idl-attributes id=the-marquee-element:event-handler-idl-attributes>event handler IDL attributes</a>, by
  <code id=the-marquee-element:the-marquee-element-18><a href=#the-marquee-element>marquee</a></code> elements:</p>

  <table><thead><tr><th><a href=#event-handlers id=the-marquee-element:event-handlers-2>Event handler</a> <th><a href=#event-handler-event-type id=the-marquee-element:event-handler-event-type-2>Event handler event type</a>
   <tbody><tr><td><dfn id=handler-marquee-onbounce><code>onbounce</code></dfn> <td> <code>bounce</code>
    <tr><td><dfn id=handler-marquee-onfinish><code>onfinish</code></dfn> <td> <code>finish</code>
    <tr><td><dfn id=handler-marquee-onstart><code>onstart</code></dfn> <td> <code>start</code>
  </table>

  <hr>

  <p>The <dfn id=dom-marquee-behavior><code>behavior</code></dfn>, <dfn id=dom-marquee-direction><code>direction</code></dfn>, <dfn id=dom-marquee-height><code>height</code></dfn>, <dfn id=dom-marquee-hspace><code>hspace</code></dfn>, <dfn id=dom-marquee-vspace><code>vspace</code></dfn>, and <dfn id=dom-marquee-width><code>width</code></dfn> IDL attributes must <a href=#reflect id=the-marquee-element:reflect>reflect</a> the
  respective content attributes of the same name.</p>

  <p>The <dfn id=dom-marquee-bgcolor><code>bgColor</code></dfn> IDL attribute must
  <a href=#reflect id=the-marquee-element:reflect-2>reflect</a> the <code>bgcolor</code> content attribute.</p>

  <p>The <dfn id=dom-marquee-scrollamount><code>scrollAmount</code></dfn> IDL attribute must
  <a href=#reflect id=the-marquee-element:reflect-3>reflect</a> the <code>scrollamount</code> content
  attribute. The default value is 6.</p>

  <p>The <dfn id=dom-marquee-scrolldelay><code>scrollDelay</code></dfn> IDL attribute must
  <a href=#reflect id=the-marquee-element:reflect-4>reflect</a> the <code>scrolldelay</code> content
  attribute. The default value is 85.</p>

  <p>The <dfn id=dom-marquee-truespeed><code>trueSpeed</code></dfn> IDL attribute must
  <a href=#reflect id=the-marquee-element:reflect-5>reflect</a> the <code id=the-marquee-element:attr-marquee-truespeed-2><a href=#attr-marquee-truespeed>truespeed</a></code> content
  attribute.</p>


  <h4 id=frames><span class=secno>15.3.2</span> Frames<a href=#frames class=self-link></a></h4>

  <p>The <dfn id=frameset data-dfn-type=element data-export=""><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->,
 <a href='#htmlconstructor' id='frames:htmlconstructor'><c- g>HTMLConstructor</c-></a>]
<c- b>interface</c-> <dfn id='htmlframesetelement'><c- g>HTMLFrameSetElement</c-></dfn> : <a href='#htmlelement' id='frames:htmlelement'><c- n>HTMLElement</c-></a> {
  [<a href='#cereactions' id='frames:cereactions'><c- g>CEReactions</c-></a>] <c- b>attribute</c-> <c- b>DOMString</c-> <a href='#dom-frameset-cols' id='frames:dom-frameset-cols'><c- g>cols</c-></a>;
  [<a href='#cereactions' id='frames:cereactions-2'><c- g>CEReactions</c-></a>] <c- b>attribute</c-> <c- b>DOMString</c-> <a href='#dom-frameset-rows' id='frames:dom-frameset-rows'><c- g>rows</c-></a>;
};
<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 <dfn id=dom-frameset-cols><code>cols</code></dfn> and <dfn id=dom-frameset-rows><code>rows</code></dfn> IDL attributes of the <code id=frames:frameset-2><a href=#frameset>frameset</a></code>
  element must <a href=#reflect id=frames:reflect>reflect</a> the respective content attributes of the same name.</p>

  <p>The <code id=frames:frameset-3><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-4><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 data-export=""><code>frame</code></dfn>
  element defines a <a href=#nested-browsing-context id=frames:nested-browsing-context>nested browsing context</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-5><a href=#frameset>frameset</a></code> element.</p>

  

  <p>A <code id=frames:frame><a href=#frame>frame</a></code> element is said to be an <dfn id=active-frame-element>active <code>frame</code> element</dfn> when
  it is <a id=frames:in-a-document href=https://dom.spec.whatwg.org/#in-a-document data-x-internal=in-a-document>in a document</a>.</p>
  

  <p>When a <code id=frames:frame-2><a href=#frame>frame</a></code> element is created as an <a href=#active-frame-element id=frames:active-frame-element>active <code>frame</code>
  element</a>, or becomes an <a href=#active-frame-element id=frames:active-frame-element-2>active <code>frame</code> element</a> after not having been
  one, the user agent must <a href=#creating-a-new-browsing-context id=frames:creating-a-new-browsing-context>create a new browsing
  context</a>, set the element's <a href=#nested-browsing-context id=frames:nested-browsing-context-2>nested browsing context</a> to the newly-created
  <a href=#browsing-context id=frames:browsing-context>browsing context</a>, and then <a href=#process-the-frame-attributes id=frames:process-the-frame-attributes>process the <code>frame</code> attributes</a> for
  the first time. If the element has a <code>name</code>
  attribute, the <a href=#browsing-context-name id=frames:browsing-context-name>browsing context name</a> must be set to the value of this attribute;
  otherwise, the <a href=#browsing-context-name id=frames:browsing-context-name-2>browsing context name</a> must be set to the empty string.</p>

  <p>When a <code id=frames:frame-3><a href=#frame>frame</a></code> element stops being an <a href=#active-frame-element id=frames:active-frame-element-3>active <code>frame</code>
  element</a>, the user agent must <a href=#a-browsing-context-is-discarded id=frames:a-browsing-context-is-discarded>discard</a>
  the element's <a href=#nested-browsing-context id=frames:nested-browsing-context-3>nested browsing context</a>, and then set the element's <a href=#nested-browsing-context id=frames:nested-browsing-context-4>nested
  browsing context</a> to null.</p>

  <p>Whenever a <code id=frames:frame-4><a href=#frame>frame</a></code> element with a non-null <a href=#nested-browsing-context id=frames:nested-browsing-context-5>nested browsing context</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> 

  <p>When the user agent is to <dfn id=process-the-frame-attributes>process the <code>frame</code> attributes</dfn>, it must run the
  first appropriate steps from the following list:</p>

  <dl class=switch><dt>If the element has no <code>src</code> attribute specified,
   and the user agent is processing the <code id=frames:frame-5><a href=#frame>frame</a></code>'s attributes for the first time<dd><p><a href=#queue-a-task id=frames:queue-a-task>Queue a task</a> to <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 the <code id=frames:frame-6><a href=#frame>frame</a></code> element using the <a href=#dom-manipulation-task-source id=frames:dom-manipulation-task-source>DOM
   manipulation task source</a>.<dt>Otherwise<dd><p>Run the <a href=#otherwise-steps-for-iframe-or-frame-elements id=frames:otherwise-steps-for-iframe-or-frame-elements>otherwise steps for <code>iframe</code> or <code>frame</code>
   elements</a>.</dl>

  <p>Any <a href=#navigate id=frames:navigate>navigation</a> required of the user agent in the <a href=#process-the-frame-attributes id=frames:process-the-frame-attributes-3>process
  the <code>frame</code> attributes</a> algorithm must use the <code id=frames:frame-7><a href=#frame>frame</a></code> element's
  <a id=frames:node-document href=https://dom.spec.whatwg.org/#concept-node-document data-x-internal=node-document>node document</a>'s <a href=#browsing-context id=frames:browsing-context-2>browsing context</a> as the <a href=#source-browsing-context id=frames:source-browsing-context>source browsing
  context</a>.</p>

  <p>Furthermore, if the <a href=#active-document id=frames:active-document>active document</a> of the element's <a href=#nested-browsing-context id=frames:nested-browsing-context-6>nested browsing
  context</a> before such a <a href=#navigate id=frames:navigate-2>navigation</a> was not <a href=#completely-loaded id=frames:completely-loaded>completely
  loaded</a> at the time of the new <a href=#navigate id=frames:navigate-3>navigation</a>, then the <a href=#navigate id=frames:navigate-4>navigation</a> must be completed with <a href=#replacement-enabled id=frames:replacement-enabled>replacement enabled</a>.</p>

  <p>Similarly, if the <a href=#nested-browsing-context id=frames:nested-browsing-context-7>nested browsing context</a>'s <a href=#session-history id=frames:session-history>session history</a> contained
  only one <code id=frames:document><a href=#document>Document</a></code> when the <a href=#process-the-frame-attributes id=frames:process-the-frame-attributes-4>process the <code>frame</code> attributes</a>
  algorithm was invoked, and that was the <code id=frames:about:blank><a href=#about:blank>about:blank</a></code> <code id=frames:document-2><a href=#document>Document</a></code> created
  when the <a href=#nested-browsing-context id=frames:nested-browsing-context-8>nested browsing context</a> was created, then any <a href=#navigate id=frames:navigate-5>navigation</a> required of the user agent in that algorithm must be completed
  with <a href=#replacement-enabled id=frames:replacement-enabled-2>replacement enabled</a>.</p> 

  

  <p>When a <code id=frames:document-3><a href=#document>Document</a></code> in a <code id=frames:frame-8><a href=#frame>frame</a></code> is marked as <a href=#completely-loaded id=frames:completely-loaded-2>completely
  loaded</a>, the user agent must <a href=https://dom.spec.whatwg.org/#concept-event-fire id=frames:concept-event-fire-2 data-x-internal=concept-event-fire>fire an event</a> named
  <code id=frames:event-load-2><a href=#event-load>load</a></code> at the <code id=frames:frame-9><a href=#frame>frame</a></code> element.</p>

  <p>When a <code id=frames:frame-10><a href=#frame>frame</a></code> element has a non-null <a href=#nested-browsing-context id=frames:nested-browsing-context-9>nested browsing context</a>, and its
  <a href=#nested-browsing-context id=frames:nested-browsing-context-10>nested browsing context</a>'s <a href=#active-document id=frames:active-document-2>active document</a> is not <a href=#ready-for-post-load-tasks id=frames:ready-for-post-load-tasks>ready for
  post-load tasks</a>, and when anything is <a href=#delay-the-load-event id=frames:delay-the-load-event>delaying the load
  event</a> of the <code id=frames:frame-11><a href=#frame>frame</a></code> element's <a href=#browsing-context id=frames:browsing-context-3>browsing context</a>'s <a href=#active-document id=frames:active-document-3>active
  document</a>, and when the <code id=frames:frame-12><a href=#frame>frame</a></code> element's <a href=#browsing-context id=frames:browsing-context-4>browsing context</a> is in the
  <a href=#delaying-load-events-mode id=frames:delaying-load-events-mode>delaying <code>load</code> events mode</a>, the <code id=frames:frame-13><a href=#frame>frame</a></code>
  must <a href=#delay-the-load-event id=frames:delay-the-load-event-2>delay the load event</a> of its document.</p>

  

  <p>Whenever the <code>name</code> attribute is set and the
  <code id=frames:frame-14><a href=#frame>frame</a></code> element's <a href=#nested-browsing-context id=frames:nested-browsing-context-11>nested browsing context</a> is non-null, the <a href=#nested-browsing-context id=frames:nested-browsing-context-12>nested
  browsing context</a>'s <a href=#browsing-context-name id=frames:browsing-context-name-3>name</a> must be changed to the
  new value. If the attribute is removed, the <a href=#browsing-context-name id=frames:browsing-context-name-4>browsing context name</a> must be set to the
  empty string.</p>

  <p>The <code id=frames:frame-15><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->,
 <a href='#htmlconstructor' id='frames:htmlconstructor-2'><c- g>HTMLConstructor</c-></a>]
<c- b>interface</c-> <dfn id='htmlframeelement'><c- g>HTMLFrameElement</c-></dfn> : <a href='#htmlelement' id='frames:htmlelement-2'><c- n>HTMLElement</c-></a> {
  [<a href='#cereactions' id='frames:cereactions-3'><c- g>CEReactions</c-></a>] <c- b>attribute</c-> <c- b>DOMString</c-> <a href='#dom-frame-name' id='frames:dom-frame-name'><c- g>name</c-></a>;
  [<a href='#cereactions' id='frames:cereactions-4'><c- g>CEReactions</c-></a>] <c- b>attribute</c-> <c- b>DOMString</c-> <a href='#dom-frame-scrolling' id='frames:dom-frame-scrolling'><c- g>scrolling</c-></a>;
  [<a href='#cereactions' id='frames:cereactions-5'><c- g>CEReactions</c-></a>] <c- b>attribute</c-> <c- b>USVString</c-> <a href='#dom-frame-src' id='frames:dom-frame-src'><c- g>src</c-></a>;
  [<a href='#cereactions' id='frames:cereactions-6'><c- g>CEReactions</c-></a>] <c- b>attribute</c-> <c- b>DOMString</c-> <a href='#dom-frame-frameborder' id='frames:dom-frame-frameborder'><c- g>frameBorder</c-></a>;
  [<a href='#cereactions' id='frames:cereactions-7'><c- g>CEReactions</c-></a>] <c- b>attribute</c-> <c- b>USVString</c-> <a href='#dom-frame-longdesc' id='frames:dom-frame-longdesc'><c- g>longDesc</c-></a>;
  [<a href='#cereactions' id='frames:cereactions-8'><c- g>CEReactions</c-></a>] <c- b>attribute</c-> <c- b>boolean</c-> <a href='#dom-frame-noresize' id='frames:dom-frame-noresize'><c- g>noResize</c-></a>;
  <c- b>readonly</c-> <c- b>attribute</c-> <a href='#document' id='frames:document-4'><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>] <c- b>attribute</c-> [<c- g>TreatNullAs</c->=<c- n>EmptyString</c->] <c- b>DOMString</c-> <a href='#dom-frame-marginheight' id='frames:dom-frame-marginheight'><c- g>marginHeight</c-></a>;
  [<a href='#cereactions' id='frames:cereactions-10'><c- g>CEReactions</c-></a>] <c- b>attribute</c-> [<c- g>TreatNullAs</c->=<c- n>EmptyString</c->] <c- b>DOMString</c-> <a href='#dom-frame-marginwidth' id='frames:dom-frame-marginwidth'><c- g>marginWidth</c-></a>;
};</code></pre>

  <p>The <dfn id=dom-frame-name><code>name</code></dfn>, <dfn id=dom-frame-scrolling><code>scrolling</code></dfn>, and <dfn id=dom-frame-src><code>src</code></dfn> IDL attributes of the <code id=frames:frame-16><a href=#frame>frame</a></code> element must
  <a href=#reflect id=frames:reflect-2>reflect</a> the respective content attributes of the same name. For the purposes of
  reflection, the <code id=frames:frame-17><a href=#frame>frame</a></code> element's <code>src</code> content
  attribute is defined as containing a <a id=frames:url href=https://url.spec.whatwg.org/#concept-url data-x-internal=url>URL</a>.</p>

  <p>The <dfn id=dom-frame-frameborder><code>frameBorder</code></dfn> IDL attribute of the
  <code id=frames:frame-18><a href=#frame>frame</a></code> element must <a href=#reflect id=frames:reflect-3>reflect</a> the element's <code>frameborder</code> content attribute.</p>

  <p>The <dfn id=dom-frame-longdesc><code>longDesc</code></dfn> IDL attribute of the
  <code id=frames:frame-19><a href=#frame>frame</a></code> element must <a href=#reflect id=frames:reflect-4>reflect</a> the element's <code>longdesc</code> content attribute, which for the purposes
  of reflection is defined as containing a <a id=frames:url-2 href=https://url.spec.whatwg.org/#concept-url data-x-internal=url>URL</a>.</p>

  <p>The <dfn id=dom-frame-noresize><code>noResize</code></dfn> IDL attribute of the
  <code id=frames:frame-20><a href=#frame>frame</a></code> element must <a href=#reflect id=frames:reflect-5>reflect</a> the element's <code>noresize</code> content attribute.</p>

  <p>The <dfn id=dom-frame-contentdocument><code>contentDocument</code></dfn> IDL attribute,
  on getting, must return the <code id=frames:frame-21><a href=#frame>frame</a></code> element's <a href=#concept-bcc-content-document id=frames:concept-bcc-content-document>content document</a>.</p>

  <p>The <dfn id=dom-frame-contentwindow><code>contentWindow</code></dfn> IDL attribute must
  return the <code id=frames:windowproxy-2><a href=#windowproxy>WindowProxy</a></code> object of the <code id=frames:frame-22><a href=#frame>frame</a></code> element's <a href=#nested-browsing-context id=frames:nested-browsing-context-13>nested
  browsing context</a>, if the element's <a href=#nested-browsing-context id=frames:nested-browsing-context-14>nested browsing context</a> is non-null, or
  return null otherwise.</p>

  <p>The <dfn id=dom-frame-marginheight><code>marginHeight</code></dfn> IDL attribute of the
  <code id=frames:frame-23><a href=#frame>frame</a></code> element must <a href=#reflect id=frames:reflect-6>reflect</a> the element's <code>marginheight</code> content attribute.</p>

  <p>The <dfn id=dom-frame-marginwidth><code>marginWidth</code></dfn> IDL attribute of the
  <code id=frames:frame-24><a href=#frame>frame</a></code> element must <a href=#reflect id=frames:reflect-7>reflect</a> the element's <code>marginwidth</code> content attribute.</p>



  <h4 id=other-elements,-attributes-and-apis><span class=secno>15.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>] <c- b>attribute</c-> <c- b>DOMString</c-> <a href='#dom-a-coords' id='other-elements,-attributes-and-apis:dom-a-coords'><c- g>coords</c-></a>;
  [<a href='#cereactions' id='other-elements,-attributes-and-apis:cereactions-2'><c- g>CEReactions</c-></a>] <c- b>attribute</c-> <c- b>DOMString</c-> <a href='#dom-a-charset' id='other-elements,-attributes-and-apis:dom-a-charset'><c- g>charset</c-></a>;
  [<a href='#cereactions' id='other-elements,-attributes-and-apis:cereactions-3'><c- g>CEReactions</c-></a>] <c- b>attribute</c-> <c- b>DOMString</c-> <a href='#dom-a-name' id='other-elements,-attributes-and-apis:dom-a-name'><c- g>name</c-></a>;
  [<a href='#cereactions' id='other-elements,-attributes-and-apis:cereactions-4'><c- g>CEReactions</c-></a>] <c- b>attribute</c-> <c- b>DOMString</c-> <a href='#dom-a-rev' id='other-elements,-attributes-and-apis:dom-a-rev'><c- g>rev</c-></a>;
  [<a href='#cereactions' id='other-elements,-attributes-and-apis:cereactions-5'><c- g>CEReactions</c-></a>] <c- b>attribute</c-> <c- b>DOMString</c-> <a href='#dom-a-shape' id='other-elements,-attributes-and-apis:dom-a-shape'><c- g>shape</c-></a>;
};</code></pre>

  <p>The <dfn id=dom-a-coords><code>coords</code></dfn>, <dfn id=dom-a-charset><code>charset</code></dfn>, <dfn id=dom-a-name><code>name</code></dfn>, <dfn id=dom-a-rev><code>rev</code></dfn>, and <dfn id=dom-a-shape><code>shape</code></dfn> IDL attributes of the
  <code id=other-elements,-attributes-and-apis:the-a-element><a href=#the-a-element>a</a></code> element must <a href=#reflect id=other-elements,-attributes-and-apis:reflect>reflect</a> the respective
  content attributes of the same name.</p>

  <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>] <c- b>attribute</c-> <c- b>boolean</c-> <a href='#dom-area-nohref' id='other-elements,-attributes-and-apis:dom-area-nohref'><c- g>noHref</c-></a>;
};</code></pre>

  <p>The <dfn id=dom-area-nohref><code>noHref</code></dfn> IDL attribute of the
  <code id=other-elements,-attributes-and-apis:the-area-element><a href=#the-area-element>area</a></code> element must <a href=#reflect id=other-elements,-attributes-and-apis:reflect-2>reflect</a> the element's <code id=other-elements,-attributes-and-apis:attr-area-nohref><a href=#attr-area-nohref>nohref</a></code> content attribute.</p>

  <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>] <c- b>attribute</c-> [<c- g>TreatNullAs</c->=<c- n>EmptyString</c->] <c- b>DOMString</c-> <a href='#dom-body-text' id='other-elements,-attributes-and-apis:dom-body-text'><c- g>text</c-></a>;
  [<a href='#cereactions' id='other-elements,-attributes-and-apis:cereactions-8'><c- g>CEReactions</c-></a>] <c- b>attribute</c-> [<c- g>TreatNullAs</c->=<c- n>EmptyString</c->] <c- b>DOMString</c-> <a href='#dom-body-link' id='other-elements,-attributes-and-apis:dom-body-link'><c- g>link</c-></a>;
  [<a href='#cereactions' id='other-elements,-attributes-and-apis:cereactions-9'><c- g>CEReactions</c-></a>] <c- b>attribute</c-> [<c- g>TreatNullAs</c->=<c- n>EmptyString</c->] <c- b>DOMString</c-> <a href='#dom-body-vlink' id='other-elements,-attributes-and-apis:dom-body-vlink'><c- g>vLink</c-></a>;
  [<a href='#cereactions' id='other-elements,-attributes-and-apis:cereactions-10'><c- g>CEReactions</c-></a>] <c- b>attribute</c-> [<c- g>TreatNullAs</c->=<c- n>EmptyString</c->] <c- b>DOMString</c-> <a href='#dom-body-alink' id='other-elements,-attributes-and-apis:dom-body-alink'><c- g>aLink</c-></a>;
  [<a href='#cereactions' id='other-elements,-attributes-and-apis:cereactions-11'><c- g>CEReactions</c-></a>] <c- b>attribute</c-> [<c- g>TreatNullAs</c->=<c- n>EmptyString</c->] <c- b>DOMString</c-> <a href='#dom-body-bgcolor' id='other-elements,-attributes-and-apis:dom-body-bgcolor'><c- g>bgColor</c-></a>;
  [<a href='#cereactions' id='other-elements,-attributes-and-apis:cereactions-12'><c- g>CEReactions</c-></a>] <c- b>attribute</c-> <c- b>DOMString</c-> <a href='#dom-body-background' id='other-elements,-attributes-and-apis:dom-body-background'><c- g>background</c-></a>;
};</code></pre>

  <p>The <dfn id=dom-body-text><code>text</code></dfn> IDL attribute of the <code id=other-elements,-attributes-and-apis:the-body-element><a href=#the-body-element>body</a></code>
  element must <a href=#reflect id=other-elements,-attributes-and-apis:reflect-3>reflect</a> the element's <code id=other-elements,-attributes-and-apis:attr-body-text><a href=#attr-body-text>text</a></code> content
  attribute.</p>

  <p>The <dfn id=dom-body-link><code>link</code></dfn> IDL attribute of the <code id=other-elements,-attributes-and-apis:the-body-element-2><a href=#the-body-element>body</a></code>
  element must <a href=#reflect id=other-elements,-attributes-and-apis:reflect-4>reflect</a> the element's <code id=other-elements,-attributes-and-apis:attr-body-link><a href=#attr-body-link>link</a></code> content
  attribute.</p>

  <p>The <dfn id=dom-body-alink><code>aLink</code></dfn> IDL attribute of the <code id=other-elements,-attributes-and-apis:the-body-element-3><a href=#the-body-element>body</a></code>
  element must <a href=#reflect id=other-elements,-attributes-and-apis:reflect-5>reflect</a> the element's <code id=other-elements,-attributes-and-apis:attr-body-alink><a href=#attr-body-alink>alink</a></code> content
  attribute.</p>

  <p>The <dfn id=dom-body-vlink><code>vLink</code></dfn> IDL attribute of the <code id=other-elements,-attributes-and-apis:the-body-element-4><a href=#the-body-element>body</a></code>
  element must <a href=#reflect id=other-elements,-attributes-and-apis:reflect-6>reflect</a> the element's <code id=other-elements,-attributes-and-apis:attr-body-vlink><a href=#attr-body-vlink>vlink</a></code> content
  attribute.</p>

  <p>The <dfn id=dom-body-bgcolor><code>bgColor</code></dfn> IDL attribute of the
  <code id=other-elements,-attributes-and-apis:the-body-element-5><a href=#the-body-element>body</a></code> element must <a href=#reflect id=other-elements,-attributes-and-apis:reflect-7>reflect</a> the element's <code id=other-elements,-attributes-and-apis:attr-body-bgcolor><a href=#attr-body-bgcolor>bgcolor</a></code> content attribute.</p>

  <p>The <dfn id=dom-body-background><code>background</code></dfn> IDL attribute of the
  <code id=other-elements,-attributes-and-apis:the-body-element-6><a href=#the-body-element>body</a></code> element must <a href=#reflect id=other-elements,-attributes-and-apis:reflect-8>reflect</a> the element's <code id=other-elements,-attributes-and-apis:attr-background><a href=#attr-background>background</a></code> content attribute. (The <code id=other-elements,-attributes-and-apis:attr-background-2><a href=#attr-background>background</a></code> content is <em>not</em> defined to contain a
  <a id=other-elements,-attributes-and-apis:url href=https://url.spec.whatwg.org/#concept-url data-x-internal=url>URL</a>, despite rules regarding its handling in the rendering section above.)</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>] <c- b>attribute</c-> <c- b>DOMString</c-> <a href='#dom-br-clear' id='other-elements,-attributes-and-apis:dom-br-clear'><c- g>clear</c-></a>;
};</code></pre>

  <p>The <dfn id=dom-br-clear><code>clear</code></dfn> IDL attribute of the <code id=other-elements,-attributes-and-apis:the-br-element><a href=#the-br-element>br</a></code>
  element must <a href=#reflect id=other-elements,-attributes-and-apis:reflect-9>reflect</a> the content attribute of the same name.</p>

  <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>] <c- b>attribute</c-> <c- b>DOMString</c-> <a href='#dom-caption-align' id='other-elements,-attributes-and-apis:dom-caption-align'><c- g>align</c-></a>;
};</code></pre>

  <p>The <dfn id=dom-caption-align><code>align</code></dfn> IDL attribute of the
  <code id=other-elements,-attributes-and-apis:the-caption-element><a href=#the-caption-element>caption</a></code> element must <a href=#reflect id=other-elements,-attributes-and-apis:reflect-10>reflect</a> the content attribute of the same name.</p>

  <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>] <c- b>attribute</c-> <c- b>DOMString</c-> <a href='#dom-col-align' id='other-elements,-attributes-and-apis:dom-col-align'><c- g>align</c-></a>;
  [<a href='#cereactions' id='other-elements,-attributes-and-apis:cereactions-16'><c- g>CEReactions</c-></a>] <c- b>attribute</c-> <c- b>DOMString</c-> <a href='#dom-col-ch' id='other-elements,-attributes-and-apis:dom-col-ch'><c- g>ch</c-></a>;
  [<a href='#cereactions' id='other-elements,-attributes-and-apis:cereactions-17'><c- g>CEReactions</c-></a>] <c- b>attribute</c-> <c- b>DOMString</c-> <a href='#dom-col-choff' id='other-elements,-attributes-and-apis:dom-col-choff'><c- g>chOff</c-></a>;
  [<a href='#cereactions' id='other-elements,-attributes-and-apis:cereactions-18'><c- g>CEReactions</c-></a>] <c- b>attribute</c-> <c- b>DOMString</c-> <a href='#dom-col-valign' id='other-elements,-attributes-and-apis:dom-col-valign'><c- g>vAlign</c-></a>;
  [<a href='#cereactions' id='other-elements,-attributes-and-apis:cereactions-19'><c- g>CEReactions</c-></a>] <c- b>attribute</c-> <c- b>DOMString</c-> <a href='#dom-col-width' id='other-elements,-attributes-and-apis:dom-col-width'><c- g>width</c-></a>;
};</code></pre>

  <p>The <dfn id=dom-col-align><code>align</code></dfn> and <dfn id=dom-col-width><code>width</code></dfn> IDL attributes of the <code id=other-elements,-attributes-and-apis:the-col-element><a href=#the-col-element>col</a></code> element must
  <a href=#reflect id=other-elements,-attributes-and-apis:reflect-11>reflect</a> the respective content attributes of the same name.</p>

  <p>The <dfn id=dom-col-ch><code>ch</code></dfn> IDL attribute of the <code id=other-elements,-attributes-and-apis:the-col-element-2><a href=#the-col-element>col</a></code> element
  must <a href=#reflect id=other-elements,-attributes-and-apis:reflect-12>reflect</a> the element's <code id=other-elements,-attributes-and-apis:attr-col-char><a href=#attr-col-char>char</a></code> content
  attribute.</p>

  <p>The <dfn id=dom-col-choff><code>chOff</code></dfn> IDL attribute of the <code id=other-elements,-attributes-and-apis:the-col-element-3><a href=#the-col-element>col</a></code>
  element must <a href=#reflect id=other-elements,-attributes-and-apis:reflect-13>reflect</a> the element's <code id=other-elements,-attributes-and-apis:attr-col-charoff><a href=#attr-col-charoff>charoff</a></code>
  content attribute.</p>

  <p>The <dfn id=dom-col-valign><code>vAlign</code></dfn> IDL attribute of the <code id=other-elements,-attributes-and-apis:the-col-element-4><a href=#the-col-element>col</a></code>
  element must <a href=#reflect id=other-elements,-attributes-and-apis:reflect-14>reflect</a> the element's <code id=other-elements,-attributes-and-apis:attr-col-valign><a href=#attr-col-valign>valign</a></code>
  content attribute.</p>

  <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->,
 <a href='#htmlconstructor' id='other-elements,-attributes-and-apis:htmlconstructor'><c- g>HTMLConstructor</c-></a>]
<c- b>interface</c-> <dfn id='htmldirectoryelement'><c- g>HTMLDirectoryElement</c-></dfn> : <a href='#htmlelement' id='other-elements,-attributes-and-apis:htmlelement'><c- n>HTMLElement</c-></a> {
  [<a href='#cereactions' id='other-elements,-attributes-and-apis:cereactions-20'><c- g>CEReactions</c-></a>] <c- b>attribute</c-> <c- b>boolean</c-> <a href='#dom-dir-compact' id='other-elements,-attributes-and-apis:dom-dir-compact'><c- g>compact</c-></a>;
};</code></pre>

  <p>The <dfn id=dom-dir-compact><code>compact</code></dfn> IDL attribute of the
  <code id=other-elements,-attributes-and-apis:dir-3><a href=#dir>dir</a></code> element must <a href=#reflect id=other-elements,-attributes-and-apis:reflect-15>reflect</a> the content attribute of the same name.</p>

  <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>] <c- b>attribute</c-> <c- b>DOMString</c-> <a href='#dom-div-align' id='other-elements,-attributes-and-apis:dom-div-align'><c- g>align</c-></a>;
};</code></pre>

  <p>The <dfn id=dom-div-align><code>align</code></dfn> IDL attribute of the <code id=other-elements,-attributes-and-apis:the-div-element><a href=#the-div-element>div</a></code>
  element must <a href=#reflect id=other-elements,-attributes-and-apis:reflect-16>reflect</a> the content attribute of the same name.</p>

  <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>] <c- b>attribute</c-> <c- b>boolean</c-> <a href='#dom-dl-compact' id='other-elements,-attributes-and-apis:dom-dl-compact'><c- g>compact</c-></a>;
};</code></pre>

  <p>The <dfn id=dom-dl-compact><code>compact</code></dfn> IDL attribute of the <code id=other-elements,-attributes-and-apis:the-dl-element><a href=#the-dl-element>dl</a></code>
  element must <a href=#reflect id=other-elements,-attributes-and-apis:reflect-17>reflect</a> the content attribute of the same name.</p>

  <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>] <c- b>attribute</c-> <c- b>DOMString</c-> <a href='#dom-embed-align' id='other-elements,-attributes-and-apis:dom-embed-align'><c- g>align</c-></a>;
  [<a href='#cereactions' id='other-elements,-attributes-and-apis:cereactions-24'><c- g>CEReactions</c-></a>] <c- b>attribute</c-> <c- b>DOMString</c-> <a href='#dom-embed-name' id='other-elements,-attributes-and-apis:dom-embed-name'><c- g>name</c-></a>;
};</code></pre>

  <p>The <dfn id=dom-embed-name><code>name</code></dfn> and <dfn id=dom-embed-align><code>align</code></dfn> IDL attributes of the <code id=other-elements,-attributes-and-apis:the-embed-element><a href=#the-embed-element>embed</a></code> element
  must <a href=#reflect id=other-elements,-attributes-and-apis:reflect-18>reflect</a> the respective content attributes of the same name.</p>

  <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->,
 <a href='#htmlconstructor' id='other-elements,-attributes-and-apis:htmlconstructor-2'><c- g>HTMLConstructor</c-></a>]
<c- b>interface</c-> <dfn id='htmlfontelement'><c- g>HTMLFontElement</c-></dfn> : <a href='#htmlelement' id='other-elements,-attributes-and-apis:htmlelement-2'><c- n>HTMLElement</c-></a> {
  [<a href='#cereactions' id='other-elements,-attributes-and-apis:cereactions-25'><c- g>CEReactions</c-></a>] <c- b>attribute</c-> [<c- g>TreatNullAs</c->=<c- n>EmptyString</c->] <c- b>DOMString</c-> <a href='#dom-font-color' id='other-elements,-attributes-and-apis:dom-font-color'><c- g>color</c-></a>;
  [<a href='#cereactions' id='other-elements,-attributes-and-apis:cereactions-26'><c- g>CEReactions</c-></a>] <c- b>attribute</c-> <c- b>DOMString</c-> <a href='#dom-font-face' id='other-elements,-attributes-and-apis:dom-font-face'><c- g>face</c-></a>;
  [<a href='#cereactions' id='other-elements,-attributes-and-apis:cereactions-27'><c- g>CEReactions</c-></a>] <c- b>attribute</c-> <c- b>DOMString</c-> <a href='#dom-font-size' id='other-elements,-attributes-and-apis:dom-font-size'><c- g>size</c-></a>; 
};</code></pre>

  <p>The <dfn id=dom-font-color><code>color</code></dfn>, <dfn id=dom-font-face><code>face</code></dfn>, and <dfn id=dom-font-size><code>size</code></dfn> IDL attributes of the <code id=other-elements,-attributes-and-apis:font-2><a href=#font>font</a></code> element must
  <a href=#reflect id=other-elements,-attributes-and-apis:reflect-19>reflect</a> the respective content attributes of the same name.</p>

  <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>] <c- b>attribute</c-> <c- b>DOMString</c-> <a href='#dom-hx-align' id='other-elements,-attributes-and-apis:dom-hx-align'><c- g>align</c-></a>;
};</code></pre>

  <p>The <dfn id=dom-hx-align><code>align</code></dfn> IDL attribute of the
  <code id=other-elements,-attributes-and-apis: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=other-elements,-attributes-and-apis: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 must <a href=#reflect id=other-elements,-attributes-and-apis:reflect-20>reflect</a> the content attribute of
  the same name.</p>

  <hr>

  <p class=note>The <dfn id=dom-head-profile><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 the DOM specifications.)</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>] <c- b>attribute</c-> <c- b>DOMString</c-> <a href='#dom-hr-align' id='other-elements,-attributes-and-apis:dom-hr-align'><c- g>align</c-></a>;
  [<a href='#cereactions' id='other-elements,-attributes-and-apis:cereactions-30'><c- g>CEReactions</c-></a>] <c- b>attribute</c-> <c- b>DOMString</c-> <a href='#dom-hr-color' id='other-elements,-attributes-and-apis:dom-hr-color'><c- g>color</c-></a>;
  [<a href='#cereactions' id='other-elements,-attributes-and-apis:cereactions-31'><c- g>CEReactions</c-></a>] <c- b>attribute</c-> <c- b>boolean</c-> <a href='#dom-hr-noshade' id='other-elements,-attributes-and-apis:dom-hr-noshade'><c- g>noShade</c-></a>;
  [<a href='#cereactions' id='other-elements,-attributes-and-apis:cereactions-32'><c- g>CEReactions</c-></a>] <c- b>attribute</c-> <c- b>DOMString</c-> <a href='#dom-hr-size' id='other-elements,-attributes-and-apis:dom-hr-size'><c- g>size</c-></a>;
  [<a href='#cereactions' id='other-elements,-attributes-and-apis:cereactions-33'><c- g>CEReactions</c-></a>] <c- b>attribute</c-> <c- b>DOMString</c-> <a href='#dom-hr-width' id='other-elements,-attributes-and-apis:dom-hr-width'><c- g>width</c-></a>;
};</code></pre>

  <p>The <dfn id=dom-hr-align><code>align</code></dfn>, <dfn id=dom-hr-color><code>color</code></dfn>, <dfn id=dom-hr-size><code>size</code></dfn>,
  and <dfn id=dom-hr-width><code>width</code></dfn> IDL attributes of the <code id=other-elements,-attributes-and-apis:the-hr-element><a href=#the-hr-element>hr</a></code>
  element must <a href=#reflect id=other-elements,-attributes-and-apis:reflect-21>reflect</a> the respective content attributes of the same name.</p>

  <p>The <dfn id=dom-hr-noshade><code>noShade</code></dfn> IDL attribute of the <code id=other-elements,-attributes-and-apis:the-hr-element-2><a href=#the-hr-element>hr</a></code>
  element must <a href=#reflect id=other-elements,-attributes-and-apis:reflect-22>reflect</a> the element's <code id=other-elements,-attributes-and-apis:attr-hr-noshade><a href=#attr-hr-noshade>noshade</a></code>
  content attribute.</p>

  <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>] <c- b>attribute</c-> <c- b>DOMString</c-> <a href='#dom-html-version' id='other-elements,-attributes-and-apis:dom-html-version'><c- g>version</c-></a>;
};</code></pre>

  <p>The <dfn id=dom-html-version><code>version</code></dfn> IDL attribute of the
  <code id=other-elements,-attributes-and-apis:the-html-element><a href=#the-html-element>html</a></code> element must <a href=#reflect id=other-elements,-attributes-and-apis:reflect-23>reflect</a> the content attribute of the same name.</p>

  <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>] <c- b>attribute</c-> <c- b>DOMString</c-> <a href='#dom-iframe-align' id='other-elements,-attributes-and-apis:dom-iframe-align'><c- g>align</c-></a>;
  [<a href='#cereactions' id='other-elements,-attributes-and-apis:cereactions-36'><c- g>CEReactions</c-></a>] <c- b>attribute</c-> <c- b>DOMString</c-> <a href='#dom-iframe-scrolling' id='other-elements,-attributes-and-apis:dom-iframe-scrolling'><c- g>scrolling</c-></a>;
  [<a href='#cereactions' id='other-elements,-attributes-and-apis:cereactions-37'><c- g>CEReactions</c-></a>] <c- b>attribute</c-> <c- b>DOMString</c-> <a href='#dom-iframe-frameborder' id='other-elements,-attributes-and-apis:dom-iframe-frameborder'><c- g>frameBorder</c-></a>;
  [<a href='#cereactions' id='other-elements,-attributes-and-apis:cereactions-38'><c- g>CEReactions</c-></a>] <c- b>attribute</c-> <c- b>USVString</c-> <a href='#dom-iframe-longdesc' id='other-elements,-attributes-and-apis:dom-iframe-longdesc'><c- g>longDesc</c-></a>;

  [<a href='#cereactions' id='other-elements,-attributes-and-apis:cereactions-39'><c- g>CEReactions</c-></a>] <c- b>attribute</c-> [<c- g>TreatNullAs</c->=<c- n>EmptyString</c->] <c- b>DOMString</c-> <a href='#dom-iframe-marginheight' id='other-elements,-attributes-and-apis:dom-iframe-marginheight'><c- g>marginHeight</c-></a>;
  [<a href='#cereactions' id='other-elements,-attributes-and-apis:cereactions-40'><c- g>CEReactions</c-></a>] <c- b>attribute</c-> [<c- g>TreatNullAs</c->=<c- n>EmptyString</c->] <c- b>DOMString</c-> <a href='#dom-iframe-marginwidth' id='other-elements,-attributes-and-apis:dom-iframe-marginwidth'><c- g>marginWidth</c-></a>;
};</code></pre>

  <p>The <dfn id=dom-iframe-align><code>align</code></dfn> and <dfn id=dom-iframe-scrolling><code>scrolling</code></dfn> IDL attributes of the
  <code id=other-elements,-attributes-and-apis:the-iframe-element><a href=#the-iframe-element>iframe</a></code> element must <a href=#reflect id=other-elements,-attributes-and-apis:reflect-24>reflect</a> the respective content attributes of the
  same name.</p>

  <p>The <dfn id=dom-iframe-frameborder><code>frameBorder</code></dfn> IDL attribute of the
  <code id=other-elements,-attributes-and-apis:the-iframe-element-2><a href=#the-iframe-element>iframe</a></code> element must <a href=#reflect id=other-elements,-attributes-and-apis:reflect-25>reflect</a> the element's <code id=other-elements,-attributes-and-apis:attr-iframe-frameborder><a href=#attr-iframe-frameborder>frameborder</a></code> content attribute.</p>

  <p>The <dfn id=dom-iframe-longdesc><code>longDesc</code></dfn> IDL attribute of the
  <code id=other-elements,-attributes-and-apis:the-iframe-element-3><a href=#the-iframe-element>iframe</a></code> element must <a href=#reflect id=other-elements,-attributes-and-apis:reflect-26>reflect</a> the element's <code id=other-elements,-attributes-and-apis:attr-iframe-longdesc><a href=#attr-iframe-longdesc>longdesc</a></code> content attribute, which for the purposes of
  reflection is defined as containing a <a id=other-elements,-attributes-and-apis:url-2 href=https://url.spec.whatwg.org/#concept-url data-x-internal=url>URL</a>.</p>

  <p>The <dfn id=dom-iframe-marginheight><code>marginHeight</code></dfn> IDL attribute of the
  <code id=other-elements,-attributes-and-apis:the-iframe-element-4><a href=#the-iframe-element>iframe</a></code> element must <a href=#reflect id=other-elements,-attributes-and-apis:reflect-27>reflect</a> the element's <code id=other-elements,-attributes-and-apis:attr-iframe-marginheight><a href=#attr-iframe-marginheight>marginheight</a></code> content attribute.</p>

  <p>The <dfn id=dom-iframe-marginwidth><code>marginWidth</code></dfn> IDL attribute of the
  <code id=other-elements,-attributes-and-apis:the-iframe-element-5><a href=#the-iframe-element>iframe</a></code> element must <a href=#reflect id=other-elements,-attributes-and-apis:reflect-28>reflect</a> the element's <code id=other-elements,-attributes-and-apis:attr-iframe-marginwidth><a href=#attr-iframe-marginwidth>marginwidth</a></code> content attribute.</p>

  <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>] <c- b>attribute</c-> <c- b>DOMString</c-> <a href='#dom-img-name' id='other-elements,-attributes-and-apis:dom-img-name'><c- g>name</c-></a>;
  [<a href='#cereactions' id='other-elements,-attributes-and-apis:cereactions-42'><c- g>CEReactions</c-></a>] <c- b>attribute</c-> <c- b>USVString</c-> <a href='#dom-img-lowsrc' id='other-elements,-attributes-and-apis:dom-img-lowsrc'><c- g>lowsrc</c-></a>;
  [<a href='#cereactions' id='other-elements,-attributes-and-apis:cereactions-43'><c- g>CEReactions</c-></a>] <c- b>attribute</c-> <c- b>DOMString</c-> <a href='#dom-img-align' id='other-elements,-attributes-and-apis:dom-img-align'><c- g>align</c-></a>;
  [<a href='#cereactions' id='other-elements,-attributes-and-apis:cereactions-44'><c- g>CEReactions</c-></a>] <c- b>attribute</c-> <c- b>unsigned</c-> <c- b>long</c-> <a href='#dom-img-hspace' id='other-elements,-attributes-and-apis:dom-img-hspace'><c- g>hspace</c-></a>;
  [<a href='#cereactions' id='other-elements,-attributes-and-apis:cereactions-45'><c- g>CEReactions</c-></a>] <c- b>attribute</c-> <c- b>unsigned</c-> <c- b>long</c-> <a href='#dom-img-vspace' id='other-elements,-attributes-and-apis:dom-img-vspace'><c- g>vspace</c-></a>;
  [<a href='#cereactions' id='other-elements,-attributes-and-apis:cereactions-46'><c- g>CEReactions</c-></a>] <c- b>attribute</c-> <c- b>USVString</c-> <a href='#dom-img-longdesc' id='other-elements,-attributes-and-apis:dom-img-longdesc'><c- g>longDesc</c-></a>;

  [<a href='#cereactions' id='other-elements,-attributes-and-apis:cereactions-47'><c- g>CEReactions</c-></a>] <c- b>attribute</c-> [<c- g>TreatNullAs</c->=<c- n>EmptyString</c->] <c- b>DOMString</c-> <a href='#dom-img-border' id='other-elements,-attributes-and-apis:dom-img-border'><c- g>border</c-></a>;
};</code></pre>

  <p>The <dfn id=dom-img-name><code>name</code></dfn>, <dfn id=dom-img-align><code>align</code></dfn>, <dfn id=dom-img-border><code>border</code></dfn>, <dfn id=dom-img-hspace><code>hspace</code></dfn>, and <dfn id=dom-img-vspace><code>vspace</code></dfn> IDL attributes of the <code id=other-elements,-attributes-and-apis:the-img-element><a href=#the-img-element>img</a></code> element
  must <a href=#reflect id=other-elements,-attributes-and-apis:reflect-29>reflect</a> the respective content attributes of the same name.</p>

  <p>The <dfn id=dom-img-longdesc><code>longDesc</code></dfn> IDL attribute of the
  <code id=other-elements,-attributes-and-apis:the-img-element-2><a href=#the-img-element>img</a></code> element must <a href=#reflect id=other-elements,-attributes-and-apis:reflect-30>reflect</a> the element's <code id=other-elements,-attributes-and-apis:attr-img-longdesc><a href=#attr-img-longdesc>longdesc</a></code> content attribute, which for the purposes of reflection
  is defined as containing a <a id=other-elements,-attributes-and-apis:url-3 href=https://url.spec.whatwg.org/#concept-url data-x-internal=url>URL</a>.</p>

  <p>The <dfn id=dom-img-lowsrc><code>lowsrc</code></dfn> IDL attribute of the <code id=other-elements,-attributes-and-apis:the-img-element-3><a href=#the-img-element>img</a></code>
  element must <a href=#reflect id=other-elements,-attributes-and-apis:reflect-31>reflect</a> the element's <code id=other-elements,-attributes-and-apis:attr-img-lowsrc><a href=#attr-img-lowsrc>lowsrc</a></code>
  content attribute, which for the purposes of reflection is defined as containing a
  <a id=other-elements,-attributes-and-apis:url-4 href=https://url.spec.whatwg.org/#concept-url data-x-internal=url>URL</a>.</p>

  <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>] <c- b>attribute</c-> <c- b>DOMString</c-> <a href='#dom-input-align' id='other-elements,-attributes-and-apis:dom-input-align'><c- g>align</c-></a>;
  [<a href='#cereactions' id='other-elements,-attributes-and-apis:cereactions-49'><c- g>CEReactions</c-></a>] <c- b>attribute</c-> <c- b>DOMString</c-> <a href='#dom-input-usemap' id='other-elements,-attributes-and-apis:dom-input-usemap'><c- g>useMap</c-></a>;
};</code></pre>

  <p>The <dfn id=dom-input-align><code>align</code></dfn> IDL attribute of the
  <code id=other-elements,-attributes-and-apis:the-input-element><a href=#the-input-element>input</a></code> element must <a href=#reflect id=other-elements,-attributes-and-apis:reflect-32>reflect</a> the content attribute of the same name.</p>

  <p>The <dfn id=dom-input-usemap><code>useMap</code></dfn> IDL attribute of the
  <code id=other-elements,-attributes-and-apis:the-input-element-2><a href=#the-input-element>input</a></code> element must <a href=#reflect id=other-elements,-attributes-and-apis:reflect-33>reflect</a> the element's <code id=other-elements,-attributes-and-apis:attr-input-usemap><a href=#attr-input-usemap>usemap</a></code> content attribute.</p>

  <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>] <c- b>attribute</c-> <c- b>DOMString</c-> <a href='#dom-legend-align' id='other-elements,-attributes-and-apis:dom-legend-align'><c- g>align</c-></a>;
};</code></pre>

  <p>The <dfn id=dom-legend-align><code>align</code></dfn> IDL attribute of the
  <code id=other-elements,-attributes-and-apis:the-legend-element><a href=#the-legend-element>legend</a></code> element must <a href=#reflect id=other-elements,-attributes-and-apis:reflect-34>reflect</a> the content attribute of the same name.</p>

  <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>] <c- b>attribute</c-> <c- b>DOMString</c-> <a href='#dom-li-type' id='other-elements,-attributes-and-apis:dom-li-type'><c- g>type</c-></a>;
};</code></pre>

  <p>The <dfn id=dom-li-type><code>type</code></dfn> IDL attribute of the <code id=other-elements,-attributes-and-apis:the-li-element><a href=#the-li-element>li</a></code>
  element must <a href=#reflect id=other-elements,-attributes-and-apis:reflect-35>reflect</a> the content attribute of the same name.</p>

  <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>] <c- b>attribute</c-> <c- b>DOMString</c-> <a href='#dom-link-charset' id='other-elements,-attributes-and-apis:dom-link-charset'><c- g>charset</c-></a>;
  [<a href='#cereactions' id='other-elements,-attributes-and-apis:cereactions-53'><c- g>CEReactions</c-></a>] <c- b>attribute</c-> <c- b>DOMString</c-> <a href='#dom-link-rev' id='other-elements,-attributes-and-apis:dom-link-rev'><c- g>rev</c-></a>;
  [<a href='#cereactions' id='other-elements,-attributes-and-apis:cereactions-54'><c- g>CEReactions</c-></a>] <c- b>attribute</c-> <c- b>DOMString</c-> <a href='#dom-link-target' id='other-elements,-attributes-and-apis:dom-link-target'><c- g>target</c-></a>;
};</code></pre>

  <p>The <dfn id=dom-link-charset><code>charset</code></dfn>, <dfn id=dom-link-rev><code>rev</code></dfn>, and <dfn id=dom-link-target><code>target</code></dfn> IDL attributes of the <code id=other-elements,-attributes-and-apis:the-link-element><a href=#the-link-element>link</a></code> element
  must <a href=#reflect id=other-elements,-attributes-and-apis:reflect-36>reflect</a> the respective content attributes of the same name.</p>

  <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>] <c- b>attribute</c-> <c- b>boolean</c-> <a href='#dom-menu-compact' id='other-elements,-attributes-and-apis:dom-menu-compact'><c- g>compact</c-></a>;
};</code></pre>

  <p>The <dfn id=dom-menu-compact><code>compact</code></dfn> IDL attribute of the
  <code id=other-elements,-attributes-and-apis:the-menu-element><a href=#the-menu-element>menu</a></code> element must <a href=#reflect id=other-elements,-attributes-and-apis:reflect-37>reflect</a> the content attribute of the same name.</p>

  <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>] <c- b>attribute</c-> <c- b>DOMString</c-> <a href='#dom-meta-scheme' id='other-elements,-attributes-and-apis:dom-meta-scheme'><c- g>scheme</c-></a>;
};</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>&quot;eGMS.subject.keyword&quot;</c-> <c- e>scheme</c-><c- o>=</c-><c- s>&quot;LGCL&quot;</c-> <c- e>content</c-><c- o>=</c-><c- s>&quot;Abandoned vehicles&quot;</c-><c- p>&gt;</c->
<c- p>&lt;</c-><c- f>meta</c-> <c- e>name</c-><c- o>=</c-><c- s>&quot;eGMS.subject.keyword&quot;</c-> <c- e>scheme</c-><c- o>=</c-><c- s>&quot;ORLY&quot;</c-> <c- e>content</c-><c- o>=</c-><c- s>&quot;Mah car: kthxbye&quot;</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>&quot;eGMS.subject.keyword&quot;</c-> <c- e>content</c-><c- o>=</c-><c- s>&quot;Abandoned vehicles&quot;</c-><c- p>&gt;</c->
<c- p>&lt;</c-><c- f>meta</c-> <c- e>name</c-><c- o>=</c-><c- s>&quot;eGMS.subject.keyword&quot;</c-> <c- e>content</c-><c- o>=</c-><c- s>&quot;Mah car: kthxbye&quot;</c-><c- p>&gt;</c-></code></pre>

  </div>

  <p>The <dfn id=dom-meta-scheme><code>scheme</code></dfn> IDL attribute of the
  <code id=other-elements,-attributes-and-apis:the-meta-element-5><a href=#the-meta-element>meta</a></code> element must <a href=#reflect id=other-elements,-attributes-and-apis:reflect-38>reflect</a> the content attribute of the same name.</p>

  <hr>

  <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>] <c- b>attribute</c-> <c- b>DOMString</c-> <a href='#dom-object-align' id='other-elements,-attributes-and-apis:dom-object-align'><c- g>align</c-></a>;
  [<a href='#cereactions' id='other-elements,-attributes-and-apis:cereactions-58'><c- g>CEReactions</c-></a>] <c- b>attribute</c-> <c- b>DOMString</c-> <a href='#dom-object-archive' id='other-elements,-attributes-and-apis:dom-object-archive'><c- g>archive</c-></a>;
  [<a href='#cereactions' id='other-elements,-attributes-and-apis:cereactions-59'><c- g>CEReactions</c-></a>] <c- b>attribute</c-> <c- b>DOMString</c-> <a href='#dom-object-code' id='other-elements,-attributes-and-apis:dom-object-code'><c- g>code</c-></a>;
  [<a href='#cereactions' id='other-elements,-attributes-and-apis:cereactions-60'><c- g>CEReactions</c-></a>] <c- b>attribute</c-> <c- b>boolean</c-> <a href='#dom-object-declare' id='other-elements,-attributes-and-apis:dom-object-declare'><c- g>declare</c-></a>;
  [<a href='#cereactions' id='other-elements,-attributes-and-apis:cereactions-61'><c- g>CEReactions</c-></a>] <c- b>attribute</c-> <c- b>unsigned</c-> <c- b>long</c-> <a href='#dom-object-hspace' id='other-elements,-attributes-and-apis:dom-object-hspace'><c- g>hspace</c-></a>;
  [<a href='#cereactions' id='other-elements,-attributes-and-apis:cereactions-62'><c- g>CEReactions</c-></a>] <c- b>attribute</c-> <c- b>DOMString</c-> <a href='#dom-object-standby' id='other-elements,-attributes-and-apis:dom-object-standby'><c- g>standby</c-></a>;
  [<a href='#cereactions' id='other-elements,-attributes-and-apis:cereactions-63'><c- g>CEReactions</c-></a>] <c- b>attribute</c-> <c- b>unsigned</c-> <c- b>long</c-> <a href='#dom-object-vspace' id='other-elements,-attributes-and-apis:dom-object-vspace'><c- g>vspace</c-></a>;
  [<a href='#cereactions' id='other-elements,-attributes-and-apis:cereactions-64'><c- g>CEReactions</c-></a>] <c- b>attribute</c-> <c- b>DOMString</c-> <a href='#dom-object-codebase' id='other-elements,-attributes-and-apis:dom-object-codebase'><c- g>codeBase</c-></a>;
  [<a href='#cereactions' id='other-elements,-attributes-and-apis:cereactions-65'><c- g>CEReactions</c-></a>] <c- b>attribute</c-> <c- b>DOMString</c-> <a href='#dom-object-codetype' id='other-elements,-attributes-and-apis:dom-object-codetype'><c- g>codeType</c-></a>;

  [<a href='#cereactions' id='other-elements,-attributes-and-apis:cereactions-66'><c- g>CEReactions</c-></a>] <c- b>attribute</c-> [<c- g>TreatNullAs</c->=<c- n>EmptyString</c->] <c- b>DOMString</c-> <a href='#dom-object-border' id='other-elements,-attributes-and-apis:dom-object-border'><c- g>border</c-></a>;
};</code></pre>

  <p>The <dfn id=dom-object-align><code>align</code></dfn>, <dfn id=dom-object-archive><code>archive</code></dfn>, <dfn id=dom-object-border><code>border</code></dfn>, <dfn id=dom-object-code><code>code</code></dfn>, <dfn id=dom-object-declare><code>declare</code></dfn>, <dfn id=dom-object-hspace><code>hspace</code></dfn>, <dfn id=dom-object-standby><code>standby</code></dfn>, and <dfn id=dom-object-vspace><code>vspace</code></dfn> IDL attributes of the <code id=other-elements,-attributes-and-apis:the-object-element><a href=#the-object-element>object</a></code>
  element must <a href=#reflect id=other-elements,-attributes-and-apis:reflect-39>reflect</a> the respective content attributes of the same name.</p>

  <p>The <dfn id=dom-object-codebase><code>codeBase</code></dfn> IDL attribute of the
  <code id=other-elements,-attributes-and-apis:the-object-element-2><a href=#the-object-element>object</a></code> element must <a href=#reflect id=other-elements,-attributes-and-apis:reflect-40>reflect</a> the element's <code id=other-elements,-attributes-and-apis:attr-object-codebase><a href=#attr-object-codebase>codebase</a></code> content attribute, which for the purposes of
  reflection is defined as containing a <a id=other-elements,-attributes-and-apis:url-5 href=https://url.spec.whatwg.org/#concept-url data-x-internal=url>URL</a>.</p>

  <p>The <dfn id=dom-object-codetype><code>codeType</code></dfn> IDL attribute of the
  <code id=other-elements,-attributes-and-apis:the-object-element-3><a href=#the-object-element>object</a></code> element must <a href=#reflect id=other-elements,-attributes-and-apis:reflect-41>reflect</a> the element's <code id=other-elements,-attributes-and-apis:attr-object-codetype><a href=#attr-object-codetype>codetype</a></code> content attribute.</p>

  <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-67'><c- g>CEReactions</c-></a>] <c- b>attribute</c-> <c- b>boolean</c-> <a href='#dom-ol-compact' id='other-elements,-attributes-and-apis:dom-ol-compact'><c- g>compact</c-></a>;
};</code></pre>

  <p>The <dfn id=dom-ol-compact><code>compact</code></dfn> IDL attribute of the <code id=other-elements,-attributes-and-apis:the-ol-element><a href=#the-ol-element>ol</a></code>
  element must <a href=#reflect id=other-elements,-attributes-and-apis:reflect-42>reflect</a> the content attribute of the same name.</p>

  <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-68'><c- g>CEReactions</c-></a>] <c- b>attribute</c-> <c- b>DOMString</c-> <a href='#dom-p-align' id='other-elements,-attributes-and-apis:dom-p-align'><c- g>align</c-></a>;
};</code></pre>

  <p>The <dfn id=dom-p-align><code>align</code></dfn> IDL attribute of the <code id=other-elements,-attributes-and-apis:the-p-element><a href=#the-p-element>p</a></code>
  element must <a href=#reflect id=other-elements,-attributes-and-apis:reflect-43>reflect</a> the content attribute of the same name.</p>

  <hr>

  <pre><code class='idl'><c- b>partial</c-> <c- b>interface</c-> <a href='#htmlparamelement' id='HTMLParamElement-partial'><c- g>HTMLParamElement</c-></a> {
  [<a href='#cereactions' id='other-elements,-attributes-and-apis:cereactions-69'><c- g>CEReactions</c-></a>] <c- b>attribute</c-> <c- b>DOMString</c-> <a href='#dom-param-type' id='other-elements,-attributes-and-apis:dom-param-type'><c- g>type</c-></a>;
  [<a href='#cereactions' id='other-elements,-attributes-and-apis:cereactions-70'><c- g>CEReactions</c-></a>] <c- b>attribute</c-> <c- b>DOMString</c-> <a href='#dom-param-valuetype' id='other-elements,-attributes-and-apis:dom-param-valuetype'><c- g>valueType</c-></a>;
};</code></pre>

  <p>The <dfn id=dom-param-type><code>type</code></dfn> IDL attribute of the <code id=other-elements,-attributes-and-apis:the-param-element><a href=#the-param-element>param</a></code>
  element must <a href=#reflect id=other-elements,-attributes-and-apis:reflect-44>reflect</a> the content attribute of the same name.</p>

  <p>The <dfn id=dom-param-valuetype><code>valueType</code></dfn> IDL attribute of the
  <code id=other-elements,-attributes-and-apis:the-param-element-2><a href=#the-param-element>param</a></code> element must <a href=#reflect id=other-elements,-attributes-and-apis:reflect-45>reflect</a> the element's <code id=other-elements,-attributes-and-apis:attr-param-valuetype><a href=#attr-param-valuetype>valuetype</a></code> content attribute.</p>

  <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-71'><c- g>CEReactions</c-></a>] <c- b>attribute</c-> <c- b>long</c-> <a href='#dom-pre-width' id='other-elements,-attributes-and-apis:dom-pre-width'><c- g>width</c-></a>;
};</code></pre>

  <p>The <dfn id=dom-pre-width><code>width</code></dfn> IDL attribute of the <code id=other-elements,-attributes-and-apis:the-pre-element-3><a href=#the-pre-element>pre</a></code>
  element must <a href=#reflect id=other-elements,-attributes-and-apis:reflect-46>reflect</a> the content attribute of the same name.</p>

  <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-72'><c- g>CEReactions</c-></a>] <c- b>attribute</c-> <c- b>DOMString</c-> <a href='#dom-style-type' id='other-elements,-attributes-and-apis:dom-style-type'><c- g>type</c-></a>;
};</code></pre>

  <p>The <dfn id=dom-style-type><code>type</code></dfn> IDL attribute of the
  <code id=other-elements,-attributes-and-apis:the-style-element><a href=#the-style-element>style</a></code> element must <a href=#reflect id=other-elements,-attributes-and-apis:reflect-47>reflect</a> the element's <code id=other-elements,-attributes-and-apis:attr-style-type><a href=#attr-style-type>type</a></code> content attribute.</p>

  <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-73'><c- g>CEReactions</c-></a>] <c- b>attribute</c-> <c- b>DOMString</c-> <a href='#dom-script-charset' id='other-elements,-attributes-and-apis:dom-script-charset'><c- g>charset</c-></a>;
  [<a href='#cereactions' id='other-elements,-attributes-and-apis:cereactions-74'><c- g>CEReactions</c-></a>] <c- b>attribute</c-> <c- b>DOMString</c-> <a href='#dom-script-event' id='other-elements,-attributes-and-apis:dom-script-event'><c- g>event</c-></a>;
  [<a href='#cereactions' id='other-elements,-attributes-and-apis:cereactions-75'><c- g>CEReactions</c-></a>] <c- b>attribute</c-> <c- b>DOMString</c-> <a href='#dom-script-htmlfor' id='other-elements,-attributes-and-apis:dom-script-htmlfor'><c- g>htmlFor</c-></a>;
};</code></pre>

  <p>The <dfn id=dom-script-charset><code>charset</code></dfn> and <dfn id=dom-script-event><code>event</code></dfn> IDL attributes of the <code id=other-elements,-attributes-and-apis:the-script-element><a href=#the-script-element>script</a></code> element
  must <a href=#reflect id=other-elements,-attributes-and-apis:reflect-48>reflect</a> the respective content attributes of the same name.</p>

  <p>The <dfn id=dom-script-htmlfor><code>htmlFor</code></dfn> IDL attribute of the
  <code id=other-elements,-attributes-and-apis:the-script-element-2><a href=#the-script-element>script</a></code> element must <a href=#reflect id=other-elements,-attributes-and-apis:reflect-49>reflect</a> the element's
  <code id=other-elements,-attributes-and-apis:attr-script-for><a href=#attr-script-for>for</a></code> content attribute.</p>

  <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-76'><c- g>CEReactions</c-></a>] <c- b>attribute</c-> <c- b>DOMString</c-> <a href='#dom-table-align' id='other-elements,-attributes-and-apis:dom-table-align'><c- g>align</c-></a>;
  [<a href='#cereactions' id='other-elements,-attributes-and-apis:cereactions-77'><c- g>CEReactions</c-></a>] <c- b>attribute</c-> <c- b>DOMString</c-> <a href='#dom-table-border' id='other-elements,-attributes-and-apis:dom-table-border'><c- g>border</c-></a>;
  [<a href='#cereactions' id='other-elements,-attributes-and-apis:cereactions-78'><c- g>CEReactions</c-></a>] <c- b>attribute</c-> <c- b>DOMString</c-> <a href='#dom-table-frame' id='other-elements,-attributes-and-apis:dom-table-frame'><c- g>frame</c-></a>;
  [<a href='#cereactions' id='other-elements,-attributes-and-apis:cereactions-79'><c- g>CEReactions</c-></a>] <c- b>attribute</c-> <c- b>DOMString</c-> <a href='#dom-table-rules' id='other-elements,-attributes-and-apis:dom-table-rules'><c- g>rules</c-></a>;
  [<a href='#cereactions' id='other-elements,-attributes-and-apis:cereactions-80'><c- g>CEReactions</c-></a>] <c- b>attribute</c-> <c- b>DOMString</c-> <a href='#dom-table-summary' id='other-elements,-attributes-and-apis:dom-table-summary'><c- g>summary</c-></a>;
  [<a href='#cereactions' id='other-elements,-attributes-and-apis:cereactions-81'><c- g>CEReactions</c-></a>] <c- b>attribute</c-> <c- b>DOMString</c-> <a href='#dom-table-width' id='other-elements,-attributes-and-apis:dom-table-width'><c- g>width</c-></a>;

  [<a href='#cereactions' id='other-elements,-attributes-and-apis:cereactions-82'><c- g>CEReactions</c-></a>] <c- b>attribute</c-> [<c- g>TreatNullAs</c->=<c- n>EmptyString</c->] <c- b>DOMString</c-> <a href='#dom-table-bgcolor' id='other-elements,-attributes-and-apis:dom-table-bgcolor'><c- g>bgColor</c-></a>;
  [<a href='#cereactions' id='other-elements,-attributes-and-apis:cereactions-83'><c- g>CEReactions</c-></a>] <c- b>attribute</c-> [<c- g>TreatNullAs</c->=<c- n>EmptyString</c->] <c- b>DOMString</c-> <a href='#dom-table-cellpadding' id='other-elements,-attributes-and-apis:dom-table-cellpadding'><c- g>cellPadding</c-></a>;
  [<a href='#cereactions' id='other-elements,-attributes-and-apis:cereactions-84'><c- g>CEReactions</c-></a>] <c- b>attribute</c-> [<c- g>TreatNullAs</c->=<c- n>EmptyString</c->] <c- b>DOMString</c-> <a href='#dom-table-cellspacing' id='other-elements,-attributes-and-apis:dom-table-cellspacing'><c- g>cellSpacing</c-></a>;
};</code></pre>

  <p>The <dfn id=dom-table-align><code>align</code></dfn>, <dfn id=dom-table-border><code>border</code></dfn>, <dfn id=dom-table-frame><code>frame</code></dfn>, <dfn id=dom-table-summary><code>summary</code></dfn>, <dfn id=dom-table-rules><code>rules</code></dfn>, and <dfn id=dom-table-width><code>width</code></dfn>, IDL attributes of the <code id=other-elements,-attributes-and-apis:the-table-element><a href=#the-table-element>table</a></code> element
  must <a href=#reflect id=other-elements,-attributes-and-apis:reflect-50>reflect</a> the respective content attributes of the same name.</p>

  <p>The <dfn id=dom-table-bgcolor><code>bgColor</code></dfn> IDL attribute of the
  <code id=other-elements,-attributes-and-apis:the-table-element-2><a href=#the-table-element>table</a></code> element must <a href=#reflect id=other-elements,-attributes-and-apis:reflect-51>reflect</a> the element's <code id=other-elements,-attributes-and-apis:attr-table-bgcolor><a href=#attr-table-bgcolor>bgcolor</a></code> content attribute.</p>

  <p>The <dfn id=dom-table-cellpadding><code>cellPadding</code></dfn> IDL attribute of the
  <code id=other-elements,-attributes-and-apis:the-table-element-3><a href=#the-table-element>table</a></code> element must <a href=#reflect id=other-elements,-attributes-and-apis:reflect-52>reflect</a> the element's <code id=other-elements,-attributes-and-apis:attr-table-cellpadding><a href=#attr-table-cellpadding>cellpadding</a></code> content attribute.</p>

  <p>The <dfn id=dom-table-cellspacing><code>cellSpacing</code></dfn> IDL attribute of the
  <code id=other-elements,-attributes-and-apis:the-table-element-4><a href=#the-table-element>table</a></code> element must <a href=#reflect id=other-elements,-attributes-and-apis:reflect-53>reflect</a> the element's <code id=other-elements,-attributes-and-apis:attr-table-cellspacing><a href=#attr-table-cellspacing>cellspacing</a></code> content attribute.</p>

  <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-85'><c- g>CEReactions</c-></a>] <c- b>attribute</c-> <c- b>DOMString</c-> <a href='#dom-tbody-align' id='other-elements,-attributes-and-apis:dom-tbody-align'><c- g>align</c-></a>;
  [<a href='#cereactions' id='other-elements,-attributes-and-apis:cereactions-86'><c- g>CEReactions</c-></a>] <c- b>attribute</c-> <c- b>DOMString</c-> <a href='#dom-tbody-ch' id='other-elements,-attributes-and-apis:dom-tbody-ch'><c- g>ch</c-></a>;
  [<a href='#cereactions' id='other-elements,-attributes-and-apis:cereactions-87'><c- g>CEReactions</c-></a>] <c- b>attribute</c-> <c- b>DOMString</c-> <a href='#dom-tbody-choff' id='other-elements,-attributes-and-apis:dom-tbody-choff'><c- g>chOff</c-></a>;
  [<a href='#cereactions' id='other-elements,-attributes-and-apis:cereactions-88'><c- g>CEReactions</c-></a>] <c- b>attribute</c-> <c- b>DOMString</c-> <a href='#dom-tbody-valign' id='other-elements,-attributes-and-apis:dom-tbody-valign'><c- g>vAlign</c-></a>;
};</code></pre>

  <p>The <dfn id=dom-tbody-align><code>align</code></dfn> IDL attribute of the
  <code id=other-elements,-attributes-and-apis:the-tbody-element><a href=#the-tbody-element>tbody</a></code>, <code id=other-elements,-attributes-and-apis:the-thead-element><a href=#the-thead-element>thead</a></code>, and <code id=other-elements,-attributes-and-apis:the-tfoot-element><a href=#the-tfoot-element>tfoot</a></code> elements must <a href=#reflect id=other-elements,-attributes-and-apis:reflect-54>reflect</a>
  the content attribute of the same name.</p>

  <p>The <dfn id=dom-tbody-ch><code>ch</code></dfn> IDL attribute of the <code id=other-elements,-attributes-and-apis:the-tbody-element-2><a href=#the-tbody-element>tbody</a></code>,
  <code id=other-elements,-attributes-and-apis:the-thead-element-2><a href=#the-thead-element>thead</a></code>, and <code id=other-elements,-attributes-and-apis:the-tfoot-element-2><a href=#the-tfoot-element>tfoot</a></code> elements must <a href=#reflect id=other-elements,-attributes-and-apis:reflect-55>reflect</a> the elements' <code id=other-elements,-attributes-and-apis:attr-tbody-char><a href=#attr-tbody-char>char</a></code> content attributes.</p>

  <p>The <dfn id=dom-tbody-choff><code>chOff</code></dfn> IDL attribute of the
  <code id=other-elements,-attributes-and-apis:the-tbody-element-3><a href=#the-tbody-element>tbody</a></code>, <code id=other-elements,-attributes-and-apis:the-thead-element-3><a href=#the-thead-element>thead</a></code>, and <code id=other-elements,-attributes-and-apis:the-tfoot-element-3><a href=#the-tfoot-element>tfoot</a></code> elements must <a href=#reflect id=other-elements,-attributes-and-apis:reflect-56>reflect</a>
  the elements' <code id=other-elements,-attributes-and-apis:attr-tbody-charoff><a href=#attr-tbody-charoff>charoff</a></code> content attributes.</p>

  <p>The <dfn id=dom-tbody-valign><code>vAlign</code></dfn> IDL attribute of the
  <code id=other-elements,-attributes-and-apis:the-tbody-element-4><a href=#the-tbody-element>tbody</a></code>, <code id=other-elements,-attributes-and-apis:the-thead-element-4><a href=#the-thead-element>thead</a></code>, and <code id=other-elements,-attributes-and-apis:the-tfoot-element-4><a href=#the-tfoot-element>tfoot</a></code> element must <a href=#reflect id=other-elements,-attributes-and-apis:reflect-57>reflect</a>
  the elements' <code id=other-elements,-attributes-and-apis:attr-tbody-valign><a href=#attr-tbody-valign>valign</a></code> content attributes.</p>

  <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-89'><c- g>CEReactions</c-></a>] <c- b>attribute</c-> <c- b>DOMString</c-> <a href='#dom-tdth-align' id='other-elements,-attributes-and-apis:dom-tdth-align'><c- g>align</c-></a>;
  [<a href='#cereactions' id='other-elements,-attributes-and-apis:cereactions-90'><c- g>CEReactions</c-></a>] <c- b>attribute</c-> <c- b>DOMString</c-> <a href='#dom-tdth-axis' id='other-elements,-attributes-and-apis:dom-tdth-axis'><c- g>axis</c-></a>;
  [<a href='#cereactions' id='other-elements,-attributes-and-apis:cereactions-91'><c- g>CEReactions</c-></a>] <c- b>attribute</c-> <c- b>DOMString</c-> <a href='#dom-tdth-height' id='other-elements,-attributes-and-apis:dom-tdth-height'><c- g>height</c-></a>;
  [<a href='#cereactions' id='other-elements,-attributes-and-apis:cereactions-92'><c- g>CEReactions</c-></a>] <c- b>attribute</c-> <c- b>DOMString</c-> <a href='#dom-tdth-width' id='other-elements,-attributes-and-apis:dom-tdth-width'><c- g>width</c-></a>;

  [<a href='#cereactions' id='other-elements,-attributes-and-apis:cereactions-93'><c- g>CEReactions</c-></a>] <c- b>attribute</c-> <c- b>DOMString</c-> <a href='#dom-tdth-ch' id='other-elements,-attributes-and-apis:dom-tdth-ch'><c- g>ch</c-></a>;
  [<a href='#cereactions' id='other-elements,-attributes-and-apis:cereactions-94'><c- g>CEReactions</c-></a>] <c- b>attribute</c-> <c- b>DOMString</c-> <a href='#dom-tdth-choff' id='other-elements,-attributes-and-apis:dom-tdth-choff'><c- g>chOff</c-></a>;
  [<a href='#cereactions' id='other-elements,-attributes-and-apis:cereactions-95'><c- g>CEReactions</c-></a>] <c- b>attribute</c-> <c- b>boolean</c-> <a href='#dom-tdth-nowrap' id='other-elements,-attributes-and-apis:dom-tdth-nowrap'><c- g>noWrap</c-></a>;
  [<a href='#cereactions' id='other-elements,-attributes-and-apis:cereactions-96'><c- g>CEReactions</c-></a>] <c- b>attribute</c-> <c- b>DOMString</c-> <a href='#dom-tdth-valign' id='other-elements,-attributes-and-apis:dom-tdth-valign'><c- g>vAlign</c-></a>;

  [<a href='#cereactions' id='other-elements,-attributes-and-apis:cereactions-97'><c- g>CEReactions</c-></a>] <c- b>attribute</c-> [<c- g>TreatNullAs</c->=<c- n>EmptyString</c->] <c- b>DOMString</c-> <a href='#dom-tdth-bgcolor' id='other-elements,-attributes-and-apis:dom-tdth-bgcolor'><c- g>bgColor</c-></a>;
};</code></pre>

  <p>The <dfn id=dom-tdth-align><code>align</code></dfn>, <dfn id=dom-tdth-axis><code>axis</code></dfn>, <dfn id=dom-tdth-height><code>height</code></dfn>, and <dfn id=dom-tdth-width><code>width</code></dfn> IDL attributes of the <code id=other-elements,-attributes-and-apis:the-td-element><a href=#the-td-element>td</a></code> and
  <code id=other-elements,-attributes-and-apis:the-th-element><a href=#the-th-element>th</a></code> elements must <a href=#reflect id=other-elements,-attributes-and-apis:reflect-58>reflect</a> the respective content attributes of the same
  name.</p>

  <p>The <dfn id=dom-tdth-ch><code>ch</code></dfn> IDL attribute of the <code id=other-elements,-attributes-and-apis:the-td-element-2><a href=#the-td-element>td</a></code> and
  <code id=other-elements,-attributes-and-apis:the-th-element-2><a href=#the-th-element>th</a></code> elements must <a href=#reflect id=other-elements,-attributes-and-apis:reflect-59>reflect</a> the elements' <code id=other-elements,-attributes-and-apis:attr-tdth-char><a href=#attr-tdth-char>char</a></code> content attributes.</p>

  <p>The <dfn id=dom-tdth-choff><code>chOff</code></dfn> IDL attribute of the <code id=other-elements,-attributes-and-apis:the-td-element-3><a href=#the-td-element>td</a></code>
  and <code id=other-elements,-attributes-and-apis:the-th-element-3><a href=#the-th-element>th</a></code> elements must <a href=#reflect id=other-elements,-attributes-and-apis:reflect-60>reflect</a> the elements' <code id=other-elements,-attributes-and-apis:attr-tdth-charoff><a href=#attr-tdth-charoff>charoff</a></code> content attributes.</p>

  <p>The <dfn id=dom-tdth-nowrap><code>noWrap</code></dfn> IDL attribute of the <code id=other-elements,-attributes-and-apis:the-td-element-4><a href=#the-td-element>td</a></code>
  and <code id=other-elements,-attributes-and-apis:the-th-element-4><a href=#the-th-element>th</a></code> elements must <a href=#reflect id=other-elements,-attributes-and-apis:reflect-61>reflect</a> the elements' <code id=other-elements,-attributes-and-apis:attr-tdth-nowrap><a href=#attr-tdth-nowrap>nowrap</a></code> content attributes.</p>

  <p>The <dfn id=dom-tdth-valign><code>vAlign</code></dfn> IDL attribute of the <code id=other-elements,-attributes-and-apis:the-td-element-5><a href=#the-td-element>td</a></code>
  and <code id=other-elements,-attributes-and-apis:the-th-element-5><a href=#the-th-element>th</a></code> elements must <a href=#reflect id=other-elements,-attributes-and-apis:reflect-62>reflect</a> the elements' <code id=other-elements,-attributes-and-apis:attr-tdth-valign><a href=#attr-tdth-valign>valign</a></code> content attributes.</p>

  <p>The <dfn id=dom-tdth-bgcolor><code>bgColor</code></dfn> IDL attribute of the
  <code id=other-elements,-attributes-and-apis:the-td-element-6><a href=#the-td-element>td</a></code> and <code id=other-elements,-attributes-and-apis:the-th-element-6><a href=#the-th-element>th</a></code> elements must <a href=#reflect id=other-elements,-attributes-and-apis:reflect-63>reflect</a> the elements' <code id=other-elements,-attributes-and-apis:attr-tdth-bgcolor><a href=#attr-tdth-bgcolor>bgcolor</a></code> content attributes.</p>

  <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-98'><c- g>CEReactions</c-></a>] <c- b>attribute</c-> <c- b>DOMString</c-> <a href='#dom-tr-align' id='other-elements,-attributes-and-apis:dom-tr-align'><c- g>align</c-></a>;
  [<a href='#cereactions' id='other-elements,-attributes-and-apis:cereactions-99'><c- g>CEReactions</c-></a>] <c- b>attribute</c-> <c- b>DOMString</c-> <a href='#dom-tr-ch' id='other-elements,-attributes-and-apis:dom-tr-ch'><c- g>ch</c-></a>;
  [<a href='#cereactions' id='other-elements,-attributes-and-apis:cereactions-100'><c- g>CEReactions</c-></a>] <c- b>attribute</c-> <c- b>DOMString</c-> <a href='#dom-tr-choff' id='other-elements,-attributes-and-apis:dom-tr-choff'><c- g>chOff</c-></a>;
  [<a href='#cereactions' id='other-elements,-attributes-and-apis:cereactions-101'><c- g>CEReactions</c-></a>] <c- b>attribute</c-> <c- b>DOMString</c-> <a href='#dom-tr-valign' id='other-elements,-attributes-and-apis:dom-tr-valign'><c- g>vAlign</c-></a>;

  [<a href='#cereactions' id='other-elements,-attributes-and-apis:cereactions-102'><c- g>CEReactions</c-></a>] <c- b>attribute</c-> [<c- g>TreatNullAs</c->=<c- n>EmptyString</c->] <c- b>DOMString</c-> <a href='#dom-tr-bgcolor' id='other-elements,-attributes-and-apis:dom-tr-bgcolor'><c- g>bgColor</c-></a>;
};</code></pre>

  <p>The <dfn id=dom-tr-align><code>align</code></dfn> IDL attribute of the <code id=other-elements,-attributes-and-apis:the-tr-element><a href=#the-tr-element>tr</a></code>
  element must <a href=#reflect id=other-elements,-attributes-and-apis:reflect-64>reflect</a> the content attribute of the same name.</p>

  <p>The <dfn id=dom-tr-ch><code>ch</code></dfn> IDL attribute of the <code id=other-elements,-attributes-and-apis:the-tr-element-2><a href=#the-tr-element>tr</a></code> element
  must <a href=#reflect id=other-elements,-attributes-and-apis:reflect-65>reflect</a> the element's <code id=other-elements,-attributes-and-apis:attr-tr-char><a href=#attr-tr-char>char</a></code> content
  attribute.</p>

  <p>The <dfn id=dom-tr-choff><code>chOff</code></dfn> IDL attribute of the <code id=other-elements,-attributes-and-apis:the-tr-element-3><a href=#the-tr-element>tr</a></code>
  element must <a href=#reflect id=other-elements,-attributes-and-apis:reflect-66>reflect</a> the element's <code id=other-elements,-attributes-and-apis:attr-tr-charoff><a href=#attr-tr-charoff>charoff</a></code>
  content attribute.</p>

  <p>The <dfn id=dom-tr-valign><code>vAlign</code></dfn> IDL attribute of the <code id=other-elements,-attributes-and-apis:the-tr-element-4><a href=#the-tr-element>tr</a></code>
  element must <a href=#reflect id=other-elements,-attributes-and-apis:reflect-67>reflect</a> the element's <code id=other-elements,-attributes-and-apis:attr-tr-valign><a href=#attr-tr-valign>valign</a></code> content
  attribute.</p>

  <p>The <dfn id=dom-tr-bgcolor><code>bgColor</code></dfn> IDL attribute of the <code id=other-elements,-attributes-and-apis:the-tr-element-5><a href=#the-tr-element>tr</a></code>
  element must <a href=#reflect id=other-elements,-attributes-and-apis:reflect-68>reflect</a> the element's <code id=other-elements,-attributes-and-apis:attr-tr-bgcolor><a href=#attr-tr-bgcolor>bgcolor</a></code>
  content attribute.</p>

  <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-103'><c- g>CEReactions</c-></a>] <c- b>attribute</c-> <c- b>boolean</c-> <a href='#dom-ul-compact' id='other-elements,-attributes-and-apis:dom-ul-compact'><c- g>compact</c-></a>;
  [<a href='#cereactions' id='other-elements,-attributes-and-apis:cereactions-104'><c- g>CEReactions</c-></a>] <c- b>attribute</c-> <c- b>DOMString</c-> <a href='#dom-ul-type' id='other-elements,-attributes-and-apis:dom-ul-type'><c- g>type</c-></a>;
};</code></pre>

  <p>The <dfn id=dom-ul-compact><code>compact</code></dfn> and <dfn id=dom-ul-type><code>type</code></dfn> IDL attributes of the <code id=other-elements,-attributes-and-apis:the-ul-element-2><a href=#the-ul-element>ul</a></code> element must
  <a href=#reflect id=other-elements,-attributes-and-apis:reflect-69>reflect</a> the respective content attributes of the same name.</p>

  <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-4><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-105'><c- g>CEReactions</c-></a>] <c- b>attribute</c-> [<c- g>TreatNullAs</c->=<c- n>EmptyString</c->] <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-106'><c- g>CEReactions</c-></a>] <c- b>attribute</c-> [<c- g>TreatNullAs</c->=<c- n>EmptyString</c->] <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-107'><c- g>CEReactions</c-></a>] <c- b>attribute</c-> [<c- g>TreatNullAs</c->=<c- n>EmptyString</c->] <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-108'><c- g>CEReactions</c-></a>] <c- b>attribute</c-> [<c- g>TreatNullAs</c->=<c- n>EmptyString</c->] <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-109'><c- g>CEReactions</c-></a>] <c- b>attribute</c-> [<c- g>TreatNullAs</c->=<c- n>EmptyString</c->] <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 href='https://dom.spec.whatwg.org/#interface-htmlcollection' data-x-internal='htmlcollection' id='other-elements,-attributes-and-apis: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 href='https://dom.spec.whatwg.org/#interface-htmlcollection' data-x-internal='htmlcollection' id='other-elements,-attributes-and-apis:htmlcollection-2'><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>void</c-> <a href='#dom-document-clear' id='other-elements,-attributes-and-apis:dom-document-clear'><c- g>clear</c-></a>();
  <c- b>void</c-> <a href='#dom-document-captureevents' id='other-elements,-attributes-and-apis:dom-document-captureevents'><c- g>captureEvents</c-></a>();
  <c- b>void</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>

  <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-70>reflect</a> the content attribute on <a href=#the-body-element-2 id=other-elements,-attributes-and-apis:the-body-element-2-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-3>the body
  element</a> is a <code id=other-elements,-attributes-and-apis:the-body-element-7><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-4>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> Content attribute
   <tbody><tr><td><dfn id=dom-document-fgcolor><code>fgColor</code></dfn>
     <td><code id=other-elements,-attributes-and-apis:attr-body-text-2><a href=#attr-body-text>text</a></code>
    <tr><td><dfn id=dom-document-linkcolor><code>linkColor</code></dfn>
     <td><code id=other-elements,-attributes-and-apis:attr-body-link-2><a href=#attr-body-link>link</a></code>
    <tr><td><dfn id=dom-document-vlinkcolor><code>vlinkColor</code></dfn>
     <td><code id=other-elements,-attributes-and-apis:attr-body-vlink-2><a href=#attr-body-vlink>vlink</a></code>
    <tr><td><dfn id=dom-document-alinkcolor><code>alinkColor</code></dfn>
     <td><code id=other-elements,-attributes-and-apis:attr-body-alink-2><a href=#attr-body-alink>alink</a></code>
    <tr><td><dfn id=dom-document-bgcolor><code>bgColor</code></dfn>
     <td><code id=other-elements,-attributes-and-apis:attr-body-bgcolor-2><a href=#attr-body-bgcolor>bgcolor</a></code>
  </table>

  <hr>

  <p>The <dfn id=dom-document-anchors><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-2><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>

  <p>The <dfn id=dom-document-applets><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>

  <p>The <dfn id=dom-document-clear><code>clear()</code></dfn>, <dfn id=dom-document-captureevents><code>captureEvents()</code></dfn>, and <dfn id=dom-document-releaseevents><code>releaseEvents()</code></dfn> methods must do nothing.</p>

  <hr>

  <p>The <dfn id=dom-document-all><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>

  <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>void</c-> <a href='#dom-window-captureevents' id='other-elements,-attributes-and-apis:dom-window-captureevents'><c- g>captureEvents</c-></a>();
  <c- b>void</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>

  <p>The <dfn id=dom-window-captureevents><code>captureEvents()</code></dfn> and <dfn id=dom-window-releaseevents><code>releaseEvents()</code></dfn> methods must do nothing.</p>

  <p>The <dfn id=dom-external><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>

  <pre><code class='idl'>[<c- g>Exposed</c->=<c- n>Window</c->,
 <c- g>NoInterfaceObject</c->]
<c- b>interface</c-> <dfn id='external'><c- g>External</c-></dfn> {
  <c- b>void</c-> <a href='#dom-external-addsearchprovider' id='other-elements,-attributes-and-apis:dom-external-addsearchprovider'><c- g>AddSearchProvider</c-></a>();
  <c- b>void</c-> <a href='#dom-external-issearchproviderinstalled' id='other-elements,-attributes-and-apis:dom-external-issearchproviderinstalled'><c- g>IsSearchProviderInstalled</c-></a>();
};</code></pre>

  <p>The <dfn id=dom-external-addsearchprovider><code>AddSearchProvider()</code></dfn> and
  <dfn id=dom-external-issearchproviderinstalled><code>IsSearchProviderInstalled()</code></dfn> methods
  must do nothing.</p>

  



  

  <h2 id=iana><span class=secno>16</span> IANA considerations<a href=#iana class=self-link></a></h2>

  


  <h3 id=text/html><span class=secno>16.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:<dd>text<dt>Subtype name:<dd>html<dt>Required parameters:<dd>No required parameters<dt>Optional parameters:<dd>
    <dl><dt><code>charset</code><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>

     </dl>
   <dt>Encoding considerations:<dd>

    8bit (see the section on <a href=#character-encoding-declaration id=text/html:character-encoding-declaration-2>character encoding
    declarations</a>)

   <dt>Security considerations:<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>

   <dt>Interoperability considerations:<dd>
    Rules for processing both conforming and non-conforming content
    are defined in this specification.
   <dt>Published specification:<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>.
   <dt>Applications that use this media type:<dd>
    Web browsers, tools for processing Web content, HTML authoring
    tools, search engines, validators.
   <dt>Additional information:<dd>
    <dl><dt>Magic number(s):<dd>No sequence of bytes can uniquely identify an HTML
     document. More information on detecting HTML documents is
     available in the WHATWG MIME Sniffing standard. <a href=#refsMIMESNIFF>[MIMESNIFF]</a><dt>File extension(s):<dd>"<code>html</code>" and "<code>htm</code>"
     are commonly, but certainly not exclusively, used as the
     extension for HTML documents.<dt>Macintosh file type code(s):<dd><code>TEXT</code></dl>
   <dt>Person &amp; email address to contact for further information:<dd>Ian Hickson &lt;ian@hixie.ch><dt>Intended usage:<dd>Common<dt>Restrictions on usage:<dd>No restrictions apply.<dt>Author:<dd>Ian Hickson &lt;ian@hixie.ch><dt>Change controller:<dd>W3C</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 <a href=#the-indicated-part-of-the-document id=text/html:the-indicated-part-of-the-document>the indicated part of the document</a> or provide state information for
  in-page scripts.</p>



  <h3 id=multipart/x-mixed-replace><span class=secno>16.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:<dd>multipart<dt>Subtype name:<dd>x-mixed-replace<dt>Required parameters:<dd>
    <ul class=brief><li><code>boundary</code> (defined in RFC2046) <a href=#refsRFC2046>[RFC2046]</a>
    </ul>
   <dt>Optional parameters:<dd>No optional parameters.<dt>Encoding considerations:<dd>binary<dt>Security considerations:<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>.
   <dt>Interoperability considerations:<dd>
    None.
   <dt>Published specification:<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>
   <dt>Applications that use this media type:<dd>
    This type is intended to be used in resources generated by Web servers, for consumption by Web browsers.
   <dt>Additional information:<dd>
    <dl><dt>Magic number(s):<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.<dt>File extension(s):<dd>No specific file extensions are recommended for this type.<dt>Macintosh file type code(s):<dd>No specific Macintosh file type codes are recommended for this type.</dl>
   <dt>Person &amp; email address to contact for further information:<dd>Ian Hickson &lt;ian@hixie.ch><dt>Intended usage:<dd>Common<dt>Restrictions on usage:<dd>No restrictions apply.<dt>Author:<dd>Ian Hickson &lt;ian@hixie.ch><dt>Change controller:<dd>W3C</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>16.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:<dd>application<dt>Subtype name:<dd>xhtml+xml<dt>Required parameters:<dd>Same as for <code id=application/xhtml+xml:application/xml><a href=#application/xml>application/xml</a></code> <a href=#refsRFC7303>[RFC7303]</a><dt>Optional parameters:<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><dt>Encoding considerations:<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><dt>Security considerations:<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><dt>Interoperability considerations:<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><dt id=authors-using-xhtml>Published specification:<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 the XML specification, the Namespaces in
   XML specification, and this specification. <a href=#refsXML>[XML]</a> <a href=#refsXMLNS>[XMLNS]</a><dt>Applications that use this media type:<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><dt>Additional information:<dd>
    <dl><dt>Magic number(s):<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><dt>File extension(s):<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>.<dt>Macintosh file type code(s):<dd><code>TEXT</code></dl>
   <dt>Person &amp; email address to contact for further information:<dd>Ian Hickson &lt;ian@hixie.ch><dt>Intended usage:<dd>Common<dt>Restrictions on usage:<dd>No restrictions apply.<dt>Author:<dd>Ian Hickson &lt;ian@hixie.ch><dt>Change controller:<dd>W3C</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/cache-manifest><span class=secno>16.4</span> <dfn><code>text/cache-manifest</code></dfn><a href=#text/cache-manifest 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:<dd>text<dt>Subtype name:<dd>cache-manifest<dt>Required parameters:<dd>No parameters<dt>Optional parameters:<dd>
    <dl><dt><code>charset</code><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>

     </dl>
   <dt>Encoding considerations:<dd>8bit (always UTF-8)<dt>Security considerations:<dd>
    <p>Cache manifests themselves pose no immediate risk unless
    sensitive information is included within the
    manifest. Implementations, however, are required to follow
    specific rules when populating a cache based on a cache manifest,
    to ensure that certain origin-based restrictions are
    honored. Failure to correctly implement these rules can result in
    information leakage, cross-site scripting attacks, and the
    like.</p>
   <dt>Interoperability considerations:<dd>
    Rules for processing both conforming and non-conforming content
    are defined in this specification.
   <dt>Published specification:<dd>
    This document is the relevant specification.
   <dt>Applications that use this media type:<dd>
    Web browsers.
   <dt>Additional information:<dd>
    <dl><dt>Magic number(s):<dd>Cache manifests begin with the string "<code>CACHE
     MANIFEST</code>", followed by either a U+0020 SPACE character, a
     U+0009 CHARACTER TABULATION (tab) character, a U+000A LINE FEED
     (LF) character, or a U+000D CARRIAGE RETURN (CR) character.<dt>File extension(s):<dd>"<code>appcache</code>"<dt>Macintosh file type code(s):<dd>No specific Macintosh file type codes are recommended for this type.</dl>
   <dt>Person &amp; email address to contact for further information:<dd>Ian Hickson &lt;ian@hixie.ch><dt>Intended usage:<dd>Common<dt>Restrictions on usage:<dd>No restrictions apply.<dt>Author:<dd>Ian Hickson &lt;ian@hixie.ch><dt>Change controller:<dd>W3C</dl>

  <p><a href=https://url.spec.whatwg.org/#concept-url-fragment id=text/cache-manifest:concept-url-fragment data-x-internal=concept-url-fragment>Fragments</a> have no meaning with
  <code id=text/cache-manifest:text/cache-manifest><a href=#text/cache-manifest>text/cache-manifest</a></code> resources.</p>


  <h3 id=text/ping><span class=secno>16.5</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:<dd>text<dt>Subtype name:<dd>ping<dt>Required parameters:<dd>No parameters<dt>Optional parameters:<dd>
    <dl><dt><code>charset</code><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>

     </dl>
   <dt>Encoding considerations:<dd>Not applicable.<dt>Security considerations:<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>
   <dt>Interoperability considerations:<dd>
    Rules applicable to this type are defined in this specification.
   <dt>Published specification:<dd>
    This document is the relevant specification.
   <dt>Applications that use this media type:<dd>
    Web browsers.
   <dt>Additional information:<dd>
    <dl><dt>Magic number(s):<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>`).<dt>File extension(s):<dd>No specific file extension is recommended for this type.<dt>Macintosh file type code(s):<dd>No specific Macintosh file type codes are recommended for this type.</dl>
   <dt>Person &amp; email address to contact for further information:<dd>Ian Hickson &lt;ian@hixie.ch><dt>Intended usage:<dd>Common<dt>Restrictions on usage:<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.<dt>Author:<dd>Ian Hickson &lt;ian@hixie.ch><dt>Change controller:<dd>W3C</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>16.6</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:<dd>application<dt>Subtype name:<dd>microdata+json<dt>Required parameters:<dd>Same as for <code id=application/microdata+json:application/json><a href=#application/json>application/json</a></code> <a href=#refsJSON>[JSON]</a><dt>Optional parameters:<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><dt>Encoding considerations:<dd>8bit (always UTF-8)<dt>Security considerations:<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><dt>Interoperability considerations:<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><dt>Published specification:<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
    the JSON specification and this specification. <a href=#refsJSON>[JSON]</a>

   <dt>Applications that use this media type:<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>

   <dt>Additional information:<dd>
    <dl><dt>Magic number(s):<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><dt>File extension(s):<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><dt>Macintosh file type code(s):<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></dl>
   <dt>Person &amp; email address to contact for further information:<dd>Ian Hickson &lt;ian@hixie.ch><dt>Intended usage:<dd>Common<dt>Restrictions on usage:<dd>No restrictions apply.<dt>Author:<dd>Ian Hickson &lt;ian@hixie.ch><dt>Change controller:<dd>W3C</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=text/event-stream><span class=secno>16.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:<dd>text<dt>Subtype name:<dd>event-stream<dt>Required parameters:<dd>No parameters<dt>Optional parameters:<dd>
    <dl><dt><code>charset</code><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>

     </dl>
   <dt>Encoding considerations:<dd>8bit (always UTF-8)<dt>Security considerations:<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>

   <dt>Interoperability considerations:<dd>
    Rules for processing both conforming and non-conforming content are defined in this
    specification.
   <dt>Published specification:<dd>
    This document is the relevant specification.
   <dt>Applications that use this media type:<dd>
    Web browsers and tools using Web services.
   <dt>Additional information:<dd>
    <dl><dt>Magic number(s):<dd>No sequence of bytes can uniquely identify an event stream.<dt>File extension(s):<dd>No specific file extensions are recommended for this type.<dt>Macintosh file type code(s):<dd>No specific Macintosh file type codes are recommended for this type.</dl>
   <dt>Person &amp; email address to contact for further information:<dd>Ian Hickson &lt;ian@hixie.ch><dt>Intended usage:<dd>Common<dt>Restrictions on usage:<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.<dt>Author:<dd>Ian Hickson &lt;ian@hixie.ch><dt>Change controller:<dd>W3C</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=ping-from><span class=secno>16.8</span> `<dfn><code>Ping-From</code></dfn>`<a href=#ping-from class=self-link></a></h3>

  <p>This section describes a header for registration in the Permanent Message Header Field
  Registry. <a href=#refsRFC3864>[RFC3864]</a></p>

  <dl><dt>Header field name:<dd>Ping-From<dt>Applicable protocol:<dd>http<dt>Status:<dd>standard<dt>Author/Change controller:<dd>W3C<dt>Specification document(s):<dd>
    This document is the relevant specification.
   <dt>Related information:<dd>None.</dl>


  <h3 id=ping-to><span class=secno>16.9</span> `<dfn><code>Ping-To</code></dfn>`<a href=#ping-to class=self-link></a></h3>

  <p>This section describes a header for registration in the Permanent Message Header Field
  Registry. <a href=#refsRFC3864>[RFC3864]</a></p>

  <dl><dt>Header field name:<dd>Ping-To<dt>Applicable protocol:<dd>http<dt>Status:<dd>standard<dt>Author/Change controller:<dd>W3C<dt>Specification document(s):<dd>
    This document is the relevant specification.
   <dt>Related information:<dd>None.</dl>


  <h3 id=refresh><span class=secno>16.10</span> `<dfn><code>Refresh</code></dfn>`<a href=#refresh class=self-link></a></h3>

  <p>This section describes a header for registration in the Permanent Message Header Field
  Registry. <a href=#refsRFC3864>[RFC3864]</a></p>

  <dl><dt>Header field name:<dd>Refresh<dt>Applicable protocol:<dd>http<dt>Status:<dd>standard<dt>Author/Change controller:<dd>WHATWG<dt>Specification document(s):<dd>
    This document is the relevant specification.
   <dt>Related information:<dd>None.</dl>


  <h3 id=last-event-id><span class=secno>16.11</span> `<dfn><code>Last-Event-ID</code></dfn>`<a href=#last-event-id class=self-link></a></h3>

  <p>This section describes a header for registration in the Permanent Message Header Field
  Registry. <a href=#refsRFC3864>[RFC3864]</a></p>

  <dl><dt>Header field name:<dd>Last-Event-ID<dt>Applicable protocol:<dd>http<dt>Status:<dd>standard<dt>Author/Change controller:<dd>W3C<dt>Specification document(s):<dd>
    This document is the relevant specification.
   <dt>Related information:<dd>None.</dl>


  <h3 id=web+-scheme-prefix><span class=secno>16.12</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:<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>.
   <dt>Status:<dd>Permanent<dt>Scheme syntax:<dd>Scheme-specific.<dt>Scheme semantics:<dd>Scheme-specific.<dt>Encoding considerations:<dd>All "<code>web+</code>" schemes should use UTF-8 encodings where relevant.<dt>Applications/protocols that use this scheme name:<dd>Scheme-specific.<dt>Interoperability considerations:<dd>The scheme is expected to be used in the context of Web applications.<dt>Security considerations:<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.
    network transfer protocols like HTTP or FTP). Similarly, such schemes must not store
    confidential information in their URLs, such as usernames, passwords, personal information, or
    confidential project names.

   <dt>Contact:<dd>Ian Hickson &lt;ian@hixie.ch><dt>Change controller:<dd>Ian Hickson &lt;ian@hixie.ch><dt>References:<dd>
    <cite>Custom scheme handlers</cite>, HTML Living Standard:
    <a href=#custom-handlers>https://html.spec.whatwg.org/#custom-handlers</a>
   </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> Description
     <th> Categories
     <th> Parents†
     <th> Children
     <th> Attributes
     <th> Interface
   <tbody><tr><th><code id=elements-3:the-a-element><a href=#the-a-element>a</a></code><td>Hyperlink<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><a href=#phrasing-content-2 id=elements-3:phrasing-content-2-2>phrasing</a><td><a href=#transparent id=elements-3:transparent>transparent</a>*<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><code id=elements-3:htmlanchorelement><a href=#htmlanchorelement>HTMLAnchorElement</a></code><tr><th><code id=elements-3:the-abbr-element><a href=#the-abbr-element>abbr</a></code><td>Abbreviation<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><a href=#phrasing-content-2 id=elements-3:phrasing-content-2-4>phrasing</a><td><a href=#phrasing-content-2 id=elements-3:phrasing-content-2-5>phrasing</a><td><a href=#global-attributes id=elements-3:global-attributes-2>globals</a><td><code id=elements-3:htmlelement><a href=#htmlelement>HTMLElement</a></code><tr><th><code id=elements-3:the-address-element><a href=#the-address-element>address</a></code><td>Contact information for a page or <code id=elements-3:the-article-element><a href=#the-article-element>article</a></code> element<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><a href=#flow-content-2 id=elements-3:flow-content-2-4>flow</a><td><a href=#flow-content-2 id=elements-3:flow-content-2-5>flow</a>*<td><a href=#global-attributes id=elements-3:global-attributes-3>globals</a><td><code id=elements-3:htmlelement-2><a href=#htmlelement>HTMLElement</a></code><tr><th><code id=elements-3:the-area-element><a href=#the-area-element>area</a></code><td>Hyperlink or dead area on an image map<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><a href=#phrasing-content-2 id=elements-3:phrasing-content-2-7>phrasing</a>*<td>empty<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><code id=elements-3:htmlareaelement><a href=#htmlareaelement>HTMLAreaElement</a></code><tr><th><code id=elements-3:the-article-element-2><a href=#the-article-element>article</a></code><td>Self-contained syndicatable or reusable composition<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><a href=#flow-content-2 id=elements-3:flow-content-2-8>flow</a><td><a href=#flow-content-2 id=elements-3:flow-content-2-9>flow</a><td><a href=#global-attributes id=elements-3:global-attributes-5>globals</a><td><code id=elements-3:htmlelement-3><a href=#htmlelement>HTMLElement</a></code><tr><th><code id=elements-3:the-aside-element><a href=#the-aside-element>aside</a></code><td>Sidebar for tangentially related content<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><a href=#flow-content-2 id=elements-3:flow-content-2-11>flow</a><td><a href=#flow-content-2 id=elements-3:flow-content-2-12>flow</a><td><a href=#global-attributes id=elements-3:global-attributes-6>globals</a><td><code id=elements-3:htmlelement-4><a href=#htmlelement>HTMLElement</a></code><tr><th><code id=elements-3:the-audio-element><a href=#the-audio-element>audio</a></code><td>Audio player<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><a href=#phrasing-content-2 id=elements-3:phrasing-content-2-9>phrasing</a><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><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><code id=elements-3:htmlaudioelement><a href=#htmlaudioelement>HTMLAudioElement</a></code><tr><th><code id=elements-3:the-b-element><a href=#the-b-element>b</a></code><td>Keywords<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><a href=#phrasing-content-2 id=elements-3:phrasing-content-2-11>phrasing</a><td><a href=#phrasing-content-2 id=elements-3:phrasing-content-2-12>phrasing</a><td><a href=#global-attributes id=elements-3:global-attributes-8>globals</a><td><code id=elements-3:htmlelement-5><a href=#htmlelement>HTMLElement</a></code><tr><th><code id=elements-3:the-base-element><a href=#the-base-element>base</a></code><td>Base URL and default target <a href=#browsing-context id=elements-3:browsing-context>browsing context</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><a href=#metadata-content-2 id=elements-3:metadata-content-2>metadata</a><td><code id=elements-3:the-head-element><a href=#the-head-element>head</a></code><td>empty<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><code id=elements-3:htmlbaseelement><a href=#htmlbaseelement>HTMLBaseElement</a></code><tr><th><code id=elements-3:the-bdi-element><a href=#the-bdi-element>bdi</a></code><td>Text directionality isolation<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><a href=#phrasing-content-2 id=elements-3:phrasing-content-2-14>phrasing</a><td><a href=#phrasing-content-2 id=elements-3:phrasing-content-2-15>phrasing</a><td><a href=#global-attributes id=elements-3:global-attributes-10>globals</a><td><code id=elements-3:htmlelement-6><a href=#htmlelement>HTMLElement</a></code><tr><th><code id=elements-3:the-bdo-element><a href=#the-bdo-element>bdo</a></code><td>Text directionality formatting<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><a href=#phrasing-content-2 id=elements-3:phrasing-content-2-17>phrasing</a><td><a href=#phrasing-content-2 id=elements-3:phrasing-content-2-18>phrasing</a><td><a href=#global-attributes id=elements-3:global-attributes-11>globals</a><td><code id=elements-3:htmlelement-7><a href=#htmlelement>HTMLElement</a></code><tr><th><code id=elements-3:the-blockquote-element><a href=#the-blockquote-element>blockquote</a></code><td>A section quoted from another source<td><a href=#flow-content-2 id=elements-3:flow-content-2-17>flow</a>;
         <a href=#sectioning-root id=elements-3:sectioning-root>sectioning root</a>;
         <a href=#palpable-content-2 id=elements-3:palpable-content-2-10>palpable</a><td><a href=#flow-content-2 id=elements-3:flow-content-2-18>flow</a><td><a href=#flow-content-2 id=elements-3:flow-content-2-19>flow</a><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><code id=elements-3:htmlquoteelement><a href=#htmlquoteelement>HTMLQuoteElement</a></code><tr><th><code id=elements-3:the-body-element><a href=#the-body-element>body</a></code><td>Document body<td><a href=#sectioning-root id=elements-3:sectioning-root-2>sectioning root</a><td><code id=elements-3:the-html-element><a href=#the-html-element>html</a></code><td><a href=#flow-content-2 id=elements-3:flow-content-2-20>flow</a><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-onpagehide><a href=#handler-window-onpagehide>onpagehide</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><code id=elements-3:htmlbodyelement><a href=#htmlbodyelement>HTMLBodyElement</a></code><tr><th><code id=elements-3:the-br-element><a href=#the-br-element>br</a></code><td>Line break, e.g. in poem or postal address<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><a href=#phrasing-content-2 id=elements-3:phrasing-content-2-20>phrasing</a><td>empty<td><a href=#global-attributes id=elements-3:global-attributes-14>globals</a><td><code id=elements-3:htmlbrelement><a href=#htmlbrelement>HTMLBRElement</a></code><tr><th><code id=elements-3:the-button-element><a href=#the-button-element>button</a></code><td>Button control<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><a href=#phrasing-content-2 id=elements-3:phrasing-content-2-22>phrasing</a><td><a href=#phrasing-content-2 id=elements-3:phrasing-content-2-23>phrasing</a>*<td><a href=#global-attributes id=elements-3:global-attributes-15>globals</a>;
         <code id=elements-3:attr-fe-autofocus><a href=#attr-fe-autofocus>autofocus</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-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><code id=elements-3:htmlbuttonelement><a href=#htmlbuttonelement>HTMLButtonElement</a></code><tr><th><code id=elements-3:the-canvas-element><a href=#the-canvas-element>canvas</a></code><td>Scriptable bitmap canvas<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><a href=#phrasing-content-2 id=elements-3:phrasing-content-2-25>phrasing</a><td><a href=#transparent id=elements-3:transparent-3>transparent</a><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><code id=elements-3:htmlcanvaselement><a href=#htmlcanvaselement>HTMLCanvasElement</a></code><tr><th><code id=elements-3:the-caption-element><a href=#the-caption-element>caption</a></code><td>Table caption<td>none<td><code id=elements-3:the-table-element><a href=#the-table-element>table</a></code><td><a href=#flow-content-2 id=elements-3:flow-content-2-24>flow</a>*<td><a href=#global-attributes id=elements-3:global-attributes-17>globals</a><td><code id=elements-3:htmltablecaptionelement><a href=#htmltablecaptionelement>HTMLTableCaptionElement</a></code><tr><th><code id=elements-3:the-cite-element><a href=#the-cite-element>cite</a></code><td>Title of a work<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><a href=#phrasing-content-2 id=elements-3:phrasing-content-2-27>phrasing</a><td><a href=#phrasing-content-2 id=elements-3:phrasing-content-2-28>phrasing</a><td><a href=#global-attributes id=elements-3:global-attributes-18>globals</a><td><code id=elements-3:htmlelement-8><a href=#htmlelement>HTMLElement</a></code><tr><th><code id=elements-3:the-code-element><a href=#the-code-element>code</a></code><td>Computer code<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><a href=#phrasing-content-2 id=elements-3:phrasing-content-2-30>phrasing</a><td><a href=#phrasing-content-2 id=elements-3:phrasing-content-2-31>phrasing</a><td><a href=#global-attributes id=elements-3:global-attributes-19>globals</a><td><code id=elements-3:htmlelement-9><a href=#htmlelement>HTMLElement</a></code><tr><th><code id=elements-3:the-col-element><a href=#the-col-element>col</a></code><td>Table column<td>none<td><code id=elements-3:the-colgroup-element><a href=#the-colgroup-element>colgroup</a></code><td>empty<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><code id=elements-3:htmltablecolelement><a href=#htmltablecolelement>HTMLTableColElement</a></code><tr><th><code id=elements-3:the-colgroup-element-2><a href=#the-colgroup-element>colgroup</a></code><td>Group of columns in a table<td>none<td><code id=elements-3:the-table-element-2><a href=#the-table-element>table</a></code><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><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><code id=elements-3:htmltablecolelement-2><a href=#htmltablecolelement>HTMLTableColElement</a></code><tr><th><code id=elements-3:the-data-element><a href=#the-data-element>data</a></code><td>Machine-readable equivalent<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><a href=#phrasing-content-2 id=elements-3:phrasing-content-2-33>phrasing</a><td><a href=#phrasing-content-2 id=elements-3:phrasing-content-2-34>phrasing</a><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><code id=elements-3:htmldataelement><a href=#htmldataelement>HTMLDataElement</a></code><tr><th><code id=elements-3:the-datalist-element><a href=#the-datalist-element>datalist</a></code><td>Container for options for <a href=#attr-input-list id=elements-3:attr-input-list>combo box control</a><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><a href=#phrasing-content-2 id=elements-3:phrasing-content-2-36>phrasing</a><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><a href=#global-attributes id=elements-3:global-attributes-23>globals</a><td><code id=elements-3:htmldatalistelement><a href=#htmldatalistelement>HTMLDataListElement</a></code><tr><th><code id=elements-3:the-dd-element><a href=#the-dd-element>dd</a></code><td>Content for corresponding <code id=elements-3:the-dt-element><a href=#the-dt-element>dt</a></code> element(s)<td>none<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><a href=#flow-content-2 id=elements-3:flow-content-2-29>flow</a><td><a href=#global-attributes id=elements-3:global-attributes-24>globals</a><td><code id=elements-3:htmlelement-10><a href=#htmlelement>HTMLElement</a></code><tr><th><code id=elements-3:the-del-element><a href=#the-del-element>del</a></code><td>A removal from the document<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>*<td><a href=#phrasing-content-2 id=elements-3:phrasing-content-2-39>phrasing</a><td><a href=#transparent id=elements-3:transparent-4>transparent</a><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><code id=elements-3:htmlmodelement><a href=#htmlmodelement>HTMLModElement</a></code><tr><th><code id=elements-3:the-details-element><a href=#the-details-element>details</a></code><td>Disclosure control for hiding details<td><a href=#flow-content-2 id=elements-3:flow-content-2-31>flow</a>;
         <a href=#sectioning-root id=elements-3:sectioning-root-3>sectioning root</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-16>palpable</a><td><a href=#flow-content-2 id=elements-3:flow-content-2-32>flow</a><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><a href=#global-attributes id=elements-3:global-attributes-26>globals</a>;
         <code id=elements-3:attr-details-open><a href=#attr-details-open>open</a></code><td><code id=elements-3:htmldetailselement><a href=#htmldetailselement>HTMLDetailsElement</a></code><tr><th><code id=elements-3:the-dfn-element><a href=#the-dfn-element>dfn</a></code><td>Defining instance<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-17>palpable</a><td><a href=#phrasing-content-2 id=elements-3:phrasing-content-2-41>phrasing</a><td><a href=#phrasing-content-2 id=elements-3:phrasing-content-2-42>phrasing</a>*<td><a href=#global-attributes id=elements-3:global-attributes-27>globals</a><td><code id=elements-3:htmlelement-11><a href=#htmlelement>HTMLElement</a></code><tr><th><code id=elements-3:the-dialog-element><a href=#the-dialog-element>dialog</a></code><td>Dialog box or window<td><a href=#flow-content-2 id=elements-3:flow-content-2-35>flow</a>;
         <a href=#sectioning-root id=elements-3:sectioning-root-4>sectioning root</a><td><a href=#flow-content-2 id=elements-3:flow-content-2-36>flow</a><td><a href=#flow-content-2 id=elements-3:flow-content-2-37>flow</a><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><code id=elements-3:htmldialogelement><a href=#htmldialogelement>HTMLDialogElement</a></code><tr><th><code id=elements-3:the-div-element-2><a href=#the-div-element>div</a></code><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><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-18>palpable</a><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><td><a href=#flow-content-2 id=elements-3:flow-content-2-40>flow</a><td><a href=#global-attributes id=elements-3:global-attributes-29>globals</a><td><code id=elements-3:htmldivelement><a href=#htmldivelement>HTMLDivElement</a></code><tr><th><code id=elements-3:the-dl-element-4><a href=#the-dl-element>dl</a></code><td>Association list consisting of zero or more name-value groups<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-19>palpable</a><td><a href=#flow-content-2 id=elements-3:flow-content-2-42>flow</a><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><a href=#global-attributes id=elements-3:global-attributes-30>globals</a><td><code id=elements-3:htmldlistelement><a href=#htmldlistelement>HTMLDListElement</a></code><tr><th><code id=elements-3:the-dt-element-3><a href=#the-dt-element>dt</a></code><td>Legend for corresponding <code id=elements-3:the-dd-element-3><a href=#the-dd-element>dd</a></code> element(s)<td>none<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><a href=#flow-content-2 id=elements-3:flow-content-2-43>flow</a>*<td><a href=#global-attributes id=elements-3:global-attributes-31>globals</a><td><code id=elements-3:htmlelement-12><a href=#htmlelement>HTMLElement</a></code><tr><th><code id=elements-3:the-em-element><a href=#the-em-element>em</a></code><td>Stress emphasis<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-20>palpable</a><td><a href=#phrasing-content-2 id=elements-3:phrasing-content-2-44>phrasing</a><td><a href=#phrasing-content-2 id=elements-3:phrasing-content-2-45>phrasing</a><td><a href=#global-attributes id=elements-3:global-attributes-32>globals</a><td><code id=elements-3:htmlelement-13><a href=#htmlelement>HTMLElement</a></code><tr><th><code id=elements-3:the-embed-element><a href=#the-embed-element>embed</a></code><td><a href=#plugin id=elements-3:plugin>Plugin</a><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-21>palpable</a><td><a href=#phrasing-content-2 id=elements-3:phrasing-content-2-47>phrasing</a><td>empty<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><code id=elements-3:htmlembedelement><a href=#htmlembedelement>HTMLEmbedElement</a></code><tr><th><code id=elements-3:the-fieldset-element><a href=#the-fieldset-element>fieldset</a></code><td>Group of form controls<td><a href=#flow-content-2 id=elements-3:flow-content-2-46>flow</a>;
         <a href=#sectioning-root id=elements-3:sectioning-root-5>sectioning root</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-22>palpable</a><td><a href=#flow-content-2 id=elements-3:flow-content-2-47>flow</a><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><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><code id=elements-3:htmlfieldsetelement><a href=#htmlfieldsetelement>HTMLFieldSetElement</a></code><tr><th><code id=elements-3:the-figcaption-element><a href=#the-figcaption-element>figcaption</a></code><td>Caption for <code id=elements-3:the-figure-element><a href=#the-figure-element>figure</a></code><td>none<td><code id=elements-3:the-figure-element-2><a href=#the-figure-element>figure</a></code><td><a href=#flow-content-2 id=elements-3:flow-content-2-49>flow</a><td><a href=#global-attributes id=elements-3:global-attributes-35>globals</a><td><code id=elements-3:htmlelement-14><a href=#htmlelement>HTMLElement</a></code><tr><th><code id=elements-3:the-figure-element-3><a href=#the-figure-element>figure</a></code><td>Figure with optional caption<td><a href=#flow-content-2 id=elements-3:flow-content-2-50>flow</a>;
         <a href=#sectioning-root id=elements-3:sectioning-root-6>sectioning root</a>;
         <a href=#palpable-content-2 id=elements-3:palpable-content-2-23>palpable</a><td><a href=#flow-content-2 id=elements-3:flow-content-2-51>flow</a><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><a href=#global-attributes id=elements-3:global-attributes-36>globals</a><td><code id=elements-3:htmlelement-15><a href=#htmlelement>HTMLElement</a></code><tr><th><code id=elements-3:the-footer-element><a href=#the-footer-element>footer</a></code><td>Footer for a page or section<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-24>palpable</a><td><a href=#flow-content-2 id=elements-3:flow-content-2-54>flow</a><td><a href=#flow-content-2 id=elements-3:flow-content-2-55>flow</a>*<td><a href=#global-attributes id=elements-3:global-attributes-37>globals</a><td><code id=elements-3:htmlelement-16><a href=#htmlelement>HTMLElement</a></code><tr><th><code id=elements-3:the-form-element><a href=#the-form-element>form</a></code><td>User-submittable form<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-25>palpable</a><td><a href=#flow-content-2 id=elements-3:flow-content-2-57>flow</a><td><a href=#flow-content-2 id=elements-3:flow-content-2-58>flow</a>*<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-fs-target-2><a href=#attr-fs-target>target</a></code><td><code id=elements-3:htmlformelement><a href=#htmlformelement>HTMLFormElement</a></code><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><td>Section heading<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-26>palpable</a><td><code id=elements-3:the-hgroup-element><a href=#the-hgroup-element>hgroup</a></code>;
         <a href=#flow-content-2 id=elements-3:flow-content-2-60>flow</a><td><a href=#phrasing-content-2 id=elements-3:phrasing-content-2-48>phrasing</a><td><a href=#global-attributes id=elements-3:global-attributes-39>globals</a><td><code id=elements-3:htmlheadingelement><a href=#htmlheadingelement>HTMLHeadingElement</a></code><tr><th><code id=elements-3:the-head-element-2><a href=#the-head-element>head</a></code><td>Container for document metadata<td>none<td><code id=elements-3:the-html-element-2><a href=#the-html-element>html</a></code><td><a href=#metadata-content-2 id=elements-3:metadata-content-2-2>metadata content</a>*<td><a href=#global-attributes id=elements-3:global-attributes-40>globals</a><td><code id=elements-3:htmlheadelement><a href=#htmlheadelement>HTMLHeadElement</a></code><tr><th><code id=elements-3:the-header-element><a href=#the-header-element>header</a></code><td>Introductory or navigational aids for a page or section<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-27>palpable</a><td><a href=#flow-content-2 id=elements-3:flow-content-2-62>flow</a><td><a href=#flow-content-2 id=elements-3:flow-content-2-63>flow</a>*<td><a href=#global-attributes id=elements-3:global-attributes-41>globals</a><td><code id=elements-3:htmlelement-17><a href=#htmlelement>HTMLElement</a></code><tr><th><code id=elements-3:the-hgroup-element-2><a href=#the-hgroup-element>hgroup</a></code><td>heading group<td><a href=#flow-content-2 id=elements-3:flow-content-2-64>flow</a>;
         <a href=#heading-content-2 id=elements-3:heading-content-2-2>heading</a>;
         <a href=#palpable-content-2 id=elements-3:palpable-content-2-28>palpable</a><td><a href=#flow-content-2 id=elements-3:flow-content-2-65>flow</a><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>;
         <a href=#script-supporting-elements-2 id=elements-3:script-supporting-elements-2-3>script-supporting elements</a><td><a href=#global-attributes id=elements-3:global-attributes-42>globals</a><td><code id=elements-3:htmlelement-18><a href=#htmlelement>HTMLElement</a></code><tr><th><code id=elements-3:the-hr-element><a href=#the-hr-element>hr</a></code><td>Thematic break<td><a href=#flow-content-2 id=elements-3:flow-content-2-66>flow</a><td><a href=#flow-content-2 id=elements-3:flow-content-2-67>flow</a><td>empty<td><a href=#global-attributes id=elements-3:global-attributes-43>globals</a><td><code id=elements-3:htmlhrelement><a href=#htmlhrelement>HTMLHRElement</a></code><tr><th><code id=elements-3:the-html-element-3><a href=#the-html-element>html</a></code><td>Root element<td>none<td>none*<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><a href=#global-attributes id=elements-3:global-attributes-44>globals</a>;
         <code id=elements-3:attr-html-manifest><a href=#attr-html-manifest>manifest</a></code><td><code id=elements-3:htmlhtmlelement><a href=#htmlhtmlelement>HTMLHtmlElement</a></code><tr><th><code id=elements-3:the-i-element><a href=#the-i-element>i</a></code><td>Alternate voice<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-29>palpable</a><td><a href=#phrasing-content-2 id=elements-3:phrasing-content-2-50>phrasing</a><td><a href=#phrasing-content-2 id=elements-3:phrasing-content-2-51>phrasing</a><td><a href=#global-attributes id=elements-3:global-attributes-45>globals</a><td><code id=elements-3:htmlelement-19><a href=#htmlelement>HTMLElement</a></code><tr><th><code id=elements-3:the-iframe-element><a href=#the-iframe-element>iframe</a></code><td><a href=#nested-browsing-context id=elements-3:nested-browsing-context>Nested browsing context</a><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-30>palpable</a><td><a href=#phrasing-content-2 id=elements-3:phrasing-content-2-53>phrasing</a><td>empty<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-iframe-allowpaymentrequest><a href=#attr-iframe-allowpaymentrequest>allowpaymentrequest</a></code>;
         <code id=elements-3:attr-iframe-allowusermedia><a href=#attr-iframe-allowusermedia>allowusermedia</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><td><code id=elements-3:htmliframeelement><a href=#htmliframeelement>HTMLIFrameElement</a></code><tr><th><code id=elements-3:the-img-element><a href=#the-img-element>img</a></code><td>Image<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-31>palpable</a><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>empty<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-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-decoding><a href=#attr-img-decoding>decoding</a></code>;
         <code id=elements-3:attr-img-referrerpolicy><a href=#attr-img-referrerpolicy>referrerpolicy</a></code><td><code id=elements-3:htmlimageelement><a href=#htmlimageelement>HTMLImageElement</a></code><tr><th><code id=elements-3:the-input-element><a href=#the-input-element>input</a></code><td>Form control<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-32>palpable</a>*<td><a href=#phrasing-content-2 id=elements-3:phrasing-content-2-57>phrasing</a><td>empty<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-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-fe-autofocus-2><a href=#attr-fe-autofocus>autofocus</a></code>;
         <code id=elements-3:attr-input-checked><a href=#attr-input-checked>checked</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-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><code id=elements-3:htmlinputelement><a href=#htmlinputelement>HTMLInputElement</a></code><tr><th><code id=elements-3:the-ins-element><a href=#the-ins-element>ins</a></code><td>An addition to the document<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-33>palpable</a><td><a href=#phrasing-content-2 id=elements-3:phrasing-content-2-59>phrasing</a><td><a href=#transparent id=elements-3:transparent-5>transparent</a><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><code id=elements-3:htmlmodelement-2><a href=#htmlmodelement>HTMLModElement</a></code><tr><th><code id=elements-3:the-kbd-element><a href=#the-kbd-element>kbd</a></code><td>User input<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-34>palpable</a><td><a href=#phrasing-content-2 id=elements-3:phrasing-content-2-61>phrasing</a><td><a href=#phrasing-content-2 id=elements-3:phrasing-content-2-62>phrasing</a><td><a href=#global-attributes id=elements-3:global-attributes-50>globals</a><td><code id=elements-3:htmlelement-20><a href=#htmlelement>HTMLElement</a></code><tr><th><code id=elements-3:the-label-element><a href=#the-label-element>label</a></code><td>Caption for a form control<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-35>palpable</a><td><a href=#phrasing-content-2 id=elements-3:phrasing-content-2-64>phrasing</a><td><a href=#phrasing-content-2 id=elements-3:phrasing-content-2-65>phrasing</a>*<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><code id=elements-3:htmllabelelement><a href=#htmllabelelement>HTMLLabelElement</a></code><tr><th><code id=elements-3:the-legend-element-2><a href=#the-legend-element>legend</a></code><td>Caption for <code id=elements-3:the-fieldset-element-2><a href=#the-fieldset-element>fieldset</a></code><td>none<td><code id=elements-3:the-fieldset-element-3><a href=#the-fieldset-element>fieldset</a></code><td><a href=#phrasing-content-2 id=elements-3:phrasing-content-2-66>phrasing</a><td><a href=#global-attributes id=elements-3:global-attributes-52>globals</a><td><code id=elements-3:htmllegendelement><a href=#htmllegendelement>HTMLLegendElement</a></code><tr><th><code id=elements-3:the-li-element><a href=#the-li-element>li</a></code><td>List item<td>none<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><a href=#flow-content-2 id=elements-3:flow-content-2-75>flow</a><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><code id=elements-3:htmllielement><a href=#htmllielement>HTMLLIElement</a></code><tr><th><code id=elements-3:the-link-element><a href=#the-link-element>link</a></code><td>Link metadata<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><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>empty<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-referrerpolicy><a href=#attr-link-referrerpolicy>referrerpolicy</a></code>;
         <code id=elements-3:attr-link-integrity><a href=#attr-link-integrity>integrity</a></code><td><code id=elements-3:htmllinkelement><a href=#htmllinkelement>HTMLLinkElement</a></code><tr><th><code id=elements-3:the-main-element><a href=#the-main-element>main</a></code><td>Container for the dominant contents of the document<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-36>palpable</a><td><a href=#flow-content-2 id=elements-3:flow-content-2-78>flow</a>*<td><a href=#flow-content-2 id=elements-3:flow-content-2-79>flow</a><td><a href=#global-attributes id=elements-3:global-attributes-55>globals</a><td><code id=elements-3:htmlelement-21><a href=#htmlelement>HTMLElement</a></code><tr><th><code id=elements-3:the-map-element><a href=#the-map-element>map</a></code><td><a href=#image-map id=elements-3:image-map>Image map</a><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-37>palpable</a><td><a href=#phrasing-content-2 id=elements-3:phrasing-content-2-70>phrasing</a><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><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><code id=elements-3:htmlmapelement><a href=#htmlmapelement>HTMLMapElement</a></code><tr><th><code id=elements-3:the-mark-element><a href=#the-mark-element>mark</a></code><td>Highlight<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-38>palpable</a><td><a href=#phrasing-content-2 id=elements-3:phrasing-content-2-72>phrasing</a><td><a href=#phrasing-content-2 id=elements-3:phrasing-content-2-73>phrasing</a><td><a href=#global-attributes id=elements-3:global-attributes-57>globals</a><td><code id=elements-3:htmlelement-22><a href=#htmlelement>HTMLElement</a></code><tr><th><a id=elements-3:mathml-math href=https://www.w3.org/Math/draft-spec/chapter2.html#interf.toplevel data-x-internal=mathml-math>MathML <code>math</code></a><td>MathML root<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-39>palpable</a><td><a href=#phrasing-content-2 id=elements-3:phrasing-content-2-75>phrasing</a><td>per <a href=#refsMATHML>[MATHML]</a><td>per <a href=#refsMATHML>[MATHML]</a><td><code id=elements-3:element><a data-x-internal=element href=https://dom.spec.whatwg.org/#interface-element>Element</a></code><tr><th><code id=elements-3:the-menu-element-2><a href=#the-menu-element>menu</a></code><td>Menu of commands<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-40>palpable</a>*<td><a href=#flow-content-2 id=elements-3:flow-content-2-84>flow</a><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><a href=#global-attributes id=elements-3:global-attributes-58>globals</a><td><code id=elements-3:htmlmenuelement><a href=#htmlmenuelement>HTMLMenuElement</a></code><tr><th><code id=elements-3:the-meta-element><a href=#the-meta-element>meta</a></code><td>Text metadata<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><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>empty<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><td><code id=elements-3:htmlmetaelement><a href=#htmlmetaelement>HTMLMetaElement</a></code><tr><th><code id=elements-3:the-meter-element><a href=#the-meter-element>meter</a></code><td>Gauge<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-41>palpable</a><td><a href=#phrasing-content-2 id=elements-3:phrasing-content-2-79>phrasing</a><td><a href=#phrasing-content-2 id=elements-3:phrasing-content-2-80>phrasing</a>*<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><code id=elements-3:htmlmeterelement><a href=#htmlmeterelement>HTMLMeterElement</a></code><tr><th><code id=elements-3:the-nav-element><a href=#the-nav-element>nav</a></code><td>Section with navigational links<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-42>palpable</a><td><a href=#flow-content-2 id=elements-3:flow-content-2-88>flow</a><td><a href=#flow-content-2 id=elements-3:flow-content-2-89>flow</a><td><a href=#global-attributes id=elements-3:global-attributes-61>globals</a><td><code id=elements-3:htmlelement-23><a href=#htmlelement>HTMLElement</a></code><tr><th><code id=elements-3:the-noscript-element-3><a href=#the-noscript-element>noscript</a></code><td>Fallback content for script<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><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>varies*<td><a href=#global-attributes id=elements-3:global-attributes-62>globals</a><td><code id=elements-3:htmlelement-24><a href=#htmlelement>HTMLElement</a></code><tr><th><code id=elements-3:the-object-element><a href=#the-object-element>object</a></code><td>Image, <a href=#nested-browsing-context id=elements-3:nested-browsing-context-2>nested browsing context</a>, or <a href=#plugin id=elements-3:plugin-2>plugin</a><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=#category-submit id=elements-3:category-submit-3>submittable</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-43>palpable</a><td><a href=#phrasing-content-2 id=elements-3:phrasing-content-2-84>phrasing</a><td><code id=elements-3:the-param-element><a href=#the-param-element>param</a></code>*;
         <a href=#transparent id=elements-3:transparent-7>transparent</a><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-typemustmatch><a href=#attr-object-typemustmatch>typemustmatch</a></code>;
         <code id=elements-3:attr-object-name><a href=#attr-object-name>name</a></code>;
         <code id=elements-3:attr-hyperlink-usemap-2><a href=#attr-hyperlink-usemap>usemap</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><code id=elements-3:htmlobjectelement><a href=#htmlobjectelement>HTMLObjectElement</a></code><tr><th><code id=elements-3:the-ol-element-2><a href=#the-ol-element>ol</a></code><td>Ordered list<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-44>palpable</a>*<td><a href=#flow-content-2 id=elements-3:flow-content-2-93>flow</a><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><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><code id=elements-3:htmlolistelement><a href=#htmlolistelement>HTMLOListElement</a></code><tr><th><code id=elements-3:the-optgroup-element><a href=#the-optgroup-element>optgroup</a></code><td>Group of options in a list box<td>none<td><code id=elements-3:the-select-element><a href=#the-select-element>select</a></code><td><code id=elements-3:the-option-element-2><a href=#the-option-element>option</a></code>;
         <a href=#script-supporting-elements-2 id=elements-3:script-supporting-elements-2-6>script-supporting elements</a><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><code id=elements-3:htmloptgroupelement><a href=#htmloptgroupelement>HTMLOptGroupElement</a></code><tr><th><code id=elements-3:the-option-element-3><a href=#the-option-element>option</a></code><td>Option in a list box or combo box control<td>none<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-2><a href=#the-optgroup-element>optgroup</a></code><td><a href=#text-content id=elements-3:text-content>text</a>*<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><code id=elements-3:htmloptionelement><a href=#htmloptionelement>HTMLOptionElement</a></code><tr><th><code id=elements-3:the-output-element><a href=#the-output-element>output</a></code><td>Calculated output value<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-45>palpable</a><td><a href=#phrasing-content-2 id=elements-3:phrasing-content-2-86>phrasing</a><td><a href=#phrasing-content-2 id=elements-3:phrasing-content-2-87>phrasing</a><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><code id=elements-3:htmloutputelement><a href=#htmloutputelement>HTMLOutputElement</a></code><tr><th><code id=elements-3:the-p-element><a href=#the-p-element>p</a></code><td>Paragraph<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-46>palpable</a><td><a href=#flow-content-2 id=elements-3:flow-content-2-96>flow</a><td><a href=#phrasing-content-2 id=elements-3:phrasing-content-2-88>phrasing</a><td><a href=#global-attributes id=elements-3:global-attributes-68>globals</a><td><code id=elements-3:htmlparagraphelement><a href=#htmlparagraphelement>HTMLParagraphElement</a></code><tr><th><code id=elements-3:the-param-element-2><a href=#the-param-element>param</a></code><td>Parameter for <code id=elements-3:the-object-element-2><a href=#the-object-element>object</a></code><td>none<td><code id=elements-3:the-object-element-3><a href=#the-object-element>object</a></code><td>empty<td><a href=#global-attributes id=elements-3:global-attributes-69>globals</a>;
         <code id=elements-3:attr-param-name><a href=#attr-param-name>name</a></code>;
         <code id=elements-3:attr-param-value><a href=#attr-param-value>value</a></code><td><code id=elements-3:htmlparamelement><a href=#htmlparamelement>HTMLParamElement</a></code><tr><th><code id=elements-3:the-picture-element-2><a href=#the-picture-element>picture</a></code><td>Image<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><td><a href=#phrasing-content-2 id=elements-3:phrasing-content-2-90>phrasing</a><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-7>script-supporting elements</a><td><a href=#global-attributes id=elements-3:global-attributes-70>globals</a><td><code id=elements-3:htmlpictureelement><a href=#htmlpictureelement>HTMLPictureElement</a></code><tr><th><code id=elements-3:the-pre-element><a href=#the-pre-element>pre</a></code><td>Block of preformatted text<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-47>palpable</a><td><a href=#flow-content-2 id=elements-3:flow-content-2-99>flow</a><td><a href=#phrasing-content-2 id=elements-3:phrasing-content-2-91>phrasing</a><td><a href=#global-attributes id=elements-3:global-attributes-71>globals</a><td><code id=elements-3:htmlpreelement><a href=#htmlpreelement>HTMLPreElement</a></code><tr><th><code id=elements-3:the-progress-element><a href=#the-progress-element>progress</a></code><td>Progress bar<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-48>palpable</a><td><a href=#phrasing-content-2 id=elements-3:phrasing-content-2-93>phrasing</a><td><a href=#phrasing-content-2 id=elements-3:phrasing-content-2-94>phrasing</a>*<td><a href=#global-attributes id=elements-3:global-attributes-72>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><code id=elements-3:htmlprogresselement><a href=#htmlprogresselement>HTMLProgressElement</a></code><tr><th><code id=elements-3:the-q-element><a href=#the-q-element>q</a></code><td>Quotation<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-49>palpable</a><td><a href=#phrasing-content-2 id=elements-3:phrasing-content-2-96>phrasing</a><td><a href=#phrasing-content-2 id=elements-3:phrasing-content-2-97>phrasing</a><td><a href=#global-attributes id=elements-3:global-attributes-73>globals</a>;
         <code id=elements-3:attr-q-cite><a href=#attr-q-cite>cite</a></code><td><code id=elements-3:htmlquoteelement-2><a href=#htmlquoteelement>HTMLQuoteElement</a></code><tr><th><code id=elements-3:the-rp-element><a href=#the-rp-element>rp</a></code><td>Parenthesis for ruby annotation text<td>none<td><code id=elements-3:the-ruby-element><a href=#the-ruby-element>ruby</a></code><td><a href=#text-content id=elements-3:text-content-2>text</a><td><a href=#global-attributes id=elements-3:global-attributes-74>globals</a><td><code id=elements-3:htmlelement-25><a href=#htmlelement>HTMLElement</a></code><tr><th><code id=elements-3:the-rt-element><a href=#the-rt-element>rt</a></code><td>Ruby annotation text<td>none<td><code id=elements-3:the-ruby-element-2><a href=#the-ruby-element>ruby</a></code><td><a href=#phrasing-content-2 id=elements-3:phrasing-content-2-98>phrasing</a><td><a href=#global-attributes id=elements-3:global-attributes-75>globals</a><td><code id=elements-3:htmlelement-26><a href=#htmlelement>HTMLElement</a></code><tr><th><code id=elements-3:the-ruby-element-3><a href=#the-ruby-element>ruby</a></code><td>Ruby annotation(s)<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-50>palpable</a><td><a href=#phrasing-content-2 id=elements-3:phrasing-content-2-100>phrasing</a><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><a href=#global-attributes id=elements-3:global-attributes-76>globals</a><td><code id=elements-3:htmlelement-27><a href=#htmlelement>HTMLElement</a></code><tr><th><code id=elements-3:the-s-element><a href=#the-s-element>s</a></code><td>Inaccurate text<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-51>palpable</a><td><a href=#phrasing-content-2 id=elements-3:phrasing-content-2-103>phrasing</a><td><a href=#phrasing-content-2 id=elements-3:phrasing-content-2-104>phrasing</a><td><a href=#global-attributes id=elements-3:global-attributes-77>globals</a><td><code id=elements-3:htmlelement-28><a href=#htmlelement>HTMLElement</a></code><tr><th><code id=elements-3:the-samp-element><a href=#the-samp-element>samp</a></code><td>Computer output<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-52>palpable</a><td><a href=#phrasing-content-2 id=elements-3:phrasing-content-2-106>phrasing</a><td><a href=#phrasing-content-2 id=elements-3:phrasing-content-2-107>phrasing</a><td><a href=#global-attributes id=elements-3:global-attributes-78>globals</a><td><code id=elements-3:htmlelement-29><a href=#htmlelement>HTMLElement</a></code><tr><th><code id=elements-3:the-script-element><a href=#the-script-element>script</a></code><td>Embedded script<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-8>script-supporting</a><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-9>script-supporting</a><td>script, data, or script documentation*<td><a href=#global-attributes id=elements-3:global-attributes-79>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-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><td><code id=elements-3:htmlscriptelement><a href=#htmlscriptelement>HTMLScriptElement</a></code><tr><th><code id=elements-3:the-section-element><a href=#the-section-element>section</a></code><td>Generic document or application section<td><a href=#flow-content-2 id=elements-3:flow-content-2-106>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-53>palpable</a><td><a href=#flow-content-2 id=elements-3:flow-content-2-107>flow</a><td><a href=#flow-content-2 id=elements-3:flow-content-2-108>flow</a><td><a href=#global-attributes id=elements-3:global-attributes-80>globals</a><td><code id=elements-3:htmlelement-30><a href=#htmlelement>HTMLElement</a></code><tr><th><code id=elements-3:the-select-element-3><a href=#the-select-element>select</a></code><td>List box control<td><a href=#flow-content-2 id=elements-3:flow-content-2-109>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-4>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-54>palpable</a><td><a href=#phrasing-content-2 id=elements-3:phrasing-content-2-111>phrasing</a><td><code id=elements-3:the-option-element-4><a href=#the-option-element>option</a></code>;
         <code id=elements-3:the-optgroup-element-3><a href=#the-optgroup-element>optgroup</a></code>;
         <a href=#script-supporting-elements-2 id=elements-3:script-supporting-elements-2-10>script-supporting elements</a><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-autofocus-3><a href=#attr-fe-autofocus>autofocus</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><code id=elements-3:htmlselectelement><a href=#htmlselectelement>HTMLSelectElement</a></code><tr><th><code id=elements-3:the-slot-element><a href=#the-slot-element>slot</a></code><td>Shadow tree slot<td><a href=#flow-content-2 id=elements-3:flow-content-2-110>flow</a>;
         <a href=#phrasing-content-2 id=elements-3:phrasing-content-2-112>phrasing</a><td><a href=#phrasing-content-2 id=elements-3:phrasing-content-2-113>phrasing</a><td><a href=#transparent id=elements-3:transparent-8>transparent</a><td><a href=#global-attributes id=elements-3:global-attributes-82>globals</a>;
         <code id=elements-3:attr-slot-name><a href=#attr-slot-name>name</a></code><td><code id=elements-3:htmlslotelement><a href=#htmlslotelement>HTMLSlotElement</a></code><tr><th><code id=elements-3:the-small-element><a href=#the-small-element>small</a></code><td>Side comment<td><a href=#flow-content-2 id=elements-3:flow-content-2-111>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-55>palpable</a><td><a href=#phrasing-content-2 id=elements-3:phrasing-content-2-115>phrasing</a><td><a href=#phrasing-content-2 id=elements-3:phrasing-content-2-116>phrasing</a><td><a href=#global-attributes id=elements-3:global-attributes-83>globals</a><td><code id=elements-3:htmlelement-31><a href=#htmlelement>HTMLElement</a></code><tr><th><code id=elements-3:the-source-element-3><a href=#the-source-element>source</a></code><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>none<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>empty<td><a href=#global-attributes id=elements-3:global-attributes-84>globals</a>;
         <code id=elements-3:attr-source-src><a href=#attr-source-src>src</a></code>;
         <code id=elements-3:attr-source-type><a href=#attr-source-type>type</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-source-media><a href=#attr-source-media>media</a></code><td><code id=elements-3:htmlsourceelement><a href=#htmlsourceelement>HTMLSourceElement</a></code><tr><th><code id=elements-3:the-span-element><a href=#the-span-element>span</a></code><td>Generic phrasing container<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-117>phrasing</a>;
         <a href=#palpable-content-2 id=elements-3:palpable-content-2-56>palpable</a><td><a href=#phrasing-content-2 id=elements-3:phrasing-content-2-118>phrasing</a><td><a href=#phrasing-content-2 id=elements-3:phrasing-content-2-119>phrasing</a><td><a href=#global-attributes id=elements-3:global-attributes-85>globals</a><td><code id=elements-3:htmlspanelement><a href=#htmlspanelement>HTMLSpanElement</a></code><tr><th><code id=elements-3:the-strong-element><a href=#the-strong-element>strong</a></code><td>Importance<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-120>phrasing</a>;
         <a href=#palpable-content-2 id=elements-3:palpable-content-2-57>palpable</a><td><a href=#phrasing-content-2 id=elements-3:phrasing-content-2-121>phrasing</a><td><a href=#phrasing-content-2 id=elements-3:phrasing-content-2-122>phrasing</a><td><a href=#global-attributes id=elements-3:global-attributes-86>globals</a><td><code id=elements-3:htmlelement-32><a href=#htmlelement>HTMLElement</a></code><tr><th><code id=elements-3:the-style-element><a href=#the-style-element>style</a></code><td>Embedded styling information<td><a href=#metadata-content-2 id=elements-3:metadata-content-2-7>metadata</a><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>text*<td><a href=#global-attributes id=elements-3:global-attributes-87>globals</a>;
         <code id=elements-3:attr-style-media><a href=#attr-style-media>media</a></code>;
     <td><code id=elements-3:htmlstyleelement><a href=#htmlstyleelement>HTMLStyleElement</a></code><tr><th><code id=elements-3:the-sub-and-sup-elements><a href=#the-sub-and-sup-elements>sub</a></code><td>Subscript<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-123>phrasing</a>;
         <a href=#palpable-content-2 id=elements-3:palpable-content-2-58>palpable</a><td><a href=#phrasing-content-2 id=elements-3:phrasing-content-2-124>phrasing</a><td><a href=#phrasing-content-2 id=elements-3:phrasing-content-2-125>phrasing</a><td><a href=#global-attributes id=elements-3:global-attributes-88>globals</a><td><code id=elements-3:htmlelement-33><a href=#htmlelement>HTMLElement</a></code><tr><th><code id=elements-3:the-summary-element-2><a href=#the-summary-element>summary</a></code><td>Caption for <code id=elements-3:the-details-element-2><a href=#the-details-element>details</a></code><td>none<td><code id=elements-3:the-details-element-3><a href=#the-details-element>details</a></code><td><a href=#phrasing-content-2 id=elements-3:phrasing-content-2-126>phrasing</a><td><a href=#global-attributes id=elements-3:global-attributes-89>globals</a><td><code id=elements-3:htmlelement-34><a href=#htmlelement>HTMLElement</a></code><tr><th><code id=elements-3:the-sub-and-sup-elements-2><a href=#the-sub-and-sup-elements>sup</a></code><td>Superscript<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-127>phrasing</a>;
         <a href=#palpable-content-2 id=elements-3:palpable-content-2-59>palpable</a><td><a href=#phrasing-content-2 id=elements-3:phrasing-content-2-128>phrasing</a><td><a href=#phrasing-content-2 id=elements-3:phrasing-content-2-129>phrasing</a><td><a href=#global-attributes id=elements-3:global-attributes-90>globals</a><td><code id=elements-3:htmlelement-35><a href=#htmlelement>HTMLElement</a></code><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><td>SVG root<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-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-60>palpable</a><td><a href=#phrasing-content-2 id=elements-3:phrasing-content-2-131>phrasing</a><td>per <a href=#refsSVG>[SVG]</a><td>per <a href=#refsSVG>[SVG]</a><td><code id=elements-3:svgsvgelement><a data-x-internal=svgsvgelement href=https://svgwg.org/svg2-draft/struct.html#InterfaceSVGSVGElement>SVGSVGElement</a></code><tr><th><code id=elements-3:the-table-element-3><a href=#the-table-element>table</a></code><td>Table<td><a href=#flow-content-2 id=elements-3:flow-content-2-117>flow</a>;
         <a href=#palpable-content-2 id=elements-3:palpable-content-2-61>palpable</a><td><a href=#flow-content-2 id=elements-3:flow-content-2-118>flow</a><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-11>script-supporting elements</a><td><a href=#global-attributes id=elements-3:global-attributes-91>globals</a><td><code id=elements-3:htmltableelement><a href=#htmltableelement>HTMLTableElement</a></code><tr><th><code id=elements-3:the-tbody-element-2><a href=#the-tbody-element>tbody</a></code><td>Group of rows in a table<td>none<td><code id=elements-3:the-table-element-4><a href=#the-table-element>table</a></code><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-12>script-supporting elements</a><td><a href=#global-attributes id=elements-3:global-attributes-92>globals</a><td><code id=elements-3:htmltablesectionelement><a href=#htmltablesectionelement>HTMLTableSectionElement</a></code><tr><th><code id=elements-3:the-td-element><a href=#the-td-element>td</a></code><td>Table cell<td><a href=#sectioning-root id=elements-3:sectioning-root-7>sectioning root</a><td><code id=elements-3:the-tr-element-3><a href=#the-tr-element>tr</a></code><td><a href=#flow-content-2 id=elements-3:flow-content-2-119>flow</a><td><a href=#global-attributes id=elements-3:global-attributes-93>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><code id=elements-3:htmltablecellelement><a href=#htmltablecellelement>HTMLTableCellElement</a></code><tr><th><code id=elements-3:the-template-element-2><a href=#the-template-element>template</a></code><td>Template<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-120>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-13>script-supporting</a><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-14>script-supporting</a>;
         <code id=elements-3:the-colgroup-element-4><a href=#the-colgroup-element>colgroup</a></code>*<td>empty<td><a href=#global-attributes id=elements-3:global-attributes-94>globals</a><td><code id=elements-3:htmltemplateelement><a href=#htmltemplateelement>HTMLTemplateElement</a></code><tr><th><code id=elements-3:the-textarea-element><a href=#the-textarea-element>textarea</a></code><td>Multiline text controls<td><a href=#flow-content-2 id=elements-3:flow-content-2-121>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-5>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-62>palpable</a><td><a href=#phrasing-content-2 id=elements-3:phrasing-content-2-135>phrasing</a><td><a href=#text-content id=elements-3:text-content-3>text</a><td><a href=#global-attributes id=elements-3:global-attributes-95>globals</a>;
         <code id=elements-3:attr-fe-autofocus-4><a href=#attr-fe-autofocus>autofocus</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><code id=elements-3:htmltextareaelement><a href=#htmltextareaelement>HTMLTextAreaElement</a></code><tr><th><code id=elements-3:the-tfoot-element-2><a href=#the-tfoot-element>tfoot</a></code><td>Group of footer rows in a table<td>none<td><code id=elements-3:the-table-element-5><a href=#the-table-element>table</a></code><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-15>script-supporting elements</a><td><a href=#global-attributes id=elements-3:global-attributes-96>globals</a><td><code id=elements-3:htmltablesectionelement-2><a href=#htmltablesectionelement>HTMLTableSectionElement</a></code><tr><th><code id=elements-3:the-th-element><a href=#the-th-element>th</a></code><td>Table header cell<td><a href=#interactive-content-2 id=elements-3:interactive-content-2-13>interactive</a>*<td><code id=elements-3:the-tr-element-5><a href=#the-tr-element>tr</a></code><td><a href=#flow-content-2 id=elements-3:flow-content-2-122>flow</a>*<td><a href=#global-attributes id=elements-3:global-attributes-97>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><code id=elements-3:htmltablecellelement-2><a href=#htmltablecellelement>HTMLTableCellElement</a></code><tr><th><code id=elements-3:the-thead-element-2><a href=#the-thead-element>thead</a></code><td>Group of heading rows in a table<td>none<td><code id=elements-3:the-table-element-6><a href=#the-table-element>table</a></code><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-16>script-supporting elements</a><td><a href=#global-attributes id=elements-3:global-attributes-98>globals</a><td><code id=elements-3:htmltablesectionelement-3><a href=#htmltablesectionelement>HTMLTableSectionElement</a></code><tr><th><code id=elements-3:the-time-element><a href=#the-time-element>time</a></code><td>Machine-readable equivalent of date- or time-related data<td><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-136>phrasing</a>;
         <a href=#palpable-content-2 id=elements-3:palpable-content-2-63>palpable</a><td><a href=#phrasing-content-2 id=elements-3:phrasing-content-2-137>phrasing</a><td><a href=#phrasing-content-2 id=elements-3:phrasing-content-2-138>phrasing</a><td><a href=#global-attributes id=elements-3:global-attributes-99>globals</a>;
         <code id=elements-3:attr-time-datetime><a href=#attr-time-datetime>datetime</a></code><td><code id=elements-3:htmltimeelement><a href=#htmltimeelement>HTMLTimeElement</a></code><tr><th><code id=elements-3:the-title-element><a href=#the-title-element>title</a></code><td>Document title<td><a href=#metadata-content-2 id=elements-3:metadata-content-2-10>metadata</a><td><code id=elements-3:the-head-element-9><a href=#the-head-element>head</a></code><td><a href=#text-content id=elements-3:text-content-4>text</a>*<td><a href=#global-attributes id=elements-3:global-attributes-100>globals</a><td><code id=elements-3:htmltitleelement><a href=#htmltitleelement>HTMLTitleElement</a></code><tr><th><code id=elements-3:the-tr-element-7><a href=#the-tr-element>tr</a></code><td>Table row<td>none<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><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-17>script-supporting elements</a><td><a href=#global-attributes id=elements-3:global-attributes-101>globals</a><td><code id=elements-3:htmltablerowelement><a href=#htmltablerowelement>HTMLTableRowElement</a></code><tr><th><code id=elements-3:the-track-element-2><a href=#the-track-element>track</a></code><td>Timed text track<td>none<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>empty<td><a href=#global-attributes id=elements-3:global-attributes-102>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><code id=elements-3:htmltrackelement><a href=#htmltrackelement>HTMLTrackElement</a></code><tr><th><code id=elements-3:the-u-element><a href=#the-u-element>u</a></code><td>Keywords<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-139>phrasing</a>;
         <a href=#palpable-content-2 id=elements-3:palpable-content-2-64>palpable</a><td><a href=#phrasing-content-2 id=elements-3:phrasing-content-2-140>phrasing</a><td><a href=#phrasing-content-2 id=elements-3:phrasing-content-2-141>phrasing</a><td><a href=#global-attributes id=elements-3:global-attributes-103>globals</a><td><code id=elements-3:htmlelement-36><a href=#htmlelement>HTMLElement</a></code><tr><th><code id=elements-3:the-ul-element-2><a href=#the-ul-element>ul</a></code><td>List<td><a href=#flow-content-2 id=elements-3:flow-content-2-125>flow</a>;
         <a href=#palpable-content-2 id=elements-3:palpable-content-2-65>palpable</a>*<td><a href=#flow-content-2 id=elements-3:flow-content-2-126>flow</a><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-18>script-supporting elements</a><td><a href=#global-attributes id=elements-3:global-attributes-104>globals</a><td><code id=elements-3:htmlulistelement><a href=#htmlulistelement>HTMLUListElement</a></code><tr><th><code id=elements-3:the-var-element><a href=#the-var-element>var</a></code><td>Variable<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-142>phrasing</a>;
         <a href=#palpable-content-2 id=elements-3:palpable-content-2-66>palpable</a><td><a href=#phrasing-content-2 id=elements-3:phrasing-content-2-143>phrasing</a><td><a href=#phrasing-content-2 id=elements-3:phrasing-content-2-144>phrasing</a><td><a href=#global-attributes id=elements-3:global-attributes-105>globals</a><td><code id=elements-3:htmlelement-37><a href=#htmlelement>HTMLElement</a></code><tr><th><code id=elements-3:the-video-element-4><a href=#the-video-element>video</a></code><td>Video player<td><a href=#flow-content-2 id=elements-3:flow-content-2-128>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-67>palpable</a><td><a href=#phrasing-content-2 id=elements-3:phrasing-content-2-146>phrasing</a><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><a href=#global-attributes id=elements-3:global-attributes-106>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-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><code id=elements-3:htmlvideoelement><a href=#htmlvideoelement>HTMLVideoElement</a></code><tr><th><code id=elements-3:the-wbr-element><a href=#the-wbr-element>wbr</a></code><td>Line breaking opportunity<td><a href=#flow-content-2 id=elements-3:flow-content-2-129>flow</a>;
         <a href=#phrasing-content-2 id=elements-3:phrasing-content-2-147>phrasing</a><td><a href=#phrasing-content-2 id=elements-3:phrasing-content-2-148>phrasing</a><td>empty<td><a href=#global-attributes id=elements-3:global-attributes-107>globals</a><td><code id=elements-3:htmlelement-38><a href=#htmlelement>HTMLElement</a></code><tr><th><a href=#autonomous-custom-element id=elements-3:autonomous-custom-element>autonomous custom elements</a><td>Author-defined elements<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-149>phrasing</a>;
         <a href=#palpable-content-2 id=elements-3:palpable-content-2-68>palpable</a><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-150>phrasing</a><td><a href=#transparent id=elements-3:transparent-10>transparent</a><td><a href=#global-attributes id=elements-3:global-attributes-108>globals</a>; any, as decided by the element's author<td>Supplied by the element's author (inherits from <code id=elements-3:htmlelement-39><a href=#htmlelement>HTMLElement</a></code>)</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> Elements
     <th> Elements with exceptions
   <tbody><tr><td> <a href=#metadata-content-2 id=element-content-categories:metadata-content-2>Metadata content</a>
     <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>
      —

    <tr><td> <a href=#flow-content-2 id=element-content-categories:flow-content-2>Flow content</a>
     <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://www.w3.org/Math/draft-spec/chapter2.html#interf.toplevel 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-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>
      <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)

    <tr><td> <a href=#sectioning-content-2 id=element-content-categories:sectioning-content-2>Sectioning content</a>
     <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>
      —

    <tr><td> <a href=#heading-content-2 id=element-content-categories:heading-content-2>Heading content</a>
     <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>
      —

    <tr><td> <a href=#phrasing-content-2 id=element-content-categories:phrasing-content-2>Phrasing content</a>
     <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://www.w3.org/Math/draft-spec/chapter2.html#interf.toplevel 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-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>
      <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)

    <tr><td> <a href=#embedded-content-category id=element-content-categories:embedded-content-category>Embedded content</a>
     <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://www.w3.org/Math/draft-spec/chapter2.html#interf.toplevel 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>
      —

    <tr><td> <a href=#interactive-content-2 id=element-content-categories:interactive-content-2>Interactive content</a>*
     <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>
      <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-object-element-4><a href=#the-object-element>object</a></code> (if the <code id=element-content-categories:attr-hyperlink-usemap-2><a href=#attr-hyperlink-usemap>usemap</a></code> attribute is present);
      <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)

    <tr><td> <a href=#sectioning-root id=element-content-categories:sectioning-root>Sectioning roots</a>
     <td>
      <code id=element-content-categories:the-blockquote-element-2><a href=#the-blockquote-element>blockquote</a></code>;
      <code id=element-content-categories:the-body-element><a href=#the-body-element>body</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-dialog-element-2><a href=#the-dialog-element>dialog</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-figure-element-2><a href=#the-figure-element>figure</a></code>;
      <code id=element-content-categories:the-td-element><a href=#the-td-element>td</a></code>
     <td>
      —

    <tr><td> <a href=#form-associated-element id=element-content-categories:form-associated-element>Form-associated elements</a>
     <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-3><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-5><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>
     <td>
      —

    <tr><td> <a href=#category-listed id=element-content-categories:category-listed>Listed elements</a>
     <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-4><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-6><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>
     <td>
      —

    <tr><td> <a href=#category-submit id=element-content-categories:category-submit>Submittable elements</a>
     <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-object-element-7><a href=#the-object-element>object</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>
     <td>
      —

    <tr><td> <a href=#category-reset id=element-content-categories:category-reset>Resettable elements</a>
     <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>
     <td>
      —

    <tr><td> <a href=#category-autocapitalize id=element-content-categories:category-autocapitalize>Autocapitalize-inheriting elements</a>
     <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-5><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>
      —

    <tr><td> <a href=#category-label id=element-content-categories:category-label>Labelable elements</a>
     <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>
     <td>
      —

    <tr><td> <a href=#palpable-content-2 id=element-content-categories:palpable-content-2>Palpable content</a>
     <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-3><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-details-element-4><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-6><a href=#the-fieldset-element>fieldset</a></code>;
      <code id=element-content-categories:the-figure-element-3><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://www.w3.org/Math/draft-spec/chapter2.html#interf.toplevel 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-8><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-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-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>
      <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>

    <tr><td> <a href=#script-supporting-elements-2 id=element-content-categories:script-supporting-elements-2>Script-supporting elements</a>
     <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>
      —

  </table>

  <p class=tablenote><small>* The <code id=element-content-categories:attr-tabindex><a href=#attr-tabindex>tabindex</a></code> attribute can also
  make any element into <a href=#interactive-content-2 id=element-content-categories:interactive-content-2-2>interactive content</a>.</small></p>



  <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> Element(s)
     <th> Description
     <th> Value
   <tbody><tr><th> <code>abbr</code>
     <td> <code id=attributes-3:attr-th-abbr><a href=#attr-th-abbr>th</a></code>
     <td> Alternative label to use for the header cell when referencing the cell in other contexts
     <td> <a href=#attribute-text>Text</a>*
    <tr><th> <code>accept</code>
     <td> <code id=attributes-3:attr-input-accept><a href=#attr-input-accept>input</a></code>
     <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> <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>
    <tr><th> <code>accept-charset</code>
     <td> <code id=attributes-3:attr-form-accept-charset><a href=#attr-form-accept-charset>form</a></code>
     <td> Character encodings to use for <a href=#form-submission-2 id=attributes-3:form-submission-2>form submission</a>
     <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>, <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>, consisting of <a href=https://encoding.spec.whatwg.org/#label id=attributes-3:encoding-label data-x-internal=encoding-label>labels</a> of <a href=#ascii-compatible-encoding id=attributes-3:ascii-compatible-encoding>ASCII-compatible encodings</a>*
    <tr><th> <code>accesskey</code>
     <td> <a href=#the-accesskey-attribute id=attributes-3:the-accesskey-attribute>HTML elements</a>
     <td> Keyboard shortcut to activate or focus element
     <td> <a href=#ordered-set-of-unique-space-separated-tokens id=attributes-3:ordered-set-of-unique-space-separated-tokens-2>Ordered set of unique space-separated tokens</a>, <a href=#case-sensitive id=attributes-3:case-sensitive>case-sensitive</a>, consisting of one code point in length
    <tr><th> <code>action</code>
     <td> <code id=attributes-3:attr-fs-action><a href=#attr-fs-action>form</a></code>
     <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> <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>
    <tr><th> <code>allow</code>
     <td> <code id=attributes-3:attr-iframe-allow><a href=#attr-iframe-allow>iframe</a></code>
     <td> <a href=https://wicg.github.io/feature-policy/#feature-policy id=attributes-3:concept-feature-policy data-x-internal=concept-feature-policy>Feature 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> <a href=https://wicg.github.io/feature-policy/#serialized-feature-policy id=attributes-3:concept-serialized-feature-policy data-x-internal=concept-serialized-feature-policy>Serialized feature policy</a>
    <tr><th> <code>allowfullscreen</code>
     <td> <code id=attributes-3:attr-iframe-allowfullscreen><a href=#attr-iframe-allowfullscreen>iframe</a></code>
     <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> <a href=#boolean-attribute id=attributes-3:boolean-attribute>Boolean attribute</a>
    <tr><th> <code>allowpaymentrequest</code>
     <td> <code id=attributes-3:attr-iframe-allowpaymentrequest><a href=#attr-iframe-allowpaymentrequest>iframe</a></code>
     <td> Whether the <code id=attributes-3:the-iframe-element-3><a href=#the-iframe-element>iframe</a></code>'s contents are allowed to use the <code id=attributes-3:paymentrequest><a data-x-internal=paymentrequest href=https://w3c.github.io/payment-request/#dom-paymentrequest>PaymentRequest</a></code> interface to make payment requests
     <td> <a href=#boolean-attribute id=attributes-3:boolean-attribute-2>Boolean attribute</a>
    <tr><th> <code>allowusermedia</code>
     <td> <code id=attributes-3:attr-iframe-allowusermedia><a href=#attr-iframe-allowusermedia>iframe</a></code>
     <td> Whether to allow the <code id=attributes-3:the-iframe-element-4><a href=#the-iframe-element>iframe</a></code>'s contents to use <code id=attributes-3:dom-mediadevices-getusermedia><a data-x-internal=dom-mediadevices-getusermedia href=https://w3c.github.io/mediacapture-main/#dom-mediadevices-getusermedia>getUserMedia()</a></code>
     <td> <a href=#boolean-attribute id=attributes-3:boolean-attribute-3>Boolean attribute</a>
    <tr><th> <code>alt</code>
     <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> Replacement text for use when images are not available
     <td> <a href=#attribute-text>Text</a>*
    <tr><th> <code>as</code>
     <td> <code id=attributes-3:attr-link-as><a href=#attr-link-as>link</a></code>
     <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> <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>"
    <tr><th> <code>async</code>
     <td> <code id=attributes-3:attr-script-async><a href=#attr-script-async>script</a></code>
     <td> Execute script when available, without blocking
     <td> <a href=#boolean-attribute id=attributes-3:boolean-attribute-4>Boolean attribute</a>
    <tr><th> <code>autocapitalize</code>
     <td> <a href=#attr-autocapitalize id=attributes-3:attr-autocapitalize>HTML elements</a>
     <td> Recommended autocapitalization behavior (for supported input methods)
     <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>"
    <tr><th> <code>autocomplete</code>
     <td> <code id=attributes-3:attr-form-autocomplete><a href=#attr-form-autocomplete>form</a></code>
     <td> Default setting for autofill feature for controls in the form
     <td> "<code>on</code>"; "<code>off</code>"
    <tr><th> <code>autocomplete</code>
     <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> Hint for form autofill feature
     <td> <a href=#autofill-field id=attributes-3:autofill-field>Autofill field</a> name and related tokens*
    <tr><th> <code>autofocus</code>
     <td> <code id=attributes-3:attr-fe-autofocus><a href=#attr-fe-autofocus>button</a></code>;
          <code id=attributes-3:attr-fe-autofocus-2><a href=#attr-fe-autofocus>input</a></code>;
          <code id=attributes-3:attr-fe-autofocus-3><a href=#attr-fe-autofocus>select</a></code>;
          <code id=attributes-3:attr-fe-autofocus-4><a href=#attr-fe-autofocus>textarea</a></code>
     <td> Automatically focus the form control when the page is loaded
     <td> <a href=#boolean-attribute id=attributes-3:boolean-attribute-5>Boolean attribute</a>
    <tr><th> <code>autoplay</code>
     <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> 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> <a href=#boolean-attribute id=attributes-3:boolean-attribute-6>Boolean attribute</a>
    <tr><th> <code>charset</code>
     <td> <code id=attributes-3:attr-meta-charset><a href=#attr-meta-charset>meta</a></code>
     <td> <a href=#character-encoding-declaration id=attributes-3:character-encoding-declaration>Character encoding declaration</a>
     <td> "<code>utf-8</code>"
    <tr><th> <code>checked</code>
     <td> <code id=attributes-3:attr-input-checked><a href=#attr-input-checked>input</a></code>
     <td> Whether the control is checked
     <td> <a href=#boolean-attribute id=attributes-3:boolean-attribute-7>Boolean attribute</a>
    <tr><th> <code>cite</code>
     <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> Link to the source of the quotation or more information about the edit
     <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>
    <tr><th> <code>class</code>
     <td> <a href=#classes id=attributes-3:classes>HTML elements</a>
     <td> Classes to which the element belongs
     <td> <a href=#set-of-space-separated-tokens id=attributes-3:set-of-space-separated-tokens>Set of space-separated tokens</a>
    <tr><th> <code>color</code>
     <td> <code id=attributes-3:attr-link-color><a href=#attr-link-color>link</a></code>
     <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> CSS <a id=attributes-3:color href=https://drafts.csswg.org/css-color/#typedef-color data-x-internal=color>&lt;color></a>
    <tr><th> <code>cols</code>
     <td> <code id=attributes-3:attr-textarea-cols><a href=#attr-textarea-cols>textarea</a></code>
     <td> Maximum number of characters per line
     <td> <a href=#valid-non-negative-integer id=attributes-3:valid-non-negative-integer>Valid non-negative integer</a> greater than zero
    <tr><th> <code>colspan</code>
     <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> Number of columns that the cell is to span
     <td> <a href=#valid-non-negative-integer id=attributes-3:valid-non-negative-integer-2>Valid non-negative integer</a> greater than zero
    <tr><th> <code>content</code>
     <td> <code id=attributes-3:attr-meta-content><a href=#attr-meta-content>meta</a></code>
     <td> Value of the element
     <td> <a href=#attribute-text>Text</a>*
    <tr><th> <code>contenteditable</code>
     <td> <a href=#attr-contenteditable id=attributes-3:attr-contenteditable>HTML elements</a>
     <td> Whether the element is editable
     <td> "<code>true</code>"; "<code>false</code>"
    <tr><th> <code>controls</code>
     <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> Show user agent controls
     <td> <a href=#boolean-attribute id=attributes-3:boolean-attribute-8>Boolean attribute</a>
    <tr><th> <code>coords</code>
     <td> <code id=attributes-3:attr-area-coords><a href=#attr-area-coords>area</a></code>
     <td> Coordinates for the shape to be created in an <a href=#image-map id=attributes-3:image-map>image map</a>
     <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>*
    <tr><th> <code>crossorigin</code>
     <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> How the element handles crossorigin requests
     <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>"
    <tr><th> <code>data</code>
     <td> <code id=attributes-3:attr-object-data><a href=#attr-object-data>object</a></code>
     <td> Address of the resource
     <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>
    <tr><th> <code>datetime</code>
     <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> Date and (optionally) time of the change
     <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>
    <tr><th> <code>datetime</code>
     <td> <code id=attributes-3:attr-time-datetime><a href=#attr-time-datetime>time</a></code>
     <td> Machine-readable value
     <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>
    <tr><th> <code>decoding</code>
     <td> <code id=attributes-3:attr-img-decoding><a href=#attr-img-decoding>img</a></code>
     <td> Decoding hint to use when processing this image for presentation
     <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>"
    <tr><th> <code>default</code>
     <td> <code id=attributes-3:attr-track-default><a href=#attr-track-default>track</a></code>
     <td> Enable the track if no other <a href=#text-track id=attributes-3:text-track>text track</a> is more suitable
     <td> <a href=#boolean-attribute id=attributes-3:boolean-attribute-9>Boolean attribute</a>
    <tr><th> <code>defer</code>
     <td> <code id=attributes-3:attr-script-defer><a href=#attr-script-defer>script</a></code>
     <td> Defer script execution
     <td> <a href=#boolean-attribute id=attributes-3:boolean-attribute-10>Boolean attribute</a>
    <tr><th> <code>dir</code>
     <td> <a href=#the-dir-attribute id=attributes-3:the-dir-attribute>HTML elements</a>
     <td> <a href=#the-directionality id=attributes-3:the-directionality>The text directionality</a> of the element
     <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>"
    <tr><th> <code>dir</code>
     <td> <code id=attributes-3:the-bdo-element><a href=#the-bdo-element>bdo</a></code>
     <td> <a href=#the-directionality id=attributes-3:the-directionality-2>The text directionality</a> of the element
     <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>"
    <tr><th> <code>dirname</code>
     <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> 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> <a href=#attribute-text>Text</a>*
    <tr><th> <code>disabled</code>
     <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>
     <td> Whether the form control is disabled
     <td> <a href=#boolean-attribute id=attributes-3:boolean-attribute-11>Boolean attribute</a>
    <tr><th> <code>disabled</code>
     <td> <code id=attributes-3:attr-fieldset-disabled><a href=#attr-fieldset-disabled>fieldset</a></code>
     <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> <a href=#boolean-attribute id=attributes-3:boolean-attribute-12>Boolean attribute</a>
    <tr><th> <code>download</code>
     <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> Whether to download the resource instead of navigating to it, and its file name if so
     <td> Text
    <tr><th> <code>draggable</code>
     <td> <a href=#the-draggable-attribute id=attributes-3:the-draggable-attribute>HTML elements</a>
     <td> Whether the element is draggable
     <td> "<code>true</code>"; "<code>false</code>"
    <tr><th> <code>enctype</code>
     <td> <code id=attributes-3:attr-fs-enctype><a href=#attr-fs-enctype>form</a></code>
     <td> Entry list encoding type to use for <a href=#form-submission-2 id=attributes-3:form-submission-2-4>form submission</a>
     <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>"
    <tr><th> <code>enterkeyhint</code>
     <td> <a href=#attr-enterkeyhint id=attributes-3:attr-enterkeyhint>HTML elements</a>
     <td> Hint for selecting an enter key action
     <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>"
    <tr><th> <code>for</code>
     <td> <code id=attributes-3:attr-label-for><a href=#attr-label-for>label</a></code>
     <td> Associate the label with form control
     <td> <a href=https://dom.spec.whatwg.org/#concept-id id=attributes-3:concept-id data-x-internal=concept-id>ID</a>*
    <tr><th> <code>for</code>
     <td> <code id=attributes-3:attr-output-for><a href=#attr-output-for>output</a></code>
     <td> Specifies controls from which the output was calculated
     <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>, <a href=#case-sensitive id=attributes-3:case-sensitive-2>case-sensitive</a>, consisting of IDs*
    <tr><th> <code>form</code>
     <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>
     <td> Associates the element with a <code id=attributes-3:the-form-element><a href=#the-form-element>form</a></code> element
     <td> <a href=https://dom.spec.whatwg.org/#concept-id id=attributes-3:concept-id-2 data-x-internal=concept-id>ID</a>*
    <tr><th> <code>formaction</code>
     <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> <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> <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>
    <tr><th> <code>formenctype</code>
     <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> Entry list encoding type to use for <a href=#form-submission-2 id=attributes-3:form-submission-2-6>form submission</a>
     <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>"
    <tr><th> <code>formmethod</code>
     <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> Variant to use for <a href=#form-submission-2 id=attributes-3:form-submission-2-7>form submission</a>
     <td> "<code>GET</code>";
          "<code>POST</code>";
          "<code>dialog</code>"
    <tr><th> <code>formnovalidate</code>
     <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> Bypass form control validation for <a href=#form-submission-2 id=attributes-3:form-submission-2-8>form submission</a>
     <td> <a href=#boolean-attribute id=attributes-3:boolean-attribute-13>Boolean attribute</a>
    <tr><th> <code>formtarget</code>
     <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> <a href=#browsing-context id=attributes-3:browsing-context>Browsing context</a> for <a href=#form-submission-2 id=attributes-3:form-submission-2-9>form submission</a>
     <td> <a href=#valid-browsing-context-name-or-keyword id=attributes-3:valid-browsing-context-name-or-keyword>Valid browsing context name or keyword</a>
    <tr><th> <code>headers</code>
     <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> The header cells for this cell
     <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>, <a href=#case-sensitive id=attributes-3:case-sensitive-3>case-sensitive</a>, consisting of IDs*
    <tr><th> <code>height</code>
     <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>video</a></code>
     <td> Vertical dimension
     <td> <a href=#valid-non-negative-integer id=attributes-3:valid-non-negative-integer-4>Valid non-negative integer</a>
    <tr><th> <code>hidden</code>
     <td> <a href=#the-hidden-attribute id=attributes-3:the-hidden-attribute>HTML elements</a>
     <td> Whether the element is relevant
     <td> <a href=#boolean-attribute id=attributes-3:boolean-attribute-14>Boolean attribute</a>
    <tr><th> <code>high</code>
     <td> <code id=attributes-3:attr-meter-high><a href=#attr-meter-high>meter</a></code>
     <td> Low limit of high range
     <td> <a href=#valid-floating-point-number id=attributes-3:valid-floating-point-number>Valid floating-point number</a>*
    <tr><th> <code>href</code>
     <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> Address of the <a href=#hyperlink id=attributes-3:hyperlink>hyperlink</a>
     <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>
    <tr><th> <code>href</code>
     <td> <code id=attributes-3:attr-link-href><a href=#attr-link-href>link</a></code>
     <td> Address of the <a href=#hyperlink id=attributes-3:hyperlink-2>hyperlink</a>
     <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>
    <tr><th> <code>href</code>
     <td> <code id=attributes-3:attr-base-href><a href=#attr-base-href>base</a></code>
     <td> <a href=#document-base-url id=attributes-3:document-base-url>Document base URL</a>
     <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>
    <tr><th> <code>hreflang</code>
     <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> Language of the linked resource
     <td> Valid BCP 47 language tag
    <tr><th> <code>http-equiv</code>
     <td> <code id=attributes-3:attr-meta-http-equiv><a href=#attr-meta-http-equiv>meta</a></code>
     <td> Pragma directive
     <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>"
    <tr><th> <code>id</code>
     <td> <a href=#the-id-attribute id=attributes-3:the-id-attribute>HTML elements</a>
     <td> The element's <a href=https://dom.spec.whatwg.org/#concept-id id=attributes-3:concept-id-3 data-x-internal=concept-id>ID</a>
     <td> <a href=#attribute-text>Text</a>*
    <tr><th> <code>inputmode</code>
     <td> <a href=#attr-inputmode id=attributes-3:attr-inputmode>HTML elements</a>
     <td> Hint for selecting an input modality
     <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>"
    <tr><th> <code>integrity</code>
     <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> Integrity metadata used in <cite>Subresource Integrity</cite> checks <a href=#refsSRI>[SRI]</a>
     <td> <a href=#attribute-text>Text</a>
    <tr><th> <code>is</code>
     <td> <a href=#attr-is id=attributes-3:attr-is>HTML elements</a>
     <td> Creates a <a href=#customized-built-in-element id=attributes-3:customized-built-in-element>customized built-in element</a>
     <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>
    <tr><th> <code>ismap</code>
     <td> <code id=attributes-3:attr-img-ismap><a href=#attr-img-ismap>img</a></code>
     <td> Whether the image is a server-side image map
     <td> <a href=#boolean-attribute id=attributes-3:boolean-attribute-15>Boolean attribute</a>
    <tr><th> <code>itemid</code>
     <td> <a href=#attr-itemid id=attributes-3:attr-itemid>HTML elements</a>
     <td> <a href=#global-identifier id=attributes-3:global-identifier>Global identifier</a> for a microdata item
     <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>
    <tr><th> <code>itemprop</code>
     <td> <a href=#names:-the-itemprop-attribute id=attributes-3:names:-the-itemprop-attribute>HTML elements</a>
     <td> <a href=#property-names id=attributes-3:property-names>Property names</a> of a microdata item
     <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>, <a href=#case-sensitive id=attributes-3:case-sensitive-4>case-sensitive</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*
    <tr><th> <code>itemref</code>
     <td> <a href=#attr-itemref id=attributes-3:attr-itemref>HTML elements</a>
     <td> <a href=#referenced id=attributes-3:referenced>Referenced</a> elements
     <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>, <a href=#case-sensitive id=attributes-3:case-sensitive-5>case-sensitive</a>, consisting of IDs*
    <tr><th> <code>itemscope</code>
     <td> <a href=#attr-itemscope id=attributes-3:attr-itemscope>HTML elements</a>
     <td> Introduces a microdata item
     <td> <a href=#boolean-attribute id=attributes-3:boolean-attribute-16>Boolean attribute</a>
    <tr><th> <code>itemtype</code>
     <td> <a href=#attr-itemtype id=attributes-3:attr-itemtype>HTML elements</a>
     <td> <a href=#item-types id=attributes-3:item-types>Item types</a> of a microdata item
     <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>, <a href=#case-sensitive id=attributes-3:case-sensitive-6>case-sensitive</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 URL</a>*
    <tr><th> <code>kind</code>
     <td> <code id=attributes-3:attr-track-kind><a href=#attr-track-kind>track</a></code>
     <td> The type of text track
     <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>"
    <tr><th> <code>label</code>
     <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> User-visible label
     <td> <a href=#attribute-text>Text</a>
    <tr><th> <code>lang</code>
     <td> <a href=#attr-lang id=attributes-3:attr-lang>HTML elements</a>
     <td> <a href=#language id=attributes-3:language>Language</a> of the element
     <td> Valid BCP 47 language tag or the empty string
    <tr><th> <code>list</code>
     <td> <code id=attributes-3:attr-input-list><a href=#attr-input-list>input</a></code>
     <td> List of autocomplete options
     <td> <a href=https://dom.spec.whatwg.org/#concept-id id=attributes-3:concept-id-4 data-x-internal=concept-id>ID</a>*
    <tr><th> <code>loop</code>
     <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> Whether to loop the <a href=#media-resource id=attributes-3:media-resource-2>media resource</a>
     <td> <a href=#boolean-attribute id=attributes-3:boolean-attribute-17>Boolean attribute</a>
    <tr><th> <code>low</code>
     <td> <code id=attributes-3:attr-meter-low><a href=#attr-meter-low>meter</a></code>
     <td> High limit of low range
     <td> <a href=#valid-floating-point-number id=attributes-3:valid-floating-point-number-2>Valid floating-point number</a>*
    <tr><th> <code>manifest</code>
     <td> <code id=attributes-3:attr-html-manifest><a href=#attr-html-manifest>html</a></code>
     <td> <a href=#concept-appcache-manifest id=attributes-3:concept-appcache-manifest>Application cache manifest</a>
     <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>
    <tr><th> <code>max</code>
     <td> <code id=attributes-3:attr-input-max><a href=#attr-input-max>input</a></code>
     <td> Maximum value
     <td> Varies*
    <tr><th> <code>max</code>
     <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> Upper bound of range
     <td> <a href=#valid-floating-point-number id=attributes-3:valid-floating-point-number-3>Valid floating-point number</a>*
    <tr><th> <code>maxlength</code>
     <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> Maximum length of value
     <td> <a href=#valid-non-negative-integer id=attributes-3:valid-non-negative-integer-5>Valid non-negative integer</a>
    <tr><th> <code>media</code>
     <td> <code id=attributes-3:attr-link-media><a href=#attr-link-media>link</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> Applicable media
     <td> <a href=#valid-media-query-list id=attributes-3:valid-media-query-list>Valid media query list</a>
    <tr><th> <code>method</code>
     <td> <code id=attributes-3:attr-fs-method><a href=#attr-fs-method>form</a></code>
     <td> Variant to use for <a href=#form-submission-2 id=attributes-3:form-submission-2-10>form submission</a>
     <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>"
    <tr><th> <code>min</code>
     <td> <code id=attributes-3:attr-input-min><a href=#attr-input-min>input</a></code>
     <td> Minimum value
     <td> Varies*
    <tr><th> <code>min</code>
     <td> <code id=attributes-3:attr-meter-min><a href=#attr-meter-min>meter</a></code>
     <td> Lower bound of range
     <td> <a href=#valid-floating-point-number id=attributes-3:valid-floating-point-number-4>Valid floating-point number</a>*
    <tr><th> <code>minlength</code>
     <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> Minimum length of value
     <td> <a href=#valid-non-negative-integer id=attributes-3:valid-non-negative-integer-6>Valid non-negative integer</a>
    <tr><th> <code>multiple</code>
     <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> Whether to allow multiple values
     <td> <a href=#boolean-attribute id=attributes-3:boolean-attribute-18>Boolean attribute</a>
    <tr><th> <code>muted</code>
     <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> Whether to mute the <a href=#media-resource id=attributes-3:media-resource-3>media resource</a> by default
     <td> <a href=#boolean-attribute id=attributes-3:boolean-attribute-19>Boolean attribute</a>
    <tr><th> <code>name</code>
     <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>
     <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> <a href=#attribute-text>Text</a>*
    <tr><th> <code>name</code>
     <td> <code id=attributes-3:attr-form-name><a href=#attr-form-name>form</a></code>
     <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> <a href=#attribute-text>Text</a>*
    <tr><th> <code>name</code>
     <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> Name of <a href=#nested-browsing-context id=attributes-3:nested-browsing-context>nested browsing context</a>
     <td> <a href=#valid-browsing-context-name-or-keyword id=attributes-3:valid-browsing-context-name-or-keyword-2>Valid browsing context name or keyword</a>
    <tr><th> <code>name</code>
     <td> <code id=attributes-3:attr-map-name><a href=#attr-map-name>map</a></code>
     <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> <a href=#attribute-text>Text</a>*
    <tr><th> <code>name</code>
     <td> <code id=attributes-3:attr-meta-name><a href=#attr-meta-name>meta</a></code>
     <td> Metadata name
     <td> <a href=#attribute-text>Text</a>*
    <tr><th> <code>name</code>
     <td> <code id=attributes-3:attr-param-name><a href=#attr-param-name>param</a></code>
     <td> Name of parameter
     <td> <a href=#attribute-text>Text</a>
    <tr><th> <code>name</code>
     <td> <code id=attributes-3:attr-slot-name><a href=#attr-slot-name>slot</a></code>
     <td> Name of shadow tree slot
     <td> <a href=#attribute-text>Text</a>
    <tr><th> <code>nomodule</code>
     <td> <code id=attributes-3:attr-script-nomodule><a href=#attr-script-nomodule>script</a></code>
     <td> Prevents execution in user agents that support <a href=#module-script id=attributes-3:module-script>module scripts</a>
     <td> <a href=#boolean-attribute id=attributes-3:boolean-attribute-20>Boolean attribute</a>
    <tr><th> <code>nonce</code>
     <td> <a href=#attr-nonce id=attributes-3:attr-nonce>HTML elements</a>
     <td> Cryptographic nonce used in <cite>Content Security Policy</cite> checks <a href=#refsCSP>[CSP]</a>
     <td> <a href=#attribute-text>Text</a>
    <tr><th> <code>novalidate</code>
     <td> <code id=attributes-3:attr-fs-novalidate><a href=#attr-fs-novalidate>form</a></code>
     <td> Bypass form control validation for <a href=#form-submission-2 id=attributes-3:form-submission-2-12>form submission</a>
     <td> <a href=#boolean-attribute id=attributes-3:boolean-attribute-21>Boolean attribute</a>
    <tr><th> <code>open</code>
     <td> <code id=attributes-3:attr-details-open><a href=#attr-details-open>details</a></code>
     <td> Whether the details are visible
     <td> <a href=#boolean-attribute id=attributes-3:boolean-attribute-22>Boolean attribute</a>
    <tr><th> <code>open</code>
     <td> <code id=attributes-3:attr-dialog-open><a href=#attr-dialog-open>dialog</a></code>
     <td> Whether the dialog box is showing
     <td> <a href=#boolean-attribute id=attributes-3:boolean-attribute-23>Boolean attribute</a>
    <tr><th> <code>optimum</code>
     <td> <code id=attributes-3:attr-meter-optimum><a href=#attr-meter-optimum>meter</a></code>
     <td> Optimum value in gauge
     <td> <a href=#valid-floating-point-number id=attributes-3:valid-floating-point-number-5>Valid floating-point number</a>*
    <tr><th> <code>pattern</code>
     <td> <code id=attributes-3:attr-input-pattern><a href=#attr-input-pattern>input</a></code>
     <td> Pattern to be matched by the form control's value
     <td> Regular expression matching the JavaScript <i id=attributes-3:js-prod-pattern><a data-x-internal=js-prod-pattern href=https://tc39.github.io/ecma262/#prod-Pattern>Pattern</a></i> production
    <tr><th> <code>ping</code>
     <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> <a href=https://url.spec.whatwg.org/#concept-url id=attributes-3:url-3 data-x-internal=url>URLs</a> to ping
     <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>
    <tr><th> <code>placeholder</code>
     <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> User-visible label to be placed within the form control
     <td> <a href=#attribute-text>Text</a>*
    <tr><th> <code>playsinline</code>
     <td> <code id=attributes-3:attr-video-playsinline><a href=#attr-video-playsinline>video</a></code>
     <td> Encourage the user agent to display video content within the element's playback area
     <td> <a href=#boolean-attribute id=attributes-3:boolean-attribute-24>Boolean attribute</a>
    <tr><th> <code>poster</code>
     <td> <code id=attributes-3:attr-video-poster><a href=#attr-video-poster>video</a></code>
     <td> Poster frame to show prior to video playback
     <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>
    <tr><th> <code>preload</code>
     <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> Hints how much buffering the <a href=#media-resource id=attributes-3:media-resource-4>media resource</a> will likely need
     <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>"
    <tr><th> <code>readonly</code>
     <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> Whether to allow the value to be edited by the user
     <td> <a href=#boolean-attribute id=attributes-3:boolean-attribute-25>Boolean attribute</a>
    <tr><th> <code>referrerpolicy</code>
     <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> <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 data-x-internal=concept-fetch>fetches</a> initiated by the element
     <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>
    <tr><th> <code>rel</code>
     <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> Relationship between the location in the document containing the <a href=#hyperlink id=attributes-3:hyperlink-3>hyperlink</a> and the destination resource
     <td> <a href=#set-of-space-separated-tokens id=attributes-3:set-of-space-separated-tokens-3>Set of space-separated tokens</a>*
    <tr><th> <code>rel</code>
     <td> <code id=attributes-3:attr-link-rel-6><a href=#attr-link-rel>link</a></code>
     <td> Relationship between the document containing the <a href=#hyperlink id=attributes-3:hyperlink-4>hyperlink</a> and the destination resource
     <td> <a href=#set-of-space-separated-tokens id=attributes-3:set-of-space-separated-tokens-4>Set of space-separated tokens</a>*
    <tr><th> <code>required</code>
     <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> Whether the control is required for <a href=#form-submission-2 id=attributes-3:form-submission-2-13>form submission</a>
     <td> <a href=#boolean-attribute id=attributes-3:boolean-attribute-26>Boolean attribute</a>
    <tr><th> <code>reversed</code>
     <td> <code id=attributes-3:attr-ol-reversed><a href=#attr-ol-reversed>ol</a></code>
     <td> Number the list backwards
     <td> <a href=#boolean-attribute id=attributes-3:boolean-attribute-27>Boolean attribute</a>
    <tr><th> <code>rows</code>
     <td> <code id=attributes-3:attr-textarea-rows><a href=#attr-textarea-rows>textarea</a></code>
     <td> Number of lines to show
     <td> <a href=#valid-non-negative-integer id=attributes-3:valid-non-negative-integer-7>Valid non-negative integer</a> greater than zero
    <tr><th> <code>rowspan</code>
     <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> Number of rows that the cell is to span
     <td> <a href=#valid-non-negative-integer id=attributes-3:valid-non-negative-integer-8>Valid non-negative integer</a>
    <tr><th> <code>sandbox</code>
     <td> <code id=attributes-3:attr-iframe-sandbox><a href=#attr-iframe-sandbox>iframe</a></code>
     <td> Security rules for nested content
     <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>, <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
          "<code id=attributes-3:attr-iframe-sandbox-allow-forms><a href=#attr-iframe-sandbox-allow-forms>allow-forms</a></code>",
          "<code id=attributes-3:attr-iframe-sandbox-allow-modals><a href=#attr-iframe-sandbox-allow-modals>allow-modals</a></code>",
          "<code id=attributes-3:attr-iframe-sandbox-allow-orientation-lock><a href=#attr-iframe-sandbox-allow-orientation-lock>allow-orientation-lock</a></code>",
          "<code id=attributes-3:attr-iframe-sandbox-allow-pointer-lock><a href=#attr-iframe-sandbox-allow-pointer-lock>allow-pointer-lock</a></code>",
          "<code id=attributes-3:attr-iframe-sandbox-allow-popups><a href=#attr-iframe-sandbox-allow-popups>allow-popups</a></code>",
          "<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>",
          "<code id=attributes-3:attr-iframe-sandbox-allow-presentation><a href=#attr-iframe-sandbox-allow-presentation>allow-presentation</a></code>",
          "<code id=attributes-3:attr-iframe-sandbox-allow-same-origin><a href=#attr-iframe-sandbox-allow-same-origin>allow-same-origin</a></code>",
          "<code id=attributes-3:attr-iframe-sandbox-allow-scripts><a href=#attr-iframe-sandbox-allow-scripts>allow-scripts</a></code>" and
          "<code id=attributes-3:attr-iframe-sandbox-allow-top-navigation><a href=#attr-iframe-sandbox-allow-top-navigation>allow-top-navigation</a></code>"
    <tr><th> <code>scope</code>
     <td> <code id=attributes-3:attr-th-scope><a href=#attr-th-scope>th</a></code>
     <td> Specifies which cells the header cell applies to
     <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>"
    <tr><th> <code>selected</code>
     <td> <code id=attributes-3:attr-option-selected><a href=#attr-option-selected>option</a></code>
     <td> Whether the option is selected by default
     <td> <a href=#boolean-attribute id=attributes-3:boolean-attribute-28>Boolean attribute</a>
    <tr><th> <code>shape</code>
     <td> <code id=attributes-3:attr-area-shape><a href=#attr-area-shape>area</a></code>
     <td> The kind of shape to be created in an <a href=#image-map id=attributes-3:image-map-3>image map</a>
     <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>"
    <tr><th> <code>size</code>
     <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> Size of the control
     <td> <a href=#valid-non-negative-integer id=attributes-3:valid-non-negative-integer-9>Valid non-negative integer</a> greater than zero
    <tr><th> <code>sizes</code>
     <td> <code id=attributes-3:attr-link-sizes><a href=#attr-link-sizes>link</a></code>
     <td> Sizes of the icons (for <code id=attributes-3:attr-link-rel-7><a href=#attr-link-rel>rel</a></code>="<code id=attributes-3:rel-icon><a href=#rel-icon>icon</a></code>")
     <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>, <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*
    <tr><th> <code>sizes</code>
     <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> Image sizes for different page layouts
     <td> <a href=#valid-source-size-list id=attributes-3:valid-source-size-list>Valid source size list</a>
    <tr><th> <code>slot</code>
     <td> <a href=#the-id-attribute id=attributes-3:the-id-attribute-2>HTML elements</a>
     <td> The element's desired slot
     <td> <a href=#attribute-text>Text</a>
    <tr><th> <code>span</code>
     <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> Number of columns spanned by the element
     <td> <a href=#valid-non-negative-integer id=attributes-3:valid-non-negative-integer-10>Valid non-negative integer</a> greater than zero
    <tr><th> <code>spellcheck</code>
     <td> <a href=#attr-spellcheck id=attributes-3:attr-spellcheck>HTML elements</a>
     <td> Whether the element is to have its spelling and grammar checked
     <td> "<code>true</code>"; "<code>false</code>"
    <tr><th> <code>src</code>
     <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>;
          <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> Address of the resource
     <td> <a href=#valid-non-empty-url-potentially-surrounded-by-spaces id=attributes-3:valid-non-empty-url-potentially-surrounded-by-spaces-7>Valid non-empty URL potentially surrounded by spaces</a>
    <tr><th> <code>srcdoc</code>
     <td> <code id=attributes-3:attr-iframe-srcdoc><a href=#attr-iframe-srcdoc>iframe</a></code>
     <td> A document to render in the <code id=attributes-3:the-iframe-element-5><a href=#the-iframe-element>iframe</a></code>
     <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>*
    <tr><th> <code>srclang</code>
     <td> <code id=attributes-3:attr-track-srclang><a href=#attr-track-srclang>track</a></code>
     <td> Language of the text track
     <td> Valid BCP 47 language tag
    <tr><th> <code>srcset</code>
     <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> Images to use in different situations (e.g. high-resolution displays, small monitors, etc)
     <td> Comma-separated list of <a href=#image-candidate-string id=attributes-3:image-candidate-string>image candidate strings</a>
    <tr><th> <code>start</code>
     <td> <code id=attributes-3:attr-ol-start><a href=#attr-ol-start>ol</a></code>
     <td> <a href=#concept-ol-start id=attributes-3:concept-ol-start>Starting value</a> of the list
     <td> <a href=#valid-integer id=attributes-3:valid-integer>Valid integer</a>
    <tr><th> <code>step</code>
     <td> <code id=attributes-3:attr-input-step><a href=#attr-input-step>input</a></code>
     <td> Granularity to be matched by the form control's value
     <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>"
    <tr><th> <code>style</code>
     <td> <a href=#the-style-attribute id=attributes-3:the-style-attribute>HTML elements</a>
     <td> Presentational and formatting instructions
     <td> CSS declarations*
    <tr><th> <code>tabindex</code>
     <td> <a href=#attr-tabindex id=attributes-3:attr-tabindex>HTML elements</a>
     <td> Whether the element is focusable, and the relative order of the element for the purposes of sequential focus navigation
     <td> <a href=#valid-integer id=attributes-3:valid-integer-2>Valid integer</a>
    <tr><th> <code>target</code>
     <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> <a href=#browsing-context id=attributes-3:browsing-context-2>Browsing context</a> for <a href=#hyperlink id=attributes-3:hyperlink-5>hyperlink</a> <a href=#navigate id=attributes-3:navigate>navigation</a>
     <td> <a href=#valid-browsing-context-name-or-keyword id=attributes-3:valid-browsing-context-name-or-keyword-3>Valid browsing context name or keyword</a>
    <tr><th> <code>target</code>
     <td> <code id=attributes-3:attr-base-target><a href=#attr-base-target>base</a></code>
     <td> Default <a href=#browsing-context id=attributes-3:browsing-context-3>browsing context</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> <a href=#valid-browsing-context-name-or-keyword id=attributes-3:valid-browsing-context-name-or-keyword-4>Valid browsing context name or keyword</a>
    <tr><th> <code>target</code>
     <td> <code id=attributes-3:attr-fs-target><a href=#attr-fs-target>form</a></code>
     <td> <a href=#browsing-context id=attributes-3:browsing-context-4>Browsing context</a> for <a href=#form-submission-2 id=attributes-3:form-submission-2-15>form submission</a>
     <td> <a href=#valid-browsing-context-name-or-keyword id=attributes-3:valid-browsing-context-name-or-keyword-5>Valid browsing context name or keyword</a>
    <tr><th> <code>title</code>
     <td> <a href=#attr-title id=attributes-3:attr-title>HTML elements</a>
     <td> Advisory information for the element
     <td> <a href=#attribute-text>Text</a>
    <tr><th> <code>title</code>
     <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> Full term or expansion of abbreviation
     <td> <a href=#attribute-text>Text</a>
    <tr><th> <code>title</code>
     <td> <code id=attributes-3:attr-input-title><a href=#attr-input-title>input</a></code>
     <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> <a href=#attribute-text>Text</a>
    <tr><th> <code>title</code>
     <td> <code id=attributes-3:attr-link-title><a href=#attr-link-title>link</a></code>
     <td> Title of the link
     <td> <a href=#attribute-text>Text</a>
    <tr><th> <code>title</code>
     <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> <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> <a href=#attribute-text>Text</a>
    <tr><th> <code>translate</code>
     <td> <a href=#attr-translate id=attributes-3:attr-translate>HTML elements</a>
     <td> Whether the element is to be translated when the page is localized
     <td> "<code>yes</code>"; "<code>no</code>"
    <tr><th> <code>type</code>
     <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> Hint for the type of the referenced resource
     <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>
    <tr><th> <code>type</code>
     <td> <code id=attributes-3:attr-button-type><a href=#attr-button-type>button</a></code>
     <td> Type of button
     <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>"
    <tr><th> <code>type</code>
     <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> Type of embedded resource
     <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>
    <tr><th> <code>type</code>
     <td> <code id=attributes-3:attr-input-type><a href=#attr-input-type>input</a></code>
     <td> Type of form control
     <td> <a href=#attr-input-type id=attributes-3:attr-input-type-2><code>input</code> type keyword</a>
    <tr><th> <code>type</code>
     <td> <code id=attributes-3:attr-ol-type><a href=#attr-ol-type>ol</a></code>
     <td> Kind of list marker
     <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>"
    <tr><th> <code>type</code>
     <td> <code id=attributes-3:attr-script-type><a href=#attr-script-type>script</a></code>
     <td> Type of script
     <td> "<code>module</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>
    <tr><th> <code>typemustmatch</code>
     <td> <code id=attributes-3:attr-object-typemustmatch><a href=#attr-object-typemustmatch>object</a></code>
     <td> Whether the <code id=attributes-3:attr-object-type-2><a href=#attr-object-type>type</a></code> attribute and the <a href=#content-type id=attributes-3:content-type>Content-Type</a> value need to match for the resource to be used
     <td> <a href=#boolean-attribute id=attributes-3:boolean-attribute-29>Boolean attribute</a>
    <tr><th> <code>usemap</code>
     <td> <code id=attributes-3:attr-hyperlink-usemap-2><a href=#attr-hyperlink-usemap>img</a></code>;
          <code id=attributes-3:attr-hyperlink-usemap-3><a href=#attr-hyperlink-usemap>object</a></code>
     <td> Name of <a href=#image-map id=attributes-3:image-map-4>image map</a> to use
     <td> <a href=#valid-hash-name-reference id=attributes-3:valid-hash-name-reference>Valid hash-name reference</a>*
    <tr><th> <code>value</code>
     <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> Value to be used for <a href=#form-submission-2 id=attributes-3:form-submission-2-16>form submission</a>
     <td> <a href=#attribute-text>Text</a>
    <tr><th> <code>value</code>
     <td> <code id=attributes-3:attr-data-value><a href=#attr-data-value>data</a></code>
     <td> Machine-readable value
     <td> <a href=#attribute-text>Text</a>*
    <tr><th> <code>value</code>
     <td> <code id=attributes-3:attr-input-value><a href=#attr-input-value>input</a></code>
     <td> Value of the form control
     <td> Varies*
    <tr><th> <code>value</code>
     <td> <code id=attributes-3:attr-li-value><a href=#attr-li-value>li</a></code>
     <td> <a href=#ordinal-value id=attributes-3:ordinal-value>Ordinal value</a> of the list item
     <td> <a href=#valid-integer id=attributes-3:valid-integer-3>Valid integer</a>
    <tr><th> <code>value</code>
     <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> Current value of the element
     <td> <a href=#valid-floating-point-number id=attributes-3:valid-floating-point-number-7>Valid floating-point number</a>
    <tr><th> <code>value</code>
     <td> <code id=attributes-3:attr-param-value><a href=#attr-param-value>param</a></code>
     <td> Value of parameter
     <td> <a href=#attribute-text>Text</a>
    <tr><th> <code>width</code>
     <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>video</a></code>
     <td> Horizontal dimension
     <td> <a href=#valid-non-negative-integer id=attributes-3:valid-non-negative-integer-11>Valid non-negative integer</a>
    <tr><th> <code>wrap</code>
     <td> <code id=attributes-3:attr-textarea-wrap><a href=#attr-textarea-wrap>textarea</a></code>
     <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> "<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>"
  </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>

  <table id=ix-event-handlers><caption>List of event handler content attributes</caption><thead><tr><th> Attribute
     <th> Element(s)
     <th> Description
     <th> Value
   <tbody><tr><th id=ix-handler-onabort> <code>onabort</code>
     <td> <a href=#handler-onabort id=attributes-3:handler-onabort>HTML elements</a>
     <td> <code id=attributes-3:event-abort><a href=#event-abort>abort</a></code> event handler
     <td> <a href=#event-handler-content-attributes id=attributes-3:event-handler-content-attributes>Event handler content attribute</a>

    <tr><th id=ix-handler-onauxclick> <code>onauxclick</code>
     <td> <a href=#handler-onauxclick id=attributes-3:handler-onauxclick>HTML elements</a>
     <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> <a href=#event-handler-content-attributes id=attributes-3:event-handler-content-attributes-2>Event handler content attribute</a>

    <tr><th id=ix-handler-window-onafterprint> <code>onafterprint</code>
     <td> <code id=attributes-3:handler-window-onafterprint><a href=#handler-window-onafterprint>body</a></code>
     <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> <a href=#event-handler-content-attributes id=attributes-3:event-handler-content-attributes-3>Event handler content attribute</a>

    <tr><th id=ix-handler-window-onbeforeprint> <code>onbeforeprint</code>
     <td> <code id=attributes-3:handler-window-onbeforeprint><a href=#handler-window-onbeforeprint>body</a></code>
     <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> <a href=#event-handler-content-attributes id=attributes-3:event-handler-content-attributes-4>Event handler content attribute</a>

    <tr><th id=ix-handler-window-onbeforeunload> <code>onbeforeunload</code>
     <td> <code id=attributes-3:handler-window-onbeforeunload><a href=#handler-window-onbeforeunload>body</a></code>
     <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> <a href=#event-handler-content-attributes id=attributes-3:event-handler-content-attributes-5>Event handler content attribute</a>

    <tr><th id=ix-handler-onblur> <code>onblur</code>
     <td> <a href=#handler-onblur id=attributes-3:handler-onblur>HTML elements</a>
     <td> <code id=attributes-3:event-blur><a href=#event-blur>blur</a></code> event handler
     <td> <a href=#event-handler-content-attributes id=attributes-3:event-handler-content-attributes-6>Event handler content attribute</a>

    <tr><th id=ix-handler-oncancel> <code>oncancel</code>
     <td> <a href=#handler-oncancel id=attributes-3:handler-oncancel>HTML elements</a>
     <td> <code id=attributes-3:event-cancel><a href=#event-cancel>cancel</a></code> event handler
     <td> <a href=#event-handler-content-attributes id=attributes-3:event-handler-content-attributes-7>Event handler content attribute</a>

    <tr><th id=ix-handler-oncanplay> <code>oncanplay</code>
     <td> <a href=#handler-oncanplay id=attributes-3:handler-oncanplay>HTML elements</a>
     <td> <code id=attributes-3:event-media-canplay><a href=#event-media-canplay>canplay</a></code> event handler
     <td> <a href=#event-handler-content-attributes id=attributes-3:event-handler-content-attributes-8>Event handler content attribute</a>

    <tr><th id=ix-handler-oncanplaythrough> <code>oncanplaythrough</code>
     <td> <a href=#handler-oncanplaythrough id=attributes-3:handler-oncanplaythrough>HTML elements</a>
     <td> <code id=attributes-3:event-media-canplaythrough><a href=#event-media-canplaythrough>canplaythrough</a></code> event handler
     <td> <a href=#event-handler-content-attributes id=attributes-3:event-handler-content-attributes-9>Event handler content attribute</a>

    <tr><th id=ix-handler-onchange> <code>onchange</code>
     <td> <a href=#handler-onchange id=attributes-3:handler-onchange>HTML elements</a>
     <td> <code id=attributes-3:event-change><a href=#event-change>change</a></code> event handler
     <td> <a href=#event-handler-content-attributes id=attributes-3:event-handler-content-attributes-10>Event handler content attribute</a>

    <tr><th id=ix-handler-onclick> <code>onclick</code>
     <td> <a href=#handler-onclick id=attributes-3:handler-onclick>HTML elements</a>
     <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> <a href=#event-handler-content-attributes id=attributes-3:event-handler-content-attributes-11>Event handler content attribute</a>

    <tr><th id=ix-handler-onclose> <code>onclose</code>
     <td> <a href=#handler-onclose id=attributes-3:handler-onclose>HTML elements</a>
     <td> <code id=attributes-3:event-close><a href=#event-close>close</a></code> event handler
     <td> <a href=#event-handler-content-attributes id=attributes-3:event-handler-content-attributes-12>Event handler content attribute</a>

    <tr><th id=ix-handler-oncontextmenu> <code>oncontextmenu</code>
     <td> <a href=#handler-oncontextmenu id=attributes-3:handler-oncontextmenu>HTML elements</a>
     <td> <code id=attributes-3:event-contextmenu><a href=#event-contextmenu>contextmenu</a></code> event handler
     <td> <a href=#event-handler-content-attributes id=attributes-3:event-handler-content-attributes-13>Event handler content attribute</a>

    <tr><th id=ix-handler-oncopy> <code>oncopy</code>
     <td> <a href=#handler-oncopy id=attributes-3:handler-oncopy>HTML elements</a>
     <td> <code id=attributes-3:event-copy><a href=#event-copy>copy</a></code> event handler
     <td> <a href=#event-handler-content-attributes id=attributes-3:event-handler-content-attributes-14>Event handler content attribute</a>

    <tr><th id=ix-handler-oncuechange> <code>oncuechange</code>
     <td> <a href=#handler-oncuechange id=attributes-3:handler-oncuechange>HTML elements</a>
     <td> <code id=attributes-3:event-media-cuechange><a href=#event-media-cuechange>cuechange</a></code> event handler
     <td> <a href=#event-handler-content-attributes id=attributes-3:event-handler-content-attributes-15>Event handler content attribute</a>

    <tr><th id=ix-handler-oncut> <code>oncut</code>
     <td> <a href=#handler-oncut id=attributes-3:handler-oncut>HTML elements</a>
     <td> <code id=attributes-3:event-cut><a href=#event-cut>cut</a></code> event handler
     <td> <a href=#event-handler-content-attributes id=attributes-3:event-handler-content-attributes-16>Event handler content attribute</a>

    <tr><th id=ix-handler-ondblclick> <code>ondblclick</code>
     <td> <a href=#handler-ondblclick id=attributes-3:handler-ondblclick>HTML elements</a>
     <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> <a href=#event-handler-content-attributes id=attributes-3:event-handler-content-attributes-17>Event handler content attribute</a>

    <tr><th id=ix-handler-ondrag> <code>ondrag</code>
     <td> <a href=#handler-ondrag id=attributes-3:handler-ondrag>HTML elements</a>
     <td> <code id=attributes-3:event-dnd-drag><a href=#event-dnd-drag>drag</a></code> event handler
     <td> <a href=#event-handler-content-attributes id=attributes-3:event-handler-content-attributes-18>Event handler content attribute</a>

    <tr><th id=ix-handler-ondragend> <code>ondragend</code>
     <td> <a href=#handler-ondragend id=attributes-3:handler-ondragend>HTML elements</a>
     <td> <code id=attributes-3:event-dnd-dragend><a href=#event-dnd-dragend>dragend</a></code> event handler
     <td> <a href=#event-handler-content-attributes id=attributes-3:event-handler-content-attributes-19>Event handler content attribute</a>

    <tr><th id=ix-handler-ondragenter> <code>ondragenter</code>
     <td> <a href=#handler-ondragenter id=attributes-3:handler-ondragenter>HTML elements</a>
     <td> <code id=attributes-3:event-dnd-dragenter><a href=#event-dnd-dragenter>dragenter</a></code> event handler
     <td> <a href=#event-handler-content-attributes id=attributes-3:event-handler-content-attributes-20>Event handler content attribute</a>

    <tr><th id=ix-handler-ondragexit> <code>ondragexit</code>
     <td> <a href=#handler-ondragexit id=attributes-3:handler-ondragexit>HTML elements</a>
     <td> <code id=attributes-3:event-dnd-dragexit><a href=#event-dnd-dragexit>dragexit</a></code> event handler
     <td> <a href=#event-handler-content-attributes id=attributes-3:event-handler-content-attributes-21>Event handler content attribute</a>

    <tr><th id=ix-handler-ondragleave> <code>ondragleave</code>
     <td> <a href=#handler-ondragleave id=attributes-3:handler-ondragleave>HTML elements</a>
     <td> <code id=attributes-3:event-dnd-dragleave><a href=#event-dnd-dragleave>dragleave</a></code> event handler
     <td> <a href=#event-handler-content-attributes id=attributes-3:event-handler-content-attributes-22>Event handler content attribute</a>

    <tr><th id=ix-handler-ondragover> <code>ondragover</code>
     <td> <a href=#handler-ondragover id=attributes-3:handler-ondragover>HTML elements</a>
     <td> <code id=attributes-3:event-dnd-dragover><a href=#event-dnd-dragover>dragover</a></code> event handler
     <td> <a href=#event-handler-content-attributes id=attributes-3:event-handler-content-attributes-23>Event handler content attribute</a>

    <tr><th id=ix-handler-ondragstart> <code>ondragstart</code>
     <td> <a href=#handler-ondragstart id=attributes-3:handler-ondragstart>HTML elements</a>
     <td> <code id=attributes-3:event-dnd-dragstart><a href=#event-dnd-dragstart>dragstart</a></code> event handler
     <td> <a href=#event-handler-content-attributes id=attributes-3:event-handler-content-attributes-24>Event handler content attribute</a>

    <tr><th id=ix-handler-ondrop> <code>ondrop</code>
     <td> <a href=#handler-ondrop id=attributes-3:handler-ondrop>HTML elements</a>
     <td> <code id=attributes-3:event-dnd-drop><a href=#event-dnd-drop>drop</a></code> event handler
     <td> <a href=#event-handler-content-attributes id=attributes-3:event-handler-content-attributes-25>Event handler content attribute</a>

    <tr><th id=ix-handler-ondurationchange> <code>ondurationchange</code>
     <td> <a href=#handler-ondurationchange id=attributes-3:handler-ondurationchange>HTML elements</a>
     <td> <code id=attributes-3:event-media-durationchange><a href=#event-media-durationchange>durationchange</a></code> event handler
     <td> <a href=#event-handler-content-attributes id=attributes-3:event-handler-content-attributes-26>Event handler content attribute</a>

    <tr><th id=ix-handler-onemptied> <code>onemptied</code>
     <td> <a href=#handler-onemptied id=attributes-3:handler-onemptied>HTML elements</a>
     <td> <code id=attributes-3:event-media-emptied><a href=#event-media-emptied>emptied</a></code> event handler
     <td> <a href=#event-handler-content-attributes id=attributes-3:event-handler-content-attributes-27>Event handler content attribute</a>

    <tr><th id=ix-handler-onended> <code>onended</code>
     <td> <a href=#handler-onended id=attributes-3:handler-onended>HTML elements</a>
     <td> <code id=attributes-3:event-media-ended><a href=#event-media-ended>ended</a></code> event handler
     <td> <a href=#event-handler-content-attributes id=attributes-3:event-handler-content-attributes-28>Event handler content attribute</a>

    <tr><th id=ix-handler-onerror> <code>onerror</code>
     <td> <a href=#handler-onerror id=attributes-3:handler-onerror>HTML elements</a>
     <td> <code id=attributes-3:event-error><a href=#event-error>error</a></code> event handler
     <td> <a href=#event-handler-content-attributes id=attributes-3:event-handler-content-attributes-29>Event handler content attribute</a>

    <tr><th id=ix-handler-onfocus> <code>onfocus</code>
     <td> <a href=#handler-onfocus id=attributes-3:handler-onfocus>HTML elements</a>
     <td> <code id=attributes-3:event-focus><a href=#event-focus>focus</a></code> event handler
     <td> <a href=#event-handler-content-attributes id=attributes-3:event-handler-content-attributes-30>Event handler content attribute</a>

    <tr><th id=ix-handler-window-onhashchange> <code>onhashchange</code>
     <td> <code id=attributes-3:handler-window-onhashchange><a href=#handler-window-onhashchange>body</a></code>
     <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> <a href=#event-handler-content-attributes id=attributes-3:event-handler-content-attributes-31>Event handler content attribute</a>

    <tr><th id=ix-handler-oninput> <code>oninput</code>
     <td> <a href=#handler-oninput id=attributes-3:handler-oninput>HTML elements</a>
     <td> <code id=attributes-3:event-input><a href=#event-input>input</a></code> event handler
     <td> <a href=#event-handler-content-attributes id=attributes-3:event-handler-content-attributes-32>Event handler content attribute</a>

    <tr><th id=ix-handler-oninvalid> <code>oninvalid</code>
     <td> <a href=#handler-oninvalid id=attributes-3:handler-oninvalid>HTML elements</a>
     <td> <code id=attributes-3:event-invalid><a href=#event-invalid>invalid</a></code> event handler
     <td> <a href=#event-handler-content-attributes id=attributes-3:event-handler-content-attributes-33>Event handler content attribute</a>

    <tr><th id=ix-handler-onkeydown> <code>onkeydown</code>
     <td> <a href=#handler-onkeydown id=attributes-3:handler-onkeydown>HTML elements</a>
     <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> <a href=#event-handler-content-attributes id=attributes-3:event-handler-content-attributes-34>Event handler content attribute</a>

    <tr><th id=ix-handler-onkeypress> <code>onkeypress</code>
     <td> <a href=#handler-onkeypress id=attributes-3:handler-onkeypress>HTML elements</a>
     <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> <a href=#event-handler-content-attributes id=attributes-3:event-handler-content-attributes-35>Event handler content attribute</a>

    <tr><th id=ix-handler-onkeyup> <code>onkeyup</code>
     <td> <a href=#handler-onkeyup id=attributes-3:handler-onkeyup>HTML elements</a>
     <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> <a href=#event-handler-content-attributes id=attributes-3:event-handler-content-attributes-36>Event handler content attribute</a>

    <tr><th id=ix-handler-window-onlanguagechange> <code>onlanguagechange</code>
     <td> <code id=attributes-3:handler-window-onlanguagechange><a href=#handler-window-onlanguagechange>body</a></code>
     <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> <a href=#event-handler-content-attributes id=attributes-3:event-handler-content-attributes-37>Event handler content attribute</a>

    <tr><th id=ix-handler-onload> <code>onload</code>
     <td> <a href=#handler-onload id=attributes-3:handler-onload>HTML elements</a>
     <td> <code id=attributes-3:event-load><a href=#event-load>load</a></code> event handler
     <td> <a href=#event-handler-content-attributes id=attributes-3:event-handler-content-attributes-38>Event handler content attribute</a>

    <tr><th id=ix-handler-onloadeddata> <code>onloadeddata</code>
     <td> <a href=#handler-onloadeddata id=attributes-3:handler-onloadeddata>HTML elements</a>
     <td> <code id=attributes-3:event-media-loadeddata><a href=#event-media-loadeddata>loadeddata</a></code> event handler
     <td> <a href=#event-handler-content-attributes id=attributes-3:event-handler-content-attributes-39>Event handler content attribute</a>

    <tr><th id=ix-handler-onloadedmetadata> <code>onloadedmetadata</code>
     <td> <a href=#handler-onloadedmetadata id=attributes-3:handler-onloadedmetadata>HTML elements</a>
     <td> <code id=attributes-3:event-media-loadedmetadata><a href=#event-media-loadedmetadata>loadedmetadata</a></code> event handler
     <td> <a href=#event-handler-content-attributes id=attributes-3:event-handler-content-attributes-40>Event handler content attribute</a>

    <tr><th id=ix-handler-onloadend> <code>onloadend</code>
     <td> <a href=#handler-onloadend id=attributes-3:handler-onloadend>HTML elements</a>
     <td> <code id=attributes-3:event-loadend><a href=#event-loadend>loadend</a></code> event handler
     <td> <a href=#event-handler-content-attributes id=attributes-3:event-handler-content-attributes-41>Event handler content attribute</a>

    <tr><th id=ix-handler-onloadstart> <code>onloadstart</code>
     <td> <a href=#handler-onloadstart id=attributes-3:handler-onloadstart>HTML elements</a>
     <td> <code id=attributes-3:event-media-loadstart><a href=#event-media-loadstart>loadstart</a></code> event handler
     <td> <a href=#event-handler-content-attributes id=attributes-3:event-handler-content-attributes-42>Event handler content attribute</a>

    <tr><th id=ix-handler-window-onmessage> <code>onmessage</code>
     <td> <code id=attributes-3:handler-window-onmessage><a href=#handler-window-onmessage>body</a></code>
     <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> <a href=#event-handler-content-attributes id=attributes-3:event-handler-content-attributes-43>Event handler content attribute</a>

    <tr><th id=ix-handler-window-onmessageerror> <code>onmessageerror</code>
     <td> <code id=attributes-3:handler-window-onmessageerror><a href=#handler-window-onmessageerror>body</a></code>
     <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> <a href=#event-handler-content-attributes id=attributes-3:event-handler-content-attributes-44>Event handler content attribute</a>

    <tr><th id=ix-handler-onmousedown> <code>onmousedown</code>
     <td> <a href=#handler-onmousedown id=attributes-3:handler-onmousedown>HTML elements</a>
     <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> <a href=#event-handler-content-attributes id=attributes-3:event-handler-content-attributes-45>Event handler content attribute</a>

    <tr><th id=ix-handler-onmouseenter> <code>onmouseenter</code>
     <td> <a href=#handler-onmouseenter id=attributes-3:handler-onmouseenter>HTML elements</a>
     <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> <a href=#event-handler-content-attributes id=attributes-3:event-handler-content-attributes-46>Event handler content attribute</a>

    <tr><th id=ix-handler-onmouseleave> <code>onmouseleave</code>
     <td> <a href=#handler-onmouseleave id=attributes-3:handler-onmouseleave>HTML elements</a>
     <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> <a href=#event-handler-content-attributes id=attributes-3:event-handler-content-attributes-47>Event handler content attribute</a>

    <tr><th id=ix-handler-onmousemove> <code>onmousemove</code>
     <td> <a href=#handler-onmousemove id=attributes-3:handler-onmousemove>HTML elements</a>
     <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> <a href=#event-handler-content-attributes id=attributes-3:event-handler-content-attributes-48>Event handler content attribute</a>

    <tr><th id=ix-handler-onmouseout> <code>onmouseout</code>
     <td> <a href=#handler-onmouseout id=attributes-3:handler-onmouseout>HTML elements</a>
     <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> <a href=#event-handler-content-attributes id=attributes-3:event-handler-content-attributes-49>Event handler content attribute</a>

    <tr><th id=ix-handler-onmouseover> <code>onmouseover</code>
     <td> <a href=#handler-onmouseover id=attributes-3:handler-onmouseover>HTML elements</a>
     <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> <a href=#event-handler-content-attributes id=attributes-3:event-handler-content-attributes-50>Event handler content attribute</a>

    <tr><th id=ix-handler-onmouseup> <code>onmouseup</code>
     <td> <a href=#handler-onmouseup id=attributes-3:handler-onmouseup>HTML elements</a>
     <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> <a href=#event-handler-content-attributes id=attributes-3:event-handler-content-attributes-51>Event handler content attribute</a>

    <tr><th id=ix-handler-onwheel> <code>onwheel</code>
     <td> <a href=#handler-onwheel id=attributes-3:handler-onwheel>HTML elements</a>
     <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> <a href=#event-handler-content-attributes id=attributes-3:event-handler-content-attributes-52>Event handler content attribute</a>

    <tr><th id=ix-handler-window-onoffline> <code>onoffline</code>
     <td> <code id=attributes-3:handler-window-onoffline><a href=#handler-window-onoffline>body</a></code>
     <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> <a href=#event-handler-content-attributes id=attributes-3:event-handler-content-attributes-53>Event handler content attribute</a>

    <tr><th id=ix-handler-window-ononline> <code>ononline</code>
     <td> <code id=attributes-3:handler-window-ononline><a href=#handler-window-ononline>body</a></code>
     <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> <a href=#event-handler-content-attributes id=attributes-3:event-handler-content-attributes-54>Event handler content attribute</a>

    <tr><th id=ix-handler-window-onpagehide> <code>onpagehide</code>
     <td> <code id=attributes-3:handler-window-onpagehide><a href=#handler-window-onpagehide>body</a></code>
     <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> <a href=#event-handler-content-attributes id=attributes-3:event-handler-content-attributes-55>Event handler content attribute</a>

    <tr><th id=ix-handler-window-onpageshow> <code>onpageshow</code>
     <td> <code id=attributes-3:handler-window-onpageshow><a href=#handler-window-onpageshow>body</a></code>
     <td> <code id=attributes-3:event-pageshow><a href=#event-pageshow>pageshow</a></code> event handler for <code id=attributes-3:window-11><a href=#window>Window</a></code> object
     <td> <a href=#event-handler-content-attributes id=attributes-3:event-handler-content-attributes-56>Event handler content attribute</a>

    <tr><th id=ix-handler-onpaste> <code>onpaste</code>
     <td> <a href=#handler-onpaste id=attributes-3:handler-onpaste>HTML elements</a>
     <td> <code id=attributes-3:event-paste><a href=#event-paste>paste</a></code> event handler
     <td> <a href=#event-handler-content-attributes id=attributes-3:event-handler-content-attributes-57>Event handler content attribute</a>

    <tr><th id=ix-handler-onpause> <code>onpause</code>
     <td> <a href=#handler-onpause id=attributes-3:handler-onpause>HTML elements</a>
     <td> <code id=attributes-3:event-media-pause><a href=#event-media-pause>pause</a></code> event handler
     <td> <a href=#event-handler-content-attributes id=attributes-3:event-handler-content-attributes-58>Event handler content attribute</a>

    <tr><th id=ix-handler-onplay> <code>onplay</code>
     <td> <a href=#handler-onplay id=attributes-3:handler-onplay>HTML elements</a>
     <td> <code id=attributes-3:event-media-play><a href=#event-media-play>play</a></code> event handler
     <td> <a href=#event-handler-content-attributes id=attributes-3:event-handler-content-attributes-59>Event handler content attribute</a>

    <tr><th id=ix-handler-onplaying> <code>onplaying</code>
     <td> <a href=#handler-onplaying id=attributes-3:handler-onplaying>HTML elements</a>
     <td> <code id=attributes-3:event-media-playing><a href=#event-media-playing>playing</a></code> event handler
     <td> <a href=#event-handler-content-attributes id=attributes-3:event-handler-content-attributes-60>Event handler content attribute</a>

    <tr><th id=ix-handler-window-onpopstate> <code>onpopstate</code>
     <td> <code id=attributes-3:handler-window-onpopstate><a href=#handler-window-onpopstate>body</a></code>
     <td> <code id=attributes-3:event-popstate><a href=#event-popstate>popstate</a></code> event handler for <code id=attributes-3:window-12><a href=#window>Window</a></code> object
     <td> <a href=#event-handler-content-attributes id=attributes-3:event-handler-content-attributes-61>Event handler content attribute</a>

    <tr><th id=ix-handler-onprogress> <code>onprogress</code>
     <td> <a href=#handler-onprogress id=attributes-3:handler-onprogress>HTML elements</a>
     <td> <code id=attributes-3:event-media-progress><a href=#event-media-progress>progress</a></code> event handler
     <td> <a href=#event-handler-content-attributes id=attributes-3:event-handler-content-attributes-62>Event handler content attribute</a>

    <tr><th id=ix-handler-onratechange> <code>onratechange</code>
     <td> <a href=#handler-onratechange id=attributes-3:handler-onratechange>HTML elements</a>
     <td> <code id=attributes-3:event-media-ratechange><a href=#event-media-ratechange>ratechange</a></code> event handler
     <td> <a href=#event-handler-content-attributes id=attributes-3:event-handler-content-attributes-63>Event handler content attribute</a>

    <tr><th id=ix-handler-onreset> <code>onreset</code>
     <td> <a href=#handler-onreset id=attributes-3:handler-onreset>HTML elements</a>
     <td> <code id=attributes-3:event-reset><a href=#event-reset>reset</a></code> event handler
     <td> <a href=#event-handler-content-attributes id=attributes-3:event-handler-content-attributes-64>Event handler content attribute</a>

    <tr><th id=ix-handler-onresize> <code>onresize</code>
     <td> <a href=#handler-onresize id=attributes-3:handler-onresize>HTML elements</a>
     <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> <a href=#event-handler-content-attributes id=attributes-3:event-handler-content-attributes-65>Event handler content attribute</a>

    <tr><th id=ix-handler-window-onrejectionhandled> <code>onrejectionhandled</code>
     <td> <code id=attributes-3:handler-window-onrejectionhandled><a href=#handler-window-onrejectionhandled>body</a></code>
     <td> <code id=attributes-3:event-rejectionhandled><a href=#event-rejectionhandled>rejectionhandled</a></code> event handler for <code id=attributes-3:window-13><a href=#window>Window</a></code> object
     <td> <a href=#event-handler-content-attributes id=attributes-3:event-handler-content-attributes-66>Event handler content attribute</a>

    <tr><th id=ix-handler-onscroll> <code>onscroll</code>
     <td> <a href=#handler-onscroll id=attributes-3:handler-onscroll>HTML elements</a>
     <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> <a href=#event-handler-content-attributes id=attributes-3:event-handler-content-attributes-67>Event handler content attribute</a>

    <tr><th id=ix-handler-onsecuritypolicyviolation> <code>onsecuritypolicyviolation</code>
     <td> <a href=#handler-onsecuritypolicyviolation id=attributes-3:handler-onsecuritypolicyviolation>HTML elements</a>
     <td> <code id=attributes-3:event-securitypolicyviolation><a href=#event-securitypolicyviolation>securitypolicyviolation</a></code> event handler
     <td> <a href=#event-handler-content-attributes id=attributes-3:event-handler-content-attributes-68>Event handler content attribute</a>

    <tr><th id=ix-handler-onseeked> <code>onseeked</code>
     <td> <a href=#handler-onseeked id=attributes-3:handler-onseeked>HTML elements</a>
     <td> <code id=attributes-3:event-media-seeked><a href=#event-media-seeked>seeked</a></code> event handler
     <td> <a href=#event-handler-content-attributes id=attributes-3:event-handler-content-attributes-69>Event handler content attribute</a>

    <tr><th id=ix-handler-onseeking> <code>onseeking</code>
     <td> <a href=#handler-onseeking id=attributes-3:handler-onseeking>HTML elements</a>
     <td> <code id=attributes-3:event-media-seeking><a href=#event-media-seeking>seeking</a></code> event handler
     <td> <a href=#event-handler-content-attributes id=attributes-3:event-handler-content-attributes-70>Event handler content attribute</a>

    <tr><th id=ix-handler-onselect> <code>onselect</code>
     <td> <a href=#handler-onselect id=attributes-3:handler-onselect>HTML elements</a>
     <td> <code id=attributes-3:event-select><a href=#event-select>select</a></code> event handler
     <td> <a href=#event-handler-content-attributes id=attributes-3:event-handler-content-attributes-71>Event handler content attribute</a>

    <tr><th id=ix-handler-onstalled> <code>onstalled</code>
     <td> <a href=#handler-onstalled id=attributes-3:handler-onstalled>HTML elements</a>
     <td> <code id=attributes-3:event-media-stalled><a href=#event-media-stalled>stalled</a></code> event handler
     <td> <a href=#event-handler-content-attributes id=attributes-3:event-handler-content-attributes-72>Event handler content attribute</a>

    <tr><th id=ix-handler-window-onstorage> <code>onstorage</code>
     <td> <code id=attributes-3:handler-window-onstorage><a href=#handler-window-onstorage>body</a></code>
     <td> <code id=attributes-3:event-storage><a href=#event-storage>storage</a></code> event handler for <code id=attributes-3:window-14><a href=#window>Window</a></code> object
     <td> <a href=#event-handler-content-attributes id=attributes-3:event-handler-content-attributes-73>Event handler content attribute</a>

    <tr><th id=ix-handler-onsubmit> <code>onsubmit</code>
     <td> <a href=#handler-onsubmit id=attributes-3:handler-onsubmit>HTML elements</a>
     <td> <code id=attributes-3:event-submit><a href=#event-submit>submit</a></code> event handler
     <td> <a href=#event-handler-content-attributes id=attributes-3:event-handler-content-attributes-74>Event handler content attribute</a>

    <tr><th id=ix-handler-onsuspend> <code>onsuspend</code>
     <td> <a href=#handler-onsuspend id=attributes-3:handler-onsuspend>HTML elements</a>
     <td> <code id=attributes-3:event-media-suspend><a href=#event-media-suspend>suspend</a></code> event handler
     <td> <a href=#event-handler-content-attributes id=attributes-3:event-handler-content-attributes-75>Event handler content attribute</a>

    <tr><th id=ix-handler-ontimeupdate> <code>ontimeupdate</code>
     <td> <a href=#handler-ontimeupdate id=attributes-3:handler-ontimeupdate>HTML elements</a>
     <td> <code id=attributes-3:event-media-timeupdate><a href=#event-media-timeupdate>timeupdate</a></code> event handler
     <td> <a href=#event-handler-content-attributes id=attributes-3:event-handler-content-attributes-76>Event handler content attribute</a>

    <tr><th id=ix-handler-ontoggle> <code>ontoggle</code>
     <td> <a href=#handler-ontoggle id=attributes-3:handler-ontoggle>HTML elements</a>
     <td> <code id=attributes-3:event-toggle><a href=#event-toggle>toggle</a></code> event handler
     <td> <a href=#event-handler-content-attributes id=attributes-3:event-handler-content-attributes-77>Event handler content attribute</a>

    <tr><th id=ix-handler-window-onunhandledrejection> <code>onunhandledrejection</code>
     <td> <code id=attributes-3:handler-window-onunhandledrejection><a href=#handler-window-onunhandledrejection>body</a></code>
     <td> <code id=attributes-3:event-unhandledrejection><a href=#event-unhandledrejection>unhandledrejection</a></code> event handler for <code id=attributes-3:window-15><a href=#window>Window</a></code> object
     <td> <a href=#event-handler-content-attributes id=attributes-3:event-handler-content-attributes-78>Event handler content attribute</a>

    <tr><th id=ix-handler-window-onunload> <code>onunload</code>
     <td> <code id=attributes-3:handler-window-onunload><a href=#handler-window-onunload>body</a></code>
     <td> <code id=attributes-3:event-unload><a href=#event-unload>unload</a></code> event handler for <code id=attributes-3:window-16><a href=#window>Window</a></code> object
     <td> <a href=#event-handler-content-attributes id=attributes-3:event-handler-content-attributes-79>Event handler content attribute</a>

    <tr><th id=ix-handler-onvolumechange> <code>onvolumechange</code>
     <td> <a href=#handler-onvolumechange id=attributes-3:handler-onvolumechange>HTML elements</a>
     <td> <code id=attributes-3:event-media-volumechange><a href=#event-media-volumechange>volumechange</a></code> event handler
     <td> <a href=#event-handler-content-attributes id=attributes-3:event-handler-content-attributes-80>Event handler content attribute</a>

    <tr><th id=ix-handler-onwaiting> <code>onwaiting</code>
     <td> <a href=#handler-onwaiting id=attributes-3:handler-onwaiting>HTML elements</a>
     <td> <code id=attributes-3:event-media-waiting><a href=#event-media-waiting>waiting</a></code> event handler
     <td> <a href=#event-handler-content-attributes id=attributes-3:event-handler-content-attributes-81>Event handler content attribute</a>

  </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> Interface(s)
   <tbody><tr><td> <code id=element-interfaces:the-a-element><a href=#the-a-element>a</a></code>
     <td> <code id=element-interfaces:htmlanchorelement><a href=#htmlanchorelement>HTMLAnchorElement</a></code> : <code id=element-interfaces:htmlelement><a href=#htmlelement>HTMLElement</a></code>

    <tr><td> <code id=element-interfaces:the-abbr-element><a href=#the-abbr-element>abbr</a></code>
     <td> <code id=element-interfaces:htmlelement-2><a href=#htmlelement>HTMLElement</a></code>

    <tr><td> <code id=element-interfaces:the-address-element><a href=#the-address-element>address</a></code>
     <td> <code id=element-interfaces:htmlelement-3><a href=#htmlelement>HTMLElement</a></code>

    <tr><td> <code id=element-interfaces:the-area-element><a href=#the-area-element>area</a></code>
     <td> <code id=element-interfaces:htmlareaelement><a href=#htmlareaelement>HTMLAreaElement</a></code> : <code id=element-interfaces:htmlelement-4><a href=#htmlelement>HTMLElement</a></code>

    <tr><td> <code id=element-interfaces:the-article-element><a href=#the-article-element>article</a></code>
     <td> <code id=element-interfaces:htmlelement-5><a href=#htmlelement>HTMLElement</a></code>

    <tr><td> <code id=element-interfaces:the-aside-element><a href=#the-aside-element>aside</a></code>
     <td> <code id=element-interfaces:htmlelement-6><a href=#htmlelement>HTMLElement</a></code>

    <tr><td> <code id=element-interfaces:the-audio-element><a href=#the-audio-element>audio</a></code>
     <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>

    <tr><td> <code id=element-interfaces:the-b-element><a href=#the-b-element>b</a></code>
     <td> <code id=element-interfaces:htmlelement-8><a href=#htmlelement>HTMLElement</a></code>

    <tr><td> <code id=element-interfaces:the-base-element><a href=#the-base-element>base</a></code>
     <td> <code id=element-interfaces:htmlbaseelement><a href=#htmlbaseelement>HTMLBaseElement</a></code> : <code id=element-interfaces:htmlelement-9><a href=#htmlelement>HTMLElement</a></code>

    <tr><td> <code id=element-interfaces:the-bdi-element><a href=#the-bdi-element>bdi</a></code>
     <td> <code id=element-interfaces:htmlelement-10><a href=#htmlelement>HTMLElement</a></code>

    <tr><td> <code id=element-interfaces:the-bdo-element><a href=#the-bdo-element>bdo</a></code>
     <td> <code id=element-interfaces:htmlelement-11><a href=#htmlelement>HTMLElement</a></code>

    <tr><td> <code id=element-interfaces:the-blockquote-element><a href=#the-blockquote-element>blockquote</a></code>
     <td> <code id=element-interfaces:htmlquoteelement><a href=#htmlquoteelement>HTMLQuoteElement</a></code> : <code id=element-interfaces:htmlelement-12><a href=#htmlelement>HTMLElement</a></code>

    <tr><td> <code id=element-interfaces:the-body-element><a href=#the-body-element>body</a></code>
     <td> <code id=element-interfaces:htmlbodyelement><a href=#htmlbodyelement>HTMLBodyElement</a></code> : <code id=element-interfaces:htmlelement-13><a href=#htmlelement>HTMLElement</a></code>

    <tr><td> <code id=element-interfaces:the-br-element><a href=#the-br-element>br</a></code>
     <td> <code id=element-interfaces:htmlbrelement><a href=#htmlbrelement>HTMLBRElement</a></code> : <code id=element-interfaces:htmlelement-14><a href=#htmlelement>HTMLElement</a></code>

    <tr><td> <code id=element-interfaces:the-button-element><a href=#the-button-element>button</a></code>
     <td> <code id=element-interfaces:htmlbuttonelement><a href=#htmlbuttonelement>HTMLButtonElement</a></code> : <code id=element-interfaces:htmlelement-15><a href=#htmlelement>HTMLElement</a></code>

    <tr><td> <code id=element-interfaces:the-canvas-element><a href=#the-canvas-element>canvas</a></code>
     <td> <code id=element-interfaces:htmlcanvaselement><a href=#htmlcanvaselement>HTMLCanvasElement</a></code> : <code id=element-interfaces:htmlelement-16><a href=#htmlelement>HTMLElement</a></code>

    <tr><td> <code id=element-interfaces:the-caption-element><a href=#the-caption-element>caption</a></code>
     <td> <code id=element-interfaces:htmltablecaptionelement><a href=#htmltablecaptionelement>HTMLTableCaptionElement</a></code> : <code id=element-interfaces:htmlelement-17><a href=#htmlelement>HTMLElement</a></code>

    <tr><td> <code id=element-interfaces:the-cite-element><a href=#the-cite-element>cite</a></code>
     <td> <code id=element-interfaces:htmlelement-18><a href=#htmlelement>HTMLElement</a></code>

    <tr><td> <code id=element-interfaces:the-code-element><a href=#the-code-element>code</a></code>
     <td> <code id=element-interfaces:htmlelement-19><a href=#htmlelement>HTMLElement</a></code>

    <tr><td> <code id=element-interfaces:the-col-element><a href=#the-col-element>col</a></code>
     <td> <code id=element-interfaces:htmltablecolelement><a href=#htmltablecolelement>HTMLTableColElement</a></code> : <code id=element-interfaces:htmlelement-20><a href=#htmlelement>HTMLElement</a></code>

    <tr><td> <code id=element-interfaces:the-colgroup-element><a href=#the-colgroup-element>colgroup</a></code>
     <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>

    <tr><td> <code id=element-interfaces:the-data-element><a href=#the-data-element>data</a></code>
     <td> <code id=element-interfaces:htmldataelement><a href=#htmldataelement>HTMLDataElement</a></code> : <code id=element-interfaces:htmlelement-22><a href=#htmlelement>HTMLElement</a></code>

    <tr><td> <code id=element-interfaces:the-datalist-element><a href=#the-datalist-element>datalist</a></code>
     <td> <code id=element-interfaces:htmldatalistelement><a href=#htmldatalistelement>HTMLDataListElement</a></code> : <code id=element-interfaces:htmlelement-23><a href=#htmlelement>HTMLElement</a></code>

    <tr><td> <code id=element-interfaces:the-dd-element><a href=#the-dd-element>dd</a></code>
     <td> <code id=element-interfaces:htmlelement-24><a href=#htmlelement>HTMLElement</a></code>

    <tr><td> <code id=element-interfaces:the-del-element><a href=#the-del-element>del</a></code>
     <td> <code id=element-interfaces:htmlmodelement><a href=#htmlmodelement>HTMLModElement</a></code> : <code id=element-interfaces:htmlelement-25><a href=#htmlelement>HTMLElement</a></code>

    <tr><td> <code id=element-interfaces:the-details-element><a href=#the-details-element>details</a></code>
     <td> <code id=element-interfaces:htmldetailselement><a href=#htmldetailselement>HTMLDetailsElement</a></code> : <code id=element-interfaces:htmlelement-26><a href=#htmlelement>HTMLElement</a></code>

    <tr><td> <code id=element-interfaces:the-dfn-element><a href=#the-dfn-element>dfn</a></code>
     <td> <code id=element-interfaces:htmlelement-27><a href=#htmlelement>HTMLElement</a></code>

    <tr><td> <code id=element-interfaces:the-dialog-element><a href=#the-dialog-element>dialog</a></code>
     <td> <code id=element-interfaces:htmldialogelement><a href=#htmldialogelement>HTMLDialogElement</a></code> : <code id=element-interfaces:htmlelement-28><a href=#htmlelement>HTMLElement</a></code>

    <tr><td> <code id=element-interfaces:the-div-element><a href=#the-div-element>div</a></code>
     <td> <code id=element-interfaces:htmldivelement><a href=#htmldivelement>HTMLDivElement</a></code> : <code id=element-interfaces:htmlelement-29><a href=#htmlelement>HTMLElement</a></code>

    <tr><td> <code id=element-interfaces:the-dl-element><a href=#the-dl-element>dl</a></code>
     <td> <code id=element-interfaces:htmldlistelement><a href=#htmldlistelement>HTMLDListElement</a></code> : <code id=element-interfaces:htmlelement-30><a href=#htmlelement>HTMLElement</a></code>

    <tr><td> <code id=element-interfaces:the-dt-element><a href=#the-dt-element>dt</a></code>
     <td> <code id=element-interfaces:htmlelement-31><a href=#htmlelement>HTMLElement</a></code>

    <tr><td> <code id=element-interfaces:the-em-element><a href=#the-em-element>em</a></code>
     <td> <code id=element-interfaces:htmlelement-32><a href=#htmlelement>HTMLElement</a></code>

    <tr><td> <code id=element-interfaces:the-embed-element><a href=#the-embed-element>embed</a></code>
     <td> <code id=element-interfaces:htmlembedelement><a href=#htmlembedelement>HTMLEmbedElement</a></code> : <code id=element-interfaces:htmlelement-33><a href=#htmlelement>HTMLElement</a></code>

    <tr><td> <code id=element-interfaces:the-fieldset-element><a href=#the-fieldset-element>fieldset</a></code>
     <td> <code id=element-interfaces:htmlfieldsetelement><a href=#htmlfieldsetelement>HTMLFieldSetElement</a></code> : <code id=element-interfaces:htmlelement-34><a href=#htmlelement>HTMLElement</a></code>

    <tr><td> <code id=element-interfaces:the-figcaption-element><a href=#the-figcaption-element>figcaption</a></code>
     <td> <code id=element-interfaces:htmlelement-35><a href=#htmlelement>HTMLElement</a></code>

    <tr><td> <code id=element-interfaces:the-figure-element><a href=#the-figure-element>figure</a></code>
     <td> <code id=element-interfaces:htmlelement-36><a href=#htmlelement>HTMLElement</a></code>

    <tr><td> <code id=element-interfaces:the-footer-element><a href=#the-footer-element>footer</a></code>
     <td> <code id=element-interfaces:htmlelement-37><a href=#htmlelement>HTMLElement</a></code>

    <tr><td> <code id=element-interfaces:the-form-element><a href=#the-form-element>form</a></code>
     <td> <code id=element-interfaces:htmlformelement><a href=#htmlformelement>HTMLFormElement</a></code> : <code id=element-interfaces:htmlelement-38><a href=#htmlelement>HTMLElement</a></code>

    <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> <code id=element-interfaces:htmlheadingelement><a href=#htmlheadingelement>HTMLHeadingElement</a></code> : <code id=element-interfaces:htmlelement-39><a href=#htmlelement>HTMLElement</a></code>

    <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> <code id=element-interfaces:htmlheadingelement-2><a href=#htmlheadingelement>HTMLHeadingElement</a></code> : <code id=element-interfaces:htmlelement-40><a href=#htmlelement>HTMLElement</a></code>

    <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> <code id=element-interfaces:htmlheadingelement-3><a href=#htmlheadingelement>HTMLHeadingElement</a></code> : <code id=element-interfaces:htmlelement-41><a href=#htmlelement>HTMLElement</a></code>

    <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> <code id=element-interfaces:htmlheadingelement-4><a href=#htmlheadingelement>HTMLHeadingElement</a></code> : <code id=element-interfaces:htmlelement-42><a href=#htmlelement>HTMLElement</a></code>

    <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> <code id=element-interfaces:htmlheadingelement-5><a href=#htmlheadingelement>HTMLHeadingElement</a></code> : <code id=element-interfaces:htmlelement-43><a href=#htmlelement>HTMLElement</a></code>

    <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> <code id=element-interfaces:htmlheadingelement-6><a href=#htmlheadingelement>HTMLHeadingElement</a></code> : <code id=element-interfaces:htmlelement-44><a href=#htmlelement>HTMLElement</a></code>

    <tr><td> <code id=element-interfaces:the-head-element><a href=#the-head-element>head</a></code>
     <td> <code id=element-interfaces:htmlheadelement><a href=#htmlheadelement>HTMLHeadElement</a></code> : <code id=element-interfaces:htmlelement-45><a href=#htmlelement>HTMLElement</a></code>

    <tr><td> <code id=element-interfaces:the-header-element><a href=#the-header-element>header</a></code>
     <td> <code id=element-interfaces:htmlelement-46><a href=#htmlelement>HTMLElement</a></code>

    <tr><td> <code id=element-interfaces:the-hgroup-element><a href=#the-hgroup-element>hgroup</a></code>
     <td> <code id=element-interfaces:htmlelement-47><a href=#htmlelement>HTMLElement</a></code>

    <tr><td> <code id=element-interfaces:the-hr-element><a href=#the-hr-element>hr</a></code>
     <td> <code id=element-interfaces:htmlhrelement><a href=#htmlhrelement>HTMLHRElement</a></code> : <code id=element-interfaces:htmlelement-48><a href=#htmlelement>HTMLElement</a></code>

    <tr><td> <code id=element-interfaces:the-html-element><a href=#the-html-element>html</a></code>
     <td> <code id=element-interfaces:htmlhtmlelement><a href=#htmlhtmlelement>HTMLHtmlElement</a></code> : <code id=element-interfaces:htmlelement-49><a href=#htmlelement>HTMLElement</a></code>

    <tr><td> <code id=element-interfaces:the-i-element><a href=#the-i-element>i</a></code>
     <td> <code id=element-interfaces:htmlelement-50><a href=#htmlelement>HTMLElement</a></code>

    <tr><td> <code id=element-interfaces:the-iframe-element><a href=#the-iframe-element>iframe</a></code>
     <td> <code id=element-interfaces:htmliframeelement><a href=#htmliframeelement>HTMLIFrameElement</a></code> : <code id=element-interfaces:htmlelement-51><a href=#htmlelement>HTMLElement</a></code>

    <tr><td> <code id=element-interfaces:the-img-element><a href=#the-img-element>img</a></code>
     <td> <code id=element-interfaces:htmlimageelement><a href=#htmlimageelement>HTMLImageElement</a></code> : <code id=element-interfaces:htmlelement-52><a href=#htmlelement>HTMLElement</a></code>

    <tr><td> <code id=element-interfaces:the-input-element><a href=#the-input-element>input</a></code>
     <td> <code id=element-interfaces:htmlinputelement><a href=#htmlinputelement>HTMLInputElement</a></code> : <code id=element-interfaces:htmlelement-53><a href=#htmlelement>HTMLElement</a></code>

    <tr><td> <code id=element-interfaces:the-ins-element><a href=#the-ins-element>ins</a></code>
     <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>

    <tr><td> <code id=element-interfaces:the-kbd-element><a href=#the-kbd-element>kbd</a></code>
     <td> <code id=element-interfaces:htmlelement-55><a href=#htmlelement>HTMLElement</a></code>

    <tr><td> <code id=element-interfaces:the-label-element><a href=#the-label-element>label</a></code>
     <td> <code id=element-interfaces:htmllabelelement><a href=#htmllabelelement>HTMLLabelElement</a></code> : <code id=element-interfaces:htmlelement-56><a href=#htmlelement>HTMLElement</a></code>

    <tr><td> <code id=element-interfaces:the-legend-element><a href=#the-legend-element>legend</a></code>
     <td> <code id=element-interfaces:htmllegendelement><a href=#htmllegendelement>HTMLLegendElement</a></code> : <code id=element-interfaces:htmlelement-57><a href=#htmlelement>HTMLElement</a></code>

    <tr><td> <code id=element-interfaces:the-li-element><a href=#the-li-element>li</a></code>
     <td> <code id=element-interfaces:htmllielement><a href=#htmllielement>HTMLLIElement</a></code> : <code id=element-interfaces:htmlelement-58><a href=#htmlelement>HTMLElement</a></code>

    <tr><td> <code id=element-interfaces:the-link-element><a href=#the-link-element>link</a></code>
     <td> <code id=element-interfaces:htmllinkelement><a href=#htmllinkelement>HTMLLinkElement</a></code> : <code id=element-interfaces:htmlelement-59><a href=#htmlelement>HTMLElement</a></code>

    <tr><td> <code id=element-interfaces:the-main-element><a href=#the-main-element>main</a></code>
     <td> <code id=element-interfaces:htmlelement-60><a href=#htmlelement>HTMLElement</a></code>

    <tr><td> <code id=element-interfaces:the-map-element><a href=#the-map-element>map</a></code>
     <td> <code id=element-interfaces:htmlmapelement><a href=#htmlmapelement>HTMLMapElement</a></code> : <code id=element-interfaces:htmlelement-61><a href=#htmlelement>HTMLElement</a></code>

    <tr><td> <code id=element-interfaces:the-mark-element><a href=#the-mark-element>mark</a></code>
     <td> <code id=element-interfaces:htmlelement-62><a href=#htmlelement>HTMLElement</a></code>

    <tr><td> <code id=element-interfaces:the-menu-element><a href=#the-menu-element>menu</a></code>
     <td> <code id=element-interfaces:htmlmenuelement><a href=#htmlmenuelement>HTMLMenuElement</a></code> : <code id=element-interfaces:htmlelement-63><a href=#htmlelement>HTMLElement</a></code>

    <tr><td> <code id=element-interfaces:the-meta-element><a href=#the-meta-element>meta</a></code>
     <td> <code id=element-interfaces:htmlmetaelement><a href=#htmlmetaelement>HTMLMetaElement</a></code> : <code id=element-interfaces:htmlelement-64><a href=#htmlelement>HTMLElement</a></code>

    <tr><td> <code id=element-interfaces:the-meter-element><a href=#the-meter-element>meter</a></code>
     <td> <code id=element-interfaces:htmlmeterelement><a href=#htmlmeterelement>HTMLMeterElement</a></code> : <code id=element-interfaces:htmlelement-65><a href=#htmlelement>HTMLElement</a></code>

    <tr><td> <code id=element-interfaces:the-nav-element><a href=#the-nav-element>nav</a></code>
     <td> <code id=element-interfaces:htmlelement-66><a href=#htmlelement>HTMLElement</a></code>

    <tr><td> <code id=element-interfaces:the-noscript-element><a href=#the-noscript-element>noscript</a></code>
     <td> <code id=element-interfaces:htmlelement-67><a href=#htmlelement>HTMLElement</a></code>

    <tr><td> <code id=element-interfaces:the-object-element><a href=#the-object-element>object</a></code>
     <td> <code id=element-interfaces:htmlobjectelement><a href=#htmlobjectelement>HTMLObjectElement</a></code> : <code id=element-interfaces:htmlelement-68><a href=#htmlelement>HTMLElement</a></code>

    <tr><td> <code id=element-interfaces:the-ol-element><a href=#the-ol-element>ol</a></code>
     <td> <code id=element-interfaces:htmlolistelement><a href=#htmlolistelement>HTMLOListElement</a></code> : <code id=element-interfaces:htmlelement-69><a href=#htmlelement>HTMLElement</a></code>

    <tr><td> <code id=element-interfaces:the-optgroup-element><a href=#the-optgroup-element>optgroup</a></code>
     <td> <code id=element-interfaces:htmloptgroupelement><a href=#htmloptgroupelement>HTMLOptGroupElement</a></code> : <code id=element-interfaces:htmlelement-70><a href=#htmlelement>HTMLElement</a></code>

    <tr><td> <code id=element-interfaces:the-option-element><a href=#the-option-element>option</a></code>
     <td> <code id=element-interfaces:htmloptionelement><a href=#htmloptionelement>HTMLOptionElement</a></code> : <code id=element-interfaces:htmlelement-71><a href=#htmlelement>HTMLElement</a></code>

    <tr><td> <code id=element-interfaces:the-output-element><a href=#the-output-element>output</a></code>
     <td> <code id=element-interfaces:htmloutputelement><a href=#htmloutputelement>HTMLOutputElement</a></code> : <code id=element-interfaces:htmlelement-72><a href=#htmlelement>HTMLElement</a></code>

    <tr><td> <code id=element-interfaces:the-p-element><a href=#the-p-element>p</a></code>
     <td> <code id=element-interfaces:htmlparagraphelement><a href=#htmlparagraphelement>HTMLParagraphElement</a></code> : <code id=element-interfaces:htmlelement-73><a href=#htmlelement>HTMLElement</a></code>

    <tr><td> <code id=element-interfaces:the-param-element><a href=#the-param-element>param</a></code>
     <td> <code id=element-interfaces:htmlparamelement><a href=#htmlparamelement>HTMLParamElement</a></code> : <code id=element-interfaces:htmlelement-74><a href=#htmlelement>HTMLElement</a></code>

    <tr><td> <code id=element-interfaces:the-picture-element><a href=#the-picture-element>picture</a></code>
     <td> <code id=element-interfaces:htmlpictureelement><a href=#htmlpictureelement>HTMLPictureElement</a></code> : <code id=element-interfaces:htmlelement-75><a href=#htmlelement>HTMLElement</a></code>

    <tr><td> <code id=element-interfaces:the-pre-element><a href=#the-pre-element>pre</a></code>
     <td> <code id=element-interfaces:htmlpreelement><a href=#htmlpreelement>HTMLPreElement</a></code> : <code id=element-interfaces:htmlelement-76><a href=#htmlelement>HTMLElement</a></code>

    <tr><td> <code id=element-interfaces:the-progress-element><a href=#the-progress-element>progress</a></code>
     <td> <code id=element-interfaces:htmlprogresselement><a href=#htmlprogresselement>HTMLProgressElement</a></code> : <code id=element-interfaces:htmlelement-77><a href=#htmlelement>HTMLElement</a></code>

    <tr><td> <code id=element-interfaces:the-q-element><a href=#the-q-element>q</a></code>
     <td> <code id=element-interfaces:htmlquoteelement-2><a href=#htmlquoteelement>HTMLQuoteElement</a></code> : <code id=element-interfaces:htmlelement-78><a href=#htmlelement>HTMLElement</a></code>

    <tr><td> <code id=element-interfaces:the-rp-element><a href=#the-rp-element>rp</a></code>
     <td> <code id=element-interfaces:htmlelement-79><a href=#htmlelement>HTMLElement</a></code>

    <tr><td> <code id=element-interfaces:the-rt-element><a href=#the-rt-element>rt</a></code>
     <td> <code id=element-interfaces:htmlelement-80><a href=#htmlelement>HTMLElement</a></code>

    <tr><td> <code id=element-interfaces:the-ruby-element><a href=#the-ruby-element>ruby</a></code>
     <td> <code id=element-interfaces:htmlelement-81><a href=#htmlelement>HTMLElement</a></code>

    <tr><td> <code id=element-interfaces:the-s-element><a href=#the-s-element>s</a></code>
     <td> <code id=element-interfaces:htmlelement-82><a href=#htmlelement>HTMLElement</a></code>

    <tr><td> <code id=element-interfaces:the-samp-element><a href=#the-samp-element>samp</a></code>
     <td> <code id=element-interfaces:htmlelement-83><a href=#htmlelement>HTMLElement</a></code>

    <tr><td> <code id=element-interfaces:the-script-element><a href=#the-script-element>script</a></code>
     <td> <code id=element-interfaces:htmlscriptelement><a href=#htmlscriptelement>HTMLScriptElement</a></code> : <code id=element-interfaces:htmlelement-84><a href=#htmlelement>HTMLElement</a></code>

    <tr><td> <code id=element-interfaces:the-section-element><a href=#the-section-element>section</a></code>
     <td> <code id=element-interfaces:htmlelement-85><a href=#htmlelement>HTMLElement</a></code>

    <tr><td> <code id=element-interfaces:the-select-element><a href=#the-select-element>select</a></code>
     <td> <code id=element-interfaces:htmlselectelement><a href=#htmlselectelement>HTMLSelectElement</a></code> : <code id=element-interfaces:htmlelement-86><a href=#htmlelement>HTMLElement</a></code>

    <tr><td> <code id=element-interfaces:the-slot-element><a href=#the-slot-element>slot</a></code>
     <td> <code id=element-interfaces:htmlslotelement><a href=#htmlslotelement>HTMLSlotElement</a></code> : <code id=element-interfaces:htmlelement-87><a href=#htmlelement>HTMLElement</a></code>

    <tr><td> <code id=element-interfaces:the-small-element><a href=#the-small-element>small</a></code>
     <td> <code id=element-interfaces:htmlelement-88><a href=#htmlelement>HTMLElement</a></code>

    <tr><td> <code id=element-interfaces:the-source-element><a href=#the-source-element>source</a></code>
     <td> <code id=element-interfaces:htmlsourceelement><a href=#htmlsourceelement>HTMLSourceElement</a></code> : <code id=element-interfaces:htmlelement-89><a href=#htmlelement>HTMLElement</a></code>

    <tr><td> <code id=element-interfaces:the-span-element><a href=#the-span-element>span</a></code>
     <td> <code id=element-interfaces:htmlspanelement><a href=#htmlspanelement>HTMLSpanElement</a></code> : <code id=element-interfaces:htmlelement-90><a href=#htmlelement>HTMLElement</a></code>

    <tr><td> <code id=element-interfaces:the-strong-element><a href=#the-strong-element>strong</a></code>
     <td> <code id=element-interfaces:htmlelement-91><a href=#htmlelement>HTMLElement</a></code>

    <tr><td> <code id=element-interfaces:the-style-element><a href=#the-style-element>style</a></code>
     <td> <code id=element-interfaces:htmlstyleelement><a href=#htmlstyleelement>HTMLStyleElement</a></code> : <code id=element-interfaces:htmlelement-92><a href=#htmlelement>HTMLElement</a></code>

    <tr><td> <code id=element-interfaces:the-sub-and-sup-elements><a href=#the-sub-and-sup-elements>sub</a></code>
     <td> <code id=element-interfaces:htmlelement-93><a href=#htmlelement>HTMLElement</a></code>

    <tr><td> <code id=element-interfaces:the-summary-element><a href=#the-summary-element>summary</a></code>
     <td> <code id=element-interfaces:htmlelement-94><a href=#htmlelement>HTMLElement</a></code>

    <tr><td> <code id=element-interfaces:the-sub-and-sup-elements-2><a href=#the-sub-and-sup-elements>sup</a></code>
     <td> <code id=element-interfaces:htmlelement-95><a href=#htmlelement>HTMLElement</a></code>

    <tr><td> <code id=element-interfaces:the-table-element><a href=#the-table-element>table</a></code>
     <td> <code id=element-interfaces:htmltableelement><a href=#htmltableelement>HTMLTableElement</a></code> : <code id=element-interfaces:htmlelement-96><a href=#htmlelement>HTMLElement</a></code>

    <tr><td> <code id=element-interfaces:the-tbody-element><a href=#the-tbody-element>tbody</a></code>
     <td> <code id=element-interfaces:htmltablesectionelement><a href=#htmltablesectionelement>HTMLTableSectionElement</a></code> : <code id=element-interfaces:htmlelement-97><a href=#htmlelement>HTMLElement</a></code>

    <tr><td> <code id=element-interfaces:the-td-element><a href=#the-td-element>td</a></code>
     <td> <code id=element-interfaces:htmltablecellelement><a href=#htmltablecellelement>HTMLTableCellElement</a></code> : <code id=element-interfaces:htmlelement-98><a href=#htmlelement>HTMLElement</a></code>

    <tr><td> <code id=element-interfaces:the-template-element><a href=#the-template-element>template</a></code>
     <td> <code id=element-interfaces:htmltemplateelement><a href=#htmltemplateelement>HTMLTemplateElement</a></code> : <code id=element-interfaces:htmlelement-99><a href=#htmlelement>HTMLElement</a></code>

    <tr><td> <code id=element-interfaces:the-textarea-element><a href=#the-textarea-element>textarea</a></code>
     <td> <code id=element-interfaces:htmltextareaelement><a href=#htmltextareaelement>HTMLTextAreaElement</a></code> : <code id=element-interfaces:htmlelement-100><a href=#htmlelement>HTMLElement</a></code>

    <tr><td> <code id=element-interfaces:the-tfoot-element><a href=#the-tfoot-element>tfoot</a></code>
     <td> <code id=element-interfaces:htmltablesectionelement-2><a href=#htmltablesectionelement>HTMLTableSectionElement</a></code> : <code id=element-interfaces:htmlelement-101><a href=#htmlelement>HTMLElement</a></code>

    <tr><td> <code id=element-interfaces:the-th-element><a href=#the-th-element>th</a></code>
     <td> <code id=element-interfaces:htmltablecellelement-2><a href=#htmltablecellelement>HTMLTableCellElement</a></code> : <code id=element-interfaces:htmlelement-102><a href=#htmlelement>HTMLElement</a></code>

    <tr><td> <code id=element-interfaces:the-thead-element><a href=#the-thead-element>thead</a></code>
     <td> <code id=element-interfaces:htmltablesectionelement-3><a href=#htmltablesectionelement>HTMLTableSectionElement</a></code> : <code id=element-interfaces:htmlelement-103><a href=#htmlelement>HTMLElement</a></code>

    <tr><td> <code id=element-interfaces:the-time-element><a href=#the-time-element>time</a></code>
     <td> <code id=element-interfaces:htmltimeelement><a href=#htmltimeelement>HTMLTimeElement</a></code> : <code id=element-interfaces:htmlelement-104><a href=#htmlelement>HTMLElement</a></code>

    <tr><td> <code id=element-interfaces:the-title-element><a href=#the-title-element>title</a></code>
     <td> <code id=element-interfaces:htmltitleelement><a href=#htmltitleelement>HTMLTitleElement</a></code> : <code id=element-interfaces:htmlelement-105><a href=#htmlelement>HTMLElement</a></code>

    <tr><td> <code id=element-interfaces:the-tr-element><a href=#the-tr-element>tr</a></code>
     <td> <code id=element-interfaces:htmltablerowelement><a href=#htmltablerowelement>HTMLTableRowElement</a></code> : <code id=element-interfaces:htmlelement-106><a href=#htmlelement>HTMLElement</a></code>

    <tr><td> <code id=element-interfaces:the-track-element><a href=#the-track-element>track</a></code>
     <td> <code id=element-interfaces:htmltrackelement><a href=#htmltrackelement>HTMLTrackElement</a></code> : <code id=element-interfaces:htmlelement-107><a href=#htmlelement>HTMLElement</a></code>

    <tr><td> <code id=element-interfaces:the-u-element><a href=#the-u-element>u</a></code>
     <td> <code id=element-interfaces:htmlelement-108><a href=#htmlelement>HTMLElement</a></code>

    <tr><td> <code id=element-interfaces:the-ul-element><a href=#the-ul-element>ul</a></code>
     <td> <code id=element-interfaces:htmlulistelement><a href=#htmlulistelement>HTMLUListElement</a></code> : <code id=element-interfaces:htmlelement-109><a href=#htmlelement>HTMLElement</a></code>

    <tr><td> <code id=element-interfaces:the-var-element><a href=#the-var-element>var</a></code>
     <td> <code id=element-interfaces:htmlelement-110><a href=#htmlelement>HTMLElement</a></code>

    <tr><td> <code id=element-interfaces:the-video-element><a href=#the-video-element>video</a></code>
     <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-111><a href=#htmlelement>HTMLElement</a></code>

    <tr><td> <code id=element-interfaces:the-wbr-element><a href=#the-wbr-element>wbr</a></code>
     <td> <code id=element-interfaces:htmlelement-112><a href=#htmlelement>HTMLElement</a></code>

    <tr><td> <a href=#custom-element id=element-interfaces:custom-element>custom elements</a>
     <td> supplied by the element's author (inherits from <code id=element-interfaces:htmlelement-113><a href=#htmlelement>HTMLElement</a></code>)

  </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></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>

  <table><caption>List of events</caption><thead><tr><th> Event
     <th> Interface
     <th> Interesting targets
     <th> Description
   <tbody><tr><td> <dfn data-dfn-for=Window id=event-abort data-dfn-type=event data-export=""><code>abort</code></dfn>
     <td> <code id=events-2:event><a data-x-internal=event href=https://dom.spec.whatwg.org/#interface-event>Event</a></code>
     <td> <code id=events-2:window><a href=#window>Window</a></code>
     <td> Fired at the <code id=events-2:window-2><a href=#window>Window</a></code> when the download was aborted by the user

    <tr><td> <dfn data-dfn-for=Document id=event-domcontentloaded data-dfn-type=event data-export=""><code>DOMContentLoaded</code></dfn>
     <td> <code id=events-2:event-2><a data-x-internal=event href=https://dom.spec.whatwg.org/#interface-event>Event</a></code>
     <td> <code id=events-2:document><a href=#document>Document</a></code>
     <td> Fired at the <code id=events-2:document-2><a href=#document>Document</a></code> once the parser has finished

    <tr><td> <dfn data-dfn-for=Window id=event-afterprint data-dfn-type=event data-export=""><code>afterprint</code></dfn>
     <td> <code id=events-2:event-3><a data-x-internal=event href=https://dom.spec.whatwg.org/#interface-event>Event</a></code>
     <td> <code id=events-2:window-3><a href=#window>Window</a></code>
     <td> Fired at the <code id=events-2:window-4><a href=#window>Window</a></code> after printing

    <tr><td> <dfn data-dfn-for=Window id=event-beforeprint data-dfn-type=event data-export=""><code>beforeprint</code></dfn>
     <td> <code id=events-2:event-4><a data-x-internal=event href=https://dom.spec.whatwg.org/#interface-event>Event</a></code>
     <td> <code id=events-2:window-5><a href=#window>Window</a></code>
     <td> Fired at the <code id=events-2:window-6><a href=#window>Window</a></code> before printing

    <tr><td> <dfn data-dfn-for=Window id=event-beforeunload data-dfn-type=event data-export=""><code>beforeunload</code></dfn>
     <td> <code id=events-2:beforeunloadevent><a href=#beforeunloadevent>BeforeUnloadEvent</a></code>
     <td> <code id=events-2:window-7><a href=#window>Window</a></code>
     <td> Fired at the <code id=events-2:window-8><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

    <tr><td> <dfn data-dfn-for=Window,HTMLElement id=event-blur data-dfn-type=event data-export=""><code>blur</code></dfn>
     <td> <code id=events-2:event-5><a data-x-internal=event href=https://dom.spec.whatwg.org/#interface-event>Event</a></code>
     <td> <code id=events-2:window-9><a href=#window>Window</a></code>, elements
     <td> Fired at nodes when they stop being <a href=#focused id=events-2:focused>focused</a>

    <tr><td> <dfn data-dfn-for=HTMLElement id=event-cancel data-dfn-type=event data-export=""><code>cancel</code></dfn>
     <td> <code id=events-2:event-6><a data-x-internal=event href=https://dom.spec.whatwg.org/#interface-event>Event</a></code>
     <td> <code id=events-2:the-dialog-element><a href=#the-dialog-element>dialog</a></code> elements
     <td> Fired at <code id=events-2:the-dialog-element-2><a href=#the-dialog-element>dialog</a></code> elements when they are canceled by the user (e.g. by pressing the Escape key)

    <tr><td> <dfn data-dfn-for=HTMLElement id=event-change data-dfn-type=event data-export=""><code id=event-input-change>change</code></dfn>
     <td> <code id=events-2:event-7><a data-x-internal=event href=https://dom.spec.whatwg.org/#interface-event>Event</a></code>
     <td> Form controls
     <td> Fired at controls when the user commits a value change (see also the <code id=events-2:event-input><a href=#event-input>input</a></code> event)

    <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> <code id=events-2:mouseevent><a data-x-internal=mouseevent href=https://w3c.github.io/uievents/#mouseevent>MouseEvent</a></code>
     <td> Elements
     <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)

    <tr><td> <dfn data-dfn-for=HTMLElement,WebSocket id=event-close data-dfn-type=event data-export=""><code>close</code></dfn>
     <td> <code id=events-2:event-8><a data-x-internal=event href=https://dom.spec.whatwg.org/#interface-event>Event</a></code>
     <td> <code id=events-2:the-dialog-element-3><a href=#the-dialog-element>dialog</a></code> elements, <code id=events-2:websocket><a href=#websocket>WebSocket</a></code>
     <td> Fired at <code id=events-2:the-dialog-element-4><a href=#the-dialog-element>dialog</a></code> elements when they are closed, and at <code id=events-2:websocket-2><a href=#websocket>WebSocket</a></code> elements when the connection is terminated

    <tr><td> <dfn data-dfn-for=SharedWorkerGlobalScope id=event-workerglobalscope-connect data-dfn-type=event data-export=""><code>connect</code></dfn>
     <td> <code id=events-2:messageevent><a href=#messageevent>MessageEvent</a></code>
     <td> <code id=events-2:sharedworkerglobalscope><a href=#sharedworkerglobalscope>SharedWorkerGlobalScope</a></code>
     <td> Fired at a shared worker's global scope when a new client connects

    <tr><td> <dfn data-dfn-for=HTMLElement id=event-contextmenu data-dfn-type=event data-export=""><code>contextmenu</code></dfn>
     <td> <code id=events-2:mouseevent-2><a data-x-internal=mouseevent href=https://w3c.github.io/uievents/#mouseevent>MouseEvent</a></code>
     <td> Elements
     <td> Fired at elements when the user requests their context menu

    <tr><td> <dfn data-dfn-for=HTMLElement id=event-copy data-dfn-type=event data-export=""><code>copy</code></dfn>
     <td> <code id=events-2:event-9><a data-x-internal=event href=https://dom.spec.whatwg.org/#interface-event>Event</a></code>
     <td> Elements
     <td> Fired at elements when the user copies data to the clipboard

    <tr><td> <dfn data-dfn-for=HTMLElement id=event-cut data-dfn-type=event data-export=""><code>cut</code></dfn>
     <td> <code id=events-2:event-10><a data-x-internal=event href=https://dom.spec.whatwg.org/#interface-event>Event</a></code>
     <td> Elements
     <td> Fired at elements when the user copies the selected data on the clipboard and removes the
     selection from the document

    <tr><td> <dfn data-dfn-for=Window,WorkerGlobalScope,HTMLElement,WebSocket,ApplicationCache,EventSource,Worker,SharedWorker,AbstractWorker id=event-error data-dfn-type=event data-export=""><code>error</code></dfn>
     <td> <code id=events-2:event-11><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> Global scope objects, <code id=events-2:worker><a href=#worker>Worker</a></code> objects, elements, networking-related objects
     <td> Fired when unexpected errors occur (e.g. networking errors, script errors, decoding errors)

    <tr><td> <dfn data-dfn-for=Window,HTMLElement id=event-focus data-dfn-type=event data-export=""><code>focus</code></dfn>
     <td> <code id=events-2:event-12><a data-x-internal=event href=https://dom.spec.whatwg.org/#interface-event>Event</a></code>
     <td> <code id=events-2:window-10><a href=#window>Window</a></code>, elements
     <td> Fired at nodes <a href=#gains-focus id=events-2:gains-focus>gaining focus</a>

    <tr><td> <dfn data-dfn-for=Window id=event-hashchange data-dfn-type=event data-export=""><code>hashchange</code></dfn>
     <td> <code id=events-2:hashchangeevent><a href=#hashchangeevent>HashChangeEvent</a></code>
     <td> <code id=events-2:window-11><a href=#window>Window</a></code>
     <td> Fired at the <code id=events-2:window-12><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

    <tr><td> <dfn data-dfn-for=HTMLElement id=event-input data-dfn-type=event data-export=""><code id=event-input-input>input</code></dfn><div class=status><input onclick=toggleStatus(this) value=⋰ type=button><p class=support><strong>Support:</strong> input-event<span class="and_chr yes"><span>Chrome for Android</span> <span>67+</span></span><span class="chrome yes"><span>Chrome</span> <span>15+</span></span><span class="ios_saf yes"><span>iOS Safari</span> <span>5.0+</span></span><span class="and_uc yes"><span>UC Browser for Android</span> <span>11.8+</span></span><span class="firefox yes"><span>Firefox</span> <span>3.6+</span></span><span class="ie yes"><span>IE</span> <span>10+</span></span><span class="op_mini no"><span>Opera Mini</span> <span>None</span></span><span class="safari yes"><span>Safari</span> <span>5.1+</span></span><span class="edge yes"><span>Edge</span> <span>12+</span></span><span class="samsung yes"><span>Samsung Internet</span> <span>4+</span></span><span class="opera yes"><span>Opera</span> <span>12.1+</span></span><span class="android yes"><span>Android Browser</span> <span>2.3+</span></span><p class=caniuse>Source: <a href="https://caniuse.com/#feat=input-event">caniuse.com</a></div>
     <td> <code id=events-2:event-13><a data-x-internal=event href=https://dom.spec.whatwg.org/#interface-event>Event</a></code>
     <td> Form controls
     <td> Fired at controls when the user changes the value (see also the <code id=events-2:event-change><a href=#event-change>change</a></code> event)

    <tr><td> <dfn data-dfn-for=HTMLElement id=event-invalid data-dfn-type=event data-export=""><code>invalid</code></dfn>
     <td> <code id=events-2:event-14><a data-x-internal=event href=https://dom.spec.whatwg.org/#interface-event>Event</a></code>
     <td> Form controls
     <td> Fired at controls during form validation if they do not satisfy their constraints

    <tr><td> <dfn data-dfn-for=Window,WorkerGlobalScope id=event-languagechange data-dfn-type=event data-export=""><code>languagechange</code></dfn>
     <td> <code id=events-2:event-15><a data-x-internal=event href=https://dom.spec.whatwg.org/#interface-event>Event</a></code>
     <td> Global scope objects
     <td> Fired at the global scope object when the user's preferred languages change

    <tr><td> <dfn data-dfn-for=Window,HTMLElement id=event-load data-dfn-type=event data-export=""><code>load</code></dfn>
     <td> <code id=events-2:event-16><a data-x-internal=event href=https://dom.spec.whatwg.org/#interface-event>Event</a></code>
     <td> <code id=events-2:window-13><a href=#window>Window</a></code>, elements
     <td> Fired at the <code id=events-2:window-14><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

    <tr><td> <dfn data-dfn-for=HTMLElement id=event-loadend data-dfn-type=event data-export=""><code>loadend</code></dfn>
     <td> <code id=events-2:event-17><a data-x-internal=event href=https://dom.spec.whatwg.org/#interface-event>Event</a></code> or <code id=events-2:progressevent><a data-x-internal=progressevent href=https://xhr.spec.whatwg.org/#interface-progressevent>ProgressEvent</a></code>
     <td> <code id=events-2:the-img-element-2><a href=#the-img-element>img</a></code> elements
     <td> Fired at <code id=events-2:the-img-element-3><a href=#the-img-element>img</a></code> elements after a successful load

    <tr><td> <dfn data-dfn-for=HTMLElement id=event-loadstart data-dfn-type=event data-export=""><code>loadstart</code></dfn>
     <td> <code id=events-2:progressevent-2><a data-x-internal=progressevent href=https://xhr.spec.whatwg.org/#interface-progressevent>ProgressEvent</a></code>
     <td> <code id=events-2:the-img-element-4><a href=#the-img-element>img</a></code> elements
     <td> Fired at <code id=events-2:the-img-element-5><a href=#the-img-element>img</a></code> elements when a load begins (see also <a href=#event-media-loadstart id=events-2:event-media-loadstart>media element events</a>)

    <tr><td> <dfn data-dfn-for=Window,EventSource,WebSocket,MessagePort,BroadcastChannel,DedicatedWorkerGlobalScope,Worker,ServiceWorkerContainer id=event-message data-dfn-type=event data-export=""><code>message</code></dfn>
     <td> <code id=events-2:messageevent-2><a href=#messageevent>MessageEvent</a></code>
     <td> <code id=events-2:window-15><a href=#window>Window</a></code>, <code id=events-2:eventsource><a href=#eventsource>EventSource</a></code>, <code id=events-2:websocket-3><a href=#websocket>WebSocket</a></code>, <code id=events-2:messageport><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> Fired at an object when it receives a message

    <tr><td> <dfn data-dfn-for=Window,MessagePort,BroadcastChannel,DedicatedWorkerGlobalScope,Worker,ServiceWorkerContainer id=event-messageerror data-dfn-type=event data-export=""><code>messageerror</code></dfn>
     <td> <code id=events-2:messageevent-3><a href=#messageevent>MessageEvent</a></code>
     <td> <code id=events-2:window-16><a href=#window>Window</a></code>, <code id=events-2:messageport-2><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> Fired at an object when it receives a message that cannot be deserialized

    <tr><td> <dfn data-dfn-for=Window,WorkerGlobalScope id=event-offline data-dfn-type=event data-export=""><code>offline</code></dfn>
     <td> <code id=events-2:event-18><a data-x-internal=event href=https://dom.spec.whatwg.org/#interface-event>Event</a></code>
     <td> Global scope objects
     <td> Fired at the global scope object when the network connections fails

    <tr><td> <dfn data-dfn-for=Window,WorkerGlobalScope id=event-online data-dfn-type=event data-export=""><code>online</code></dfn>
     <td> <code id=events-2:event-19><a data-x-internal=event href=https://dom.spec.whatwg.org/#interface-event>Event</a></code>
     <td> Global scope objects
     <td> Fired at the global scope object when the network connections returns

    <tr><td> <dfn data-dfn-for=EventSource,WebSocket id=event-open data-dfn-type=event data-export=""><code>open</code></dfn>
     <td> <code id=events-2:event-20><a data-x-internal=event href=https://dom.spec.whatwg.org/#interface-event>Event</a></code>
     <td> <code id=events-2:eventsource-2><a href=#eventsource>EventSource</a></code>, <code id=events-2:websocket-4><a href=#websocket>WebSocket</a></code>
     <td> Fired at networking-related objects when a connection is established

    <tr><td> <dfn data-dfn-for=Window id=event-pagehide data-dfn-type=event data-export=""><code>pagehide</code></dfn>
     <td> <code id=events-2:pagetransitionevent><a href=#pagetransitionevent>PageTransitionEvent</a></code>
     <td> <code id=events-2:window-17><a href=#window>Window</a></code>
     <td> Fired at the <code id=events-2:window-18><a href=#window>Window</a></code> when the page's entry in the <a href=#session-history id=events-2:session-history>session history</a> stops being the <a href=#current-entry id=events-2:current-entry>current entry</a>

    <tr><td> <dfn data-dfn-for=Window id=event-pageshow data-dfn-type=event data-export=""><code>pageshow</code></dfn><div class=status><input onclick=toggleStatus(this) value=⋰ type=button><p class=support><strong>Support:</strong> page-transition-events<span class="and_chr yes"><span>Chrome for Android</span> <span>67+</span></span><span class="chrome yes"><span>Chrome</span> <span>4+</span></span><span class="ios_saf yes"><span>iOS Safari</span> <span>5.0+</span></span><span class="and_uc yes"><span>UC Browser for Android</span> <span>11.8+</span></span><span class="firefox yes"><span>Firefox</span> <span>2+</span></span><span class="ie yes"><span>IE</span> <span>11+</span></span><span class="op_mini no"><span>Opera Mini</span> <span>None</span></span><span class="safari yes"><span>Safari</span> <span>5+</span></span><span class="edge yes"><span>Edge</span> <span>12+</span></span><span class="samsung yes"><span>Samsung Internet</span> <span>4+</span></span><span class="opera yes"><span>Opera</span> <span>15+</span></span><span class="android yes"><span>Android Browser</span> <span>2.3+</span></span><p class=caniuse>Source: <a href="https://caniuse.com/#feat=page-transition-events">caniuse.com</a></div>
     <td> <code id=events-2:pagetransitionevent-2><a href=#pagetransitionevent>PageTransitionEvent</a></code>
     <td> <code id=events-2:window-19><a href=#window>Window</a></code>
     <td> Fired at the <code id=events-2:window-20><a href=#window>Window</a></code> when the page's entry in the <a href=#session-history id=events-2:session-history-2>session history</a> becomes the <a href=#current-entry id=events-2:current-entry-2>current entry</a>

    <tr><td> <dfn data-dfn-for=HTMLElement id=event-paste data-dfn-type=event data-export=""><code>paste</code></dfn>
     <td> <code id=events-2:event-21><a data-x-internal=event href=https://dom.spec.whatwg.org/#interface-event>Event</a></code>
     <td> Elements
     <td> Fired at elements when the user will insert the clipboard data in the most suitable
     format (if any) supported for the given context

    <tr><td> <dfn data-dfn-for=Window id=event-popstate data-dfn-type=event data-export=""><code>popstate</code></dfn>
     <td> <code id=events-2:popstateevent><a href=#popstateevent>PopStateEvent</a></code>
     <td> <code id=events-2:window-21><a href=#window>Window</a></code>
     <td> Fired at the <code id=events-2:window-22><a href=#window>Window</a></code> when the user navigates the <a href=#session-history id=events-2:session-history-3>session history</a>

    <tr><td> <dfn data-dfn-for=HTMLElement id=event-progress data-dfn-type=event data-export=""><code>progress</code></dfn>
     <td> <code id=events-2:progressevent-3><a data-x-internal=progressevent href=https://xhr.spec.whatwg.org/#interface-progressevent>ProgressEvent</a></code>
     <td> <code id=events-2:the-img-element-6><a href=#the-img-element>img</a></code> elements
     <td> Fired at <code id=events-2:the-img-element-7><a href=#the-img-element>img</a></code> elements during a <a href=#cors-same-origin id=events-2:cors-same-origin>CORS-same-origin</a> image load (see also <a href=#event-media-progress id=events-2:event-media-progress>media element events</a>)

    <tr><td> <dfn data-dfn-for=Document id=event-readystatechange data-dfn-type=event data-export=""><code>readystatechange</code></dfn>
     <td> <code id=events-2:event-22><a data-x-internal=event href=https://dom.spec.whatwg.org/#interface-event>Event</a></code>
     <td> <code id=events-2:document-3><a href=#document>Document</a></code>
     <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

    <tr><td> <dfn data-dfn-for=Window,WorkerGlobalScope id=event-rejectionhandled data-dfn-type=event data-export=""><code>rejectionhandled</code></dfn>
     <td> <code id=events-2:promiserejectionevent><a href=#promiserejectionevent>PromiseRejectionEvent</a></code>
     <td> Global scope objects
     <td> Fired at global scope objects when a previously-unhandled promise rejection becomes handled

    <tr><td> <dfn data-dfn-for=HTMLElement id=event-reset data-dfn-type=event data-export=""><code>reset</code></dfn>
     <td> <code id=events-2:event-23><a data-x-internal=event href=https://dom.spec.whatwg.org/#interface-event>Event</a></code>
     <td> <code id=events-2:the-form-element><a href=#the-form-element>form</a></code> elements
     <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=#concept-form-reset id=events-2:concept-form-reset>reset</a>

    <tr><td> <dfn data-dfn-for=HTMLElement id=event-securitypolicyviolation data-dfn-type=event data-export=""><code>securitypolicyviolation</code></dfn>
     <td> <code id=events-2:event-24><a data-x-internal=event href=https://dom.spec.whatwg.org/#interface-event>Event</a></code>
     <td> Elements
     <td> Fired at elements when a Content Security Policy violation is generated <a href=#refsCSP>[CSP]</a>

    <tr><td> <dfn data-dfn-for=HTMLElement id=event-select data-dfn-type=event data-export=""><code>select</code></dfn>
     <td> <code id=events-2:event-25><a data-x-internal=event href=https://dom.spec.whatwg.org/#interface-event>Event</a></code>
     <td> Form controls
     <td> Fired at form controls when their text selection is adjusted (whether by an API or by the user)

    <tr><td> <dfn data-dfn-for=Window id=event-storage data-dfn-type=event data-export=""><code>storage</code></dfn>
     <td> <code id=events-2:storageevent><a href=#storageevent>StorageEvent</a></code>
     <td> <code id=events-2:window-23><a href=#window>Window</a></code>
     <td> Fired at <code id=events-2:window-24><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

    <tr><td> <dfn data-dfn-for=HTMLElement id=event-submit data-dfn-type=event data-export=""><code>submit</code></dfn>
     <td> <code id=events-2:event-26><a data-x-internal=event href=https://dom.spec.whatwg.org/#interface-event>Event</a></code>
     <td> <code id=events-2:the-form-element-3><a href=#the-form-element>form</a></code> elements
     <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-submit id=events-2:concept-form-submit>submitted</a>

    <tr><td> <dfn data-dfn-for=HTMLElement id=event-toggle data-dfn-type=event data-export=""><code>toggle</code></dfn>
     <td> <code id=events-2:event-27><a data-x-internal=event href=https://dom.spec.whatwg.org/#interface-event>Event</a></code>
     <td> <code id=events-2:the-details-element><a href=#the-details-element>details</a></code> element
     <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

    <tr><td> <dfn data-dfn-for=Window,WorkerGlobalScope id=event-unhandledrejection data-dfn-type=event data-export=""><code>unhandledrejection</code></dfn>
     <td> <code id=events-2:promiserejectionevent-2><a href=#promiserejectionevent>PromiseRejectionEvent</a></code>
     <td> Global scope objects
     <td> Fired at global scope objects when a promise rejection goes unhandled

    <tr><td> <dfn data-dfn-for=Window id=event-unload data-dfn-type=event data-export=""><code>unload</code></dfn>
     <td> <code id=events-2:event-28><a data-x-internal=event href=https://dom.spec.whatwg.org/#interface-event>Event</a></code>
     <td> <code id=events-2:window-25><a href=#window>Window</a></code>
     <td> Fired at the <code id=events-2:window-26><a href=#window>Window</a></code> object when the page is going away

  </table>

  <p class=note>See also <a href=#mediaevents>media element events</a>, <a href=#appcacheevents>application cache events</a>, and <a href=#dndevents>drag-and-drop
  events</a>.</p>



  <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><dd>Atom <a href=#refsATOM>[ATOM]</a><dt><dfn id=application/ecmascript><code>application/ecmascript</code></dfn><dd>JavaScript (legacy type) <a href=#refsJAVASCRIPT>[JAVASCRIPT]</a>

   <dt><dfn id=application/javascript><code>application/javascript</code></dfn><dd>JavaScript (legacy type) <a href=#refsJAVASCRIPT>[JAVASCRIPT]</a>

   <dt><dfn id=application/json><code>application/json</code></dfn><dd>JSON <a href=#refsJSON>[JSON]</a><dt><dfn id=application/x-ecmascript><code>application/x-ecmascript</code></dfn><dd>JavaScript (legacy type) <a href=#refsJAVASCRIPT>[JAVASCRIPT]</a>

   <dt><dfn id=application/x-javascript><code>application/x-javascript</code></dfn><dd>JavaScript (legacy type) <a href=#refsJAVASCRIPT>[JAVASCRIPT]</a>

   <dt><dfn id=application/octet-stream><a href=https://tools.ietf.org/html/rfc2046#section-4.5.1><code>application/octet-stream</code></a></dfn><dd>Generic binary data <a href=#refsRFC2046>[RFC2046]</a><dt><code id=mime-types-2:application/microdata+json><a href=#application/microdata+json>application/microdata+json</a></code><dd>Microdata as JSON

   <dt><dfn id=application/rss+xml><code>application/rss+xml</code></dfn><dd>RSS 

   <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><dd>Form submission<dt><code id=mime-types-2:application/xhtml+xml><a href=#application/xhtml+xml>application/xhtml+xml</a></code><dd>HTML<dt><dfn id=application/xml><code>application/xml</code></dfn><dd>XML <a href=#refsXML>[XML]</a> <a href=#refsRFC7303>[RFC7303]</a><dt><dfn id=image/gif><code>image/gif</code></dfn><dd>GIF images <a href=#refsGIF>[GIF]</a><dt><dfn id=image/jpeg><code>image/jpeg</code></dfn><dd>JPEG images <a href=#refsJPEG>[JPEG]</a><dt><dfn id=image/png><code>image/png</code></dfn><dd>PNG images <a href=#refsPNG>[PNG]</a><dt><dfn id=image/svg+xml><code>image/svg+xml</code></dfn><dd>SVG images <a href=#refsSVG>[SVG]</a><dt><dfn id=multipart/form-data><code>multipart/form-data</code></dfn><dd>Form submission <a href=#refsRFC7578>[RFC7578]</a><dt><dfn id=multipart/mixed><code>multipart/mixed</code></dfn><dd>Generic mixed content <a href=#refsRFC2046>[RFC2046]</a><dt><code id=mime-types-2:multipart/x-mixed-replace><a href=#multipart/x-mixed-replace>multipart/x-mixed-replace</a></code><dd>Streaming server push<dt><code id=mime-types-2:text/cache-manifest><a href=#text/cache-manifest>text/cache-manifest</a></code><dd>Offline application cache manifests<dt><dfn id=text/css><code>text/css</code></dfn><dd>CSS <a href=#refsCSS>[CSS]</a><dt><dfn id=text/ecmascript><code>text/ecmascript</code></dfn><dd>JavaScript (legacy type) <a href=#refsJAVASCRIPT>[JAVASCRIPT]</a>

   <dt><code id=mime-types-2:text/event-stream><a href=#text/event-stream>text/event-stream</a></code><dd>Server-sent event streams<dt><dfn id=text/javascript><code>text/javascript</code></dfn><dd>JavaScript <a href=#refsJAVASCRIPT>[JAVASCRIPT]</a>

   

   <dt><dfn id=text/javascript1.0><code>text/javascript1.0</code></dfn><dd>JavaScript (legacy type) <a href=#refsJAVASCRIPT>[JAVASCRIPT]</a>

   <dt><dfn id=text/javascript1.1><code>text/javascript1.1</code></dfn><dd>JavaScript (legacy type) <a href=#refsJAVASCRIPT>[JAVASCRIPT]</a>

   <dt><dfn id=text/javascript1.2><code>text/javascript1.2</code></dfn><dd>JavaScript (legacy type) <a href=#refsJAVASCRIPT>[JAVASCRIPT]</a>

   <dt><dfn id=text/javascript1.3><code>text/javascript1.3</code></dfn><dd>JavaScript (legacy type) <a href=#refsJAVASCRIPT>[JAVASCRIPT]</a>

   <dt><dfn id=text/javascript1.4><code>text/javascript1.4</code></dfn><dd>JavaScript (legacy type) <a href=#refsJAVASCRIPT>[JAVASCRIPT]</a>

   <dt><dfn id=text/javascript1.5><code>text/javascript1.5</code></dfn><dd>JavaScript (legacy type) <a href=#refsJAVASCRIPT>[JAVASCRIPT]</a>

   <dt><dfn id=text/jscript><code>text/jscript</code></dfn><dd>JavaScript (legacy type) <a href=#refsJAVASCRIPT>[JAVASCRIPT]</a>

   <dt><dfn id=text/json><code>text/json</code></dfn><dd>JSON (legacy type)<dt><dfn id=text/livescript><code>text/livescript</code></dfn><dd>JavaScript (legacy type) <a href=#refsJAVASCRIPT>[JAVASCRIPT]</a>

   <dt><dfn id=text/plain><a href=https://tools.ietf.org/html/rfc2046#section-4.1.3><code>text/plain</code></a></dfn><dd>Generic plain text <a href=#refsRFC2046>[RFC2046]</a> <a href=#refsRFC3676>[RFC3676]</a><dt><code id=mime-types-2:text/html><a href=#text/html>text/html</a></code><dd>HTML<dt><code id=mime-types-2:text/ping><a href=#text/ping>text/ping</a></code><dd>Hyperlink auditing<dt><dfn id=text/uri-list><code>text/uri-list</code></dfn><dd>List of URLs <a href=#refsRFC2483>[RFC2483]</a>

   <dt><dfn id=text/vcard><code>text/vcard</code></dfn><dd>vCard <a href=#refsRFC6350>[RFC6350]</a>

   <dt><dfn id=text/vtt><code>text/vtt</code></dfn><dd>WebVTT <a href=#refsWEBVTT>[WEBVTT]</a><dt><dfn id=text/x-ecmascript><code>text/x-ecmascript</code></dfn><dd>JavaScript (legacy type) <a href=#refsJAVASCRIPT>[JAVASCRIPT]</a>

   <dt><dfn id=text/x-javascript><code>text/x-javascript</code></dfn><dd>JavaScript (legacy type) <a href=#refsJAVASCRIPT>[JAVASCRIPT]</a>

   <dt><dfn id=text/xml><code>text/xml</code></dfn><dd>XML <a href=#refsXML>[XML]</a> <a href=#refsRFC7303>[RFC7303]</a><dt><dfn id=video/mp4><a href=https://tools.ietf.org/html/rfc4337#section-3><code>video/mp4</code></a></dfn><dd>MPEG-4 video <a href=#refsRFC4337>[RFC4337]</a><dt><dfn id=video/mpeg><code>video/mpeg</code></dfn><dd>MPEG video <a href=#refsRFC2046>[RFC2046]</a></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]<dd><cite><a href=https://tools.ietf.org/html/std68>Augmented BNF for Syntax Specifications: ABNF</a></cite>, D. Crocker, P. Overell. IETF.<dt id=refsABOUT>[ABOUT]<dd><cite><a href=https://tools.ietf.org/html/rfc6694>The 'about' URI scheme</a></cite>, S. Moonesamy. IETF.<dt id=refsAPNG>[APNG]<dd>(Non-normative) <cite><a href=https://wiki.mozilla.org/APNG_Specification>APNG Specification</a></cite>. S. Parmenter, V. Vukicevic, A. Smith. Mozilla.<dt id=refsARIA>[ARIA]<dd><cite><a href=https://w3c.github.io/aria/aria/aria.html>Accessible Rich Internet Applications (WAI-ARIA)</a></cite>, J. Diggs, J. Craig, S. McCarron, M. Cooper. W3C.<dt id=refsARIAHTML>[ARIAHTML]<dd><cite><a href=https://w3c.github.io/html-aria/>ARIA in HTML</a></cite>, S. Faulkner. W3C.<dt id=refsATAG>[ATAG]<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.<dt id=refsATOM>[ATOM]<dd>(Non-normative) <cite><a href=https://tools.ietf.org/html/rfc4287>The Atom Syndication Format</a></cite>, M. Nottingham, R. Sayre. IETF.<dt id=refsBATTERY>[BATTERY]<dd>(Non-normative) <cite><a href=https://w3c.github.io/battery/>Battery Status API</a></cite>, A. Kostiainen, M. Lamouri. W3C.<dt id=refsBCP47>[BCP47]<dd><cite><a href=https://tools.ietf.org/html/bcp47>Tags for Identifying Languages; Matching of Language Tags</a></cite>, A. Phillips, M. Davis. IETF.<dt id=refsBEZIER>[BEZIER]<dd><cite>Courbes à poles</cite>, P. de Casteljau. INPI, 1959.<dt id=refsBIDI>[BIDI]<dd><cite><a href=https://www.unicode.org/reports/tr9/>UAX #9: Unicode Bidirectional Algorithm</a></cite>, M. Davis. Unicode Consortium.<dt id=refsBOCU1>[BOCU1]<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.<dt id=refsCESU8>[CESU8]<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.<dt id=refsCHARMOD>[CHARMOD]<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.<dt id=refsCLDR>[CLDR]<dd><cite><a href=http://cldr.unicode.org/>Unicode Common Locale Data Repository</a></cite>. Unicode.<dt id=refsCOMPOSITE>[COMPOSITE]<dd><cite><a href=https://drafts.fxtf.org/compositing/>Compositing and Blending</a></cite>, R. Cabanier, N. Andronikos. W3C.<dt id=refsCOMPUTABLE>[COMPUTABLE]<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.<dt id=refsCOOKIES>[COOKIES]<dd><cite><a href=https://tools.ietf.org/html/rfc6265>HTTP State Management Mechanism</a></cite>, A. Barth. IETF.<dt id=refsCSP>[CSP]<dd><cite><a href=https://w3c.github.io/webappsec-csp/>Content Security Policy</a></cite>, M. West, D. Veditz. W3C.<dt id=refsCSS>[CSS]<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.<dt id=refsCSSALIGN>[CSSALIGN]<dd><cite><a href=https://drafts.csswg.org/css-align/>CSS Box Alignment</a></cite>, E. Etemad, T. Atkins. W3C.<dt id=refsCSSANIMATIONS>[CSSANIMATIONS]<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.<dt id=refsCSSATTR>[CSSATTR]<dd><cite><a href=https://drafts.csswg.org/css-style-attr/>CSS Style Attributes</a></cite>, T. Çelik, E. Etemad. W3C.<dt id=refsCSSBG>[CSSBG]<dd><cite><a href=https://drafts.csswg.org/css-backgrounds/>CSS Backgrounds and Borders </a></cite>, B. Bos, E. Etemad, B. Kemper. W3C.<dt id=refsCSSCASCADE>[CSSCASCADE]<dd><cite><a href=https://drafts.csswg.org/css-cascade/>CSS Cascading and Inheritance</a></cite>, E. Etemad, T. Atkins. W3C.<dt id=refsCSSCOLOR>[CSSCOLOR]<dd><cite><a href=https://drafts.csswg.org/css-color/>CSS Color Module</a></cite>, T. Çelik, C. Lilley, L. Baron. W3C.<dt id=refsCSSDISPLAY>[CSSDISPLAY]<dd><cite><a href=https://drafts.csswg.org/css-display/>CSS Display</a></cite>, T. Atkins, E. Etemad. W3C.<dt id=refsCSSFONTLOAD>[CSSFONTLOAD]<dd><cite><a href=https://drafts.csswg.org/css-font-loading/>CSS Font Loading</a></cite>, T. Atkins, J. Daggett. W3C.<dt id=refsCSSFONTS>[CSSFONTS]<dd><cite><a href=https://drafts.csswg.org/css-fonts/>CSS Fonts</a></cite>, J. Daggett. W3C.<dt id=refsCSSFLEXBOX>[CSSFLEXBOX]<dd><cite><a href=https://drafts.csswg.org/css-flexbox/>CSS Flexible Box Layout</a></cite>, T. Atkins, E. Etemad, R. Atanassov. W3C.<dt id=refsCSSGC>[CSSGC]<dd><cite><a href=https://drafts.csswg.org/css-content/>CSS Generated Content</a></cite>, H. Lie, E. Etemad, I. Hickson. W3C.<dt id=refsCSSGRID>[CSSGRID]<dd><cite><a href=https://drafts.csswg.org/css-grid/>CSS Grid Layout</a></cite>, T. Atkins, E. Etemad, R. Atanassov. W3C.<dt id=refsCSSIMAGES>[CSSIMAGES]<dd><cite><a href=https://drafts.csswg.org/css-images/>CSS Image Values and Replaced Content Module</a></cite>, E. Etemad, T. Atkins. W3C.<dt id=refsCSSLISTS>[CSSLISTS]<dd><cite><a href=https://drafts.csswg.org/css-lists/>CSS Lists and Counters</a></cite>, T. Atkins. W3C.<dt id=refsCSSLOGICAL>[CSSLOGICAL]<dd><cite><a href=https://drafts.csswg.org/css-logical/>CSS Logical Properties</a></cite>, R. Atanassov, E. Etemad. W3C.<dt id=refsCSSMULTICOL>[CSSMULTICOL]<dd><cite><a href=https://drafts.csswg.org/css-multicol/>CSS Multi-column Layout</a></cite>, H. Lie, F. Rivoal, R. Andrew. W3C.<dt id=refsCSSOM>[CSSOM]<dd><cite><a href=https://drafts.csswg.org/cssom/>Cascading Style Sheets Object Model (CSSOM)</a></cite>, S. Pieters, G. Adams. W3C.<dt id=refsCSSOMVIEW>[CSSOMVIEW]<dd><cite><a href=https://drafts.csswg.org/cssom-view/>CSSOM View Module</a></cite>, S. Pieters, G. Adams. W3C.<dt id=refsCSSOVERFLOW>[CSSOVERFLOW]<dd><cite><a href=https://drafts.csswg.org/css-overflow-3/>CSS Overflow Module</a></cite>, L. Baron, F. Rivoal. W3C.<dt id=refsCSSPOSITION>[CSSPOSITION]<dd><cite><a href=https://drafts.csswg.org/css-position/>CSS Positioned Layout</a></cite>, R. Atanassov, A. Eicholz. W3C.<dt id=refsCSSRUBY>[CSSRUBY]<dd><cite><a href=https://drafts.csswg.org/css-ruby/>CSS3 Ruby Module</a></cite>, R. Ishida. W3C.<dt id=refsCSSTRANSITIONS>[CSSTRANSITIONS]<dd>(Non-normative) <cite><a href=https://drafts.csswg.org/css-transitions/>CSS Transitions</a></cite>, D. Jackson, D. Hyatt, C. Marrin, L. Baron. W3C.<dt id=refsCSSUI>[CSSUI]<dd><cite><a href=https://drafts.csswg.org/css-ui/>CSS3 Basic User Interface Module</a></cite>, T. Çelik. W3C.<dt id=refsCSSSYNTAX>[CSSSYNTAX]<dd><cite><a href=https://drafts.csswg.org/css-syntax/>CSS Syntax</a></cite>, T. Atkins, S. Sapin. W3C.<dt id=refsCSSTABLE>[CSSTABLE]<dd><cite><a href=https://drafts.csswg.org/css-tables/>CSS Table</a></cite>, F. Remy, G. Whitworth. W3C.<dt id=refsCSSTEXT>[CSSTEXT]<dd><cite><a href=https://drafts.csswg.org/css-text/>CSS Text</a></cite>, E. Etemad, K. Ishii. W3C.<dt id=refsCSSVALUES>[CSSVALUES]<dd><cite><a href=https://drafts.csswg.org/css-values/>CSS3 Values and Units</a></cite>, H. Lie, T. Atkins, E. Etemad. W3C.<dt id=refsCSSWM>[CSSWM]<dd><cite><a href=https://drafts.csswg.org/css-writing-modes/>CSS Writing Modes</a></cite>, E. Etemad, K. Ishii. W3C.<dt id=refsDASH>[DASH]<dd><cite><a href=https://www.iso.org/standard/65274.html>Dynamic adaptive streaming over HTTP (DASH)</a></cite>. ISO.<dt id=refsDOM>[DOM]<dd><cite><a href=https://dom.spec.whatwg.org/>DOM</a></cite>, A. van Kesteren, A. Gregor, Ms2ger. WHATWG.<dt id=refsDOMPARSING>[DOMPARSING]<dd><cite><a href=https://w3c.github.io/DOM-Parsing/>DOM Parsing and Serialization</a></cite>, T. Leithead. W3C.<dt id=refsDOT>[DOT]<dd>(Non-normative) <cite><a href=http://www.graphviz.org/content/dot-language>The DOT Language</a></cite>. Graphviz.<dt id=refsE163>[E163]<dd><cite>Recommendation E.163 — Numbering Plan for The International Telephone Service</cite>, CCITT Blue Book, Fascicle II.2, pp. 128-134, November 1988.<dt id=refsENCODING>[ENCODING]<dd><cite><a href=https://encoding.spec.whatwg.org/>Encoding</a></cite>, A. van Kesteren, J. Bell. WHATWG.<dt id=refsEXECCOMMAND>[EXECCOMMAND]<dd><cite><a href=https://w3c.github.io/editing/execCommand.html>execCommand</a></cite>, J. Wilm, A. Gregor. W3C Editing APIs CG.<dt id=refsEXIF>[EXIF]<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.<dt id=refsFEATUREPOLICY>[FEATUREPOLICY]<dd><cite><a href=https://wicg.github.io/feature-policy/>Feature Policy</a></cite>, I. Clelland, WICG.<dt id=refsFETCH>[FETCH]<dd><cite><a href=https://fetch.spec.whatwg.org/>Fetch</a></cite>, A. van Kesteren. WHATWG.<dt id=refsFILEAPI>[FILEAPI]<dd><cite><a href=https://w3c.github.io/FileAPI/>File API</a></cite>, A. Ranganathan. W3C.<dt id=refsFILTERS>[FILTERS]<dd><cite><a href=https://drafts.fxtf.org/filter-effects/>Filter Effects</a></cite>, D. Jackson, E. Dahlström, D. Schulze. W3C.<dt id=refsFULLSCREEN>[FULLSCREEN]<dd><cite><a href=https://fullscreen.spec.whatwg.org/>Fullscreen</a></cite>, A. van Kesteren, T. Çelik. WHATWG.<dt id=refsGEOMETRY>[GEOMETRY]<dd><cite><a href=https://drafts.fxtf.org/geometry/>Geometry Interfaces Module</a></cite>. S. Pieters, D. Schulze, R. Cabanier. W3C.<dt id=refsGIF>[GIF]<dd>(Non-normative) <cite><a href=https://www.w3.org/Graphics/GIF/spec-gif89a.txt>Graphics Interchange Format</a></cite>. CompuServe.<dt id=refsGRAPHICS>[GRAPHICS]<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.<dt id=refsGREGORIAN>[GREGORIAN]<dd>(Non-normative) <cite>Inter Gravissimas</cite>, A. Lilius, C. Clavius. Gregory XIII Papal Bull, February 1582.<dt id=refsHRT>[HRT]<dd><cite><a href=https://w3c.github.io/hr-time/>High Resolution Time</a></cite>, I. Grigorik, J. Simonsen, J. Mann. W3C.<dt id=refsHTMLAAM>[HTMLAAM]<dd><cite><a href=https://w3c.github.io/aria/html-aam/html-aam.html>HTML Accessibility API Mappings 1.0</a></cite>, S. Faulkner, J. Kiss, A. Surkov. W3C.<dt id=refsHTTP>[HTTP]<dd><cite><a href=https://tools.ietf.org/html/rfc7230>Hypertext Transfer Protocol (HTTP/1.1): Message Syntax and Routing</a></cite>, R. Fielding, J. Reschke. IETF.<dd><cite><a href=https://tools.ietf.org/html/rfc7231>Hypertext Transfer Protocol (HTTP/1.1): Semantics and Content</a></cite>, R. Fielding, J. Reschke. IETF.<dd><cite><a href=https://tools.ietf.org/html/rfc7232>Hypertext Transfer Protocol (HTTP/1.1): Conditional Requests</a></cite>, R. Fielding, J. Reschke. IETF.<dd><cite><a href=https://tools.ietf.org/html/rfc7233>Hypertext Transfer Protocol (HTTP/1.1): Range Requests</a></cite>, R. Fielding, Y. Lafon, J. Reschke. IETF.<dd><cite><a href=https://tools.ietf.org/html/rfc7234>Hypertext Transfer Protocol (HTTP/1.1): Caching</a></cite>, R. Fielding, M. Nottingham, J. Reschke. IETF.<dd><cite><a href=https://tools.ietf.org/html/rfc7235>Hypertext Transfer Protocol (HTTP/1.1): Authentication</a></cite>, R. Fielding, J. Reschke. IETF.<dt id=refsINDEXEDDB>[INDEXEDDB]<dd><cite><a href=https://w3c.github.io/IndexedDB/>Indexed Database API</a></cite>, A. Alabbas, J. Bell. W3C.<dt id=refsINBAND>[INBAND]<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.<dt id=refsINFRA>[INFRA]<dd><cite><a href=https://infra.spec.whatwg.org/>Infra</a></cite>, A. van Kesteren, D. Denicola. WHATWG.<dt id=refsINTERSECTIONOBSERVER>[INTERSECTIONOBSERVER]<dd><cite><a href=https://w3c.github.io/IntersectionObserver/>Intersection Observer</a></cite>, S. Zager. W3C.<dt id=refsISO3166>[ISO3166]<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.<dt id=refsISO4217>[ISO4217]<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.<dt id=refsISO8601>[ISO8601]<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.<dt id=refsJAVASCRIPT>[JAVASCRIPT]<dd><cite><a href=https://tc39.github.io/ecma262/>ECMAScript Language Specification</a></cite>. Ecma International.<dt id=refsJLREQ>[JLREQ]<dd><cite><a href=https://www.w3.org/TR/jlreq/>Requirements for Japanese Text Layout</a></cite>. W3C.<dt id=refsJPEG>[JPEG]<dd><cite><a href=https://www.w3.org/Graphics/JPEG/jfif3.pdf>JPEG File Interchange Format</a></cite>, E. Hamilton.<dt id=refsJSBIGINT>[JSBIGINT]<dd><cite><a href=https://tc39.github.io/proposal-bigint/>BigInt</a></cite>. Ecma International.<dt id=refsJSIMPORT>[JSIMPORT]<dd><cite><a href=https://tc39.github.io/proposal-dynamic-import/>import()</a></cite>. Ecma International.<dt id=refsJSIMPORTMETA>[JSIMPORTMETA]<dd><cite><a href=https://tc39.github.io/proposal-import-meta/>import.meta</a></cite>. Ecma International.<dt id=refsJSINTL>[JSINTL]<dd><cite><a href=https://tc39.github.io/ecma402/>ECMAScript Internationalization API Specification</a></cite>. Ecma International.<dt id=refsJSON>[JSON]<dd><cite><a href=https://tools.ietf.org/html/rfc7159>The JavaScript Object Notation (JSON) Data Interchange Format</a></cite>, T. Bray. IETF.<dt id=refsMAILTO>[MAILTO]<dd>(Non-normative) <cite><a href=https://tools.ietf.org/html/rfc6068>The 'mailto' URI scheme</a></cite>, M. Duerst, L. Masinter, J. Zawinski. IETF.<dt id=refsMATHML>[MATHML]<dd><cite><a href=https://www.w3.org/Math/draft-spec/>Mathematical Markup Language (MathML)</a></cite>, D. Carlisle, P. Ion, R. Miner. W3C.<dt id=refsMEDIAFRAG>[MEDIAFRAG]<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.<dt id=refsMEDIASOURCE>[MEDIASOURCE]<dd><cite><a href=https://w3c.github.io/media-source/>Media Source Extensions</a></cite>, A. Colwell, A. Bateman, M. Watson. W3C.<dt id=refsMEDIASTREAM>[MEDIASTREAM]<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.<dt id=refsMFREL>[MFREL]<dd><cite><a href=http://microformats.org/wiki/existing-rel-values#HTML5_link_type_extensions>Microformats Wiki: existing rel values</a></cite>. Microformats.<dt id=refsMIMESNIFF>[MIMESNIFF]<dd><cite><a href=https://mimesniff.spec.whatwg.org/>MIME Sniffing</a></cite>, G. Hemsley. WHATWG.<dt id=refsMIX>[MIX]<dd><cite><a href=https://w3c.github.io/webappsec-mixed-content/>Mixed Content</a></cite>, M. West. W3C.<dt id=refsMNG>[MNG]<dd><cite><a href=http://www.libpng.org/pub/mng/spec/>MNG (Multiple-image Network Graphics) Format</a></cite>. G. Randers-Pehrson.<dt id=refsMPEG2>[MPEG2]<dd><cite>ISO/IEC 13818-1: Information technology — Generic coding of moving pictures and associated audio information: Systems</cite>. ISO/IEC.<dt id=refsMPEG4>[MPEG4]<dd><cite>ISO/IEC 14496-12: ISO base media file format</cite>. ISO/IEC.<dt id=refsMQ>[MQ]<dd><cite><a href=https://drafts.csswg.org/mediaqueries/>Media Queries</a></cite>, H. Lie, T. Çelik, D. Glazman, A. van Kesteren. W3C.<dt id=refsNAVMODEL>[NAVMODEL]<dd><cite><a href=https://arxiv.org/abs/1608.05444>A Model of Navigation History</a></cite>. C. Brewster, A. Jeffrey.<dt id=refsNPAPI>[NPAPI]<dd>(Non-normative) <cite><a href=https://developer.mozilla.org/en-US/docs/Plugins/Guide>Gecko Plugin API Reference</a></cite>. Mozilla.<dt id=refsOGGSKELETONHEADERS>[OGGSKELETONHEADERS]<dd><cite><a href=https://wiki.xiph.org/SkeletonHeaders>SkeletonHeaders</a></cite>. Xiph.Org.<dt id=refsOPENSEARCH>[OPENSEARCH]<dd><cite><a href=http://www.opensearch.org/Specifications/OpenSearch/1.1#Autodiscovery_in_HTML.2FXHTML>Autodiscovery in HTML/XHTML</a></cite>. In <cite>OpenSearch 1.1 Draft 4</cite>, Section 4.6.2. OpenSearch.org.<dt id=refsORIGIN>[ORIGIN]<dd>(Non-normative) <cite><a href=https://tools.ietf.org/html/rfc6454>The Web Origin Concept</a></cite>, A. Barth. IETF.<dt id=refsPAGEVIS>[PAGEVIS]<dd>(Non-normative) <cite><a href=https://w3c.github.io/page-visibility/>Page Visibility Level 2</a></cite>, I. Grigorik, A. Jain, J. Mann. W3C.<dt id=refsPAYMENTREQUEST>[PAYMENTREQUEST]<dd><cite><a href=https://w3c.github.io/browser-payment-api/>Payment Request API</a></cite>, A. Bateman, Z. Koch, R. McElmurry. W3C.<dt id=refsPDF>[PDF]<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.<dt id=refsPINGBACK>[PINGBACK]<dd><cite><a href=https://www.hixie.ch/specs/pingback/pingback>Pingback 1.0</a></cite>, S. Langridge, I. Hickson.<dt id=refsPNG>[PNG]<dd><cite><a href=https://www.w3.org/TR/PNG/>Portable Network Graphics (PNG) Specification</a></cite>, D. Duce. W3C.<dt id=refsPOINTEREVENTS>[POINTEREVENTS]<dd><cite><a href=https://w3c.github.io/pointerevents/>Pointer Events</a></cite>, J. Rossi, M. Brubeck, R. Byers, P. H. Lauke. W3C.<dt id=refsPOINTERLOCK>[POINTERLOCK]<dd><cite><a href=https://w3c.github.io/pointerlock/>Pointer Lock</a></cite>, V. Scheib. W3C.<dt id=refsPPUTF8>[PPUTF8]<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>.<dt id=refsPRELOAD>[PRELOAD]<dd><cite><a href=https://w3c.github.io/preload/>Preload</a></cite>, I. Grigorik. W3C.<dt id=refsPRESENTATION>[PRESENTATION]<dd><cite><a href=https://w3c.github.io/presentation-api/>Presentation API</a></cite>, M. Foltz, D. Röttsches. W3C.<dt id=refsREFERRERPOLICY>[REFERRERPOLICY]<dd><cite><a href=https://w3c.github.io/webappsec-referrer-policy/>Referrer Policy</a></cite>, J. Eisinger, E. Stark. W3C.<dt id=refsREQUESTIDLECALLBACK>[REQUESTIDLECALLBACK]<dd>(Non-normative) <cite><a href=https://w3c.github.io/requestidlecallback/>Cooperative Scheduling of Background Tasks</a></cite>, R. McIlry, I. Grigorik. W3C.<dt id=refsRESOURCEHINTS>[RESOURCEHINTS]<dd><cite><a href=https://w3c.github.io/resource-hints/>Resource Hints</a></cite>, I. Grigorik. W3C.<dt id=refsRFC1034>[RFC1034]<dd><cite><a href=https://tools.ietf.org/html/rfc1034>Domain Names - Concepts and Facilities</a></cite>, P. Mockapetris. IETF, November 1987.<dt id=refsRFC1123>[RFC1123]<dd><cite><a href=https://tools.ietf.org/html/rfc1123>Requirements for Internet Hosts -- Application and Support</a></cite>, R. Braden. IETF, October 1989.<dt id=refsRFC2046>[RFC2046]<dd><cite><a href=https://tools.ietf.org/html/rfc2046>Multipurpose Internet Mail Extensions (MIME) Part Two: Media Types</a></cite>, N. Freed, N.  Borenstein. IETF.<dt id=refsRFC2397>[RFC2397]<dd><cite><a href=https://tools.ietf.org/html/rfc2397>The "data" URL scheme</a></cite>, L. Masinter. IETF.<dt id=refsRFC5545>[RFC5545]<dd><cite><a href=https://tools.ietf.org/html/rfc5545>Internet Calendaring and Scheduling Core Object Specification (iCalendar)</a></cite>, B. Desruisseaux. IETF.<dt id=refsRFC2483>[RFC2483]<dd><cite><a href=https://tools.ietf.org/html/rfc2483>URI Resolution Services Necessary for URN Resolution</a></cite>, M. Mealling, R. Daniel. IETF.<dt id=refsRFC3676>[RFC3676]<dd><cite><a href=https://tools.ietf.org/html/rfc3676>The Text/Plain Format and DelSp Parameters</a></cite>, R. Gellens. IETF.<dt id=refsRFC3864>[RFC3864]<dd><cite><a href=https://tools.ietf.org/html/rfc3864>Registration Procedures for Message Header Fields</a></cite>, G. Klyne, M. Nottingham, J. Mogul. IETF.<dt id=refsRFC4329>[RFC4329]<dd>(Non-normative) <cite><a href=https://tools.ietf.org/html/rfc4329>Scripting Media Types</a></cite>, B. Höhrmann. IETF.<dt id=refsRFC4337>[RFC4337]<dd>(Non-normative) <cite><a href=https://tools.ietf.org/html/rfc4337>MIME Type Registration for MPEG-4</a></cite>, Y. Lim, D. Singer. IETF.<dt id=refsRFC7595>[RFC7595]<dd><cite><a href=https://tools.ietf.org/html/rfc7595>Guidelines and Registration Procedures for URI Schemes</a></cite>, D. Thaler, T. Hansen, T. Hardie. IETF.<dt id=refsRFC5322>[RFC5322]<dd><cite><a href=https://tools.ietf.org/html/rfc5322>Internet Message Format</a></cite>, P. Resnick. IETF.<dt id=refsRFC6381>[RFC6381]<dd><cite><a href=https://tools.ietf.org/html/rfc6381>The 'Codecs' and 'Profiles' Parameters for "Bucket" Media Types</a></cite>, R. Gellens, D. Singer, P. Frojdh. IETF.<dt id=refsRFC6266>[RFC6266]<dd><cite><a href=https://tools.ietf.org/html/rfc6266>Use of the Content-Disposition Header Field in the Hypertext Transfer Protocol (HTTP)</a></cite>, J. Reschke. IETF.<dt id=refsRFC6350>[RFC6350]<dd><cite><a href=https://tools.ietf.org/html/rfc6350>vCard Format Specification</a></cite>, S. Perreault. IETF.<dt id=refsRFC6596>[RFC6596]<dd><cite><a href=https://tools.ietf.org/html/rfc6596>The Canonical Link Relation</a></cite>, M. Ohye, J. Kupke. IETF.<dt id=refsRFC7303>[RFC7303]<dd><cite><a href=https://tools.ietf.org/html/rfc7303>XML Media Types</a></cite>, H. Thompson, C. Lilley. IETF.<dt id=refsRFC7578>[RFC7578]<dd><cite><a href=https://tools.ietf.org/html/rfc7578>Returning Values from Forms: multipart/form-data</a></cite>, L. Masinter. IETF.<dt id=refsSCREENORIENTATION>[SCREENORIENTATION]<dd><cite><a href=https://w3c.github.io/screen-orientation/>Screen Orientation API</a></cite>, M. Lamouri, M. Cáceres. W3C.<dt id=refsSCSU>[SCSU]<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.<dt id=refsSECURE-CONTEXTS>[SECURE-CONTEXTS]<dd><cite><a href=https://w3c.github.io/webappsec-secure-contexts/>Secure Contexts</a></cite>, M. West. W3C.<dt id=refsSELECTION>[SELECTION]<dd><cite><a href=https://w3c.github.io/selection-api/>Selection API</a></cite>, R. Niwa. W3C.<dt id=refsSELECTORS>[SELECTORS]<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.<dt id=refsSMS>[SMS]<dd>(Non-normative) <cite><a href=https://tools.ietf.org/html/rfc5724>URI Scheme for Global System for Mobile Communications (GSM) Short Message Service (SMS)</a></cite>, E. Wilde, A. Vaha-Sipila. IETF.<dt id=refsSRGB>[SRGB]<dd><cite lang=en-GB><a href=https://webstore.iec.ch/publication/6169>IEC 61966-2-1: Multimedia systems and equipment — Colour measurement and management — Part 2-1: Colour management — Default RGB colour space — sRGB</a></cite>. IEC.<dt id=refsSRI>[SRI]<dd><cite><a href=https://w3c.github.io/webappsec-subresource-integrity/>Subresource Integrity</a></cite>, D. Akhawe, F. Braun, F. Marier, J. Weinberger. W3C.<dt id=refsSVG>[SVG]<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.<dt id=refsSW>[SW]<dd><cite><a href=https://w3c.github.io/ServiceWorker/>Service Workers</a></cite>, A. Russell, J. Song, J. Archibald. W3C.<dt id=refsTOR>[TOR]<dd>(Non-normative) <cite><a href=https://www.torproject.org/>Tor</a></cite>.<dt id=refsTOUCH>[TOUCH]<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.<dt id=refsTZDATABASE>[TZDATABASE]<dd>(Non-normative) <cite><a href=https://www.iana.org/time-zones>Time Zone Database</a></cite>. IANA.<dt id=refsUAAG>[UAAG]<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.<dt id=refsUIEVENTS>[UIEVENTS]<dd><cite><a href=https://w3c.github.io/uievents/>UI Events Specification</a></cite>, G. Kacmarcik, T. Leithead. W3C.<dt id=refsUNICODE>[UNICODE]<dd><cite><a href=https://www.unicode.org/versions/>The Unicode Standard</a></cite>. Unicode Consortium.<dt id=refsUNIVCHARDET>[UNIVCHARDET]<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>.<dt id=refsURL>[URL]<dd><cite><a href=https://url.spec.whatwg.org/>URL</a></cite>, A. van Kesteren. WHATWG.<dt id=refsURN>[URN]<dd><cite><a href=https://tools.ietf.org/html/rfc2141>URN Syntax</a></cite>, R. Moats. IETF.<dt id=refsUTF7>[UTF7]<dd>(Non-normative) <cite><a href=https://tools.ietf.org/html/rfc2152>UTF-7: A Mail-Safe Transformation Format of Unicode</a></cite>, D. Goldsmith, M. Davis. IETF.<dt id=refsUTF8DET>[UTF8DET]<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.<dt id=refsUTR36>[UTR36]<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.<dt id=refsWCAG>[WCAG]<dd>(Non-normative) <cite><a href=https://www.w3.org/TR/WCAG20/>Web Content Accessibility Guidelines (WCAG) 2.0</a></cite>, B. Caldwell, M. Cooper, L. Reid, G. Vanderheiden. W3C.<dt id=refsWEBANIMATIONS>[WEBANIMATIONS]<dd><cite><a href=https://drafts.csswg.org/web-animations/>Web Animations</a></cite>, B. Birtles, S. Stephens, D. Stockwell. W3C.<dt id=refsWEBCRYPTO>[WEBCRYPTO]<dd>(Non-normative) <cite><a href=https://w3c.github.io/webcrypto/Overview.html>Web Cryptography API</a></cite>, M. Watson. W3C.<dt id=refsWEBGL>[WEBGL]<dd><cite><a href=https://www.khronos.org/registry/webgl/specs/latest/>WebGL Specifications</a></cite>, D. Jackson, J. Gilbert. Khronos Group.<dt id=refsWEBIDL>[WEBIDL]<dd><cite><a href=https://heycam.github.io/webidl/>Web IDL</a></cite>, C. McCormack. W3C.<dt id=refsWEBLINK>[WEBLINK]<dd><cite><a href=https://tools.ietf.org/html/rfc5988>Web Linking</a></cite>, M. Nottingham. IETF.<dt id=refsWEBMCG>[WEBMCG]<dd><cite><a href=https://www.webmproject.org/docs/container/>WebM Container Guidelines</a></cite>. The WebM Project.<dt id=refsWEBVTT>[WEBVTT]<dd><cite><a href=https://w3c.github.io/webvtt/>WebVTT</a></cite>, S. Pieters. W3C.<dt id=refsWHATWGWIKI>[WHATWGWIKI]<dd><cite><a href=https://wiki.whatwg.org/>The WHATWG Wiki</a></cite>. WHATWG.<dt id=refsWORKLETS>[WORKLETS]<dd><cite><a href=https://drafts.css-houdini.org/worklets/>Worklets</a></cite>. I. Kilpatrick. W3C.<dt id=refsWSP>[WSP]<dd><cite><a href=https://tools.ietf.org/html/rfc6455>The WebSocket protocol</a></cite>, I. Fette, A. Melnikov. IETF.<dt id=refsX121>[X121]<dd><cite>Recommendation X.121 — International Numbering Plan for Public Data Networks</cite>, CCITT Blue Book, Fascicle VIII.3, pp. 317-332.<dt id=refsXFN>[XFN]<dd><cite><a href=https://gmpg.org/xfn/11>XFN 1.1 profile</a></cite>, T. Çelik, M. Mullenweg, E. Meyer. GMPG.<dt id=refsXHR>[XHR]<dd><cite><a href=https://xhr.spec.whatwg.org/><code>XMLHttpRequest</code></a></cite>, A. van Kesteren. WHATWG.<dt id=refsXKCD1288>[XKCD1288]<dd>(Non-normative) <cite><a href=https://xkcd.com/1288/>Substitutions</a></cite>, Randall Munroe. xkcd.<dt id=refsXML>[XML]<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.<dt id=refsXMLENTITY>[XMLENTITY]<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.<dt id=refsXMLNS>[XMLNS]<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.<dt id=refsXMLSSPI>[XMLSSPI]<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.<dt id=refsXPATH10>[XPATH10]<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.<dt id=refsXSLT10>[XSLT10]<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.<dt id=refsXSLTP>[XSLTP]<dd>(Non-normative) <cite><a href=https://wiki.whatwg.org/wiki/DOM_XSLTProcessor>DOM XSLTProcessor</a></cite>, WHATWG Wiki. WHATWG.</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,
  Abhishek Gupta, 
  Adam Barth,
  Adam de Boor,
  Adam Hepton,
  Adam Klein,
  Adam Roben,
  Addison Phillips,
  Adele Peterson,
  Adrian Bateman,
  Adrian Roselli,
  Adrian Sutton,
  Agustín Fernández,
  Aharon (Vladimir) Lanin,
  Ajai Tirumali,
  Akatsuki Kitamura,
  Alan Plum,
  Alastair Campbell,
  Alejandro G. Castro,
  Aleksey Shvayka,
  Alex Bishop,
  Alex Nicolaou,
  Alex Nozdriukhin,
  Alex Rousskov,
  Alexander Farkas,
  Alexander J. Vincent,
  Alexandre Morgaut,
  Alexey Feldgendler,
  Алексей Проскуряков (Alexey Proskuryakov),
  Alexis Deveria,
  Alfred Agrell, 
  Ali Juma,
  Alice Boxhall,
  Alice Wonder,
  Allan Clements,
  Allen Wirfs-Brock,
  Alex Komoroske,
  Alex Russell,
  Alphan Chen,
  Ami Fischman,
  Amos Jeffries,
  Amos Lim,
  Anders Carlsson,
  André Bargull,
  André E. Veltstra,
  Andrea Rendine,
  Andreas,
  Andreas Kling,
  Andrei Popescu,
  Andres Gomez,
  Andres Rios,
  Andrew Barfield,
  Andrew Clover,
  Andrew Gove,
  Andrew Grieve,
  Andrew Oakley,
  Andrew Sidwell,
  Andrew Simons,
  Andrew Smith,
  Andrew W. Hagen,
  Andrey V. Lukyanov,
  Andry Rendy,
  Andy Earnshaw,
  Andy Heydon,
  Andy Paicu,
  Andy Palay,
  Anjana Vakil,
  Ankur Kaushal,
  Anna Belle Leiserson,
  Anthony Boyd,
  Anthony Bryan,
  Anthony Hickson,
  Anthony Ramine,
  Anthony Ricaud,
  Anton Vayvod,
  Antti Koivisto,
  Arkadiusz Michalski,
  Arne Thomassen,
  Aron Spohr,
  Arphen Lin,
  Arthur Stolyar,
  Arun Patole,
  Aryeh Gregor,
  Asbjørn Ulsberg,
  Ashley Gullen,
  Ashley Sheridan,
  Atsushi Takayama,
  Aurelien Levy,
  Ave Wrigley,
  Avi Drissman,
  Axel Dahmen,
  Ben Boyle,
  Ben Godfrey,
  Ben Kelly,
  Ben Lerner,
  Ben Leslie,
  Ben Meadowcroft,
  Ben Millard,
  Benjamin Carl Wiley Sittler,
  Benjamin Hawkes-Lewis,
  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 Perelló Marín,
  Casey Leask,
  Cătălin Badea,
  Cătălin Mariș,
  Chao Cai,
  윤석찬 (Channy Yun),
  Charl van Niekerk,
  Charlene Wright,
  Charles Iliya Krempeaux,
  Charles McCathie Nevile,
  Charlie Reis,
  Chris Apers,
  Chris Cressman,
  Chris Dumez,
  Chris Evans,
  Chris Harrelson,
  Chris Markiewicz,
  Chris Morris,
  Chris Nardi,
  Chris Pearce,
  Chris Peterson,
  Chris Rebert,
  Chris Weber,
  Chris Wilson,
  Christian Biesinger,
  Christian Johansen,
  Christian Schmidt,
  Christoph Päper,
  Christophe Dumez,
  Christopher Aillon,
  Christopher Ferris,
  Chriswa,
  Clark Buehler,
  Cole Robison,
  Colin Fine,
  Collin Jackson,
  Corey Farwell,
  Corprew Reed,
  Craig Cockburn,
  Csaba Gabor,
  Csaba Marton,
  Cynthia Shelly,
  Cyrille Tuzi,
  Daksh Shah,
  Dan Callahan,
  Dan Ehrenberg,
  Dan Yoder,
  Dane Foster, 
  Daniel Barclay,
  Daniel Bratell,
  Daniel Brooks,
  Daniel Brumbaugh Keeney,
  Daniel Buchner,
  Daniel Cheng,
  Daniel Davis,
  Daniel Glazman,
  Daniel Peng,
  Daniel Schattenkirchner,
  Daniel Spång,
  Daniel Steinberg,
  Daniel Trebbien,
  Danny Sullivan,
  Darin Adler,
  Darin Fisher,
  Darxus,
  Dave Camp,
  Dave Cramer,
  Dave Hodder,
  Dave Lampton,
  Dave Singer,
  Dave Tapuska,
  Dave Townsend,
  David Baron,
  David Bloom,
  David Bruant,
  David Carlisle,
  David E. Cleary,
  David Egan Evans,
  David Fink,
  David Flanagan,
  David Gerard,
  David Grogan,
  David Håsäther,
  David Hyatt,
  David I. Lehn,
  David John Burrowes,
  David Kendal,
  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,
  Debi Orton,
  Delan Azabani,
  Derek Featherstone,
  Devarshi Pant,
  Devdatta,
  Diego Ferreiro Val,
  Diego Ponce de León,
  Dimitri Glazkov,
  Dimitry Golubovsky,
  Dirk Pranke,
  Dirk Schulze,
  Dirkjan Ochtman,
  Divya Manian,
  Dmitry Titov,
  dolphinling,
  Dominic Cooney,
  Dominic Farolino,
  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,
  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 Rescorla,
  Eric Semling,
  Eric Willigers,
  Erik Arvidsson,
  Erik Charlebois,
  Erik Rose,
  espretto, 
  Evan Jacobs,
  Evan Martin,
  Evan Prodromou,
  Evan Stade,
  Evert,
  Evgeny Kapun,
  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,
  Fredrik Söderquist,
  鵜飼文敏 (Fumitoshi Ukai),
  Futomi Hatano,
  Gavin Carothers,
  Gavin Kistner,
  Gareth Rees,
  Garrett Smith,
  Gary Kacmarcik,
  Gary Katsevman,
  Geoff Richards,
  Geoffrey Garen,
  Geoffrey Sneddon,
  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,
  Guilherme Johansson Tramontina,
  guest271314,
  Gytis Jakutonis,
  Håkon Wium Lie,
  Habib Virji,
  Hajime Morrita,
  Hallvord Reiar Michaelsen Steen,
  Hans S. Tømmerhalt,
  Hans Stimer,
  Harald Alvestrand,
  Hayato Ito,
  Henri Sivonen,
  Henrik Lied,
  Henry Lewis,
  Henry Mason,
  Henry Story,
  Hermann Donfack Zeufack,
  中川博貴 (Hiroki Nakagawa), 
  Hiroshige Hayashizaki,
  Hitoshi Yoshida,
  Hongchan Choi, 
  Hugh Bellamy,
  Hugh Guiney,
  Hugh Winkler,
  Ian Bicking,
  Ian Clelland,
  Ian Davis,
  Ian Fette,
  Ian Kilpatrick,
  Ibrahim Ahmed,
  Ido Green,
  Ignacio Javier,
  Igor Oliveira,
  Ingvar Stepanyan,
  isonmad,
  Iurii Kucherov,
  Ivan Enderlin,
  Ivan Nikulin, 
  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 Craig,
  James Graham,
  James Greene,
  James Justin Harrell,
  James Kozianski,
  James M Snell,
  James Perrett,
  James Robinson,
  Jamie Lokier,
  Jan Kühle, 
  Jan Miksovsky,
  Janusz Majnert,
  Jan-Klaas Kollhof,
  Jared Jacobs,
  Jason Duell,
  Jason Kersey,
  Jason Lustig,
  Jason Orendorff,
  Jason White,
  Jasper Bryant-Greene,
  Jasper St. Pierre,
  Jatinder Mann,
  Jean-Yves Avenard,
  Jed Hartman,
  Jeff Balogh,
  Jeff Cutsinger,
  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,
  Jinho Bang,
  Jinjiang (勾三股四), 
  Jirka Kosek,
  Jjgod Jiang,
  João Eiras,
  Jochen Eisinger,
  Joe Clark,
  Joe Gregorio,
  Joel Spolsky,
  Joel Verhagen,
  Johan Herland,
  John Boyer,
  John Bussjaeger,
  John Carpenter,
  John Daggett,
  John Fallows,
  John Foliot,
  John Harding,
  John Keiser,
  John Musgrave,
  John Snyders,
  John Stockton,
  John-Mark Bell,
  Johnny Stenback,
  Jon Coppeard,
  Jon Ferraiolo,
  Jon Gibbins,
  Jon Perlow,
  Jonas Sicking,
  Jonathan Cook,
  Jonathan Neal,
  Jonathan Oddy,
  Jonathan Rees,
  Jonathan Watt,
  Jonathan Worent,
  Jonny Axelsson,
  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 Randall,
  Juan Olvera, 
  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,
  Kartikaya Gupta,
  Kat Graff,
  Kathy Walton,
  Keith Rollin,
  Keith Yeung,
  Kelly Ford,
  Kelly Norton,
  Ken Russell,
  Kenji Baheux,
  Kevin Benson,
  Kevin Cole,
  Kevin Gadd,
  Kevin Venkiteswaran,
  Kinuko Yasuda,
  Koji Ishii,
  Kornél Pál,
  Kornel Lesinski,
  上野 康平 (UENO, Kouhei),
  Kris Northfield,
  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,
  Lobotom Dysmon,
  Logan,
  Loune,
  Lucas Gadani,
  Łukasz Pilorz,
  Luke Kenneth Casson Leighton,
  Maciej Stachowiak,
  Magne Andersson,
  Magnus Kristiansen,
  Maik Merten,
  Majid Valipour,
  Malcolm Rowe,
  Manish Goregaokar,
  Manish Tripathi,
  Marc Hoyois,
  Marc-André Choquette, 
  Marc-André Lafortune,
  Marco Zehe,
  Marcus Bointon,
  Marijn Kruisselbrink,
  Mark Amery,
  Mark Birbeck,
  Mark Davis,
  Mark Miller,
  Mark Nottingham,
  Mark Pilgrim,
  Mark Rowe,
  Mark Schenk,
  Mark Vickers,
  Mark Wilton-Jones,
  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 Mize,
  Mathias Bynens,
  Mathieu Henri,
  Matias Larsson,
  Matt Brubeck,
  Matt Di Pasquale,
  Matt Falkenhagen,
  Matt Schmidt,
  Matt Wright,
  Matthew Gregan,
  Matthew Mastracci,
  Matthew Noorenberghe,
  Matthew Raymond,
  Matthew Thomas,
  Mattias Waldau,
  Max Romantschuk,
  Menachem Salomon,
  Menno van Slooten,
  Micah Dubinko,
  Michael 'Ratt' Iannarelli,
  Michael A. Nachbaur,
  Michael A. Puls II,
  Michael Carter,
  Michael Daskalov,
  Michael Day,
  Michael Dyck,
  Michael Enright,
  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,
  Mihai Şucan,
  Mihai Parparita,
  Mike Brown,
  Mike Dierken,
  Mike Dixon,
  Mike Hearn,
  Mike Pennisi,
  Mike Schinkel,
  Mike Shaver,
  Mikko Rantalainen,
  Mingye Wang,
  Mohamed Zergaoui,
  Mohammad Al Houssami,
  Mohammad Reza Zakerinasab,
  Momdo Nakamura,
  Morten Stenshorne,
  Mounir Lamouri,
  Ms2ger,
  Mukilan Thiyagarajan,
  Mustaq Ahmed,
  Nadia Heninger,
  NARUSE Yui,
  Navid Zolghadr,
  Neil Deakin,
  Neil Rashbrook,
  Neil Soiffer,
  Nicholas Shanks,
  Nicholas Stimpson,
  Nicholas Zakas,
  Nickolay Ponomarev,
  Nicolas Gallagher,
  Nikki Bee,
  Noah Mendelsohn,
  Noah Slater,
  Noel Gordon,
  Nolan Waite,
  NoozNooz42,
  Norbert Lindenberg,
  Ojan Vafai,
  Olaf Hoffmann,
  Olav Junker Kjær,
  Oldřich Vetešník,
  Oli Studholme,
  Oliver Hunt,
  Oliver Rigby,
  Olivier Gendrin,
  Olli Pettay,
  Ori Avtalion,
  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 Taylor,
  Philip TAYLOR,
  Philippe De Ryck,
  Pierre-Arnaud Allumé,
‏  Pooja Sanklecha,
  Prashant Hiremath,
  Prashanth Chandra,
  Prateek Rungta,
  Pravir Gupta,
  Prayag Verma,
  李普君 (Pujun Li),
  Rachid Finge,
  Rafael Weinstein,
  Rafał Miłecki,
  Rahul Purohit,
  Raj Doshi,
  Rajas Moonka,
  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,
  Rigo Wenning,
  Rikkert Koppes,
  Rimantas Liubertas,
  Riona Macnamara,
  Rob Buis,
  Rob Ennals,
  Rob Jellinghaus,
  Rob S,
  Robert Blaut,
  Robert Collins,
  Robert Hogan,
  Robert Kieffer,
  Robert Millan,
  Robert O'Callahan,
  Robert Sayre,
  Robin Berjon,
  Robin Schaufler,
  Rodger Combs,
  Roland Steiner,
  Roma Matusevich,
  Roman Ivanov,
  Roy Fielding,
  Rune Lillesveen,
  Russell Bicknell,
  Ruud Steltenpool,
  Ryan King,
  Ryan Landay,
  Ryan Sleevi,
  Ryo Kato,
  Ryosuke Niwa,
  S. Mike Dierken,
  Salvatore Loreto,
  Sam Dutton,
  Sam Kuper,
  Sam Ruby,
  Sam Weinig,
  Samikshya Chand,
  Samuel Bronson,
  Samy Kamkar,
  Sander van Lambalgen,
  Sanjoy Pal,
  Sarah Gebauer,
  Sarven Capadisli,
  Scott Beardsley,
  Scott González,
  Scott Hess,
  Scott Miles,
  Scott O'Hara,
  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,
  Sierk Bornemann,
  Sigbjørn Finne,
  Sigbjørn Vik,
  Silver Ghost, 
  Silvia Pfeiffer,
  Šime Vidas,
  Simon Fraser,
  Simon Montagu,
  Simon Sapin,
  Simon Spiegel,
  skeww, 
  Smylers,
  Srirama Chandra Sekhar Mogali,
  Stanton McCandlish,
  Stefan Håkansson,
  Stefan Haustein,
  Stefan Santesson,
  Stefan Schumacher,
  Stefan Weiss,
  Steffen Meschkat,
  Stephen Ma,
  Stephen Stewart,
  Stephen White,
  Steve Comstock,
  Steve Faulkner,
  Steve Orvell,
  Steve Runyon,
  Steven Bennett,
  Steven Garrity,
  Steven Tate,
  Stewart Brodie,
  Stuart Ballard,
  Stuart Langridge,
  Stuart Parmenter,
  Subramanian Peruvemba,
  Sudhanshu Jaiswal,
  sudokus999, 
  Sunava Dutta,
  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),
  Taylor Hunt,
  Ted Mielczarek,
  Terrence Wood,
  Tetsuharu OHZEKI,
  Theresa O'Connor,
  Thijs van der Vossen,
  Thomas Broyer,
  Thomas Koetter,
  Thomas O'Connor,
  Tim Altman,
  Tim Dresser,
  Tim Johansson,
  Tim Perry,
  Tim van der Lippe,
  TJ VanToll,
  Tobias Schneider,
  Tobie Langel,
  Toby Inkster,
  Todd Moody,
  Tom Baker,
  Tom Pike,
  Tom Schuster,
  Tomasz Jakut, 
  Tommy Thorsen,
  Tony Ross,
  Tooru Fujisawa,
  Travis Leithead,
  Trevor Rowbotham,
  Trevor Saunders,
  triple-underscore, 
  Tyler Close,
  Valentin Gosu,
  Vardhan Gupta,
  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,
  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,
  Yay295,
  Ye-Kui Wang,
  Yehuda Katz,
  Yi-An Huang,
  Yngve Nysaeter Pettersen,
  Yoav Weiss,
  Yonathan Randolph,
  Yury Delendik,
  平野裕 (Yutaka Hirano),
  Yuzo Fujishima,
  Zhenbin Xu,
  张智强 (Zhiqiang Zhang),
  Zoltan Herczeg,
  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>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>Part of the revision history of the <code id=acknowledgments:the-picture-element-2><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>.</p>

  <p>Part of the revision history of the <code id=acknowledgments: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>.</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 Permissive
  Document License</a>.</p>

  <p>Part of the revision history of the <code id=acknowledgments:dom-innertext><a href=#dom-innertext>innerText</a></code> IDL attribute
  can be found in the <a href=https://github.com/rocallahan/innerText-spec><code>rocallahan/innerText-spec</code>
  repository</a>.</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>).
  More recently,
  Simon Pieters (<a href=https://bocoup.com/>Bocoup</a>, <a href=mailto:zcorpan@gmail.com>zcorpan@gmail.com</a>),
  <a href=https://annevankesteren.nl/>Anne van Kesteren</a> (<a href=https://www.mozilla.org/>Mozilla</a>, <a href=mailto:annevk@annevk.nl>annevk@annevk.nl</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
  <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>),
  all previously long-time contributors, have joined Ian in editing the text directly.</p>

  
  <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>)
  </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>)
  </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>)
  </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=acknowledgments:attr-script-async><a href=#attr-script-async>async</a></code> and <code id=acknowledgments:attr-script-defer><a href=#attr-script-defer>defer</a></code> impact <code id=acknowledgments: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></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>Copyright © <span class=pubyear>2018</span> 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>.</p>

  

 



Anon7 - 2022
AnonSec Team